1include "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.
6class F<string name> : Flag<["/", "-", "/?", "-?"], name>;
7
8// Flag that takes one argument after ":".
9class P<string name, string help> :
10      Joined<["/", "-", "/?", "-?"], name#":">, HelpText<help>;
11
12// Same as P<> above, but without help texts, for private undocumented
13// options.
14class P_priv<string name> :
15      Joined<["/", "-", "/?", "-?"], name#":">;
16
17// 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>;
22}
23
24// 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
31def align   : P<"align", "Section alignment">;
32def aligncomm : P<"aligncomm", "Set common symbol alignment">;
33def alternatename : P<"alternatename", "Define weak alias">;
34def base    : P<"base", "Base address of the program">;
35def color_diagnostics: Flag<["--"], "color-diagnostics">,
36    HelpText<"Alias for --color-diagnostics=always">;
37def no_color_diagnostics: Flag<["--"], "no-color-diagnostics">,
38    HelpText<"Alias for --color-diagnostics=never">;
39def color_diagnostics_eq: Joined<["--"], "color-diagnostics=">,
40    HelpText<"Use colors in diagnostics (default: auto)">,
41    MetaVarName<"[auto,always,never]">;
42def defaultlib : P<"defaultlib", "Add the library to the list of input files">;
43def delayload : P<"delayload", "Delay loaded DLL name">;
44def entry   : P<"entry", "Name of entry point symbol">;
45def errorlimit : P<"errorlimit",
46    "Maximum number of errors to emit before stopping (0 = no limit)">;
47def export  : P<"export", "Export a function">;
48// No help text because /failifmismatch is not intended to be used by the user.
49def failifmismatch : P<"failifmismatch", "">;
50def filealign : P<"filealign", "Section alignment in the output file">;
51def functionpadmin : F<"functionpadmin">;
52def functionpadmin_opt : P<"functionpadmin",
53    "Prepares an image for hotpatching">;
54def guard   : P<"guard", "Control flow guard">;
55def heap    : P<"heap", "Size of the heap">;
56def ignore : P<"ignore", "Specify warning codes to ignore">;
57def implib  : P<"implib", "Import library name">;
58def lib : F<"lib">,
59    HelpText<"Act like lib.exe; must be first argument if present">;
60def libpath : P<"libpath", "Additional library search path">;
61def linkrepro : Joined<["/", "-", "/?", "-?"], "linkrepro:">,
62    MetaVarName<"directory">,
63    HelpText<"Write repro.tar containing inputs and command to reproduce link">;
64def lldignoreenv : F<"lldignoreenv">,
65    HelpText<"Ignore environment variables like %LIB%">;
66def lldltocache : P<"lldltocache",
67    "Path to ThinLTO cached object file directory">;
68def lldltocachepolicy : P<"lldltocachepolicy",
69    "Pruning policy for the ThinLTO cache">;
70def lldsavetemps : F<"lldsavetemps">,
71    HelpText<"Save intermediate LTO compilation results">;
72def machine : P<"machine", "Specify target platform">;
73def merge   : P<"merge", "Combine sections">;
74def mllvm   : P<"mllvm", "Options to pass to LLVM">;
75def nodefaultlib : P<"nodefaultlib", "Remove a default library">;
76def opt     : P<"opt", "Control optimizations">;
77def order   : P<"order", "Put functions in order">;
78def out     : P<"out", "Path to file to write output">;
79def natvis : P<"natvis", "Path to natvis file to embed in the PDB">;
80def pdb : P<"pdb", "PDB file path">;
81def pdbaltpath : P<"pdbaltpath", "PDB file path to embed in the image">;
82def pdbpagesize : P<"pdbpagesize", "PDB page size">;
83def pdbstripped : P<"pdbstripped", "Stripped PDB file path">;
84def pdbstream : Joined<["/", "-", "/?", "-?"], "pdbstream:">,
85    MetaVarName<"<name>=<file>">,
86    HelpText<"Embed the contents of <file> in the PDB as named stream <name>">;
87def section : P<"section", "Specify section attributes">;
88def stack   : P<"stack", "Size of the stack">;
89def stub    : P<"stub", "Specify DOS stub file">;
90def subsystem : P<"subsystem", "Specify subsystem">;
91def timestamp : P<"timestamp", "Specify the PE header timestamp">;
92def version : P<"version", "Specify a version number in the PE header">;
93def wholearchive_file : P<"wholearchive",
94    "Include all object files from this library">;
95
96def disallowlib : Joined<["/", "-", "/?", "-?"], "disallowlib:">,
97    Alias<nodefaultlib>;
98
99def manifest : F<"manifest">, HelpText<"Create .manifest file">;
100def manifest_colon : P<
101    "manifest",
102    "NO disables manifest output; EMBED[,ID=#] embeds manifest as resource in the image">;
103def manifestuac : P<"manifestuac", "User access control">;
104def manifestfile : P<"manifestfile", "Manifest output path, with /manifest">;
105def manifestdependency : P<
106    "manifestdependency",
107    "Attributes for <dependency> element in manifest file; implies /manifest">;
108def manifestinput : P<
109    "manifestinput",
110    "Additional manifest inputs; only valid with /manifest:embed">;
111
112// We cannot use multiclass P because class name "incl" is different
113// from its command line option name. We do this because "include" is
114// a reserved keyword in tablegen.
115def incl : Joined<["/", "-", "/?", "-?"], "include:">,
116    HelpText<"Force symbol to be added to symbol table as undefined one">;
117
118// "def" is also a keyword.
119def deffile : Joined<["/", "-", "/?", "-?"], "def:">,
120    HelpText<"Use module-definition file">;
121
122def debug : F<"debug">, HelpText<"Embed a symbol table in the image">;
123def debug_opt : P<"debug", "Embed a symbol table in the image with option">;
124def debugtype : P<"debugtype", "Debug Info Options">;
125def dll : F<"dll">, HelpText<"Create a DLL">;
126def driver : F<"driver">, HelpText<"Generate a Windows NT Kernel Mode Driver">;
127def driver_wdm : F<"driver:wdm">,
128    HelpText<"Set IMAGE_FILE_UP_SYSTEM_ONLY bit in PE header">;
129def driver_uponly : F<"driver:uponly">,
130    HelpText<"Set IMAGE_DLL_CHARACTERISTICS_WDM_DRIVER bit in PE header">;
131def driver_wdm_uponly : F<"driver:wdm,uponly">;
132def driver_uponly_wdm : F<"driver:uponly,wdm">;
133def nodefaultlib_all : F<"nodefaultlib">,
134    HelpText<"Remove all default libraries">;
135def noentry : F<"noentry">,
136    HelpText<"Don't add reference to DllMainCRTStartup; only valid with /dll">;
137def profile : F<"profile">;
138def repro : F<"Brepro">,
139    HelpText<"Use a hash of the executable as the PE header timestamp">;
140def reproduce : Joined<["/", "-", "/?", "-?"], "reproduce:">,
141    MetaVarName<"filename">,
142    HelpText<"Write tar file containing inputs and command to reproduce link">;
143def swaprun : P<"swaprun",
144  "Comma-separated list of 'cd' or 'net'">;
145def swaprun_cd : F<"swaprun:cd">, Alias<swaprun>, AliasArgs<["cd"]>,
146  HelpText<"Make loader run output binary from swap instead of from CD">;
147def swaprun_net : F<"swaprun:net">, Alias<swaprun>, AliasArgs<["net"]>,
148  HelpText<"Make loader run output binary from swap instead of from network">;
149def verbose : F<"verbose">;
150def wholearchive_flag : F<"wholearchive">,
151    HelpText<"Include all object files from all libraries">;
152
153def force : F<"force">,
154    HelpText<"Allow undefined and multiply defined symbols">;
155def force_unresolved : F<"force:unresolved">,
156    HelpText<"Allow undefined symbols when creating executables">;
157def force_multiple : F<"force:multiple">,
158    HelpText<"Allow multiply defined symbols when creating executables">;
159def force_multipleres : F<"force:multipleres">,
160    HelpText<"Allow multiply defined resources when creating executables">;
161defm WX : B<"WX", "Treat warnings as errors", "Don't treat warnings as errors">;
162
163defm allowbind : B<"allowbind", "Enable DLL binding (default)",
164                   "Disable DLL binding">;
165defm allowisolation : B<"allowisolation", "Enable DLL isolation (default)",
166                        "Disable DLL isolation">;
167defm appcontainer : B<"appcontainer",
168                      "Image can only be run in an app container",
169                      "Image can run outside an app container (default)">;
170defm cetcompat : B<"cetcompat", "Mark executable image as compatible with Control-flow Enforcement Technology (CET) Shadow Stack",
171                   "Don't mark executable image as compatible with Control-flow Enforcement Technology (CET) Shadow Stack (default)">;
172defm dynamicbase : B<"dynamicbase", "Enable ASLR (default unless /fixed)",
173                     "Disable ASLR (default when /fixed)">;
174defm fixed : B<"fixed", "Disable base relocations",
175               "Enable base relocations (default)">;
176defm highentropyva : B<"highentropyva",
177                       "Enable 64-bit ASLR (default on 64-bit)",
178                       "Disable 64-bit ASLR">;
179defm incremental : B<"incremental",
180                     "Keep original import library if contents are unchanged",
181                     "Overwrite import library even if contents are unchanged">;
182defm integritycheck : B<"integritycheck",
183                        "Set FORCE_INTEGRITY bit in PE header",
184                        "No effect (default)">;
185defm largeaddressaware : B<"largeaddressaware",
186                           "Enable large addresses (default on 64-bit)",
187                           "Disable large addresses (default on 32-bit)">;
188defm nxcompat : B<"nxcompat", "Enable data execution prevention (default)",
189                  "Disable data execution provention">;
190defm safeseh : B<"safeseh",
191                 "Produce an image with Safe Exception Handler (only for x86)",
192                 "Don't produce an image with Safe Exception Handler">;
193defm tsaware  : B<"tsaware",
194                  "Create Terminal Server aware executable (default)",
195                  "Create non-Terminal Server aware executable">;
196
197def help : F<"help">;
198
199// /?? and -?? must be before /? and -? to not confuse lib/Options.
200def help_q : Flag<["/??", "-??", "/?", "-?"], "">, Alias<help>;
201
202// LLD extensions
203defm auto_import : B_priv<"auto-import">;
204defm runtime_pseudo_reloc : B_priv<"runtime-pseudo-reloc">;
205def end_lib : F<"end-lib">,
206  HelpText<"End group of objects treated as if they were in a library">;
207def exclude_all_symbols : F<"exclude-all-symbols">;
208def export_all_symbols : F<"export-all-symbols">;
209defm demangle : B<"demangle",
210    "Demangle symbols in output (default)",
211    "Do not demangle symbols in output">;
212def include_optional : Joined<["/", "-", "/?", "-?"], "includeoptional:">,
213    HelpText<"Add symbol as undefined, but allow it to remain undefined">;
214def kill_at : F<"kill-at">;
215def lldmingw : F<"lldmingw">;
216def noseh : F<"noseh">;
217def osversion : P_priv<"osversion">;
218def output_def : Joined<["/", "-", "/?", "-?"], "output-def:">;
219def pdb_source_path : P<"pdbsourcepath",
220    "Base path used to make relative source file path absolute in PDB">;
221def rsp_quoting : Joined<["--"], "rsp-quoting=">,
222  HelpText<"Quoting style for response files, 'windows' (default) or 'posix'">;
223def start_lib : F<"start-lib">,
224  HelpText<"Start group of objects treated as if they were in a library">;
225defm stdcall_fixup : B_priv<"stdcall-fixup">;
226def thinlto_emit_imports_files :
227    F<"thinlto-emit-imports-files">,
228    HelpText<"Emit .imports files with -thinlto-index-only">;
229def thinlto_index_only :
230    F<"thinlto-index-only">,
231    HelpText<"Instead of linking, emit ThinLTO index files">;
232def thinlto_index_only_arg : P<
233    "thinlto-index-only",
234    "-thinlto-index-only and also write native module names to file">;
235def thinlto_object_suffix_replace : P<
236    "thinlto-object-suffix-replace",
237    "'old;new' replace old suffix with new suffix in ThinLTO index">;
238def thinlto_prefix_replace: P<
239    "thinlto-prefix-replace",
240    "'old;new' replace old prefix with new prefix in ThinLTO outputs">;
241def lto_obj_path : P<
242    "lto-obj-path",
243    "output native object for merged LTO unit to this path">;
244def lto_cs_profile_generate: F<"lto-cs-profile-generate">,
245    HelpText<"Perform context sensitive PGO instrumentation">;
246def lto_cs_profile_file : P<"lto-cs-profile-file",
247    "Context sensitive profile file path">;
248defm lto_pgo_warn_mismatch: B<
249     "lto-pgo-warn-mismatch",
250     "turn on warnings about profile cfg mismatch (default)>",
251     "turn off warnings about profile cfg mismatch">;
252def dash_dash_version : Flag<["--"], "version">,
253  HelpText<"Display the version number and exit">;
254def threads
255    : P<"threads", "Number of threads. '1' disables multi-threading. By "
256                   "default all available hardware threads are used">;
257def call_graph_ordering_file: P<
258    "call-graph-ordering-file",
259    "Layout sections to optimize the given callgraph">;
260defm call_graph_profile_sort: B<
261    "call-graph-profile-sort",
262    "Reorder sections with call graph profile (default)",
263    "Do not reorder sections with call graph profile">;
264def print_symbol_order: P<
265    "print-symbol-order",
266    "Print a symbol order specified by /call-graph-ordering-file and "
267    "/call-graph-profile-sort into the specified file">;
268def wrap : P_priv<"wrap">;
269
270// Flags for debugging
271def lldmap : F<"lldmap">;
272def lldmap_file : P_priv<"lldmap">;
273def map : F<"map">;
274def map_file : P_priv<"map">;
275def show_timing : F<"time">;
276def summary : F<"summary">;
277
278//==============================================================================
279// The flags below do nothing. They are defined only for link.exe compatibility.
280//==============================================================================
281
282def ignoreidl : F<"ignoreidl">;
283def ltcg : F<"ltcg">;
284def nologo : F<"nologo">;
285def throwingnew : F<"throwingnew">;
286def editandcontinue : F<"editandcontinue">;
287def fastfail : F<"fastfail">;
288
289def delay : P_priv<"delay">;
290def errorreport : P_priv<"errorreport">;
291def idlout : P_priv<"idlout">;
292def ilk : P_priv<"ilk">;
293def ltcg_opt : P_priv<"ltcg">;
294def ltcgout : P_priv<"ltcgout">;
295def maxilksize : P_priv<"maxilksize">;
296def tlbid : P_priv<"tlbid">;
297def tlbout : P_priv<"tlbout">;
298def verbose_all : P_priv<"verbose">;
299def guardsym : P_priv<"guardsym">;
300