[llvm-branch-commits] [lld] 77fb45e - [lld/mac] Add --version flag
Nico Weber via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Dec 22 19:11:31 PST 2020
Author: Nico Weber
Date: 2020-12-22T22:06:39-05:00
New Revision: 77fb45e59e49d25fbc57854b62599ae24aa2c4c9
URL: https://github.com/llvm/llvm-project/commit/77fb45e59e49d25fbc57854b62599ae24aa2c4c9
DIFF: https://github.com/llvm/llvm-project/commit/77fb45e59e49d25fbc57854b62599ae24aa2c4c9.diff
LOG: [lld/mac] Add --version flag
It's an extension to ld64, but all the other ports have it, and
someone asked for it in PR43721.
While here, change the COFF help text to match the other ports.
Differential Revision: https://reviews.llvm.org/D93491
Added:
Modified:
lld/COFF/Options.td
lld/MachO/Driver.cpp
lld/MachO/Options.td
lld/test/MachO/driver.test
Removed:
################################################################################
diff --git a/lld/COFF/Options.td b/lld/COFF/Options.td
index 2b8e65587ad7..5447c8312128 100644
--- a/lld/COFF/Options.td
+++ b/lld/COFF/Options.td
@@ -240,7 +240,7 @@ def lto_obj_path : P<
"lto-obj-path",
"output native object for merged LTO unit to this path">;
def dash_dash_version : Flag<["--"], "version">,
- HelpText<"Print version information">;
+ HelpText<"Display the version number and exit">;
def threads
: P<"threads", "Number of threads. '1' disables multi-threading. By "
"default all available hardware threads are used">;
diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 82ddcf084dc0..edc9fe001ab5 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -690,10 +690,15 @@ bool macho::link(llvm::ArrayRef<const char *> argsArr, bool canExitEarly,
if (args.hasArg(OPT_help_hidden)) {
parser.printHelp(argsArr[0], /*showHidden=*/true);
return true;
- } else if (args.hasArg(OPT_help)) {
+ }
+ if (args.hasArg(OPT_help)) {
parser.printHelp(argsArr[0], /*showHidden=*/false);
return true;
}
+ if (args.hasArg(OPT_version)) {
+ message(getLLDVersion());
+ return true;
+ }
if (const char *path = getReproduceOption(args)) {
// Note that --reproduce is a debug option so you can ignore it
diff --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index 52a351836a15..8e88c74efc0e 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -18,6 +18,8 @@ def reproduce: Separate<["--"], "reproduce">;
def reproduce_eq: Joined<["--"], "reproduce=">,
Alias<!cast<Separate>(reproduce)>,
HelpText<"Write tar file containing inputs and command to reproduce link">;
+def version: Flag<["--"], "version">,
+ HelpText<"Display the version number and exit">;
// This is a complete Options.td compiled from Apple's ld(1) manpage
@@ -508,7 +510,7 @@ def bitcode_symbol_map : Separate<["-"], "bitcode_symbol_map">,
def grp_rare : OptionGroup<"rare">, HelpText<"RARELY USED">;
def v : Flag<["-"], "v">,
- HelpText<"Print the linker version">,
+ HelpText<"Print the linker version and search paths and exit">,
Group<grp_rare>;
def version_details : Flag<["-"], "version_details">,
HelpText<"Print the linker version in JSON form">,
diff --git a/lld/test/MachO/driver.test b/lld/test/MachO/driver.test
index 229ec3ef6963..417c71eac561 100644
--- a/lld/test/MachO/driver.test
+++ b/lld/test/MachO/driver.test
@@ -1,5 +1,7 @@
-# RUN: not %lld ---help 2>&1 | FileCheck -check-prefix=SPELLHELP %s
+# RUN: %lld --version | FileCheck -check-prefix=VERSION %s
+VERSION: {{LLD [0-9]+\.[0-9]+}}
+# RUN: not %lld ---help 2>&1 | FileCheck -check-prefix=SPELLHELP %s
SPELLHELP: error: unknown argument '---help', did you mean '--help'
# FIXME: This should say "no input files" instead
SPELLHELP: error: undefined symbol: _main
More information about the llvm-branch-commits
mailing list