2017-11-18 02:14:09 +08:00
|
|
|
include "llvm/Option/OptParser.td"
|
|
|
|
|
2022-05-27 05:05:05 +08:00
|
|
|
// 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>;
|
|
|
|
}
|
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
// 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>;
|
|
|
|
class J<string name>: Joined<["--", "-"], name>;
|
|
|
|
class S<string name>: Separate<["--", "-"], name>;
|
|
|
|
|
2018-10-22 16:34:37 +08:00
|
|
|
multiclass Eq<string name, string help> {
|
|
|
|
def NAME: Separate<["--", "-"], name>;
|
|
|
|
def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>,
|
|
|
|
HelpText<help>;
|
2017-12-07 11:19:53 +08:00
|
|
|
}
|
|
|
|
|
2018-03-13 21:12:03 +08:00
|
|
|
multiclass B<string name, string help1, string help2> {
|
|
|
|
def NAME: Flag<["--", "-"], name>, HelpText<help1>;
|
|
|
|
def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>;
|
|
|
|
}
|
|
|
|
|
2018-11-15 08:37:21 +08:00
|
|
|
// The following flags are shared with the ELF linker
|
2020-10-08 05:48:37 +08:00
|
|
|
def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">;
|
|
|
|
|
2020-11-18 01:15:42 +08:00
|
|
|
defm color_diagnostics: B<"color-diagnostics",
|
|
|
|
"Alias for --color-diagnostics=always",
|
|
|
|
"Alias for --color-diagnostics=never">;
|
2017-11-18 02:14:09 +08:00
|
|
|
def color_diagnostics_eq: J<"color-diagnostics=">,
|
2020-11-18 01:15:42 +08:00
|
|
|
HelpText<"Use colors in diagnostics (default: auto)">,
|
|
|
|
MetaVarName<"[auto,always,never]">;
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2018-08-18 03:42:46 +08:00
|
|
|
def compress_relocations: F<"compress-relocations">,
|
|
|
|
HelpText<"Compress the relocation targets in the code section.">;
|
|
|
|
|
2018-03-13 21:12:03 +08:00
|
|
|
defm demangle: B<"demangle",
|
|
|
|
"Demangle symbol names",
|
|
|
|
"Do not demangle symbol names">;
|
|
|
|
|
2019-05-24 21:28:27 +08:00
|
|
|
def emit_relocs: F<"emit-relocs">, HelpText<"Generate relocations in output">;
|
|
|
|
|
2020-05-02 00:14:59 +08:00
|
|
|
def error_unresolved_symbols: F<"error-unresolved-symbols">,
|
|
|
|
HelpText<"Report unresolved symbols as errors">;
|
|
|
|
|
2018-09-28 05:06:25 +08:00
|
|
|
defm export_dynamic: B<"export-dynamic",
|
|
|
|
"Put symbols in the dynamic symbol table",
|
|
|
|
"Do not put symbols in the dynamic symbol table (default)">;
|
2018-09-26 05:50:15 +08:00
|
|
|
|
2018-01-29 03:57:04 +08:00
|
|
|
def entry: S<"entry">, MetaVarName<"<entry>">,
|
|
|
|
HelpText<"Name of entry point symbol">;
|
|
|
|
|
2022-05-27 05:05:05 +08:00
|
|
|
defm error_limit:
|
|
|
|
EEq<"error-limit", "Maximum number of errors to emit before stopping (0 = no limit)">;
|
2018-01-29 03:57:04 +08:00
|
|
|
|
|
|
|
def fatal_warnings: F<"fatal-warnings">,
|
|
|
|
HelpText<"Treat warnings as errors">;
|
|
|
|
|
2018-03-13 21:16:15 +08:00
|
|
|
defm gc_sections: B<"gc-sections",
|
|
|
|
"Enable garbage collection of unused sections",
|
|
|
|
"Disable garbage collection of unused sections">;
|
2018-01-31 09:45:47 +08:00
|
|
|
|
2022-05-27 05:05:05 +08:00
|
|
|
defm merge_data_segments: BB<"merge-data-segments",
|
[WebAssembly] Add a flag to control merging data segments
Merging data segments produces smaller code sizes because each segment
has some boilerplate. Therefore, merging data segments is generally the
right approach, especially with wasm where binaries are typically
delivered over the network.
However, when analyzing wasm binaries, it can be helpful to get a
conservative picture of which functions are using which data
segments[0]. Perhaps there is a large data segment that you didn't
expect to be included in the wasm, introduced by some library you're
using, and you'd like to know which library it was. In this scenario,
merging data segments only makes the analysis worse.
Alternatively, perhaps you will remove some dead functions by-hand[1]
that can't be statically proven dead by the compiler or lld, and
removing these functions might make some data garbage collect-able, and
you'd like to run `--gc-sections` again so that this now-unused data can
be collected. If the segments were originally merged, then a single use
of the merged data segment will entrench all of the data.
[0] https://github.com/rustwasm/twiggy
[1] https://github.com/fitzgen/wasm-snip
Patch by Nick Fitzgerald!
Differential Revision: https://reviews.llvm.org/D46417
llvm-svn: 332013
2018-05-11 02:23:51 +08:00
|
|
|
"Enable merging data segments",
|
|
|
|
"Disable merging data segments">;
|
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
def help: F<"help">, HelpText<"Print option help">;
|
|
|
|
|
|
|
|
def l: JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">,
|
|
|
|
HelpText<"Root name of library to use">;
|
|
|
|
|
2018-01-29 03:57:04 +08:00
|
|
|
def L: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">,
|
|
|
|
HelpText<"Add a directory to the library search path">;
|
|
|
|
|
2020-06-16 06:31:10 +08:00
|
|
|
def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
|
|
|
|
|
2022-05-27 05:05:05 +08:00
|
|
|
defm mllvm: Eq<"mllvm", "Additional arguments to forward to LLVM's option processing">;
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2020-03-28 07:52:27 +08:00
|
|
|
defm Map: Eq<"Map", "Print a link map to the specified file">;
|
|
|
|
|
2018-01-29 03:57:04 +08:00
|
|
|
def no_fatal_warnings: F<"no-fatal-warnings">;
|
2017-11-30 09:40:08 +08:00
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
|
|
|
|
HelpText<"Path to file to write output">;
|
|
|
|
|
2018-05-19 07:28:05 +08:00
|
|
|
def O: JoinedOrSeparate<["-"], "O">, HelpText<"Optimize output file size">;
|
|
|
|
|
2018-11-15 08:37:21 +08:00
|
|
|
defm pie: B<"pie",
|
|
|
|
"Create a position independent executable",
|
|
|
|
"Do not create a position independent executable (default)">;
|
|
|
|
|
2018-03-13 21:16:15 +08:00
|
|
|
defm print_gc_sections: B<"print-gc-sections",
|
|
|
|
"List removed unused sections",
|
|
|
|
"Do not list removed unused sections">;
|
2018-01-31 09:45:47 +08:00
|
|
|
|
2020-03-28 07:52:27 +08:00
|
|
|
def print_map: F<"print-map">,
|
|
|
|
HelpText<"Print a link map to the standard output">;
|
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">;
|
|
|
|
|
2022-05-27 05:05:05 +08:00
|
|
|
defm reproduce: EEq<"reproduce", "Dump linker invocation and input files for debugging">;
|
2019-05-21 19:52:14 +08:00
|
|
|
|
2020-03-05 03:29:45 +08:00
|
|
|
defm rsp_quoting: Eq<"rsp-quoting", "Quoting style for response files">,
|
|
|
|
MetaVarName<"[posix,windows]">;
|
|
|
|
|
2018-11-15 08:37:21 +08:00
|
|
|
def shared: F<"shared">, HelpText<"Build a shared object">;
|
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
def strip_all: F<"strip-all">, HelpText<"Strip all symbols">;
|
|
|
|
|
|
|
|
def strip_debug: F<"strip-debug">, HelpText<"Strip debugging information">;
|
|
|
|
|
[lld][COFF][ELF][WebAssembly] Replace --[no-]threads /threads[:no] with --threads={1,2,...} /threads:{1,2,...}
--no-threads is a name copied from gold.
gold has --no-thread, --thread-count and several other --thread-count-*.
There are needs to customize the number of threads (running several lld
processes concurrently or customizing the number of LTO threads).
Having a single --threads=N is a straightforward replacement of gold's
--no-threads + --thread-count.
--no-threads is used rarely. So just delete --no-threads instead of
keeping it for compatibility for a while.
If --threads= is specified (ELF,wasm; COFF /threads: is similar),
--thinlto-jobs= defaults to --threads=,
otherwise all available hardware threads are used.
There is currently no way to override a --threads={1,2,...}. It is still
a debate whether we should use --threads=all.
Reviewed By: rnk, aganea
Differential Revision: https://reviews.llvm.org/D76885
2020-03-18 03:40:19 +08:00
|
|
|
defm threads
|
|
|
|
: Eq<"threads", "Number of threads. '1' disables multi-threading. By "
|
|
|
|
"default all available hardware threads are used">;
|
2018-01-29 03:57:04 +08:00
|
|
|
|
2019-02-06 10:35:18 +08:00
|
|
|
def trace: F<"trace">, HelpText<"Print the names of the input files">;
|
|
|
|
|
|
|
|
defm trace_symbol: Eq<"trace-symbol", "Trace references to symbols">;
|
|
|
|
|
2018-10-22 16:34:37 +08:00
|
|
|
defm undefined: Eq<"undefined", "Force undefined symbol during linking">;
|
2017-12-07 11:19:53 +08:00
|
|
|
|
2020-05-02 00:14:59 +08:00
|
|
|
defm unresolved_symbols:
|
|
|
|
Eq<"unresolved-symbols", "Determine how to handle unresolved symbols">;
|
|
|
|
|
2018-01-29 03:57:04 +08:00
|
|
|
def v: Flag<["-"], "v">, HelpText<"Display the version number">;
|
|
|
|
|
|
|
|
def verbose: F<"verbose">, HelpText<"Verbose mode">;
|
|
|
|
|
|
|
|
def version: F<"version">, HelpText<"Display the version number and exit">;
|
|
|
|
|
2020-05-02 00:14:59 +08:00
|
|
|
def warn_unresolved_symbols: F<"warn-unresolved-symbols">,
|
|
|
|
HelpText<"Report unresolved symbols as warnings">;
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2019-05-24 22:14:25 +08:00
|
|
|
defm wrap: Eq<"wrap", "Use wrapper functions for symbol">,
|
|
|
|
MetaVarName<"<symbol>=<symbol>">;
|
|
|
|
|
2020-05-02 00:14:59 +08:00
|
|
|
def z: JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">,
|
|
|
|
HelpText<"Linker option extensions">;
|
|
|
|
|
2018-01-29 03:57:04 +08:00
|
|
|
// The follow flags are unique to wasm
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2018-01-29 03:57:04 +08:00
|
|
|
def allow_undefined: F<"allow-undefined">,
|
2021-10-27 21:52:17 +08:00
|
|
|
HelpText<"Allow undefined symbols in linked binary. "
|
|
|
|
"This options is equivalent to --import-undefined "
|
|
|
|
"and --unresolved-symbols=ignore-all">;
|
2021-05-28 05:27:10 +08:00
|
|
|
|
|
|
|
def import_undefined: F<"import-undefined">,
|
|
|
|
HelpText<"Turn undefined symbols into imports where possible">;
|
2017-12-09 01:58:25 +08:00
|
|
|
|
2018-01-29 03:57:04 +08:00
|
|
|
def allow_undefined_file: J<"allow-undefined-file=">,
|
|
|
|
HelpText<"Allow symbols listed in <file> to be undefined in linked binary">;
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2018-01-29 03:57:04 +08:00
|
|
|
def allow_undefined_file_s: Separate<["-"], "allow-undefined-file">,
|
|
|
|
Alias<allow_undefined_file>;
|
|
|
|
|
2018-10-22 16:34:37 +08:00
|
|
|
defm export: Eq<"export", "Force a symbol to be exported">;
|
2018-01-13 06:10:35 +08:00
|
|
|
|
2021-04-05 23:00:30 +08:00
|
|
|
defm export_if_defined: Eq<"export-if-defined",
|
|
|
|
"Force a symbol to be exported, if it is defined in the input">;
|
|
|
|
|
2022-05-27 05:05:05 +08:00
|
|
|
def export_all: FF<"export-all">,
|
2018-06-07 09:27:07 +08:00
|
|
|
HelpText<"Export all symbols (normally combined with --no-gc-sections)">;
|
|
|
|
|
2022-05-27 05:05:05 +08:00
|
|
|
def export_table: FF<"export-table">,
|
2018-03-28 01:38:51 +08:00
|
|
|
HelpText<"Export function table to the environment">;
|
|
|
|
|
2022-05-27 05:05:05 +08:00
|
|
|
def growable_table: FF<"growable-table">,
|
2019-08-28 06:58:21 +08:00
|
|
|
HelpText<"Remove maximum size from function table, allowing table to grow">;
|
|
|
|
|
2022-05-27 05:05:05 +08:00
|
|
|
def global_base: JJ<"global-base=">,
|
2017-11-18 02:14:09 +08:00
|
|
|
HelpText<"Where to start to place global data">;
|
|
|
|
|
2022-05-27 05:05:05 +08:00
|
|
|
def import_memory: FF<"import-memory">,
|
2018-01-29 03:57:04 +08:00
|
|
|
HelpText<"Import memory from the environment">;
|
|
|
|
|
2022-05-27 05:05:05 +08:00
|
|
|
def shared_memory: FF<"shared-memory">,
|
2018-11-07 01:59:32 +08:00
|
|
|
HelpText<"Use shared linear memory">;
|
|
|
|
|
2022-05-27 05:05:05 +08:00
|
|
|
def import_table: FF<"import-table">,
|
2018-03-28 01:38:51 +08:00
|
|
|
HelpText<"Import function table from the environment">;
|
|
|
|
|
2022-05-27 05:05:05 +08:00
|
|
|
def initial_memory: JJ<"initial-memory=">,
|
2017-11-18 02:14:09 +08:00
|
|
|
HelpText<"Initial size of the linear memory">;
|
|
|
|
|
2022-05-27 05:05:05 +08:00
|
|
|
def max_memory: JJ<"max-memory=">,
|
2017-11-18 02:14:09 +08:00
|
|
|
HelpText<"Maximum size of the linear memory">;
|
|
|
|
|
2022-05-27 05:05:05 +08:00
|
|
|
def no_entry: FF<"no-entry">,
|
2018-01-29 03:57:04 +08:00
|
|
|
HelpText<"Do not output any entry point">;
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2022-05-27 05:05:05 +08:00
|
|
|
def stack_first: FF<"stack-first">,
|
2018-05-04 01:21:53 +08:00
|
|
|
HelpText<"Place stack at start of linear memory rather than after data">;
|
|
|
|
|
2018-07-24 07:51:19 +08:00
|
|
|
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)">;
|
|
|
|
|
2022-05-27 05:05:05 +08:00
|
|
|
defm check_features: BB<"check-features",
|
2019-03-26 12:11:05 +08:00
|
|
|
"Check feature compatibility of linked objects (default)",
|
|
|
|
"Ignore feature compatibility of linked objects">;
|
|
|
|
|
|
|
|
def features: CommaJoined<["--", "-"], "features=">,
|
|
|
|
HelpText<"Comma-separated used features, inferred from input objects by default.">;
|
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
// Aliases
|
2018-09-28 05:06:25 +08:00
|
|
|
def: JoinedOrSeparate<["-"], "e">, Alias<entry>;
|
|
|
|
def: J<"entry=">, Alias<entry>;
|
|
|
|
def: Flag<["-"], "E">, Alias<export_dynamic>, HelpText<"Alias for --export-dynamic">;
|
|
|
|
def: Flag<["-"], "i">, Alias<initial_memory>;
|
2020-03-28 07:52:27 +08:00
|
|
|
def: Flag<["-"], "M">, Alias<print_map>, HelpText<"Alias for --print-map">;
|
2018-09-28 05:06:25 +08:00
|
|
|
def: Flag<["-"], "r">, Alias<relocatable>;
|
2018-11-01 03:30:43 +08:00
|
|
|
def: Flag<["-"], "s">, Alias<strip_all>, HelpText<"Alias for --strip-all">;
|
|
|
|
def: Flag<["-"], "S">, Alias<strip_debug>, HelpText<"Alias for --strip-debug">;
|
2019-02-06 10:35:18 +08:00
|
|
|
def: Flag<["-"], "t">, Alias<trace>, HelpText<"Alias for --trace">;
|
|
|
|
def: JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>, HelpText<"Alias for --trace-symbol">;
|
2018-09-28 05:06:25 +08:00
|
|
|
def: JoinedOrSeparate<["-"], "u">, Alias<undefined>;
|
2018-05-31 02:07:52 +08:00
|
|
|
|
|
|
|
// LTO-related options.
|
2022-05-27 05:05:05 +08:00
|
|
|
def lto_O: JJ<"lto-O">, MetaVarName<"<opt-level>">,
|
2018-05-31 02:07:52 +08:00
|
|
|
HelpText<"Optimization level for LTO">;
|
2022-05-27 05:05:05 +08:00
|
|
|
def lto_partitions: JJ<"lto-partitions=">,
|
2018-05-31 02:07:52 +08:00
|
|
|
HelpText<"Number of LTO codegen partitions">;
|
|
|
|
def disable_verify: F<"disable-verify">;
|
2021-01-19 03:39:28 +08:00
|
|
|
def save_temps: F<"save-temps">, HelpText<"Save intermediate LTO compilation results">;
|
2022-05-27 05:05:05 +08:00
|
|
|
def thinlto_cache_dir: JJ<"thinlto-cache-dir=">,
|
2018-05-31 02:07:52 +08:00
|
|
|
HelpText<"Path to ThinLTO cached object file directory">;
|
2022-05-27 05:05:05 +08:00
|
|
|
defm thinlto_cache_policy: EEq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">;
|
|
|
|
def thinlto_jobs: JJ<"thinlto-jobs=">,
|
[lld][COFF][ELF][WebAssembly] Replace --[no-]threads /threads[:no] with --threads={1,2,...} /threads:{1,2,...}
--no-threads is a name copied from gold.
gold has --no-thread, --thread-count and several other --thread-count-*.
There are needs to customize the number of threads (running several lld
processes concurrently or customizing the number of LTO threads).
Having a single --threads=N is a straightforward replacement of gold's
--no-threads + --thread-count.
--no-threads is used rarely. So just delete --no-threads instead of
keeping it for compatibility for a while.
If --threads= is specified (ELF,wasm; COFF /threads: is similar),
--thinlto-jobs= defaults to --threads=,
otherwise all available hardware threads are used.
There is currently no way to override a --threads={1,2,...}. It is still
a debate whether we should use --threads=all.
Reviewed By: rnk, aganea
Differential Revision: https://reviews.llvm.org/D76885
2020-03-18 03:40:19 +08:00
|
|
|
HelpText<"Number of ThinLTO jobs. Default to --threads=">;
|
2022-05-27 05:05:05 +08:00
|
|
|
def no_lto_legacy_pass_manager: FF<"no-lto-legacy-pass-manager">,
|
2022-04-06 22:21:20 +08:00
|
|
|
HelpText<"Use new pass manager">;
|
2022-05-27 05:05:05 +08:00
|
|
|
def lto_debug_pass_manager: FF<"lto-debug-pass-manager">,
|
2020-12-02 04:22:27 +08:00
|
|
|
HelpText<"Debug new pass manager">;
|
2020-06-13 03:05:40 +08:00
|
|
|
|
|
|
|
// Experimental PIC mode.
|
2022-05-27 05:05:05 +08:00
|
|
|
def experimental_pic: FF<"experimental-pic">,
|
2020-06-13 03:05:40 +08:00
|
|
|
HelpText<"Enable Experimental PIC">;
|