mirror of
https://github.com/rui314/mold.git
synced 2024-12-26 18:02:30 +03:00
Do not exit immediately on --version
This commit is contained in:
parent
3fab4ce3d2
commit
8dd0accc89
13
cmdline.cc
13
cmdline.cc
@ -364,15 +364,11 @@ void parse_nonpositional_args(Context<E> &ctx,
|
||||
args = args.subspan(1);
|
||||
|
||||
ctx.arg.thread_count = get_default_thread_count();
|
||||
bool version_shown = false;
|
||||
|
||||
while (!args.empty()) {
|
||||
std::string_view arg;
|
||||
|
||||
if (read_flag(args, "v") || read_flag(args, "version")) {
|
||||
SyncOut(ctx) << get_version_string();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (read_flag(args, "help")) {
|
||||
SyncOut(ctx) << "Usage: " << ctx.cmdline_args[0]
|
||||
<< " [options] file...\n" << helpmsg;
|
||||
@ -386,9 +382,13 @@ void parse_nonpositional_args(Context<E> &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")) {
|
||||
SyncOut(ctx) << get_version_string();
|
||||
version_shown = true;
|
||||
} else if (read_flag(args, "V")) {
|
||||
SyncOut(ctx) << get_version_string()
|
||||
<< "\n Supported emulations:\n elf_x86_64\n elf_i386";
|
||||
version_shown = true;
|
||||
} else if (read_flag(args, "export-dynamic") || read_flag(args, "E")) {
|
||||
ctx.arg.export_dynamic = true;
|
||||
} else if (read_flag(args, "no-export-dynamic")) {
|
||||
@ -693,6 +693,9 @@ void parse_nonpositional_args(Context<E> &ctx,
|
||||
|
||||
if (ctx.arg.output.empty())
|
||||
ctx.arg.output = "a.out";
|
||||
|
||||
if (version_shown && remaining.empty())
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#define INSTANTIATE(E) \
|
||||
|
@ -12,4 +12,15 @@ mkdir -p $t
|
||||
../mold -V | grep -q elf_x86_64
|
||||
../mold -V | grep -q elf_i386
|
||||
|
||||
cat <<EOF | clang -c -xc -o $t/a.o -
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
printf("Hello world\n");
|
||||
}
|
||||
EOF
|
||||
|
||||
clang -fuse-ld=`pwd`/../mold -Wl,--version -o $t/exe $t/a.o | grep -q mold
|
||||
$t/exe | grep -q 'Hello world'
|
||||
|
||||
echo OK
|
||||
|
Loading…
Reference in New Issue
Block a user