[lld] 87628f5 - [lld][WebAssembly] Require double dash for modern linker flags
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Thu May 26 14:43:00 PDT 2022
Author: Sam Clegg
Date: 2022-05-26T14:42:52-07:00
New Revision: 87628f5804e23a40986692f6cdcf66654ce3f017
URL: https://github.com/llvm/llvm-project/commit/87628f5804e23a40986692f6cdcf66654ce3f017
DIFF: https://github.com/llvm/llvm-project/commit/87628f5804e23a40986692f6cdcf66654ce3f017.diff
LOG: [lld][WebAssembly] Require double dash for modern linker flags
This matches the behaviour of the ELF backend (in fact this change
is mostly just copying directly from ELF/Options.td).
Differential Revision: https://reviews.llvm.org/D126500
Added:
Modified:
lld/test/wasm/lto/atomics.ll
lld/test/wasm/lto/pic-empty.s
lld/wasm/Options.td
Removed:
################################################################################
diff --git a/lld/test/wasm/lto/atomics.ll b/lld/test/wasm/lto/atomics.ll
index f231b3225fe8b..7e367157675cd 100644
--- a/lld/test/wasm/lto/atomics.ll
+++ b/lld/test/wasm/lto/atomics.ll
@@ -1,5 +1,5 @@
; RUN: llvm-as %s -o %t.o
-; RUN: wasm-ld %t.o -o %t.wasm -lto-O0
+; RUN: wasm-ld %t.o -o %t.wasm --lto-O0
; Atomic operations will not fail to compile if atomics are not
; enabled because LLVM atomics will be lowered to regular ops.
diff --git a/lld/test/wasm/lto/pic-empty.s b/lld/test/wasm/lto/pic-empty.s
index 88e0f42542e24..51938e1ad429d 100644
--- a/lld/test/wasm/lto/pic-empty.s
+++ b/lld/test/wasm/lto/pic-empty.s
@@ -6,7 +6,7 @@
; See https://bugs.llvm.org/show_bug.cgi?id=52339
; RUN: llvm-as %s -o %t.o
-; RUN: wasm-ld -lto-O2 --experimental-pic -shared --no-gc-sections --export=tls_int %t.o -o %t.so
+; RUN: wasm-ld --lto-O2 --experimental-pic -shared --no-gc-sections --export=tls_int %t.o -o %t.so
; RUN: obj2yaml %t.so | FileCheck %s
target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20"
diff --git a/lld/wasm/Options.td b/lld/wasm/Options.td
index a5395bbda1c7a..b0c4a811e85a0 100644
--- a/lld/wasm/Options.td
+++ b/lld/wasm/Options.td
@@ -1,5 +1,23 @@
include "llvm/Option/OptParser.td"
+// Convenience classes for long options which only accept two dashes. For lld
+// specific or newer long options, we prefer two dashes to avoid collision with
+// short options. For many others, we have to accept both forms to be compatible
+// with GNU ld.
+class FF<string name> : Flag<["--"], name>;
+class JJ<string name>: Joined<["--"], name>;
+
+multiclass EEq<string name, string help> {
+ def NAME: Separate<["--"], name>;
+ def NAME # _eq: Joined<["--"], name # "=">, Alias<!cast<Separate>(NAME)>,
+ HelpText<help>;
+}
+
+multiclass BB<string name, string help1, string help2> {
+ def NAME: Flag<["--"], name>, HelpText<help1>;
+ def no_ # NAME: Flag<["--"], "no-" # name>, HelpText<help2>;
+}
+
// For options whose names are multiple letters, either one dash or
// two can precede the option name except those that start with 'o'.
class F<string name>: Flag<["--", "-"], name>;
@@ -17,11 +35,6 @@ multiclass B<string name, string help1, string help2> {
def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>;
}
-multiclass BB<string name, string help1, string help2> {
- def NAME: Flag<["--"], name>, HelpText<help1>;
- def no_ # NAME: Flag<["--"], "no-" # name>, HelpText<help2>;
-}
-
// The following flags are shared with the ELF linker
def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">;
@@ -51,8 +64,8 @@ defm export_dynamic: B<"export-dynamic",
def entry: S<"entry">, MetaVarName<"<entry>">,
HelpText<"Name of entry point symbol">;
-def error_limit: J<"error-limit=">,
- HelpText<"Maximum number of errors to emit before stopping (0 = no limit)">;
+defm error_limit:
+ EEq<"error-limit", "Maximum number of errors to emit before stopping (0 = no limit)">;
def fatal_warnings: F<"fatal-warnings">,
HelpText<"Treat warnings as errors">;
@@ -61,7 +74,7 @@ defm gc_sections: B<"gc-sections",
"Enable garbage collection of unused sections",
"Disable garbage collection of unused sections">;
-defm merge_data_segments: B<"merge-data-segments",
+defm merge_data_segments: BB<"merge-data-segments",
"Enable merging data segments",
"Disable merging data segments">;
@@ -75,7 +88,7 @@ def L: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">,
def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
-def mllvm: S<"mllvm">, HelpText<"Options to pass to LLVM">;
+defm mllvm: Eq<"mllvm", "Additional arguments to forward to LLVM's option processing">;
defm Map: Eq<"Map", "Print a link map to the specified file">;
@@ -99,7 +112,7 @@ def print_map: F<"print-map">,
def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">;
-defm reproduce: Eq<"reproduce", "Dump linker invocation and input files for debugging">;
+defm reproduce: EEq<"reproduce", "Dump linker invocation and input files for debugging">;
defm rsp_quoting: Eq<"rsp-quoting", "Quoting style for response files">,
MetaVarName<"[posix,windows]">;
@@ -159,44 +172,44 @@ defm export: Eq<"export", "Force a symbol to be exported">;
defm export_if_defined: Eq<"export-if-defined",
"Force a symbol to be exported, if it is defined in the input">;
-def export_all: F<"export-all">,
+def export_all: FF<"export-all">,
HelpText<"Export all symbols (normally combined with --no-gc-sections)">;
-def export_table: F<"export-table">,
+def export_table: FF<"export-table">,
HelpText<"Export function table to the environment">;
-def growable_table: F<"growable-table">,
+def growable_table: FF<"growable-table">,
HelpText<"Remove maximum size from function table, allowing table to grow">;
-def global_base: J<"global-base=">,
+def global_base: JJ<"global-base=">,
HelpText<"Where to start to place global data">;
-def import_memory: F<"import-memory">,
+def import_memory: FF<"import-memory">,
HelpText<"Import memory from the environment">;
-def shared_memory: F<"shared-memory">,
+def shared_memory: FF<"shared-memory">,
HelpText<"Use shared linear memory">;
-def import_table: F<"import-table">,
+def import_table: FF<"import-table">,
HelpText<"Import function table from the environment">;
-def initial_memory: J<"initial-memory=">,
+def initial_memory: JJ<"initial-memory=">,
HelpText<"Initial size of the linear memory">;
-def max_memory: J<"max-memory=">,
+def max_memory: JJ<"max-memory=">,
HelpText<"Maximum size of the linear memory">;
-def no_entry: F<"no-entry">,
+def no_entry: FF<"no-entry">,
HelpText<"Do not output any entry point">;
-def stack_first: F<"stack-first">,
+def stack_first: FF<"stack-first">,
HelpText<"Place stack at start of linear memory rather than after data">;
defm whole_archive: B<"whole-archive",
"Force load of all members in a static library",
"Do not force load of all members in a static library (default)">;
-defm check_features: B<"check-features",
+defm check_features: BB<"check-features",
"Check feature compatibility of linked objects (default)",
"Ignore feature compatibility of linked objects">;
@@ -217,22 +230,22 @@ def: JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>, HelpText<"Alias for --tr
def: JoinedOrSeparate<["-"], "u">, Alias<undefined>;
// LTO-related options.
-def lto_O: J<"lto-O">, MetaVarName<"<opt-level>">,
+def lto_O: JJ<"lto-O">, MetaVarName<"<opt-level>">,
HelpText<"Optimization level for LTO">;
-def lto_partitions: J<"lto-partitions=">,
+def lto_partitions: JJ<"lto-partitions=">,
HelpText<"Number of LTO codegen partitions">;
def disable_verify: F<"disable-verify">;
def save_temps: F<"save-temps">, HelpText<"Save intermediate LTO compilation results">;
-def thinlto_cache_dir: J<"thinlto-cache-dir=">,
+def thinlto_cache_dir: JJ<"thinlto-cache-dir=">,
HelpText<"Path to ThinLTO cached object file directory">;
-defm thinlto_cache_policy: Eq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">;
-def thinlto_jobs: J<"thinlto-jobs=">,
+defm thinlto_cache_policy: EEq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">;
+def thinlto_jobs: JJ<"thinlto-jobs=">,
HelpText<"Number of ThinLTO jobs. Default to --threads=">;
-def no_lto_legacy_pass_manager: F<"no-lto-legacy-pass-manager">,
+def no_lto_legacy_pass_manager: FF<"no-lto-legacy-pass-manager">,
HelpText<"Use new pass manager">;
-def lto_debug_pass_manager: F<"lto-debug-pass-manager">,
+def lto_debug_pass_manager: FF<"lto-debug-pass-manager">,
HelpText<"Debug new pass manager">;
// Experimental PIC mode.
-def experimental_pic: F<"experimental-pic">,
+def experimental_pic: FF<"experimental-pic">,
HelpText<"Enable Experimental PIC">;
More information about the llvm-commits
mailing list