mirror of
https://git.proxmox.com/git/llvm-toolchain
synced 2025-08-13 18:49:52 +00:00
Build compiler-rt for wasm32 and wasm64
Current shortcomings/future work: * Unfortunately this currently takes the form of a separate, standalone build (with the just-built stage2 toolchain), which makes this a little more convoluted. The upstream compiler-rt build system does not have a way (that I could find) to manually add additional targets to the build. * GNU strip (binutils) does not understand the WebAssembly binary, so dh_strip fails. llvm-strip does, but a) does not understand all the arguments that dh_strip passes (e.g. -N), b) fails with "invalid relocation offset" on --strip-debug (but works with --strip-all). This currently passes -X to dh_strip to exclude them from being stripped entirely. Invoking llvm-strip manually with --strip-all can be considered in the future. * The wasm32/wasm64 binaries are, by design, architecture-independent. With this commit, they are being built in every architecture, and shipped in the libclang-common-X.Y-dev package, which is arch: any, but ships both architecture-dependent (native/host compiler-rt) and architecture-independent files (include headers etc.). In a future iteration, the wasm32/wasm64 compiler-rt library could be factored out to a separate (arch: all) package. This is left outstanding because it should probably happen alongside a different split for libclang-common-X.Y-dev that will include splitting the native libclang-rt as well. Closes: #1010932
This commit is contained in:
parent
6ba6091ca0
commit
50a54f4edc
43
debian/rules
vendored
43
debian/rules
vendored
@ -679,7 +679,38 @@ debian-libclc-build:
|
||||
ninja $(NJOBS) $(VERBOSE)
|
||||
touch $@
|
||||
|
||||
override_dh_auto_build: debian-full-build debian-libfuzzer-build debian-libclc-build
|
||||
debian-rtlib-wasm-build:
|
||||
echo "Using cmake: $(CMAKE_BIN)"
|
||||
for build in wasm32 wasm64; do \
|
||||
mkdir -p build-compiler-rt-$$build; \
|
||||
$(CMAKE_BIN) -B build-compiler-rt-$$build -S compiler-rt/lib/builtins/ \
|
||||
-G Ninja \
|
||||
-DCMAKE_C_COMPILER_TARGET=$$build-unknown-unknown \
|
||||
-DCMAKE_CXX_COMPILER_TARGET=$$build-unknown-unknown \
|
||||
-DCMAKE_ASM_COMPILER_TARGET=$$build-unknown-unknown \
|
||||
-DCMAKE_C_COMPILER=$(STAGE_2_BIN_DIR)/clang \
|
||||
-DCMAKE_CXX_COMPILER=$(STAGE_2_BIN_DIR)/clang++ \
|
||||
-DCMAKE_C_FLAGS="$(opt_flags) $(STAGE_2_CFLAGS)" \
|
||||
-DCMAKE_CXX_FLAGS="$(opt_flags) $(STAGE_2_CXXFLAGS)" \
|
||||
-DCMAKE_SHARED_LINKER_FLAGS="$(STAGE_2_LDFLAGS) -L$(STAGE_2_LIB_DIR)" \
|
||||
-DCMAKE_MODULE_LINKER_FLAGS="$(STAGE_2_LDFLAGS) -L$(STAGE_2_LIB_DIR)" \
|
||||
-DCMAKE_EXE_LINKER_FLAGS="$(STAGE_2_LDFLAGS) -L$(STAGE_2_LIB_DIR)" \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr/lib/llvm-$(LLVM_VERSION)/lib/clang/$(LLVM_VERSION_FULL) \
|
||||
-DCMAKE_INSTALL_DATADIR=lib \
|
||||
-DCMAKE_INSTALL_INCLUDEDIR=include \
|
||||
-DLLVM_CONFIG_PATH=$(STAGE_2_BIN_DIR)/llvm-config \
|
||||
-DCOMPILER_RT_STANDALONE_BUILD=ON \
|
||||
-DCOMPILER_RT_BAREMETAL_BUILD=ON \
|
||||
-DCOMPILER_RT_INCLUDE_TESTS=OFF \
|
||||
-DCOMPILER_RT_USE_LIBCXX=OFF \
|
||||
-DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON \
|
||||
-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=$$build-unknown-unknown \
|
||||
-DCOMPILER_RT_OS_DIR=wasi; \
|
||||
ninja -C build-compiler-rt-$$build $(NJOBS) $(VERBOSE); \
|
||||
done
|
||||
touch $@
|
||||
|
||||
override_dh_auto_build: debian-full-build debian-libfuzzer-build debian-libclc-build debian-rtlib-wasm-build
|
||||
|
||||
override_dh_prep: build_doc
|
||||
dh_prep
|
||||
@ -819,6 +850,9 @@ endif
|
||||
|
||||
DESTDIR=$(DEB_INST) ninja $(VERBOSE) -C libclc/build install
|
||||
|
||||
DESTDIR=$(DEB_INST) ninja $(VERBOSE) -C build-compiler-rt-wasm32 install
|
||||
DESTDIR=$(DEB_INST) ninja $(VERBOSE) -C build-compiler-rt-wasm64 install
|
||||
|
||||
# Rename binaries
|
||||
mkdir -p $(DEB_INST)/usr/bin/
|
||||
cd $(DEB_INST)/usr/bin/; \
|
||||
@ -964,7 +998,9 @@ ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' bin
|
||||
: # for some reasons, the +x might be removed
|
||||
chmod -f +x $(CURDIR)/debian/*/usr/lib/llvm-$(LLVM_VERSION)/bin/* || true
|
||||
else
|
||||
dh_strip -a -v
|
||||
# GNU strip doesn't recognize WebAssembly binaries, and actually corrupts them.
|
||||
# llvm-strip (as of 15.0.2) fails with --strip-debug (but works with --strip-all)
|
||||
dh_strip -a -v -Xlibclang_rt.builtins-wasm32.a -Xlibclang_rt.builtins-wasm64.a
|
||||
endif
|
||||
|
||||
override_dh_install:
|
||||
@ -1098,6 +1134,7 @@ override_dh_auto_clean:
|
||||
rm -f $(CURDIR)/clang/tools/clang-format/clang-format-diff-$(LLVM_VERSION)
|
||||
rm -f $(CURDIR)/clang/tools/clang-format/clang-format-$(LLVM_VERSION).py
|
||||
rm -rf libclc/build
|
||||
rm -rf build-compiler-rt-wasm32 build-compiler-rt-wasm64
|
||||
if test -f lld/docs/ld.lld-$(LLVM_VERSION).1; then \
|
||||
mv lld/docs/ld.lld-$(LLVM_VERSION).1 lld/docs/ld.lld.1; \
|
||||
fi
|
||||
@ -1113,4 +1150,4 @@ override_dh_auto_clean:
|
||||
: # remove extra stamps
|
||||
rm -f debian-*-build
|
||||
|
||||
.PHONY: override_dh_strip preconfigure debian-full-build debian-libfuzzer-build debian-libclc-build
|
||||
.PHONY: override_dh_strip preconfigure debian-full-build debian-libfuzzer-build debian-libclc-build debian-rtlib-wasm-build
|
||||
|
Loading…
Reference in New Issue
Block a user