[ELF] Enforce double-dash form for --color-diagnostics/--rsp-quoting/--symbol-ordering-file

They are LLD-specific and by convention we enforce the double-dash form to avoid
collision with short options (e.g. weird `-c olor-diagnostics` interpretation in
GNU ld). They are rarely used and to the best of my investigation the undesired
single-dash forms are not used in the wild.
This commit is contained in:
Fangrui Song 2022-01-06 01:02:14 -08:00
parent c41aa41957
commit 6e4bbbfcc8
2 changed files with 9 additions and 9 deletions

View File

@ -119,10 +119,10 @@ defm call_graph_profile_sort: BB<"call-graph-profile-sort",
// --chroot doesn't have a help text because it is an internal option.
def chroot: Separate<["--"], "chroot">;
defm color_diagnostics: B<"color-diagnostics",
defm color_diagnostics: BB<"color-diagnostics",
"Alias for --color-diagnostics=always",
"Alias for --color-diagnostics=never">;
def color_diagnostics_eq: J<"color-diagnostics=">,
def color_diagnostics_eq: JJ<"color-diagnostics=">,
HelpText<"Use colors in diagnostics (default: auto)">,
MetaVarName<"[auto,always,never]">;
@ -395,7 +395,7 @@ def strip_all: F<"strip-all">, HelpText<"Strip all symbols. Implies --strip-debu
def strip_debug: F<"strip-debug">, HelpText<"Strip debugging information">;
defm symbol_ordering_file:
Eq<"symbol-ordering-file", "Layout sections to place symbols in the order specified by symbol ordering file">;
EEq<"symbol-ordering-file", "Layout sections to place symbols in the order specified by symbol ordering file">;
defm sysroot: Eq<"sysroot", "Set the system root">;
@ -445,7 +445,7 @@ defm undefined_version: B<"undefined-version",
"Allow unused version in version script (default)",
"Report version scripts that refer undefined symbols">;
defm rsp_quoting: Eq<"rsp-quoting", "Quoting style for response files">,
defm rsp_quoting: EEq<"rsp-quoting", "Quoting style for response files">,
MetaVarName<"[posix,windows]">;
def v: Flag<["-"], "v">, HelpText<"Display the version number">;

View File

@ -1,21 +1,21 @@
# Windows command prompt doesn't support ANSI escape sequences.
# REQUIRES: shell
# RUN: not ld.lld -xyz -color-diagnostics /nosuchfile 2>&1 \
# RUN: not ld.lld -xyz --color-diagnostics /nosuchfile 2>&1 \
# RUN: | FileCheck -check-prefix=COLOR %s
# RUN: not ld.lld -xyz -color-diagnostics=always /nosuchfile 2>&1 \
# RUN: not ld.lld -xyz --color-diagnostics=always /nosuchfile 2>&1 \
# RUN: | FileCheck -check-prefix=COLOR %s
# COLOR: {{ld.lld: .\[0;31merror: .\[0munknown argument '-xyz'}}
# COLOR: {{ld.lld: .\[0;31merror: .\[0mcannot open /nosuchfile}}
# RUN: not ld.lld -color-diagnostics=foobar 2>&1 | FileCheck -check-prefix=ERR %s
# RUN: not ld.lld --color-diagnostics=foobar 2>&1 | FileCheck -check-prefix=ERR %s
# ERR: unknown option: --color-diagnostics=foobar
# RUN: not ld.lld /nosuchfile 2>&1 | FileCheck -check-prefix=NOCOLOR %s
# RUN: not ld.lld -color-diagnostics=never /nosuchfile 2>&1 \
# RUN: not ld.lld --color-diagnostics=never /nosuchfile 2>&1 \
# RUN: | FileCheck -check-prefix=NOCOLOR %s
# RUN: not ld.lld -color-diagnostics=always -no-color-diagnostics \
# RUN: not ld.lld --color-diagnostics=always --no-color-diagnostics \
# RUN: /nosuchfile 2>&1 | FileCheck -check-prefix=NOCOLOR %s
# NOCOLOR: ld.lld: error: cannot open /nosuchfile