diff --git a/lld/test/wasm/lto/atomics.ll b/lld/test/wasm/lto/atomics.ll --- 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 --- 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 --- 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 : Flag<["--"], name>; +class JJ: Joined<["--"], name>; + +multiclass EEq { + def NAME: Separate<["--"], name>; + def NAME # _eq: Joined<["--"], name # "=">, Alias(NAME)>, + HelpText; +} + +multiclass BB { + def NAME: Flag<["--"], name>, HelpText; + def no_ # NAME: Flag<["--"], "no-" # name>, HelpText; +} + // 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: Flag<["--", "-"], name>; @@ -17,11 +35,6 @@ def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText; } -multiclass BB { - def NAME: Flag<["--"], name>, HelpText; - def no_ # NAME: Flag<["--"], "no-" # name>, HelpText; -} - // The following flags are shared with the ELF linker def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">; @@ -51,8 +64,8 @@ def entry: S<"entry">, MetaVarName<"">, 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 @@ "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 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 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_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<["-"], "u">, Alias; // LTO-related options. -def lto_O: J<"lto-O">, MetaVarName<"">, +def lto_O: JJ<"lto-O">, MetaVarName<"">, 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">;