Index: COFF/Driver.cpp =================================================================== --- COFF/Driver.cpp +++ COFF/Driver.cpp @@ -1236,6 +1236,9 @@ // 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) { Index: test/COFF/could-not-open.test =================================================================== --- test/COFF/could-not-open.test +++ test/COFF/could-not-open.test @@ -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