[clang] [WebAssembly] fix: respect -Wl, --no-demangle option (PR #213878)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 4 01:53:44 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Martin Liška (marxin)
<details>
<summary>Changes</summary>
Right now, the option is not passed to the wasm-ld.
---
Full diff: https://github.com/llvm/llvm-project/pull/213878.diff
2 Files Affected:
- (modified) clang/lib/Driver/ToolChains/WebAssembly.cpp (+3)
- (modified) clang/test/Driver/wasm-toolchain.c (+4)
``````````diff
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 7dabefbee7f79..2e8afb163b30a 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -121,6 +121,9 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasArg(options::OPT_s))
CmdArgs.push_back("--strip-all");
+ if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
+ CmdArgs.push_back("--no-demangle");
+
// On `wasip2` the default linker is `wasm-component-ld` which wraps the
// execution of `wasm-ld`. Find `wasm-ld` and pass it as an argument of where
// to find it to avoid it needing to hunt and rediscover or search `PATH` for
diff --git a/clang/test/Driver/wasm-toolchain.c b/clang/test/Driver/wasm-toolchain.c
index c02a102fab081..467d79e57aff1 100644
--- a/clang/test/Driver/wasm-toolchain.c
+++ b/clang/test/Driver/wasm-toolchain.c
@@ -19,6 +19,10 @@
// LINK: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
// LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins.a" "-o" "a.out"
+// RUN: %clang -### --target=wasm32-unknown-unknown --sysroot=/foo %s -Wl,--no-demangle 2>&1 \
+// RUN: | FileCheck -check-prefix=LINK_NO_DEMANGLE %s
+// LINK_NO_DEMANGLE: wasm-ld{{.*}}"--no-demangle"
+
// A basic C link command-line with optimization with unknown OS.
// RUN: %clang -### -O2 --target=wasm32-unknown-unknown --sysroot=/foo %s 2>&1 \
``````````
</details>
https://github.com/llvm/llvm-project/pull/213878
More information about the cfe-commits
mailing list