diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp --- a/lld/MinGW/Driver.cpp +++ b/lld/MinGW/Driver.cpp @@ -320,6 +320,11 @@ else add("-opt:noref"); + if (args.hasFlag(OPT_demangle, OPT_no_demangle, true)) + add("-demangle"); + else + add("-demangle:no"); + if (args.hasFlag(OPT_enable_auto_import, OPT_disable_auto_import, true)) add("-auto-import"); else diff --git a/lld/MinGW/Options.td b/lld/MinGW/Options.td --- a/lld/MinGW/Options.td +++ b/lld/MinGW/Options.td @@ -28,6 +28,9 @@ "Do not allow multiple definitions (default)">; def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries">; def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">; +defm demangle: B<"demangle", + "Demangle symbol names (default)", + "Do not demangle symbol names">; def disable_auto_import: F<"disable-auto-import">, HelpText<"Don't automatically import data symbols from other DLLs without dllimport">; def disable_runtime_pseudo_reloc: F<"disable-runtime-pseudo-reloc">, diff --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test --- a/lld/test/MinGW/driver.test +++ b/lld/test/MinGW/driver.test @@ -285,3 +285,12 @@ RUN: ld.lld -### -m i386pep foo.o -wrap foo1 --wrap foo2 | FileCheck -check-prefix WRAP %s RUN: ld.lld -### -m i386pep foo.o -wrap=foo1 --wrap=foo2 | FileCheck -check-prefix WRAP %s WRAP: -wrap:foo1 -wrap:foo2 + +RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix DEMANGLE %s +RUN: ld.lld -### -m i386pep foo.o -demangle | FileCheck -check-prefix DEMANGLE %s +RUN: ld.lld -### -m i386pep foo.o --demangle | FileCheck -check-prefix DEMANGLE %s +DEMANGLE: -demangle{{ }} + +RUN: ld.lld -### -m i386pep foo.o -no-demangle | FileCheck -check-prefix NO-DEMANGLE %s +RUN: ld.lld -### -m i386pep foo.o --no-demangle | FileCheck -check-prefix NO-DEMANGLE %s +NO-DEMANGLE: -demangle:no