[lld] r344514 - [LLD][ELF] - Check options before processing the -v/-version options.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 15 07:21:43 PDT 2018
Author: grimar
Date: Mon Oct 15 07:21:43 2018
New Revision: 344514
URL: http://llvm.org/viewvc/llvm-project?rev=344514&view=rev
Log:
[LLD][ELF] - Check options before processing the -v/-version options.
This is https://bugs.llvm.org/show_bug.cgi?id=39289.
Currently both gold and bfd report errors about invalid options values
even with -v/-versions. But LLD does not.
This makes complicated to check the options available when LLD is used.
Patch makes LLD behavior to be consistent with GNU linkers.
Differential revision: https://reviews.llvm.org/D53278
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/test/ELF/driver.test
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=344514&r1=344513&r2=344514&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Mon Oct 15 07:21:43 2018
@@ -396,13 +396,6 @@ void LinkerDriver::main(ArrayRef<const c
if (Args.hasArg(OPT_v) || Args.hasArg(OPT_version))
message(getLLDVersion() + " (compatible with GNU linkers)");
- // The behavior of -v or --version is a bit strange, but this is
- // needed for compatibility with GNU linkers.
- if (Args.hasArg(OPT_v) && !Args.hasArg(OPT_INPUT))
- return;
- if (Args.hasArg(OPT_version))
- return;
-
if (const char *Path = getReproduceOption(Args)) {
// Note that --reproduce is a debug option so you can ignore it
// if you are trying to understand the whole picture of the code.
@@ -421,6 +414,14 @@ void LinkerDriver::main(ArrayRef<const c
readConfigs(Args);
checkZOptions(Args);
+
+ // The behavior of -v or --version is a bit strange, but this is
+ // needed for compatibility with GNU linkers.
+ if (Args.hasArg(OPT_v) && !Args.hasArg(OPT_INPUT))
+ return;
+ if (Args.hasArg(OPT_version))
+ return;
+
initLLVM();
createFiles(Args);
if (errorCount())
Modified: lld/trunk/test/ELF/driver.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/driver.test?rev=344514&r1=344513&r2=344514&view=diff
==============================================================================
--- lld/trunk/test/ELF/driver.test (original)
+++ lld/trunk/test/ELF/driver.test Mon Oct 15 07:21:43 2018
@@ -62,6 +62,9 @@
# RUN: not ld.lld %t -z foo 2>&1 | FileCheck -check-prefix=ERR10 %s
# ERR10: unknown -z value: foo
+## Check we report "unknown -z value" error even with -v.
+# RUN: not ld.lld %t -z foo -v 2>&1 | FileCheck -check-prefix=ERR10 %s
+
# RUN: not ld.lld %t -z max-page-size 2>&1 | FileCheck -check-prefix=ERR11 %s
# ERR11: unknown -z value: max-page-size
More information about the llvm-commits
mailing list