[lld] r355878 - lld-link: Only print demangled symbol names by default
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 11 16:02:19 PDT 2019
Author: nico
Date: Mon Mar 11 16:02:18 2019
New Revision: 355878
URL: http://llvm.org/viewvc/llvm-project?rev=355878&view=rev
Log:
lld-link: Only print demangled symbol names by default
This makes lld-link's output a bit more concise. Since most developers can't
read mangled names, this should make the output a bit easier to understand as
well. It also makes lld-link's output consistent with ld.lld's output.
(link.exe prints both demangled and mangled names; lld-link used to match
link.exe output but now no longer does.)
For people working on toolchains, add a `/demangle:no` flag that makes lld-link
print the mangled name instead of the demangled name. (If desired, people could
pipe that through `demumble -b` to get the old behavior of both demangled and
mangled output.)
Differential Revision: https://reviews.llvm.org/D58132
Modified:
lld/trunk/COFF/Config.h
lld/trunk/COFF/Driver.cpp
lld/trunk/COFF/Options.td
lld/trunk/COFF/Symbols.cpp
lld/trunk/test/COFF/undefined-symbol-cv.s
lld/trunk/test/COFF/undefined-symbol.s
Modified: lld/trunk/COFF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Config.h?rev=355878&r1=355877&r2=355878&view=diff
==============================================================================
--- lld/trunk/COFF/Config.h (original)
+++ lld/trunk/COFF/Config.h Mon Mar 11 16:02:18 2019
@@ -90,6 +90,7 @@ struct Configuration {
bool NoEntry = false;
std::string OutputFile;
std::string ImportName;
+ bool Demangle = true;
bool DoGC = true;
bool DoICF = true;
bool TailMerge;
Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=355878&r1=355877&r2=355878&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Mon Mar 11 16:02:18 2019
@@ -1081,6 +1081,9 @@ void LinkerDriver::link(ArrayRef<const c
Config->Incremental = true;
}
+ // Handle /demangle
+ Config->Demangle = Args.hasFlag(OPT_demangle, OPT_demangle_no);
+
// Handle /debugtype
Config->DebugTypes = parseDebugTypes(Args);
Modified: lld/trunk/COFF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Options.td?rev=355878&r1=355877&r2=355878&view=diff
==============================================================================
--- lld/trunk/COFF/Options.td (original)
+++ lld/trunk/COFF/Options.td Mon Mar 11 16:02:18 2019
@@ -154,6 +154,9 @@ def help_q : Flag<["/?", "-?"], "">, Ali
// LLD extensions
def exclude_all_symbols : F<"exclude-all-symbols">;
def export_all_symbols : F<"export-all-symbols">;
+defm demangle : B<"demangle",
+ "Demangle symbols in output (default)",
+ "Do not demangle symbols in output">;
def kill_at : F<"kill-at">;
def lldmingw : F<"lldmingw">;
def output_def : Joined<["/", "-"], "output-def:">;
@@ -178,11 +181,6 @@ def show_timing : F<"time">;
class QF<string name> : Joined<["/", "-", "-?"], name#":">;
-multiclass QB<string name> {
- def "" : F<name>;
- def _no : F<name#":no">;
-}
-
def ignoreidl : F<"ignoreidl">;
def nologo : F<"nologo">;
def throwingnew : F<"throwingnew">;
Modified: lld/trunk/COFF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Symbols.cpp?rev=355878&r1=355877&r2=355878&view=diff
==============================================================================
--- lld/trunk/COFF/Symbols.cpp (original)
+++ lld/trunk/COFF/Symbols.cpp Mon Mar 11 16:02:18 2019
@@ -18,10 +18,13 @@
using namespace llvm;
using namespace llvm::object;
+using namespace lld::coff;
+
// Returns a symbol name for an error message.
std::string lld::toString(coff::Symbol &B) {
- if (Optional<std::string> S = lld::demangleMSVC(B.getName()))
- return ("\"" + *S + "\" (" + B.getName() + ")").str();
+ if (Config->Demangle)
+ if (Optional<std::string> S = lld::demangleMSVC(B.getName()))
+ return *S;
return B.getName();
}
Modified: lld/trunk/test/COFF/undefined-symbol-cv.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/undefined-symbol-cv.s?rev=355878&r1=355877&r2=355878&view=diff
==============================================================================
--- lld/trunk/test/COFF/undefined-symbol-cv.s (original)
+++ lld/trunk/test/COFF/undefined-symbol-cv.s Mon Mar 11 16:02:18 2019
@@ -2,19 +2,19 @@
# RUN: llvm-mc -triple=x86_64-windows-msvc -filetype=obj -o %t.obj %s
# RUN: not lld-link /out:%t.exe %t.obj 2>&1 | FileCheck %s
-# CHECK: error: undefined symbol: "int __cdecl foo(void)" (?foo@@YAHXZ)
+# CHECK: error: undefined symbol: int __cdecl foo(void)
# CHECK-NEXT: >>> referenced by file1.cpp:1
# CHECK-NEXT: >>> {{.*}}.obj:(main)
# CHECK-NEXT: >>> referenced by file1.cpp:2
# CHECK-NEXT: >>> {{.*}}.obj:(main)
# CHECK-EMPTY:
-# CHECK-NEXT: error: undefined symbol: "int __cdecl bar(void)" (?bar@@YAHXZ)
+# CHECK-NEXT: error: undefined symbol: int __cdecl bar(void)
# CHECK-NEXT: >>> referenced by file2.cpp:3
# CHECK-NEXT: >>> {{.*}}.obj:(main)
# CHECK-NEXT: >>> referenced by file1.cpp:4
# CHECK-NEXT: >>> {{.*}}.obj:(f1)
# CHECK-EMPTY:
-# CHECK-NEXT: error: undefined symbol: "int __cdecl baz(void)" (?baz@@YAHXZ)
+# CHECK-NEXT: error: undefined symbol: int __cdecl baz(void)
# CHECK-NEXT: >>> referenced by file1.cpp:5
# CHECK-NEXT: >>> {{.*}}.obj:(f2)
Modified: lld/trunk/test/COFF/undefined-symbol.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/undefined-symbol.s?rev=355878&r1=355877&r2=355878&view=diff
==============================================================================
--- lld/trunk/test/COFF/undefined-symbol.s (original)
+++ lld/trunk/test/COFF/undefined-symbol.s Mon Mar 11 16:02:18 2019
@@ -1,16 +1,22 @@
# REQUIRES: x86
# RUN: llvm-mc -triple=x86_64-windows-msvc -filetype=obj -o %t.obj %s
# RUN: not lld-link /out:%t.exe %t.obj 2>&1 | FileCheck %s
+# RUN: not lld-link /out:%t.exe /demangle %t.obj 2>&1 | FileCheck %s
+# RUN: not lld-link /out:%t.exe /demangle:no %t.obj 2>&1 | FileCheck --check-prefix=NODEMANGLE %s
-# CHECK: error: undefined symbol: "int __cdecl foo(void)" (?foo@@YAHXZ)
+# NODEMANGLE: error: undefined symbol: ?foo@@YAHXZ
+# NODEMANGLE: error: undefined symbol: ?bar@@YAHXZ
+# NODEMANGLE: error: undefined symbol: __imp_?baz@@YAHXZ
+
+# CHECK: error: undefined symbol: int __cdecl foo(void)
# CHECK-NEXT: >>> referenced by {{.*}}.obj:(main)
# CHECK-NEXT: >>> referenced by {{.*}}.obj:(main)
# CHECK-EMPTY:
-# CHECK-NEXT: error: undefined symbol: "int __cdecl bar(void)" (?bar@@YAHXZ)
+# CHECK-NEXT: error: undefined symbol: int __cdecl bar(void)
# CHECK-NEXT: >>> referenced by {{.*}}.obj:(main)
# CHECK-NEXT: >>> referenced by {{.*}}.obj:(f1)
# CHECK-EMPTY:
-# CHECK-NEXT: error: undefined symbol: "__declspec(dllimport) int __cdecl baz(void)" (__imp_?baz@@YAHXZ)
+# CHECK-NEXT: error: undefined symbol: __declspec(dllimport) int __cdecl baz(void)
# CHECK-NEXT: >>> referenced by {{.*}}.obj:(f2)
.section .text,"xr",one_only,main
More information about the llvm-commits
mailing list