[PATCH] D49189: Omit path to lld binary from lld's error and warning diagnostics.

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 11 07:59:22 PDT 2018


thakis created this revision.
thakis added a reviewer: ruiu.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

lld currently prepends the absolute path to itself to every diagnostic it emits. This path can be longer than the diagnostic, and makes the actual error message hard to read.

There isn't a good reason for printing this path: if you want to know which lld you're running, pass -v to clang – chances are that if you're unsure of this, you're not only unsure when it errors out. So just omit it.

Before:

  $ out/bin/clang -target x86_64-unknown-linux -x c++ /dev/null -fuse-ld=lld 
  /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: cannot open crt1.o: No such file or directory
  /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: cannot open crti.o: No such file or directory
  /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: cannot open crtbegin.o: No such file or directory
  /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: unable to find library -lgcc
  /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: unable to find library -lgcc_s
  /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: unable to find library -lc
  /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: unable to find library -lgcc
  /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: unable to find library -lgcc_s
  /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: cannot open crtend.o: No such file or directory
  /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: cannot open crtn.o: No such file or directory
  clang: error: linker command failed with exit code 1 (use -v to see invocation)

After:

  $ out/bin/clang -target x86_64-unknown-linux -x c++ /dev/null -fuse-ld=lld 
  error: cannot open crt1.o: No such file or directory
  error: cannot open crti.o: No such file or directory
  error: cannot open crtbegin.o: No such file or directory
  error: unable to find library -lgcc
  error: unable to find library -lgcc_s
  error: unable to find library -lc
  error: unable to find library -lgcc
  error: unable to find library -lgcc_s
  error: cannot open crtend.o: No such file or directory
  error: cannot open crtn.o: No such file or directory
  clang: error: linker command failed with exit code 1 (use -v to see invocation)

(The path is still printed for log messages.)


https://reviews.llvm.org/D49189

Files:
  lld/Common/ErrorHandler.cpp
  lld/test/ELF/basic.s
  lld/test/ELF/color-diagnostics.test


Index: lld/test/ELF/color-diagnostics.test
===================================================================
--- lld/test/ELF/color-diagnostics.test
+++ lld/test/ELF/color-diagnostics.test
@@ -6,13 +6,13 @@
 # RUN: not ld.lld -xyz -color-diagnostics=always /nosuchfile 2>&1 \
 # RUN:   | FileCheck -check-prefix=COLOR %s
 
-# COLOR: {{ld.lld: .\[0;1;31merror: .\[0munknown argument: -xyz}}
-# COLOR: {{ld.lld: .\[0;1;31merror: .\[0mcannot open /nosuchfile}}
+# COLOR: {{.\[0;1;31merror: .\[0munknown argument: -xyz}}
+# COLOR: {{.\[0;1;31merror: .\[0mcannot open /nosuchfile}}
 
 # RUN: not ld.lld /nosuchfile 2>&1 | FileCheck -check-prefix=NOCOLOR %s
 # RUN: not ld.lld -color-diagnostics=never /nosuchfile 2>&1 \
 # RUN:   | FileCheck -check-prefix=NOCOLOR %s
 # RUN: not ld.lld -color-diagnostics=always -no-color-diagnostics \
 # RUN:   /nosuchfile 2>&1 | FileCheck -check-prefix=NOCOLOR %s
 
-# NOCOLOR: ld.lld: error: cannot open /nosuchfile
+# NOCOLOR: error: cannot open /nosuchfile
Index: lld/test/ELF/basic.s
===================================================================
--- lld/test/ELF/basic.s
+++ lld/test/ELF/basic.s
@@ -224,7 +224,7 @@
 
 # RUN: not ld.lld -o %t2 2>&1 | \
 # RUN:  FileCheck --check-prefix=NO_INPUT %s
-# NO_INPUT: ld.lld{{.*}}: no input files
+# NO_INPUT: error: no input files
 
 # RUN: not ld.lld %t.no.such.file -o %t2 2>&1 | \
 # RUN:  FileCheck --check-prefix=CANNOT_OPEN %s
Index: lld/Common/ErrorHandler.cpp
===================================================================
--- lld/Common/ErrorHandler.cpp
+++ lld/Common/ErrorHandler.cpp
@@ -74,7 +74,6 @@
 }
 
 void ErrorHandler::print(StringRef S, raw_ostream::Colors C) {
-  *ErrorOS << LogName << ": ";
   if (ColorDiagnostics) {
     ErrorOS->changeColor(C, true);
     *ErrorOS << S;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49189.155000.patch
Type: text/x-patch
Size: 1790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180711/115226c3/attachment.bin>


More information about the llvm-commits mailing list