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>;
|
|
|
|
|
2017-12-07 11:19:53 +08:00
|
|
|
multiclass Eq<string name> {
|
|
|
|
def "": Separate<["--", "-"], name>;
|
|
|
|
def _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>;
|
|
|
|
}
|
|
|
|
|
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-01-29 03:57:04 +08:00
|
|
|
// The follow 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-03-13 21:12:03 +08:00
|
|
|
defm demangle: B<"demangle",
|
|
|
|
"Demangle symbol names",
|
|
|
|
"Do not demangle symbol names">;
|
|
|
|
|
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-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">;
|
|
|
|
|
|
|
|
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">;
|
|
|
|
|
2017-12-07 11:19:53 +08:00
|
|
|
defm undefined: Eq<"undefined">,
|
|
|
|
HelpText<"Force undefined symbol during linking">;
|
|
|
|
|
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">;
|
|
|
|
|
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-01-13 06:10:35 +08:00
|
|
|
defm export: Eq<"export">,
|
|
|
|
HelpText<"Force a symbol to be exported">;
|
|
|
|
|
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">;
|
|
|
|
|
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-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)">;
|
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
// Aliases
|
2018-01-29 03:57:04 +08:00
|
|
|
def alias_entry_e: JoinedOrSeparate<["-"], "e">, Alias<entry>;
|
|
|
|
def alias_entry_entry: J<"entry=">, Alias<entry>;
|
2017-11-18 02:14:09 +08:00
|
|
|
def alias_initial_memory_i: Flag<["-"], "i">, Alias<initial_memory>;
|
|
|
|
def alias_max_memory_m: Flag<["-"], "m">, Alias<max_memory>;
|
|
|
|
def alias_relocatable_r: Flag<["-"], "r">, Alias<relocatable>;
|
2017-12-07 11:19:53 +08:00
|
|
|
def alias_undefined_u: 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">;
|
|
|
|
defm thinlto_cache_policy: Eq<"thinlto-cache-policy">,
|
|
|
|
HelpText<"Pruning policy for the ThinLTO cache">;
|
|
|
|
def thinlto_jobs: J<"thinlto-jobs=">, HelpText<"Number of ThinLTO jobs">;
|