lld-link: For nonexisting inputs, omit follow-on diagnostics
authorNico Weber <nicolasweber@gmx.de>
Thu, 13 Sep 2018 18:13:21 +0000 (18:13 +0000)
committerNico Weber <nicolasweber@gmx.de>
Thu, 13 Sep 2018 18:13:21 +0000 (18:13 +0000)
For lld-link missing.obj, lld-link currently prints:

  lld-link: error: could not open foo.obj: No such file or directory
  lld-link: warning: /machine is not specified. x64 is assumed
  lld-link: error: subsystem must be defined

The 2nd and 3rd diagnostics are consequences of the input not existing and are
not interesting. If input files are missing, the best thing we can do is point
that out and then return.

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

llvm-svn: 342158

lld/COFF/Driver.cpp
lld/test/COFF/could-not-open.test [new file with mode: 0644]

index 0584c74..4c3ad67 100644 (file)
@@ -1236,6 +1236,9 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
   // Read all input files given via the command line.
   run();
 
+  if (errorCount())
+    return;
+
   // We should have inferred a machine type by now from the input files, but if
   // not we assume x64.
   if (Config->Machine == IMAGE_FILE_MACHINE_UNKNOWN) {
diff --git a/lld/test/COFF/could-not-open.test b/lld/test/COFF/could-not-open.test
new file mode 100644 (file)
index 0000000..87f11c3
--- /dev/null
@@ -0,0 +1,5 @@
+RUN: not lld-link 01 2>&1 | FileCheck %s
+
+CHECK:     could not open 01
+CHECK-NOT: /machine is not specified
+CHECK-NOT: subsystem must be defined