Show "Unknown -z option" error message even if --version or --help are given.

Previously, we validated -z options after we process --version or --help flags.
So, if one of these flags is given, we wouldn't show an "unknown -z option"
error. This patch fixes that behavior.

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

llvm-svn: 353967
This commit is contained in:
Rui Ueyama 2019-02-13 18:48:39 +00:00
parent 9239b9a0e2
commit 265e8e8252
2 changed files with 2 additions and 1 deletions

View File

@ -370,6 +370,7 @@ void LinkerDriver::main(ArrayRef<const char *> ArgsArr) {
// Interpret this flag early because error() depends on them. // Interpret this flag early because error() depends on them.
errorHandler().ErrorLimit = args::getInteger(Args, OPT_error_limit, 20); errorHandler().ErrorLimit = args::getInteger(Args, OPT_error_limit, 20);
checkZOptions(Args);
// Handle -help // Handle -help
if (Args.hasArg(OPT_help)) { if (Args.hasArg(OPT_help)) {
@ -410,7 +411,6 @@ void LinkerDriver::main(ArrayRef<const char *> ArgsArr) {
} }
readConfigs(Args); readConfigs(Args);
checkZOptions(Args);
// The behavior of -v or --version is a bit strange, but this is // The behavior of -v or --version is a bit strange, but this is
// needed for compatibility with GNU linkers. // needed for compatibility with GNU linkers.

View File

@ -60,6 +60,7 @@
# ERR9: cannot open output file utput=/no/such/file # 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 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 # ERR10: unknown -z value: foo
## Check we report "unknown -z value" error even with -v. ## Check we report "unknown -z value" error even with -v.