Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -328,6 +328,8 @@ void LinkerDriver::main(ArrayRef ArgsArr) { ELFOptTable Parser; opt::InputArgList Args = Parser.parse(ArgsArr.slice(1)); + if (errorCount()) + return; // Interpret this flag early because error() depends on them. errorHandler().ErrorLimit = args::getInteger(Args, OPT_error_limit, 20); @@ -1054,7 +1056,7 @@ } } - if (Files.empty() && errorCount() == 0) + if (Files.empty()) error("no input files"); } Index: wasm/Driver.cpp =================================================================== --- wasm/Driver.cpp +++ wasm/Driver.cpp @@ -293,6 +293,8 @@ void LinkerDriver::link(ArrayRef ArgsArr) { WasmOptTable Parser; opt::InputArgList Args = Parser.parse(ArgsArr.slice(1)); + if (errorCount()) + return; // Handle --help if (Args.hasArg(OPT_help)) { @@ -425,8 +427,6 @@ } createFiles(Args); - if (errorCount()) - return; // Add all files to the symbol table. This will add almost all // symbols that we need to the symbol table.