blob: 1116eb871412a69e241600e37f5dec1fe42d236b [file] [log] [blame]
Rui Ueyama411c63602015-05-28 19:09:301include "llvm/Option/OptParser.td"
2
3// link.exe accepts options starting with either a dash or a slash.
4
5// Flag that takes no arguments.
Nico Weber4b81e9f2019-05-07 14:15:356class F<string name> : Flag<["/", "-", "/?", "-?"], name>;
Rui Ueyama411c63602015-05-28 19:09:307
8// Flag that takes one argument after ":".
9class P<string name, string help> :
Nico Weber4b81e9f2019-05-07 14:15:3510 Joined<["/", "-", "/?", "-?"], name#":">, HelpText<help>;
Rui Ueyama411c63602015-05-28 19:09:3011
Martin Storsjö45c4c542020-10-03 22:29:4512// Same as P<> above, but without help texts, for private undocumented
13// options.
14class P_priv<string name> :
15 Joined<["/", "-", "/?", "-?"], name#":">;
16
Shoaib Meenai59bf3622017-10-24 21:17:1617// Boolean flag which can be suffixed by ":no". Using it unsuffixed turns the
18// flag on and using it suffixed by ":no" turns it off.
19multiclass B<string name, string help_on, string help_off> {
20 def "" : F<name>, HelpText<help_on>;
21 def _no : F<name#":no">, HelpText<help_off>;
Rui Ueyama411c63602015-05-28 19:09:3022}
23
Martin Storsjö7f0e6c32020-04-25 21:49:4424// Same as B<> above, but without help texts, for private undocumented
25// options.
26multiclass B_priv<string name> {
27 def "" : F<name>;
28 def _no : F<name#":no">;
29}
30
Rui Ueyama411c63602015-05-28 19:09:3031def align : P<"align", "Section alignment">;
Martin Storsjod2752aa2017-08-14 19:07:2732def aligncomm : P<"aligncomm", "Set common symbol alignment">;
Rui Ueyama411c63602015-05-28 19:09:3033def alternatename : P<"alternatename", "Define weak alias">;
34def base : P<"base", "Base address of the program">;
Nico Webercac2b332018-05-10 18:19:0235def color_diagnostics: Flag<["--"], "color-diagnostics">,
Nico Weberbaa2aa22020-11-17 17:15:4236 HelpText<"Alias for --color-diagnostics=always">;
37def no_color_diagnostics: Flag<["--"], "no-color-diagnostics">,
38 HelpText<"Alias for --color-diagnostics=never">;
Nico Webercac2b332018-05-10 18:19:0239def color_diagnostics_eq: Joined<["--"], "color-diagnostics=">,
Nico Weberbaa2aa22020-11-17 17:15:4240 HelpText<"Use colors in diagnostics (default: auto)">,
41 MetaVarName<"[auto,always,never]">;
Rui Ueyama411c63602015-05-28 19:09:3042def defaultlib : P<"defaultlib", "Add the library to the list of input files">;
43def delayload : P<"delayload", "Delay loaded DLL name">;
Peter Kastingc5fb05f2022-02-16 14:20:0344def diasdkdir : P<"diasdkdir", "Set the location of the DIA SDK">;
Rui Ueyama411c63602015-05-28 19:09:3045def entry : P<"entry", "Name of entry point symbol">;
Bob Haarmanac8f7fc2017-04-05 00:43:5446def errorlimit : P<"errorlimit",
47 "Maximum number of errors to emit before stopping (0 = no limit)">;
Rui Ueyama411c63602015-05-28 19:09:3048def export : P<"export", "Export a function">;
49// No help text because /failifmismatch is not intended to be used by the user.
50def failifmismatch : P<"failifmismatch", "">;
Rui Ueyama74de6202019-05-24 12:42:3651def filealign : P<"filealign", "Section alignment in the output file">;
Alexandre Ganead307c4c2019-02-23 01:46:1852def functionpadmin : F<"functionpadmin">;
Nico Weberc7d8cc42019-09-14 23:41:4253def functionpadmin_opt : P<"functionpadmin",
54 "Prepares an image for hotpatching">;
Reid Kleckneraf2f7da2018-02-06 01:58:2655def guard : P<"guard", "Control flow guard">;
Rui Ueyama411c63602015-05-28 19:09:3056def heap : P<"heap", "Size of the heap">;
Bob Haarmane90ac012017-12-28 07:02:1357def ignore : P<"ignore", "Specify warning codes to ignore">;
Rui Ueyama411c63602015-05-28 19:09:3058def implib : P<"implib", "Import library name">;
Tobias Hietaeb4eef92022-04-12 14:06:4659def noimplib : F<"noimplib">,
60 HelpText<"Don't output an import lib">;
Nico Weberc421fe52018-07-14 04:07:5161def lib : F<"lib">,
62 HelpText<"Act like lib.exe; must be first argument if present">;
Rui Ueyama411c63602015-05-28 19:09:3063def libpath : P<"libpath", "Additional library search path">;
Nico Webera0994cb2020-11-27 18:33:5564def linkrepro : Joined<["/", "-", "/?", "-?"], "linkrepro:">,
65 MetaVarName<"directory">,
66 HelpText<"Write repro.tar containing inputs and command to reproduce link">;
Nico Weberd48ea5d2019-09-13 13:13:5267def lldignoreenv : F<"lldignoreenv">,
68 HelpText<"Ignore environment variables like %LIB%">;
Nico Weberc7d8cc42019-09-14 23:41:4269def lldltocache : P<"lldltocache",
70 "Path to ThinLTO cached object file directory">;
71def lldltocachepolicy : P<"lldltocachepolicy",
72 "Pruning policy for the ThinLTO cache">;
Bob Haarman69b196d2017-02-08 18:36:4173def lldsavetemps : F<"lldsavetemps">,
Sam Clegg299b0e52021-01-18 19:39:2874 HelpText<"Save intermediate LTO compilation results">;
Rui Ueyama411c63602015-05-28 19:09:3075def machine : P<"machine", "Specify target platform">;
76def merge : P<"merge", "Combine sections">;
77def mllvm : P<"mllvm", "Options to pass to LLVM">;
78def nodefaultlib : P<"nodefaultlib", "Remove a default library">;
79def opt : P<"opt", "Control optimizations">;
Rui Ueyama57175aa2018-01-27 00:34:4680def order : P<"order", "Put functions in order">;
Rui Ueyama411c63602015-05-28 19:09:3081def out : P<"out", "Path to file to write output">;
Zachary Turnerf2282762018-03-23 19:57:2582def natvis : P<"natvis", "Path to natvis file to embed in the PDB">;
Rui Ueyama411c63602015-05-28 19:09:3083def pdb : P<"pdb", "PDB file path">;
Peter Collingbournec8f5c052018-04-20 22:11:2884def pdbaltpath : P<"pdbaltpath", "PDB file path to embed in the image">;
Nico Weberf964ca82021-10-30 15:22:5585def pdbpagesize : P<"pdbpagesize", "PDB page size">;
86def pdbstripped : P<"pdbstripped", "Stripped PDB file path">;
Eric Astora39b14f2020-04-07 20:16:2287def pdbstream : Joined<["/", "-", "/?", "-?"], "pdbstream:">,
88 MetaVarName<"<name>=<file>">,
89 HelpText<"Embed the contents of <file> in the PDB as named stream <name>">;
Rui Ueyama411c63602015-05-28 19:09:3090def section : P<"section", "Specify section attributes">;
91def stack : P<"stack", "Size of the stack">;
92def stub : P<"stub", "Specify DOS stub file">;
93def subsystem : P<"subsystem", "Specify subsystem">;
Zachary Turnerc8dd6cc2018-05-17 15:11:0194def timestamp : P<"timestamp", "Specify the PE header timestamp">;
Peter Kastingc5fb05f2022-02-16 14:20:0395def vctoolsdir : P<"vctoolsdir", "Set the location of the VC tools">;
96def vctoolsversion : P<"vctoolsversion",
97 "Specify which VC tools version to use">;
Rui Ueyama411c63602015-05-28 19:09:3098def version : P<"version", "Specify a version number in the PE header">;
Nico Weberc7d8cc42019-09-14 23:41:4299def wholearchive_file : P<"wholearchive",
100 "Include all object files from this library">;
Peter Kastingc5fb05f2022-02-16 14:20:03101def winsdkdir : P<"winsdkdir", "Set the location of the Windows SDK">;
102def winsdkversion : P<"winsdkversion", "Specify which SDK version to use">;
103def winsysroot : P<"winsysroot",
104 "Adds several subdirectories to the library search paths">;
Rui Ueyama411c63602015-05-28 19:09:30105
Nico Weber4b81e9f2019-05-07 14:15:35106def disallowlib : Joined<["/", "-", "/?", "-?"], "disallowlib:">,
107 Alias<nodefaultlib>;
Rui Ueyama411c63602015-05-28 19:09:30108
Nico Weber64fb85c2019-01-09 19:18:03109def manifest : F<"manifest">, HelpText<"Create .manifest file">;
110def manifest_colon : P<
111 "manifest",
112 "NO disables manifest output; EMBED[,ID=#] embeds manifest as resource in the image">;
Rui Ueyama411c63602015-05-28 19:09:30113def manifestuac : P<"manifestuac", "User access control">;
Nico Weber64fb85c2019-01-09 19:18:03114def manifestfile : P<"manifestfile", "Manifest output path, with /manifest">;
115def manifestdependency : P<
116 "manifestdependency",
117 "Attributes for <dependency> element in manifest file; implies /manifest">;
118def manifestinput : P<
119 "manifestinput",
120 "Additional manifest inputs; only valid with /manifest:embed">;
Rui Ueyama411c63602015-05-28 19:09:30121
122// We cannot use multiclass P because class name "incl" is different
123// from its command line option name. We do this because "include" is
124// a reserved keyword in tablegen.
Nico Weber4b81e9f2019-05-07 14:15:35125def incl : Joined<["/", "-", "/?", "-?"], "include:">,
Rui Ueyama411c63602015-05-28 19:09:30126 HelpText<"Force symbol to be added to symbol table as undefined one">;
127
128// "def" is also a keyword.
Nico Weber4b81e9f2019-05-07 14:15:35129def deffile : Joined<["/", "-", "/?", "-?"], "def:">,
Rui Ueyama411c63602015-05-28 19:09:30130 HelpText<"Use module-definition file">;
131
Reid Kleckner981576d2015-07-31 16:40:38132def debug : F<"debug">, HelpText<"Embed a symbol table in the image">;
Will Wilson3cb18342018-09-24 15:28:03133def debug_opt : P<"debug", "Embed a symbol table in the image with option">;
Saleem Abdulrasoola2cca7e2016-08-08 22:02:44134def debugtype : P<"debugtype", "Debug Info Options">;
Reid Kleckner981576d2015-07-31 16:40:38135def dll : F<"dll">, HelpText<"Create a DLL">;
Rui Ueyamaf95ed692019-11-13 04:53:15136def driver : F<"driver">, HelpText<"Generate a Windows NT Kernel Mode Driver">;
137def driver_wdm : F<"driver:wdm">,
138 HelpText<"Set IMAGE_FILE_UP_SYSTEM_ONLY bit in PE header">;
139def driver_uponly : F<"driver:uponly">,
140 HelpText<"Set IMAGE_DLL_CHARACTERISTICS_WDM_DRIVER bit in PE header">;
141def driver_wdm_uponly : F<"driver:wdm,uponly">;
142def driver_uponly_wdm : F<"driver:uponly,wdm">;
Nico Weber64fb85c2019-01-09 19:18:03143def nodefaultlib_all : F<"nodefaultlib">,
144 HelpText<"Remove all default libraries">;
145def noentry : F<"noentry">,
146 HelpText<"Don't add reference to DllMainCRTStartup; only valid with /dll">;
Rui Ueyama411c63602015-05-28 19:09:30147def profile : F<"profile">;
Nico Weber64fb85c2019-01-09 19:18:03148def repro : F<"Brepro">,
149 HelpText<"Use a hash of the executable as the PE header timestamp">;
Nico Webera0994cb2020-11-27 18:33:55150def reproduce : Joined<["/", "-", "/?", "-?"], "reproduce:">,
151 MetaVarName<"filename">,
152 HelpText<"Write tar file containing inputs and command to reproduce link">;
Nico Weberc0838af2019-04-25 14:02:26153def swaprun : P<"swaprun",
154 "Comma-separated list of 'cd' or 'net'">;
155def swaprun_cd : F<"swaprun:cd">, Alias<swaprun>, AliasArgs<["cd"]>,
156 HelpText<"Make loader run output binary from swap instead of from CD">;
157def swaprun_net : F<"swaprun:net">, Alias<swaprun>, AliasArgs<["net"]>,
158 HelpText<"Make loader run output binary from swap instead of from network">;
Rui Ueyama411c63602015-05-28 19:09:30159def verbose : F<"verbose">;
Nico Weberc7d8cc42019-09-14 23:41:42160def wholearchive_flag : F<"wholearchive">,
161 HelpText<"Include all object files from all libraries">;
Rui Ueyama411c63602015-05-28 19:09:30162
163def force : F<"force">,
Nico Weberc7d8cc42019-09-14 23:41:42164 HelpText<"Allow undefined and multiply defined symbols">;
Rui Ueyama11ca38f2018-09-13 22:05:10165def force_unresolved : F<"force:unresolved">,
Rui Ueyama411c63602015-05-28 19:09:30166 HelpText<"Allow undefined symbols when creating executables">;
Rui Ueyama11ca38f2018-09-13 22:05:10167def force_multiple : F<"force:multiple">,
168 HelpText<"Allow multiply defined symbols when creating executables">;
Nico Weber81862f82019-05-02 21:21:55169def force_multipleres : F<"force:multipleres">,
170 HelpText<"Allow multiply defined resources when creating executables">;
Nico Weber75196b92022-04-11 15:01:34171defm WX : B<"WX", "Treat warnings as errors",
172 "Don't treat warnings as errors (default)">;
Rui Ueyama411c63602015-05-28 19:09:30173
Shoaib Meenai59bf3622017-10-24 21:17:16174defm allowbind : B<"allowbind", "Enable DLL binding (default)",
175 "Disable DLL binding">;
176defm allowisolation : B<"allowisolation", "Enable DLL isolation (default)",
177 "Disable DLL isolation">;
Saleem Abdulrasool671029d2017-04-06 23:07:53178defm appcontainer : B<"appcontainer",
Shoaib Meenai59bf3622017-10-24 21:17:16179 "Image can only be run in an app container",
180 "Image can run outside an app container (default)">;
Rui Ueyamaa2923b22020-03-13 10:41:18181defm cetcompat : B<"cetcompat", "Mark executable image as compatible with Control-flow Enforcement Technology (CET) Shadow Stack",
182 "Don't mark executable image as compatible with Control-flow Enforcement Technology (CET) Shadow Stack (default)">;
Shoaib Meenai59bf3622017-10-24 21:17:16183defm dynamicbase : B<"dynamicbase", "Enable ASLR (default unless /fixed)",
184 "Disable ASLR (default when /fixed)">;
185defm fixed : B<"fixed", "Disable base relocations",
186 "Enable base relocations (default)">;
187defm highentropyva : B<"highentropyva",
188 "Enable 64-bit ASLR (default on 64-bit)",
189 "Disable 64-bit ASLR">;
Bob Haarman5ec44852018-01-31 23:44:00190defm incremental : B<"incremental",
191 "Keep original import library if contents are unchanged",
Nico Weberd657c252018-05-31 13:43:02192 "Overwrite import library even if contents are unchanged">;
193defm integritycheck : B<"integritycheck",
194 "Set FORCE_INTEGRITY bit in PE header",
195 "No effect (default)">;
Shoaib Meenai59bf3622017-10-24 21:17:16196defm largeaddressaware : B<"largeaddressaware",
197 "Enable large addresses (default on 64-bit)",
198 "Disable large addresses (default on 32-bit)">;
199defm nxcompat : B<"nxcompat", "Enable data execution prevention (default)",
200 "Disable data execution provention">;
201defm safeseh : B<"safeseh",
202 "Produce an image with Safe Exception Handler (only for x86)",
203 "Don't produce an image with Safe Exception Handler">;
204defm tsaware : B<"tsaware",
205 "Create Terminal Server aware executable (default)",
206 "Create non-Terminal Server aware executable">;
Rui Ueyama411c63602015-05-28 19:09:30207
208def help : F<"help">;
Nico Weber4b81e9f2019-05-07 14:15:35209
210// /?? and -?? must be before /? and -? to not confuse lib/Options.
211def help_q : Flag<["/??", "-??", "/?", "-?"], "">, Alias<help>;
Rui Ueyama411c63602015-05-28 19:09:30212
Rui Ueyama96401732015-09-21 23:43:31213// LLD extensions
Martin Storsjö7f0e6c32020-04-25 21:49:44214defm auto_import : B_priv<"auto-import">;
215defm runtime_pseudo_reloc : B_priv<"runtime-pseudo-reloc">;
Bob Haarman7dc5e7a02019-09-03 20:32:16216def end_lib : F<"end-lib">,
Nico Webera0994cb2020-11-27 18:33:55217 HelpText<"End group of objects treated as if they were in a library">;
Martin Storsjo272d8c12019-02-19 21:57:44218def exclude_all_symbols : F<"exclude-all-symbols">;
Martin Storsjo7f71acd2017-10-12 05:37:13219def export_all_symbols : F<"export-all-symbols">;
Nico Weber020d92c2019-03-11 23:02:18220defm demangle : B<"demangle",
221 "Demangle symbols in output (default)",
222 "Do not demangle symbols in output">;
Martin Storsjoc02f6bf2019-06-08 18:26:18223def include_optional : Joined<["/", "-", "/?", "-?"], "includeoptional:">,
224 HelpText<"Add symbol as undefined, but allow it to remain undefined">;
Martin Storsjo53518912018-03-14 20:17:16225def kill_at : F<"kill-at">;
Martin Storsjo31fe4cd2017-09-13 19:29:39226def lldmingw : F<"lldmingw">;
Martin Storsjö745eb022020-07-27 20:44:41227def noseh : F<"noseh">;
Martin Storsjö45c4c542020-10-03 22:29:45228def osversion : P_priv<"osversion">;
Nico Weber4b81e9f2019-05-07 14:15:35229def output_def : Joined<["/", "-", "/?", "-?"], "output-def:">;
Takuto Ikutad8559282018-07-19 04:56:22230def pdb_source_path : P<"pdbsourcepath",
Nico Weberc7d8cc42019-09-14 23:41:42231 "Base path used to make relative source file path absolute in PDB">;
Nico Webera05cbb82017-09-05 23:46:45232def rsp_quoting : Joined<["--"], "rsp-quoting=">,
233 HelpText<"Quoting style for response files, 'windows' (default) or 'posix'">;
Bob Haarman7dc5e7a02019-09-03 20:32:16234def start_lib : F<"start-lib">,
Nico Webera0994cb2020-11-27 18:33:55235 HelpText<"Start group of objects treated as if they were in a library">;
Martin Storsjöce211c52021-06-17 18:51:37236defm stdcall_fixup : B_priv<"stdcall-fixup">;
Bob Haarman63efb282019-07-11 18:03:14237def thinlto_emit_imports_files :
238 F<"thinlto-emit-imports-files">,
239 HelpText<"Emit .imports files with -thinlto-index-only">;
240def thinlto_index_only :
241 F<"thinlto-index-only">,
242 HelpText<"Instead of linking, emit ThinLTO index files">;
243def thinlto_index_only_arg : P<
244 "thinlto-index-only",
245 "-thinlto-index-only and also write native module names to file">;
Bob Haarman5011b832019-07-11 18:48:58246def thinlto_object_suffix_replace : P<
247 "thinlto-object-suffix-replace",
248 "'old;new' replace old suffix with new suffix in ThinLTO index">;
249def thinlto_prefix_replace: P<
250 "thinlto-prefix-replace",
251 "'old;new' replace old prefix with new prefix in ThinLTO outputs">;
Bob Haarman5375b942019-08-21 18:24:59252def lto_obj_path : P<
253 "lto-obj-path",
254 "output native object for merged LTO unit to this path">;
Yolanda Chen4f9c61e2021-03-25 02:55:18255def lto_cs_profile_generate: F<"lto-cs-profile-generate">,
256 HelpText<"Perform context sensitive PGO instrumentation">;
257def lto_cs_profile_file : P<"lto-cs-profile-file",
258 "Context sensitive profile file path">;
Yolanda Chen8fa16cc2021-08-11 16:45:55259defm lto_pgo_warn_mismatch: B<
260 "lto-pgo-warn-mismatch",
261 "turn on warnings about profile cfg mismatch (default)>",
262 "turn off warnings about profile cfg mismatch">;
Rui Ueyamaa4cf97b2017-10-23 14:57:53263def dash_dash_version : Flag<["--"], "version">,
Nico Weber77fb45e2020-12-22 20:51:20264 HelpText<"Display the version number and exit">;
Fangrui Songeb4663d2020-03-17 19:40:19265def threads
266 : P<"threads", "Number of threads. '1' disables multi-threading. By "
267 "default all available hardware threads are used">;
Zequan Wu763671f2020-07-21 20:46:11268def call_graph_ordering_file: P<
Tobias Hieta2af43852022-04-12 11:59:45269 "call-graph-ordering-file",
Zequan Wu763671f2020-07-21 20:46:11270 "Layout sections to optimize the given callgraph">;
271defm call_graph_profile_sort: B<
272 "call-graph-profile-sort",
273 "Reorder sections with call graph profile (default)",
274 "Do not reorder sections with call graph profile">;
275def print_symbol_order: P<
276 "print-symbol-order",
277 "Print a symbol order specified by /call-graph-ordering-file and "
278 "/call-graph-profile-sort into the specified file">;
Martin Storsjö3785a412020-10-06 10:54:49279def wrap : P_priv<"wrap">;
Rui Ueyama96401732015-09-21 23:43:31280
Peter Collingbournebe549552015-06-26 18:58:24281// Flags for debugging
Hans Wennborg1818e652016-12-09 20:54:44282def lldmap : F<"lldmap">;
Nico Weber66dc44f2021-08-27 02:01:00283def lldmap_file : P_priv<"lldmap">;
Sylvain Audib91905a2020-03-23 21:06:48284def map : F<"map">;
Nico Weber66dc44f2021-08-27 02:01:00285def map_file : P_priv<"map">;
Zachary Turner727f1532018-01-17 19:16:26286def show_timing : F<"time">;
Alexandre Ganea3e60ee92019-03-14 18:45:08287def summary : F<"summary">;
Rui Ueyama411c63602015-05-28 19:09:30288
289//==============================================================================
290// The flags below do nothing. They are defined only for link.exe compatibility.
291//==============================================================================
292
Rui Ueyama411c63602015-05-28 19:09:30293def ignoreidl : F<"ignoreidl">;
Nico Weber34ac7a72021-08-27 02:03:26294def ltcg : F<"ltcg">;
Rui Ueyama411c63602015-05-28 19:09:30295def nologo : F<"nologo">;
Rui Ueyama432383172015-07-29 21:01:15296def throwingnew : F<"throwingnew">;
Rui Ueyama3c4737d2015-08-11 16:46:08297def editandcontinue : F<"editandcontinue">;
Reid Kleckner9cd77ce2016-03-25 18:09:29298def fastfail : F<"fastfail">;
Rui Ueyama411c63602015-05-28 19:09:30299
Nico Weber66dc44f2021-08-27 02:01:00300def delay : P_priv<"delay">;
301def errorreport : P_priv<"errorreport">;
302def idlout : P_priv<"idlout">;
Nico Weber34ac7a72021-08-27 02:03:26303def ilk : P_priv<"ilk">;
304def ltcg_opt : P_priv<"ltcg">;
305def ltcgout : P_priv<"ltcgout">;
Nico Weber66dc44f2021-08-27 02:01:00306def maxilksize : P_priv<"maxilksize">;
307def tlbid : P_priv<"tlbid">;
308def tlbout : P_priv<"tlbout">;
309def verbose_all : P_priv<"verbose">;
310def guardsym : P_priv<"guardsym">;