2017-11-18 02:14:09 +08:00
|
|
|
include "llvm/Option/OptParser.td"
|
|
|
|
|
|
|
|
// 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
|
2017-11-18 02:14:09 +08:00
|
|
|
def color_diagnostics: F<"color-diagnostics">,
|
|
|
|
HelpText<"Use colors in diagnostics">;
|
|
|
|
|
|
|
|
def color_diagnostics_eq: J<"color-diagnostics=">,
|
2018-05-11 02:19:02 +08:00
|
|
|
HelpText<"Use colors in diagnostics; one of 'always', 'never', 'auto'">;
|
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">;
|
|
|
|
|
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">;
|
|
|
|
|
|
|
|
def error_limit: J<"error-limit=">,
|
|
|
|
HelpText<"Maximum number of errors to emit before stopping (0 = no limit)">;
|
|
|
|
|
|
|
|
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
|
|
|
|
[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
|
|
|
defm merge_data_segments: B<"merge-data-segments",
|
|
|
|
"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">;
|
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
def mllvm: S<"mllvm">, HelpText<"Options to pass to LLVM">;
|
|
|
|
|
|
|
|
def no_threads: F<"no-threads">,
|
|
|
|
HelpText<"Do not run the linker multi-threaded">;
|
|
|
|
|
|
|
|
def no_color_diagnostics: F<"no-color-diagnostics">,
|
|
|
|
HelpText<"Do not use colors in diagnostics">;
|
|
|
|
|
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
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">;
|
|
|
|
|
2019-05-21 19:52:14 +08:00
|
|
|
defm reproduce: Eq<"reproduce", "Dump linker invocation and input files for debugging">;
|
|
|
|
|
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">;
|
|
|
|
|
2018-01-29 03:57:04 +08:00
|
|
|
def threads: F<"threads">, HelpText<"Run the linker multi-threaded">;
|
|
|
|
|
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
|
|
|
|
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">;
|
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
def z: JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">,
|
|
|
|
HelpText<"Linker option extensions">;
|
|
|
|
|
2019-05-24 22:14:25 +08:00
|
|
|
defm wrap: Eq<"wrap", "Use wrapper functions for symbol">,
|
|
|
|
MetaVarName<"<symbol>=<symbol>">;
|
|
|
|
|
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">,
|
|
|
|
HelpText<"Allow undefined symbols in linked binary">;
|
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
|
|
|
|
2018-06-07 09:27:07 +08:00
|
|
|
def export_all: F<"export-all">,
|
|
|
|
HelpText<"Export all symbols (normally combined with --no-gc-sections)">;
|
|
|
|
|
2018-03-28 01:38:51 +08:00
|
|
|
def export_table: F<"export-table">,
|
|
|
|
HelpText<"Export function table to the environment">;
|
|
|
|
|
2019-08-28 06:58:21 +08:00
|
|
|
def growable_table: F<"growable-table">,
|
|
|
|
HelpText<"Remove maximum size from function table, allowing table to grow">;
|
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
def global_base: J<"global-base=">,
|
|
|
|
HelpText<"Where to start to place global data">;
|
|
|
|
|
2018-01-29 03:57:04 +08:00
|
|
|
def import_memory: F<"import-memory">,
|
|
|
|
HelpText<"Import memory from the environment">;
|
|
|
|
|
2018-11-07 01:59:32 +08:00
|
|
|
def shared_memory: F<"shared-memory">,
|
|
|
|
HelpText<"Use shared linear memory">;
|
|
|
|
|
2018-03-28 01:38:51 +08:00
|
|
|
def import_table: F<"import-table">,
|
|
|
|
HelpText<"Import function table from the environment">;
|
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
def initial_memory: J<"initial-memory=">,
|
|
|
|
HelpText<"Initial size of the linear memory">;
|
|
|
|
|
|
|
|
def max_memory: J<"max-memory=">,
|
|
|
|
HelpText<"Maximum size of the linear memory">;
|
|
|
|
|
2018-01-29 03:57:04 +08:00
|
|
|
def no_entry: F<"no-entry">,
|
|
|
|
HelpText<"Do not output any entry point">;
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2018-05-04 01:21:53 +08:00
|
|
|
def stack_first: F<"stack-first">,
|
|
|
|
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)">;
|
|
|
|
|
2019-03-26 12:11:05 +08:00
|
|
|
defm check_features: B<"check-features",
|
|
|
|
"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>;
|
|
|
|
def: Flag<["-"], "m">, Alias<max_memory>;
|
|
|
|
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.
|
|
|
|
def lto_O: J<"lto-O">, MetaVarName<"<opt-level>">,
|
|
|
|
HelpText<"Optimization level for LTO">;
|
|
|
|
def lto_partitions: J<"lto-partitions=">,
|
|
|
|
HelpText<"Number of LTO codegen partitions">;
|
|
|
|
def disable_verify: F<"disable-verify">;
|
|
|
|
def save_temps: F<"save-temps">;
|
|
|
|
def thinlto_cache_dir: J<"thinlto-cache-dir=">,
|
|
|
|
HelpText<"Path to ThinLTO cached object file directory">;
|
2018-10-22 16:34:37 +08:00
|
|
|
defm thinlto_cache_policy: Eq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">;
|
2018-05-31 02:07:52 +08:00
|
|
|
def thinlto_jobs: J<"thinlto-jobs=">, HelpText<"Number of ThinLTO jobs">;
|