llvm-toolchain/debian/patches/wasm-compiler-rt-default.diff
Faidon Liambotis a94a2fe7c3 Default to compiler-rt for WebAssembly (wasm32/64)
Our packaging overrides the upstream choice for rtlib to default always
to libgcc. Unfortunately, libgcc is not available for WebAssembly
(wasm32/wasm64 targets). This makes every build to -target
wasm32-unknown-wasi fail, unless one passes --rtlib=compiler-rt.

Patch the upstream source to default, and only accept, compiler-rt for
the WebAssembly target to make everything work out of the box. This
mirrors similar code that the upstream Darwin and Fuchsia targets have.

GCC seems fairly far from supporting WebAssembly. If/when that day
comes, this patch can be dropped.
2022-10-07 15:45:21 +03:00

32 lines
1.3 KiB
Diff

--- 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,