1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-04 08:37:28 +03:00

[ELF] Redefine --color-diagnostics as an alias for --color-diagnostics=auto

It was accidentally mapped to --color-diagnostics=always, but it
was a bug. For the sake of compatibility with other tools such as
clang or lld, it should be defined as an alias for `auto`.
This commit is contained in:
Rui Ueyama 2022-05-05 17:59:25 +08:00
parent 0dc5ed38ed
commit ca25f1fd20
2 changed files with 3 additions and 4 deletions

View File

@ -618,14 +618,13 @@ std::vector<std::string> parse_nonpositional_args(Context<E> &ctx) {
ctx.arg.directory = arg;
} else if (read_arg("chroot")) {
ctx.arg.chroot = arg;
} else if (read_flag("color-diagnostics=auto")) {
} else if (read_flag("color-diagnostics") ||
read_flag("color-diagnostics=auto")) {
ctx.arg.color_diagnostics = isatty(STDERR_FILENO);
} else if (read_flag("color-diagnostics=always")) {
ctx.arg.color_diagnostics = true;
} else if (read_flag("color-diagnostics=never")) {
ctx.arg.color_diagnostics = false;
} else if (read_flag("color-diagnostics")) {
ctx.arg.color_diagnostics = true;
} else if (read_flag("warn-common")) {
ctx.arg.warn_common = true;
} else if (read_flag("no-warn-common")) {

View File

@ -20,7 +20,7 @@ int main() { foo(); }
EOF
! "$mold" -o $t/exe $t/a.o --color-diagnostics 2> $t/log
grep -q $'\033' $t/log
! grep -q $'\033' $t/log || false
! "$mold" -o $t/exe $t/a.o --color-diagnostics=always 2> $t/log
grep -q $'\033' $t/log