mirror of
https://git.proxmox.com/git/llvm-toolchain
synced 2025-06-14 11:33:58 +00:00
Fix wasm include paths, unbreaking compiler-rt builds on !x86
compiler-rt WebAssembly builds were failing, and as a workaround commitca9dbba
introduced COMPILER_RT_WASM_ENABLE, disabling its compilation on several architectures (arm64 armel mips64el mipsel ppc64el armhf). This was ultimately caused by the WebAssembly driver including paths in bare /usr/include, when compiling for wasnNN-unknown-unknown targets. This in turn resulted in this chain of include paths when building compiler-rt, as one example out of many: 1. compiler-rt/lib/builtins/divtf3.c:15 #include "fp_lib.h" 2. compiler-rt/lib/builtins/fp_lib.h:23 #include "int_lib.h" 3. compiler-rt/lib/builtins/int_lib.h:93 #include <limits.h> 4. /usr/lib/llvm-14/lib/clang/14.0.6/include/limits.h:20 #if __has_include_next(<limits.h>) #include_next <limits.h> 5. /usr/include/limits.h:26 #include <bits/libc-header-start.h> 6. fatal error: 'bits/libc-header-start.h' file not found /usr/include/stdint.h is the host's glibc header, and bits/libc-header-start.h doesn't exist for the wasm targets. This is the case with or without wasi-libc, as wasi-libc is musl-based and doesn't have these paths at all. The only reason builds worked on amd64 is accident:lly the B-D chain brings in libc6-dev-i386 (through g++-multilib), which creates this symlink: /usr/include/bits -> x86_64-linux-gnu/bits This effectively meant that on amd64 builds, compiler-rt for wasm targets was compiled with glibc x86_64 headers. Ultimately this was rooted on the sysroot-based assumptions that the upstream driver makes and that we are patching (evidently incompletely) with our wasm-sysroot-usr.diff patch. Update our patch to explicitly NOT include the bare /usr/include path on non-OS targets (wasm32-unknown-unknown etc.), while keeping existing behavior for backwards compatibility when --sysroot is passed. Given this should (fingers crossed) address this invariance between amd64 and other architectures, and unbreak those builds, revert commitca9dbba
and the COMPILER_RT_WASM_ENABLE flag.
This commit is contained in:
parent
bde3d49c95
commit
b91115bd58
16
debian/patches/wasm/wasm-sysroot-usr.diff
vendored
16
debian/patches/wasm/wasm-sysroot-usr.diff
vendored
@ -27,21 +27,31 @@ Index: llvm-toolchain-14-14.0.6/clang/lib/Driver/ToolChains/WebAssembly.cpp
|
||||
|
||||
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
|
||||
SmallString<128> P(D.ResourceDir);
|
||||
@@ -421,10 +423,10 @@ void WebAssembly::AddClangSystemIncludeA
|
||||
@@ -419,12 +421,20 @@ void WebAssembly::AddClangSystemIncludeA
|
||||
return;
|
||||
}
|
||||
|
||||
+ // add the multiarch path on e.g. wasm32-wasi
|
||||
if (getTriple().getOS() != llvm::Triple::UnknownOS) {
|
||||
const std::string MultiarchTriple =
|
||||
- getMultiarchTriple(D, getTriple(), D.SysRoot);
|
||||
- addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/include/" + MultiarchTriple);
|
||||
+ getMultiarchTriple(D, getTriple(), SysRoot);
|
||||
+ addSystemInclude(DriverArgs, CC1Args, SysRoot + "/local/include/" + MultiarchTriple);
|
||||
+ addSystemInclude(DriverArgs, CC1Args, SysRoot + "/local/include");
|
||||
+ addSystemInclude(DriverArgs, CC1Args, SysRoot + "/include/" + MultiarchTriple);
|
||||
}
|
||||
- addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/include");
|
||||
+ addSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
|
||||
+
|
||||
+ // also add the non-multiarch path, only on a known OS (as above), or when
|
||||
+ // a sysroot is given, for backwards compatibility with the original driver
|
||||
+ if (getTriple().getOS() != llvm::Triple::UnknownOS ||
|
||||
+ !getDriver().SysRoot.empty())
|
||||
+ addSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
|
||||
}
|
||||
|
||||
void WebAssembly::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
||||
@@ -467,3 +469,15 @@ SanitizerMask WebAssembly::getSupportedS
|
||||
@@ -467,3 +477,15 @@ SanitizerMask WebAssembly::getSupportedS
|
||||
Tool *WebAssembly::buildLinker() const {
|
||||
return new tools::wasm::Linker(*this);
|
||||
}
|
||||
|
13
debian/rules
vendored
13
debian/rules
vendored
@ -302,12 +302,6 @@ ifeq ($(LIBUNWIND_ENABLE),yes)
|
||||
endif
|
||||
endif
|
||||
|
||||
COMPILER_RT_WASM_ENABLE=yes
|
||||
|
||||
ifneq (,$(filter $(DEB_HOST_ARCH), arm64 armel mips64el mipsel ppc64el armhf))
|
||||
COMPILER_RT_WASM_ENABLE=no
|
||||
endif
|
||||
|
||||
# Do not install objects
|
||||
STAGE_ALL_CMAKE_EXTRA += -DMLIR_INSTALL_AGGREGATE_OBJECTS=OFF
|
||||
|
||||
@ -716,7 +710,6 @@ debian-libclc-build:
|
||||
touch $@
|
||||
|
||||
debian-rtlib-wasm-build:
|
||||
ifeq (${COMPILER_RT_WASM_ENABLE},yes)
|
||||
echo "Using cmake: $(CMAKE_BIN)"
|
||||
for build in wasm32 wasm64; do \
|
||||
mkdir -p build-compiler-rt-$$build; \
|
||||
@ -746,9 +739,6 @@ ifeq (${COMPILER_RT_WASM_ENABLE},yes)
|
||||
-DCOMPILER_RT_OS_DIR=wasi; \
|
||||
ninja -C build-compiler-rt-$$build $(NJOBS) $(VERBOSE); \
|
||||
done
|
||||
else
|
||||
echo "Skip on this arch"
|
||||
endif
|
||||
touch $@
|
||||
|
||||
|
||||
@ -901,10 +891,9 @@ endif
|
||||
$(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/build/utils/lit/lit/*/__pycache__/
|
||||
|
||||
DESTDIR=$(DEB_INST) ninja $(VERBOSE) -C libclc/build install
|
||||
ifeq (${COMPILER_RT_WASM_ENABLE},yes)
|
||||
|
||||
DESTDIR=$(DEB_INST) ninja $(VERBOSE) -C build-compiler-rt-wasm32 install
|
||||
DESTDIR=$(DEB_INST) ninja $(VERBOSE) -C build-compiler-rt-wasm64 install
|
||||
endif
|
||||
|
||||
# Rename binaries
|
||||
mkdir -p $(DEB_INST)/usr/bin/
|
||||
|
Loading…
Reference in New Issue
Block a user