[clang] f078d99 - [WebAssembly] fix: respect -Wl, --no-demangle option (#213878)

via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 19 08:52:56 PDT 2026


Author: Martin Liška
Date: 2026-08-19T08:52:51-07:00
New Revision: f078d99d6119f2c0f4116c903a4155cbbf8f27ca

URL: https://github.com/llvm/llvm-project/commit/f078d99d6119f2c0f4116c903a4155cbbf8f27ca
DIFF: https://github.com/llvm/llvm-project/commit/f078d99d6119f2c0f4116c903a4155cbbf8f27ca.diff

LOG: [WebAssembly] fix: respect -Wl,--no-demangle option (#213878)

Right now, the option is not passed to the wasm-ld.

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/WebAssembly.cpp
    clang/test/Driver/wasm-toolchain.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 3a919ce68b3db..7d5d406df2399 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -120,6 +120,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 \


        


More information about the cfe-commits mailing list