mirror of
https://git.proxmox.com/git/llvm-toolchain
synced 2025-08-12 09:53:57 +00:00
Merge branch '15-wasm' into '15'
Better support for the WebAssembly (wasm32/wasm64) targets See merge request pkg-llvm-team/llvm-toolchain!96
This commit is contained in:
commit
72a2374787
12
debian/changelog
vendored
12
debian/changelog
vendored
@ -1,3 +1,15 @@
|
||||
llvm-toolchain-15 (1:15.0.2-2~exp2) UNRELEASED; urgency=medium
|
||||
|
||||
* Add better support for the WebAssembly (wasm32/wasm64) targets:
|
||||
- Ship compiler-rt for the wasm32 and wasm64 targets. (Closes: #1010932)
|
||||
- Add patch wasm-compiler-rt-default.diff to default to compiler-rt for
|
||||
these targets. libgcc does not currently exist for WebAssembly in neither
|
||||
Debian nor upstream, and therefore compiler-rt is the only option.
|
||||
- Add patch wasm-sysroot-usr.diff to support a system-installed (i.e. shipped
|
||||
in /usr) wasi-libc. (Closes: #1020746)
|
||||
|
||||
-- Faidon Liambotis <paravoid@debian.org> Fri, 07 Oct 2022 16:44:57 +0300
|
||||
|
||||
llvm-toolchain-15 (1:15.0.2-2~exp1) experimental; urgency=medium
|
||||
|
||||
* Ship bolt
|
||||
|
2
debian/patches/series
vendored
2
debian/patches/series
vendored
@ -138,6 +138,8 @@ llvm-runtimes-builtins-build-check.diff
|
||||
compilerrt-builtins-arch-fix-armhf.diff
|
||||
compilerrt-build-scudo-standalone-option.diff
|
||||
wasm-ld-path.diff
|
||||
wasm-compiler-rt-default.diff
|
||||
wasm-sysroot-usr.diff
|
||||
issue-54242.diff
|
||||
revert-update-doc.diff
|
||||
unwind-force-pthread-dl.diff
|
||||
|
31
debian/patches/wasm-compiler-rt-default.diff
vendored
Normal file
31
debian/patches/wasm-compiler-rt-default.diff
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
|
||||
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
|
||||
@@ -369,6 +369,18 @@ ToolChain::RuntimeLibType WebAssembly::G
|
||||
return ToolChain::RLT_CompilerRT;
|
||||
}
|
||||
|
||||
+ToolChain::RuntimeLibType WebAssembly::GetRuntimeLibType(
|
||||
+ const ArgList &Args) const {
|
||||
+ if (Arg *A = Args.getLastArg(options::OPT_rtlib_EQ)) {
|
||||
+ StringRef Value = A->getValue();
|
||||
+ if (Value != "compiler-rt")
|
||||
+ getDriver().Diag(clang::diag::err_drv_unsupported_rtlib_for_platform)
|
||||
+ << Value << "WebAssembly";
|
||||
+ }
|
||||
+
|
||||
+ return ToolChain::RLT_CompilerRT;
|
||||
+}
|
||||
+
|
||||
ToolChain::CXXStdlibType
|
||||
WebAssembly::GetCXXStdlibType(const ArgList &Args) const {
|
||||
if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
|
||||
--- a/clang/lib/Driver/ToolChains/WebAssembly.h
|
||||
+++ b/clang/lib/Driver/ToolChains/WebAssembly.h
|
||||
@@ -61,6 +61,7 @@ private:
|
||||
llvm::opt::ArgStringList &CC1Args,
|
||||
Action::OffloadKind DeviceOffloadKind) const override;
|
||||
RuntimeLibType GetDefaultRuntimeLibType() const override;
|
||||
+ RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const override;
|
||||
CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
|
||||
void
|
||||
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
|
62
debian/patches/wasm-sysroot-usr.diff
vendored
Normal file
62
debian/patches/wasm-sysroot-usr.diff
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
|
||||
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
|
||||
@@ -174,7 +174,7 @@ WebAssembly::WebAssembly(const Driver &D
|
||||
|
||||
getProgramPaths().push_back(getDriver().getInstalledDir());
|
||||
|
||||
- auto SysRoot = getDriver().SysRoot;
|
||||
+ std::string SysRoot = computeSysRoot();
|
||||
if (getTriple().getOS() == llvm::Triple::UnknownOS) {
|
||||
// Theoretically an "unknown" OS should mean no standard libraries, however
|
||||
// it could also mean that a custom set of libraries is in use, so just add
|
||||
@@ -402,6 +402,7 @@ void WebAssembly::AddClangSystemIncludeA
|
||||
return;
|
||||
|
||||
const Driver &D = getDriver();
|
||||
+ std::string SysRoot = computeSysRoot();
|
||||
|
||||
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
|
||||
SmallString<128> P(D.ResourceDir);
|
||||
@@ -427,10 +428,10 @@ void WebAssembly::AddClangSystemIncludeA
|
||||
|
||||
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 + "/include/" + MultiarchTriple);
|
||||
}
|
||||
- addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/include");
|
||||
+ addSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
|
||||
}
|
||||
|
||||
void WebAssembly::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
||||
@@ -478,6 +479,17 @@ Tool *WebAssembly::buildLinker() const {
|
||||
return new tools::wasm::Linker(*this);
|
||||
}
|
||||
|
||||
+std::string WebAssembly::computeSysRoot() const {
|
||||
+ if (!getDriver().SysRoot.empty())
|
||||
+ return getDriver().SysRoot;
|
||||
+
|
||||
+ std::string Path = "/usr";
|
||||
+ if (getVFS().exists(Path))
|
||||
+ return Path;
|
||||
+
|
||||
+ return std::string();
|
||||
+}
|
||||
+
|
||||
void WebAssembly::addLibCxxIncludePaths(
|
||||
const llvm::opt::ArgList &DriverArgs,
|
||||
llvm::opt::ArgStringList &CC1Args) const {
|
||||
--- a/clang/lib/Driver/ToolChains/WebAssembly.h
|
||||
+++ b/clang/lib/Driver/ToolChains/WebAssembly.h
|
||||
@@ -89,6 +89,8 @@ private:
|
||||
llvm::opt::ArgStringList &CC1Args) const;
|
||||
void addLibStdCXXIncludePaths(const llvm::opt::ArgList &DriverArgs,
|
||||
llvm::opt::ArgStringList &CC1Args) const;
|
||||
+
|
||||
+ std::string computeSysRoot() const override;
|
||||
};
|
||||
|
||||
} // end namespace toolchains
|
45
debian/rules
vendored
45
debian/rules
vendored
@ -27,7 +27,7 @@ DEBIAN_REVISION := $(shell dpkg-parsechangelog | sed -rne "s,^Version: 1:([0-9.
|
||||
ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
|
||||
NJOBS := -j $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
|
||||
else
|
||||
NJOBS := $(shell nproc)
|
||||
NJOBS := -j $(shell nproc)
|
||||
endif
|
||||
|
||||
VENDOR=$(shell lsb_release -is)
|
||||
@ -713,7 +713,38 @@ else
|
||||
endif
|
||||
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
|
||||
@ -860,6 +891,9 @@ ifeq ($(LLVM_SPIRV_INSTALLED),yes)
|
||||
DESTDIR=$(DEB_INST) ninja $(VERBOSE) -C libclc/build install
|
||||
endif
|
||||
|
||||
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/; \
|
||||
@ -1007,7 +1041,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:
|
||||
@ -1143,6 +1179,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
|
||||
@ -1158,4 +1195,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