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

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 6 01:02:18 PST 2022


Author: Fangrui Song
Date: 2022-01-06T01:02:14-08:00
New Revision: 6e4bbbfcc8327465440da38d86f1f4b37d452e43

URL: https://github.com/llvm/llvm-project/commit/6e4bbbfcc8327465440da38d86f1f4b37d452e43
DIFF: https://github.com/llvm/llvm-project/commit/6e4bbbfcc8327465440da38d86f1f4b37d452e43.diff

LOG: [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.

Added: 
    

Modified: 
    lld/ELF/Options.td
    lld/test/ELF/color-diagnostics.test

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Options.td b/lld/ELF/Options.td
index 14b138e99da5..ca9fdcde791f 100644
--- a/lld/ELF/Options.td
+++ b/lld/ELF/Options.td
@@ -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">;

diff  --git a/lld/test/ELF/color-diagnostics.test b/lld/test/ELF/color-diagnostics.test
index 7f1e46c13492..6d87b1130bee 100644
--- a/lld/test/ELF/color-diagnostics.test
+++ b/lld/test/ELF/color-diagnostics.test
@@ -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


        


More information about the llvm-commits mailing list