Index: test/wasm/demangle.ll =================================================================== --- test/wasm/demangle.ll +++ test/wasm/demangle.ll @@ -0,0 +1,17 @@ +; RUN: llc -filetype=obj %s -o %t.o +; RUN: not wasm-ld --check-signatures --undefined _Z3fooi \ +; RUN: -o %t.wasm %t.o 2>&1 | FileCheck %s + +; CHECK: error: undefined symbol: foo(int) + +; RUN: not wasm-ld --check-signatures --no-demangle --undefined _Z3fooi \ +; RUN: -o %t.wasm %t.o 2>&1 | FileCheck -check-prefix=CHECK-NODEMANGLE %s + +; CHECK-NODEMANGLE: error: undefined symbol: _Z3fooi + +target triple = "wasm32-unknown-unknown-wasm" + +define hidden void @_start() local_unnamed_addr { +entry: + ret void +} Index: wasm/Driver.cpp =================================================================== --- wasm/Driver.cpp +++ wasm/Driver.cpp @@ -280,6 +280,7 @@ Config->AllowUndefined = Args.hasArg(OPT_allow_undefined); Config->CheckSignatures = Args.hasFlag(OPT_check_signatures, OPT_no_check_signatures, false); + Config->Demangle = Args.hasFlag(OPT_demangle, OPT_no_demangle, true); Config->Entry = getEntry(Args, Args.hasArg(OPT_relocatable) ? "" : "_start"); Config->ImportMemory = Args.hasArg(OPT_import_memory); Config->OutputFile = Args.getLastArgValue(OPT_o); Index: wasm/Options.td =================================================================== --- wasm/Options.td +++ wasm/Options.td @@ -11,6 +11,11 @@ def _eq: Joined<["--", "-"], name # "=">, Alias(NAME)>; } +multiclass B { + def NAME: Flag<["--", "-"], name>, HelpText; + def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText; +} + // The follow flags are shared with the ELF linker def color_diagnostics: F<"color-diagnostics">, HelpText<"Use colors in diagnostics">; @@ -18,6 +23,10 @@ def color_diagnostics_eq: J<"color-diagnostics=">, HelpText<"Use colors in diagnostics">; +defm demangle: B<"demangle", + "Demangle symbol names", + "Do not demangle symbol names">; + def entry: S<"entry">, MetaVarName<"">, HelpText<"Name of entry point symbol">;