[llvm-branch-commits] [lld] 8f24d17 - [LLD] [MinGW] Support both "--opt value" and "--opt=value" for more options
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Aug 9 23:24:50 PDT 2021
Author: Martin Storsjö
Date: 2021-08-09T23:24:23-07:00
New Revision: 8f24d178691f522d9ed46eef84f8408979b1db51
URL: https://github.com/llvm/llvm-project/commit/8f24d178691f522d9ed46eef84f8408979b1db51
DIFF: https://github.com/llvm/llvm-project/commit/8f24d178691f522d9ed46eef84f8408979b1db51.diff
LOG: [LLD] [MinGW] Support both "--opt value" and "--opt=value" for more options
This does the same fix as D107237 but for a couple more options,
converting all remaining cases of such options to accept both
forms, for consistency. This fixes building e.g. openldap, which
uses --image-base=<value>.
Differential Revision: https://reviews.llvm.org/D107253
(cherry picked from commit b7fb5b54a93099cf3d7ac64f4a95d9942bc2e6a7)
Added:
Modified:
lld/MinGW/Options.td
lld/test/MinGW/driver.test
Removed:
################################################################################
diff --git a/lld/MinGW/Options.td b/lld/MinGW/Options.td
index 7b250614e434b..fb178a1438e55 100644
--- a/lld/MinGW/Options.td
+++ b/lld/MinGW/Options.td
@@ -16,6 +16,11 @@ multiclass EqLong<string name, string help> {
HelpText<help>;
}
+multiclass EqNoHelp<string name> {
+ def NAME: Separate<["--", "-"], name>;
+ def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>;
+}
+
multiclass B<string name, string help1, string help2> {
def NAME: Flag<["--", "-"], name>, HelpText<help1>;
def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>;
@@ -57,8 +62,8 @@ defm gc_sections: B<"gc-sections",
"Remove unused sections",
"Don't remove unused sections">;
def help: F<"help">, HelpText<"Print option help">;
-def icf: J<"icf=">, HelpText<"Identical code folding">;
-def image_base: S<"image-base">, HelpText<"Base address of the program">;
+defm icf: Eq<"icf", "Identical code folding">;
+defm image_base: Eq<"image-base", "Base address of the program">;
defm insert_timestamp: B<"insert-timestamp",
"Include PE header timestamp",
"Don't include PE header timestamp">;
@@ -109,12 +114,11 @@ def _HASH_HASH_HASH : Flag<["-"], "###">,
HelpText<"Print (but do not run) the commands to run for this compilation">;
def appcontainer: F<"appcontainer">, HelpText<"Set the appcontainer flag in the executable">;
defm delayload: Eq<"delayload", "DLL to load only on demand">;
-def mllvm: S<"mllvm">;
+defm mllvm: EqNoHelp<"mllvm">;
defm pdb: Eq<"pdb", "Output PDB debug info file, chosen implicitly if the argument is empty">;
defm thinlto_cache_dir: EqLong<"thinlto-cache-dir",
"Path to ThinLTO cached object file directory">;
-def Xlink : J<"Xlink=">, MetaVarName<"<arg>">,
- HelpText<"Pass <arg> to the COFF linker">;
+defm Xlink : Eq<"Xlink", "Pass <arg> to the COFF linker">, MetaVarName<"<arg>">;
// Alias
def alias_Bdynamic_call_shared: Flag<["-"], "call_shared">, Alias<Bdynamic>;
@@ -135,15 +139,13 @@ def: F<"enable-auto-image-base">;
def: F<"end-group">;
def: Flag<["--"], "full-shutdown">;
def: F<"high-entropy-va">;
-def: S<"major-image-version">;
-def: S<"minor-image-version">;
+defm: EqNoHelp<"major-image-version">;
+defm: EqNoHelp<"minor-image-version">;
def: F<"no-undefined">;
def: F<"nxcompat">;
def: F<"pic-executable">;
-def: S<"plugin">;
-def: J<"plugin=">;
-def: S<"plugin-opt">;
-def: J<"plugin-opt=">;
-def: J<"sysroot">;
+defm: EqNoHelp<"plugin">;
+defm: EqNoHelp<"plugin-opt">;
+defm: EqNoHelp<"sysroot">;
def: F<"start-group">;
def: F<"tsaware">;
diff --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test
index 29ea69bd7ba94..a8f4121399f21 100644
--- a/lld/test/MinGW/driver.test
+++ b/lld/test/MinGW/driver.test
@@ -161,6 +161,7 @@ NO-DISABLE-DYNAMICBASE-NOT: -dynamicbase:no
RUN: ld.lld -### -m i386pep foo.o --image-base 0x1230000 2>&1 | FileCheck -check-prefix IMAGE-BASE %s
RUN: ld.lld -### -m i386pep foo.o -image-base 0x1230000 2>&1 | FileCheck -check-prefix IMAGE-BASE %s
+RUN: ld.lld -### -m i386pep foo.o --image-base=0x1230000 2>&1 | FileCheck -check-prefix IMAGE-BASE %s
IMAGE-BASE: -base:0x1230000
RUN: ld.lld -### -m i386pep foo.o 2>&1 | FileCheck -check-prefix NO-GC-SECTIONS %s
@@ -180,6 +181,7 @@ ICF-NONE: -opt:noicf
RUN: ld.lld -### -m i386pep foo.o --icf=all 2>&1 | FileCheck -check-prefix ICF %s
RUN: ld.lld -### -m i386pep foo.o -icf=all 2>&1 | FileCheck -check-prefix ICF %s
+RUN: ld.lld -### -m i386pep foo.o --icf all 2>&1 | FileCheck -check-prefix ICF %s
ICF: -opt:icf
RUN: ld.lld -### -m i386pep --start-group foo.o --end-group 2> /dev/null
More information about the llvm-branch-commits
mailing list