Index: lld/ELF/Driver.cpp =================================================================== --- lld/ELF/Driver.cpp +++ lld/ELF/Driver.cpp @@ -368,6 +368,7 @@ void LinkerDriver::main(ArrayRef ArgsArr) { ELFOptTable Parser; opt::InputArgList Args = Parser.parse(ArgsArr.slice(1)); + checkZOptions(Args); // Interpret this flag early because error() depends on them. errorHandler().ErrorLimit = args::getInteger(Args, OPT_error_limit, 20); @@ -413,7 +414,6 @@ } readConfigs(Args); - checkZOptions(Args); // The behavior of -v or --version is a bit strange, but this is // needed for compatibility with GNU linkers. Index: lld/test/ELF/driver.test =================================================================== --- lld/test/ELF/driver.test +++ lld/test/ELF/driver.test @@ -60,6 +60,7 @@ # ERR9: cannot open output file utput=/no/such/file # RUN: not ld.lld %t -z foo 2>&1 | FileCheck -check-prefix=ERR10 %s +# RUN: not ld.lld %t -z foo --version 2>&1 | FileCheck -check-prefix=ERR10 %s # ERR10: unknown -z value: foo ## Check we report "unknown -z value" error even with -v.