261 lines · plain
1include "llvm/Option/OptParser.td"2 3class F<string name>: Flag<["--", "-"], name>;4class J<string name>: Joined<["--", "-"], name>;5class S<string name>: Separate<["--", "-"], name>;6 7// Convenience classes for long options which only accept two dashes. For lld8// specific or newer long options, we prefer two dashes to avoid collision with9// short options. For many others, we have to accept both forms to be compatible10// with GNU ld.11class FF<string name> : Flag<["--"], name>;12class JJ<string name>: Joined<["--"], name>;13 14multiclass Eq<string name, string help> {15 def NAME: Separate<["--", "-"], name>;16 def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>,17 HelpText<help>;18}19 20multiclass EEq<string name, string help> {21 def NAME: Separate<["--"], name>;22 def NAME # _eq: Joined<["--"], name # "=">, Alias<!cast<Separate>(NAME)>,23 HelpText<help>;24}25 26multiclass EqLong<string name, string help> {27 def NAME: Separate<["--"], name>;28 def NAME # _eq: Joined<["--"], name # "=">, Alias<!cast<Separate>(NAME)>,29 HelpText<help>;30}31 32multiclass EqNoHelp<string name> {33 def NAME: Separate<["--", "-"], name>;34 def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>;35}36 37multiclass B<string name, string help1, string help2> {38 def NAME: Flag<["--", "-"], name>, HelpText<help1>;39 def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>;40}41 42multiclass B_disable<string name, string help1, string help2> {43 def NAME: Flag<["--", "-"], name>, HelpText<help1>;44 def disable_ # NAME: Flag<["--", "-"], "disable-" # name>, HelpText<help2>;45}46 47multiclass B_enable_disable<string name, string help1, string help2> {48 def enable_ # NAME: Flag<["--", "-"], "enable-" # name>, HelpText<help1>;49 def disable_ # NAME: Flag<["--", "-"], "disable-" # name>, HelpText<help2>;50}51 52def L: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">,53 HelpText<"Add a directory to the library search path">;54defm allow_multiple_definition: B<"allow-multiple-definition",55 "Allow multiple definitions",56 "Do not allow multiple definitions (default)">;57def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries">;58def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">;59defm demangle: B<"demangle",60 "Demangle symbol names (default)",61 "Do not demangle symbol names">;62def disable_auto_import: F<"disable-auto-import">,63 HelpText<"Don't automatically import data symbols from other DLLs without dllimport">;64def disable_runtime_pseudo_reloc: F<"disable-runtime-pseudo-reloc">,65 HelpText<"Don't do automatic imports that require runtime fixups">;66def disable_stdcall_fixup: F<"disable-stdcall-fixup">,67 HelpText<"Don't resolve stdcall/fastcall/vectorcall to undecorated symbols">;68defm dynamicbase: B_disable<"dynamicbase", "Enable ASLR", "Disable ASLR">;69def enable_auto_import: F<"enable-auto-import">,70 HelpText<"Automatically import data symbols from other DLLs where needed">;71def enable_runtime_pseudo_reloc: F<"enable-runtime-pseudo-reloc">,72 HelpText<"Allow automatic imports that require runtime fixups">;73def enable_stdcall_fixup: F<"enable-stdcall-fixup">,74 HelpText<"Resolve stdcall/fastcall/vectorcall to undecorated symbols without warnings">;75defm entry: Eq<"entry", "Name of entry point symbol">, MetaVarName<"<entry>">;76def exclude_all_symbols: F<"exclude-all-symbols">,77 HelpText<"Don't automatically export any symbols">;78defm exclude_symbols: Eq<"exclude-symbols",79 "Exclude symbols from automatic export">, MetaVarName<"<symbol[,symbol,...]>">;80def export_all_symbols: F<"export-all-symbols">,81 HelpText<"Export all symbols even if a def file or dllexport attributes are used">;82defm dll_search_prefix:Eq<"dll-search-prefix", "Specify DLL prefix instead of 'lib'">,83 MetaVarName<"<dll_search_prefix>">;84defm fatal_warnings: B<"fatal-warnings",85 "Treat warnings as errors",86 "Do not treat warnings as errors (default)">;87defm file_alignment: Eq<"file-alignment", "Set file alignment">;88defm gc_sections: B<"gc-sections",89 "Remove unused sections",90 "Don't remove unused sections">;91defm heap: Eq<"heap", "Set size of the initial heap">;92def help: F<"help">, HelpText<"Print option help">;93defm high_entropy_va: B_disable<"high-entropy-va",94 "Set the 'high entropy VA' flag", "Don't set the 'high entropy VA' flag">;95defm icf: Eq<"icf", "Identical code folding">;96defm image_base: Eq<"image-base", "Base address of the program">;97defm insert_timestamp: B<"insert-timestamp",98 "Include PE header timestamp",99 "Don't include PE header timestamp">;100def kill_at: F<"kill-at">, HelpText<"Remove @n from exported symbols">;101def l: JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">,102 HelpText<"Root name of library to use">;103def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;104defm major_os_version: EqLong<"major-os-version",105 "Set the OS and subsystem major version">;106defm major_subsystem_version: EqLong<"major-subsystem-version",107 "Set the OS and subsystem major version">;108defm map: Eq<"Map", "Output a linker map">;109defm minor_os_version: EqLong<"minor-os-version",110 "Set the OS and subsystem minor version">;111defm minor_subsystem_version: EqLong<"minor-subsystem-version",112 "Set the OS and subsystem minor version">;113defm no_seh: B_disable<"no-seh",114 "Set the 'no SEH' flag in the executable", "Don't set the 'no SEH' flag">;115defm nxcompat: B_disable<"nxcompat",116 "Set the 'nxcompat' flag in the executable", "Don't set the 'nxcompat' flag">;117def large_address_aware: Flag<["--"], "large-address-aware">,118 HelpText<"Enable large addresses">;119def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,120 HelpText<"Path to file to write output">;121defm out_implib: Eq<"out-implib", "Import library name">;122defm output_def: Eq<"output-def", "Output def file">;123defm reloc_section: B_enable_disable<"reloc-section",124 "Enable base relocations", "Disable base relocations">;125defm section_alignment: Eq<"section-alignment", "Set section alignment">;126def shared: F<"shared">, HelpText<"Build a shared object">;127defm subs: Eq<"subsystem", "Specify subsystem">;128defm stack: Eq<"stack", "Set size of the initial stack">;129def strip_all: F<"strip-all">,130 HelpText<"Omit all symbol information from the output binary">;131def strip_debug: F<"strip-debug">,132 HelpText<"Omit all debug information, but keep symbol information">;133defm reproduce: Eq<"reproduce",134 "Write a tar file containing input files and command line options to reproduce link">;135defm require_defined: Eq<"require-defined",136 "Force symbol to be added to symbol table as an undefined one">;137defm threads138 : EEq<"threads",139 "Number of threads. '1' disables multi-threading. By default all "140 "available hardware threads are used">;141defm tsaware: B_disable<"tsaware",142 "Set the 'Terminal Server aware' flag", "Don't set the 'Terminal Server aware' flag">;143defm undefined: Eq<"undefined", "Include symbol in the link, if available">;144defm undefined_glob: EEq<"undefined-glob", "Force undefined symbol during linking">,145 MetaVarName<"<pattern>">;146defm whole_archive: B<"whole-archive",147 "Include all object files for following archives",148 "No longer include all object files for following archives">;149def v: Flag<["-"], "v">, HelpText<"Display the version number">;150def verbose: F<"verbose">, HelpText<"Verbose mode">;151def version: F<"version">, HelpText<"Display the version number and exit">;152defm wrap: Eq<"wrap", "Use wrapper functions for symbol">,153 MetaVarName<"<symbol>">;154 155 156// LLD specific options, for LTO, shared with the ELF backend157def lto_O: JJ<"lto-O">, MetaVarName<"<opt-level>">,158 HelpText<"Optimization level for LTO">;159def lto_CGO: JJ<"lto-CGO">, MetaVarName<"<cgopt-level>">,160 HelpText<"Codegen optimization level for LTO">;161def lto_cs_profile_generate: FF<"lto-cs-profile-generate">,162 HelpText<"Perform context sensitive PGO instrumentation">;163def lto_cs_profile_file: JJ<"lto-cs-profile-file=">,164 HelpText<"Context sensitive profile file path">;165def lto_emit_asm: FF<"lto-emit-asm">,166 HelpText<"Emit assembly code">;167def lto_sample_profile: JJ<"lto-sample-profile=">,168 HelpText<"Sample profile file path">;169 170def thinlto_cache_dir: JJ<"thinlto-cache-dir=">,171 HelpText<"Path to ThinLTO cached object file directory">;172defm thinlto_cache_policy: EEq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">;173def thinlto_emit_imports_files: FF<"thinlto-emit-imports-files">;174def thinlto_index_only: FF<"thinlto-index-only">;175def thinlto_index_only_eq: JJ<"thinlto-index-only=">;176def thinlto_jobs_eq: JJ<"thinlto-jobs=">,177 HelpText<"Number of ThinLTO jobs. Default to --threads=">;178def thinlto_object_suffix_replace_eq: JJ<"thinlto-object-suffix-replace=">;179def thinlto_prefix_replace_eq: JJ<"thinlto-prefix-replace=">;180 181def plugin_opt_eq_minus: J<"plugin-opt=-">,182 HelpText<"Specify an LLVM option for compatibility with LLVMgold.so">;183def: J<"plugin-opt=thinlto">;184 185def: J<"plugin-opt=O">, Alias<lto_O>, HelpText<"Alias for --lto-O">;186def: F<"plugin-opt=cs-profile-generate">,187 Alias<lto_cs_profile_generate>, HelpText<"Alias for --lto-cs-profile-generate">;188def: J<"plugin-opt=cs-profile-path=">,189 Alias<lto_cs_profile_file>, HelpText<"Alias for --lto-cs-profile-file">;190def plugin_opt_dwo_dir_eq: J<"plugin-opt=dwo_dir=">,191 HelpText<"Directory to store .dwo files when LTO and debug fission are used">;192def plugin_opt_emit_asm: F<"plugin-opt=emit-asm">,193 Alias<lto_emit_asm>, HelpText<"Alias for --lto-emit-asm">;194def plugin_opt_emit_llvm: F<"plugin-opt=emit-llvm">;195def: J<"plugin-opt=jobs=">, Alias<thinlto_jobs_eq>, HelpText<"Alias for --thinlto-jobs=">;196def plugin_opt_mcpu_eq: J<"plugin-opt=mcpu=">;197 198// This may be either an unhandled LLVMgold.so feature or GCC passed199// -plugin-opt=path/to/{liblto_plugin.so,lto-wrapper}200def plugin_opt_eq : J<"plugin-opt=">;201 202// LLD specific options203def _HASH_HASH_HASH : Flag<["-"], "###">,204 HelpText<"Print (but do not run) the commands to run for this compilation">;205def appcontainer: F<"appcontainer">, HelpText<"Set the appcontainer flag in the executable">;206defm delayload: Eq<"delayload", "DLL to load only on demand">;207defm dependent_load_flag: EEq<"dependent-load-flag", "Override default LibraryLoad flags">;208defm mllvm: EqNoHelp<"mllvm">;209defm pdb: Eq<"pdb", "Output PDB debug info file, chosen implicitly if the argument is empty">;210defm Xlink : Eq<"Xlink", "Pass <arg> to the COFF linker">, MetaVarName<"<arg>">;211defm guard_cf : B<"guard-cf", "Enable Control Flow Guard" ,212 "Do not enable Control Flow Guard (default)">;213defm guard_longjmp : B<"guard-longjmp",214 "Enable Control Flow Guard long jump hardening (default for --guard-cf)" ,215 "Do not enable Control Flow Guard long jump hardening">;216defm error_limit:217 EqLong<"error-limit", "Maximum number of errors to emit before stopping (0 = no limit)">;218def build_id: J<"build-id=">, HelpText<"Generate build ID note (pass none to disable)">,219 MetaVarName<"<arg>">;220def : F<"build-id">, Alias<build_id>, HelpText<"Alias for --build-id=">;221def functionpadmin: J<"functionpadmin=">, HelpText<"Prepares an image for hotpatching">,222 MetaVarName<"<arg>">;223def : F<"functionpadmin">, Alias<functionpadmin>, HelpText<"Alias for --functionpadmin=">;224 225// Alias226def alias_Bdynamic_call_shared: Flag<["-"], "call_shared">, Alias<Bdynamic>;227def alias_Bdynamic_dy: Flag<["-"], "dy">, Alias<Bdynamic>;228def alias_Bstatic_dn: Flag<["-"], "dn">, Alias<Bstatic>;229def alias_Bstatic_non_shared: Flag<["-"], "non_shared">, Alias<Bstatic>;230def alias_Bstatic_static: Flag<["-"], "static">, Alias<Bstatic>;231def alias_dll: F<"dll">, Alias<shared>;232def alias_entry_e: JoinedOrSeparate<["-"], "e">, Alias<entry>;233def alias_no_dynamicbase: F<"no-dynamicbase">, Alias<disable_dynamicbase>;234def alias_strip_s: Flag<["-"], "s">, Alias<strip_all>;235def alias_strip_S: Flag<["-"], "S">, Alias<strip_debug>;236def alias_undefined_u: JoinedOrSeparate<["-"], "u">, Alias<undefined>;237 238// Ignored options239def: Joined<["-"], "O">;240def: F<"as-needed">;241def: F<"disable-auto-image-base">;242def: F<"enable-auto-image-base">;243def: F<"end-group">;244def: Flag<["--"], "full-shutdown">;245defm: EqNoHelp<"major-image-version">;246defm: EqNoHelp<"minor-image-version">;247def: F<"no-undefined">;248def: F<"pic-executable">;249defm: EqNoHelp<"plugin">;250defm: EqNoHelp<"sysroot">;251def: F<"sort-common">;252def: F<"start-group">;253 254// Ignored options, that produce warnings255defm rpath: EqNoHelp<"rpath">;256 257// Ignore GCC collect2 LTO plugin related options. Note that we don't support258// GCC LTO, but GCC collect2 passes these options even in non-LTO mode.259def: J<"plugin-opt=-fresolution=">;260def: J<"plugin-opt=-pass-through=">;261