[lld] 248e345 - [LLD] [MinGW] Pass the --demangle and --no-demangle options to the COFF linker

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 7 00:08:28 PST 2021


Author: Martin Storsjö
Date: 2021-01-07T10:02:19+02:00
New Revision: 248e3450fb8a1ab7146c0cbe8f0ea7204782f542

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

LOG: [LLD] [MinGW] Pass the --demangle and --no-demangle options to the COFF linker

Differential Revision: https://reviews.llvm.org/D93950

Added: 
    

Modified: 
    lld/MinGW/Driver.cpp
    lld/MinGW/Options.td
    lld/test/MinGW/driver.test

Removed: 
    


################################################################################
diff  --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp
index fae5cb77ec5d..f8eb4e76b7f9 100644
--- a/lld/MinGW/Driver.cpp
+++ b/lld/MinGW/Driver.cpp
@@ -320,6 +320,11 @@ bool mingw::link(ArrayRef<const char *> argsArr, bool canExitEarly,
   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
index 7bc5936d58d6..95b61952fc5e 100644
--- a/lld/MinGW/Options.td
+++ b/lld/MinGW/Options.td
@@ -28,6 +28,9 @@ defm allow_multiple_definition: B<"allow-multiple-definition",
     "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
index 015c26963923..33503d45189e 100644
--- a/lld/test/MinGW/driver.test
+++ b/lld/test/MinGW/driver.test
@@ -285,3 +285,12 @@ NO_ALLOW_MULTIPLE_DEFINITION-NOT: -force:multiple
 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


        


More information about the llvm-commits mailing list