From fd1855a67bc1e62a77a2e9493ec7bf77d5706789 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 24 Jun 2021 16:45:03 +0900 Subject: [PATCH] Make --version to exit immediately This is needed by Gentoo's dev-lang/spidermonkey-78.10.1 package, as its configure script assumes that the linker exit normally even if extra options are given after `--version`. --- cmdline.cc | 5 ++++- test/version.sh | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cmdline.cc b/cmdline.cc index e090cd7b..e61f78f9 100644 --- a/cmdline.cc +++ b/cmdline.cc @@ -448,9 +448,12 @@ void parse_nonpositional_args(Context &ctx, ctx.arg.dynamic_linker = arg; } else if (read_arg(ctx, args, arg, "no-dynamic-linker")) { ctx.arg.dynamic_linker = ""; - } else if (read_flag(args, "v") || read_flag(args, "version")) { + } else if (read_flag(args, "v")) { SyncOut(ctx) << get_version_string(); version_shown = true; + } else if (read_flag(args, "version")) { + SyncOut(ctx) << get_version_string(); + exit(0); } else if (read_flag(args, "V")) { SyncOut(ctx) << get_version_string() << "\n Supported emulations:\n elf_x86_64\n elf_i386"; diff --git a/test/version.sh b/test/version.sh index a676dbb3..6d63aa31 100755 --- a/test/version.sh +++ b/test/version.sh @@ -20,7 +20,11 @@ int main() { } EOF +rm -f $t/exe clang -fuse-ld=`pwd`/../mold -Wl,--version -o $t/exe $t/a.o | grep -q mold +! [ -f $t/exe ] || false + +clang -fuse-ld=`pwd`/../mold -Wl,-v -o $t/exe $t/a.o | grep -q mold $t/exe | grep -q 'Hello world' echo OK