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 pdbstripped : P<"pdbstripped", "Stripped PDB file path">;
82def pdbaltpath : P<"pdbaltpath", "PDB file path to embed in the image">;
83def pdbstream : Joined<["/", "-", "/?", "-?"], "pdbstream:">,
84    MetaVarName<"<name>=<file>">,
85    HelpText<"Embed the contents of <file> in the PDB as named stream <name>">;
86def section : P<"section", "Specify section attributes">;
87def stack   : P<"stack", "Size of the stack">;
88def stub    : P<"stub", "Specify DOS stub file">;
89def subsystem : P<"subsystem", "Specify subsystem">;
90def timestamp : P<"timestamp", "Specify the PE header timestamp">;
91def version : P<"version", "Specify a version number in the PE header">;
92def wholearchive_file : P<"wholearchive",
93    "Include all object files from this library">;
94
95def disallowlib : Joined<["/", "-", "/?", "-?"], "disallowlib:">,
96    Alias<nodefaultlib>;
97
98def manifest : F<"manifest">, HelpText<"Create .manifest file">;
99def manifest_colon : P<
100    "manifest",
101    "NO disables manifest output; EMBED[,ID=#] embeds manifest as resource in the image">;
102def manifestuac : P<"manifestuac", "User access control">;
103def manifestfile : P<"manifestfile", "Manifest output path, with /manifest">;
104def manifestdependency : P<
105    "manifestdependency",
106    "Attributes for <dependency> element in manifest file; implies /manifest">;
107def manifestinput : P<
108    "manifestinput",
109    "Additional manifest inputs; only valid with /manifest:embed">;
110
111// We cannot use multiclass P because class name "incl" is different
112// from its command line option name. We do this because "include" is
113// a reserved keyword in tablegen.
114def incl : Joined<["/", "-", "/?", "-?"], "include:">,
115    HelpText<"Force symbol to be added to symbol table as undefined one">;
116
117// "def" is also a keyword.
118def deffile : Joined<["/", "-", "/?", "-?"], "def:">,
119    HelpText<"Use module-definition file">;
120
121def debug : F<"debug">, HelpText<"Embed a symbol table in the image">;
122def debug_opt : P<"debug", "Embed a symbol table in the image with option">;
123def debugtype : P<"debugtype", "Debug Info Options">;
124def dll : F<"dll">, HelpText<"Create a DLL">;
125def driver : F<"driver">, HelpText<"Generate a Windows NT Kernel Mode Driver">;
126def driver_wdm : F<"driver:wdm">,
127    HelpText<"Set IMAGE_FILE_UP_SYSTEM_ONLY bit in PE header">;
128def driver_uponly : F<"driver:uponly">,
129    HelpText<"Set IMAGE_DLL_CHARACTERISTICS_WDM_DRIVER bit in PE header">;
130def driver_wdm_uponly : F<"driver:wdm,uponly">;
131def driver_uponly_wdm : F<"driver:uponly,wdm">;
132def nodefaultlib_all : F<"nodefaultlib">,
133    HelpText<"Remove all default libraries">;
134def noentry : F<"noentry">,
135    HelpText<"Don't add reference to DllMainCRTStartup; only valid with /dll">;
136def profile : F<"profile">;
137def repro : F<"Brepro">,
138    HelpText<"Use a hash of the executable as the PE header timestamp">;
139def reproduce : Joined<["/", "-", "/?", "-?"], "reproduce:">,
140    MetaVarName<"filename">,
141    HelpText<"Write tar file containing inputs and command to reproduce link">;
142def swaprun : P<"swaprun",
143  "Comma-separated list of 'cd' or 'net'">;
144def swaprun_cd : F<"swaprun:cd">, Alias<swaprun>, AliasArgs<["cd"]>,
145  HelpText<"Make loader run output binary from swap instead of from CD">;
146def swaprun_net : F<"swaprun:net">, Alias<swaprun>, AliasArgs<["net"]>,
147  HelpText<"Make loader run output binary from swap instead of from network">;
148def verbose : F<"verbose">;
149def wholearchive_flag : F<"wholearchive">,
150    HelpText<"Include all object files from all libraries">;
151
152def force : F<"force">,
153    HelpText<"Allow undefined and multiply defined symbols">;
154def force_unresolved : F<"force:unresolved">,
155    HelpText<"Allow undefined symbols when creating executables">;
156def force_multiple : F<"force:multiple">,
157    HelpText<"Allow multiply defined symbols when creating executables">;
158def force_multipleres : F<"force:multipleres">,
159    HelpText<"Allow multiply defined resources when creating executables">;
160defm WX : B<"WX", "Treat warnings as errors", "Don't treat warnings as errors">;
161
162defm allowbind : B<"allowbind", "Enable DLL binding (default)",
163                   "Disable DLL binding">;
164defm allowisolation : B<"allowisolation", "Enable DLL isolation (default)",
165                        "Disable DLL isolation">;
166defm appcontainer : B<"appcontainer",
167                      "Image can only be run in an app container",
168                      "Image can run outside an app container (default)">;
169defm cetcompat : B<"cetcompat", "Mark executable image as compatible with Control-flow Enforcement Technology (CET) Shadow Stack",
170                   "Don't mark executable image as compatible with Control-flow Enforcement Technology (CET) Shadow Stack (default)">;
171defm dynamicbase : B<"dynamicbase", "Enable ASLR (default unless /fixed)",
172                     "Disable ASLR (default when /fixed)">;
173defm fixed : B<"fixed", "Disable base relocations",
174               "Enable base relocations (default)">;
175defm highentropyva : B<"highentropyva",
176                       "Enable 64-bit ASLR (default on 64-bit)",
177                       "Disable 64-bit ASLR">;
178defm incremental : B<"incremental",
179                     "Keep original import library if contents are unchanged",
180                     "Overwrite import library even if contents are unchanged">;
181defm integritycheck : B<"integritycheck",
182                        "Set FORCE_INTEGRITY bit in PE header",
183                        "No effect (default)">;
184defm largeaddressaware : B<"largeaddressaware",
185                           "Enable large addresses (default on 64-bit)",
186                           "Disable large addresses (default on 32-bit)">;
187defm nxcompat : B<"nxcompat", "Enable data execution prevention (default)",
188                  "Disable data execution provention">;
189defm safeseh : B<"safeseh",
190                 "Produce an image with Safe Exception Handler (only for x86)",
191                 "Don't produce an image with Safe Exception Handler">;
192defm tsaware  : B<"tsaware",
193                  "Create Terminal Server aware executable (default)",
194                  "Create non-Terminal Server aware executable">;
195
196def help : F<"help">;
197
198// /?? and -?? must be before /? and -? to not confuse lib/Options.
199def help_q : Flag<["/??", "-??", "/?", "-?"], "">, Alias<help>;
200
201// LLD extensions
202defm auto_import : B_priv<"auto-import">;
203defm runtime_pseudo_reloc : B_priv<"runtime-pseudo-reloc">;
204def end_lib : F<"end-lib">,
205  HelpText<"End group of objects treated as if they were in a library">;
206def exclude_all_symbols : F<"exclude-all-symbols">;
207def export_all_symbols : F<"export-all-symbols">;
208defm demangle : B<"demangle",
209    "Demangle symbols in output (default)",
210    "Do not demangle symbols in output">;
211def include_optional : Joined<["/", "-", "/?", "-?"], "includeoptional:">,
212    HelpText<"Add symbol as undefined, but allow it to remain undefined">;
213def kill_at : F<"kill-at">;
214def lldmingw : F<"lldmingw">;
215def noseh : F<"noseh">;
216def osversion : P_priv<"osversion">;
217def output_def : Joined<["/", "-", "/?", "-?"], "output-def:">;
218def pdb_source_path : P<"pdbsourcepath",
219    "Base path used to make relative source file path absolute in PDB">;
220def rsp_quoting : Joined<["--"], "rsp-quoting=">,
221  HelpText<"Quoting style for response files, 'windows' (default) or 'posix'">;
222def start_lib : F<"start-lib">,
223  HelpText<"Start group of objects treated as if they were in a library">;
224def thinlto_emit_imports_files :
225    F<"thinlto-emit-imports-files">,
226    HelpText<"Emit .imports files with -thinlto-index-only">;
227def thinlto_index_only :
228    F<"thinlto-index-only">,
229    HelpText<"Instead of linking, emit ThinLTO index files">;
230def thinlto_index_only_arg : P<
231    "thinlto-index-only",
232    "-thinlto-index-only and also write native module names to file">;
233def thinlto_object_suffix_replace : P<
234    "thinlto-object-suffix-replace",
235    "'old;new' replace old suffix with new suffix in ThinLTO index">;
236def thinlto_prefix_replace: P<
237    "thinlto-prefix-replace",
238    "'old;new' replace old prefix with new prefix in ThinLTO outputs">;
239def lto_obj_path : P<
240    "lto-obj-path",
241    "output native object for merged LTO unit to this path">;
242def dash_dash_version : Flag<["--"], "version">,
243  HelpText<"Display the version number and exit">;
244def threads
245    : P<"threads", "Number of threads. '1' disables multi-threading. By "
246                   "default all available hardware threads are used">;
247def call_graph_ordering_file: P<
248    "call-graph-ordering-file",
249    "Layout sections to optimize the given callgraph">;
250defm call_graph_profile_sort: B<
251    "call-graph-profile-sort",
252    "Reorder sections with call graph profile (default)",
253    "Do not reorder sections with call graph profile">;
254def print_symbol_order: P<
255    "print-symbol-order",
256    "Print a symbol order specified by /call-graph-ordering-file and "
257    "/call-graph-profile-sort into the specified file">;
258def wrap : P_priv<"wrap">;
259
260// Flags for debugging
261def lldmap : F<"lldmap">;
262def lldmap_file : Joined<["/", "-", "/?", "-?"], "lldmap:">;
263def map : F<"map">;
264def map_file : Joined<["/", "-", "/?", "-?"], "map:">;
265def show_timing : F<"time">;
266def summary : F<"summary">;
267
268//==============================================================================
269// The flags below do nothing. They are defined only for link.exe compatibility.
270//==============================================================================
271
272class QF<string name> : Joined<["/", "-", "/?", "-?"], name#":">;
273
274def ignoreidl : F<"ignoreidl">;
275def nologo : F<"nologo">;
276def throwingnew : F<"throwingnew">;
277def editandcontinue : F<"editandcontinue">;
278def fastfail : F<"fastfail">;
279
280def delay : QF<"delay">;
281def errorreport : QF<"errorreport">;
282def idlout : QF<"idlout">;
283def maxilksize : QF<"maxilksize">;
284def tlbid : QF<"tlbid">;
285def tlbout : QF<"tlbout">;
286def verbose_all : QF<"verbose">;
287def guardsym : QF<"guardsym">;
288