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 diasdkdir : P<"diasdkdir", "Set the location of the DIA SDK">;
45def entry   : P<"entry", "Name of entry point symbol">;
46def errorlimit : P<"errorlimit",
47    "Maximum number of errors to emit before stopping (0 = no limit)">;
48def 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", "">;
51def filealign : P<"filealign", "Section alignment in the output file">;
52def functionpadmin : F<"functionpadmin">;
53def functionpadmin_opt : P<"functionpadmin",
54    "Prepares an image for hotpatching">;
55def guard   : P<"guard", "Control flow guard">;
56def heap    : P<"heap", "Size of the heap">;
57def ignore : P<"ignore", "Specify warning codes to ignore">;
58def implib  : P<"implib", "Import library name">;
59def noimplib : F<"noimplib">,
60    HelpText<"Don't output an import lib">;
61def lib : F<"lib">,
62    HelpText<"Act like lib.exe; must be first argument if present">;
63def libpath : P<"libpath", "Additional library search path">;
64def linkrepro : Joined<["/", "-", "/?", "-?"], "linkrepro:">,
65    MetaVarName<"directory">,
66    HelpText<"Write repro.tar containing inputs and command to reproduce link">;
67def lldignoreenv : F<"lldignoreenv">,
68    HelpText<"Ignore environment variables like %LIB%">;
69def lldltocache : P<"lldltocache",
70    "Path to ThinLTO cached object file directory">;
71def lldltocachepolicy : P<"lldltocachepolicy",
72    "Pruning policy for the ThinLTO cache">;
73def lldsavetemps : F<"lldsavetemps">,
74    HelpText<"Save intermediate LTO compilation results">;
75def 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">;
80def order   : P<"order", "Put functions in order">;
81def out     : P<"out", "Path to file to write output">;
82def natvis : P<"natvis", "Path to natvis file to embed in the PDB">;
83def pdb : P<"pdb", "PDB file path">;
84def pdbaltpath : P<"pdbaltpath", "PDB file path to embed in the image">;
85def pdbpagesize : P<"pdbpagesize", "PDB page size">;
86def pdbstripped : P<"pdbstripped", "Stripped PDB file path">;
87def pdbstream : Joined<["/", "-", "/?", "-?"], "pdbstream:">,
88    MetaVarName<"<name>=<file>">,
89    HelpText<"Embed the contents of <file> in the PDB as named stream <name>">;
90def 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">;
94def timestamp : P<"timestamp", "Specify the PE header timestamp">;
95def vctoolsdir : P<"vctoolsdir", "Set the location of the VC tools">;
96def vctoolsversion : P<"vctoolsversion",
97    "Specify which VC tools version to use">;
98def version : P<"version", "Specify a version number in the PE header">;
99def wholearchive_file : P<"wholearchive",
100    "Include all object files from this library">;
101def 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">;
105
106def disallowlib : Joined<["/", "-", "/?", "-?"], "disallowlib:">,
107    Alias<nodefaultlib>;
108
109def 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">;
113def manifestuac : P<"manifestuac", "User access control">;
114def 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">;
121
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.
125def incl : Joined<["/", "-", "/?", "-?"], "include:">,
126    HelpText<"Force symbol to be added to symbol table as undefined one">;
127
128// "def" is also a keyword.
129def deffile : Joined<["/", "-", "/?", "-?"], "def:">,
130    HelpText<"Use module-definition file">;
131
132def debug : F<"debug">, HelpText<"Embed a symbol table in the image">;
133def debug_opt : P<"debug", "Embed a symbol table in the image with option">;
134def debugtype : P<"debugtype", "Debug Info Options">;
135def dll : F<"dll">, HelpText<"Create a DLL">;
136def 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">;
143def 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">;
147def profile : F<"profile">;
148def repro : F<"Brepro">,
149    HelpText<"Use a hash of the executable as the PE header timestamp">;
150def reproduce : Joined<["/", "-", "/?", "-?"], "reproduce:">,
151    MetaVarName<"filename">,
152    HelpText<"Write tar file containing inputs and command to reproduce link">;
153def 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">;
159def verbose : F<"verbose">;
160def wholearchive_flag : F<"wholearchive">,
161    HelpText<"Include all object files from all libraries">;
162
163def force : F<"force">,
164    HelpText<"Allow undefined and multiply defined symbols">;
165def force_unresolved : F<"force:unresolved">,
166    HelpText<"Allow undefined symbols when creating executables">;
167def force_multiple : F<"force:multiple">,
168    HelpText<"Allow multiply defined symbols when creating executables">;
169def force_multipleres : F<"force:multipleres">,
170    HelpText<"Allow multiply defined resources when creating executables">;
171defm WX : B<"WX", "Treat warnings as errors",
172                  "Don't treat warnings as errors (default)">;
173
174defm allowbind : B<"allowbind", "Enable DLL binding (default)",
175                   "Disable DLL binding">;
176defm allowisolation : B<"allowisolation", "Enable DLL isolation (default)",
177                        "Disable DLL isolation">;
178defm appcontainer : B<"appcontainer",
179                      "Image can only be run in an app container",
180                      "Image can run outside an app container (default)">;
181defm 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)">;
183defm 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">;
190defm incremental : B<"incremental",
191                     "Keep original import library if contents are unchanged",
192                     "Overwrite import library even if contents are unchanged">;
193defm integritycheck : B<"integritycheck",
194                        "Set FORCE_INTEGRITY bit in PE header",
195                        "No effect (default)">;
196defm 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">;
207
208def help : F<"help">;
209
210// /?? and -?? must be before /? and -? to not confuse lib/Options.
211def help_q : Flag<["/??", "-??", "/?", "-?"], "">, Alias<help>;
212
213// LLD extensions
214defm auto_import : B_priv<"auto-import">;
215defm runtime_pseudo_reloc : B_priv<"runtime-pseudo-reloc">;
216def end_lib : F<"end-lib">,
217  HelpText<"End group of objects treated as if they were in a library">;
218def exclude_all_symbols : F<"exclude-all-symbols">;
219def export_all_symbols : F<"export-all-symbols">;
220defm demangle : B<"demangle",
221    "Demangle symbols in output (default)",
222    "Do not demangle symbols in output">;
223def include_optional : Joined<["/", "-", "/?", "-?"], "includeoptional:">,
224    HelpText<"Add symbol as undefined, but allow it to remain undefined">;
225def kill_at : F<"kill-at">;
226def lldmingw : F<"lldmingw">;
227def noseh : F<"noseh">;
228def osversion : P_priv<"osversion">;
229def output_def : Joined<["/", "-", "/?", "-?"], "output-def:">;
230def pdb_source_path : P<"pdbsourcepath",
231    "Base path used to make relative source file path absolute in PDB">;
232def rsp_quoting : Joined<["--"], "rsp-quoting=">,
233  HelpText<"Quoting style for response files, 'windows' (default) or 'posix'">;
234def start_lib : F<"start-lib">,
235  HelpText<"Start group of objects treated as if they were in a library">;
236defm stdcall_fixup : B_priv<"stdcall-fixup">;
237def 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">;
246def 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">;
252def lto_obj_path : P<
253    "lto-obj-path",
254    "output native object for merged LTO unit to this path">;
255def 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">;
259defm 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">;
263def dash_dash_version : Flag<["--"], "version">,
264  HelpText<"Display the version number and exit">;
265def threads
266    : P<"threads", "Number of threads. '1' disables multi-threading. By "
267                   "default all available hardware threads are used">;
268def call_graph_ordering_file: P<
269    "call-graph-ordering-file",
270    "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">;
279def wrap : P_priv<"wrap">;
280
281def vfsoverlay : P<"vfsoverlay", "Path to a vfsoverlay yaml file to optionally look for /defaultlib's in">;
282
283// Flags for debugging
284def lldmap : F<"lldmap">;
285def lldmap_file : P_priv<"lldmap">;
286def map : F<"map">;
287def map_file : P_priv<"map">;
288def show_timing : F<"time">;
289def summary : F<"summary">;
290
291//==============================================================================
292// The flags below do nothing. They are defined only for link.exe compatibility.
293//==============================================================================
294
295def ignoreidl : F<"ignoreidl">;
296def ltcg : F<"ltcg">;
297def nologo : F<"nologo">;
298def throwingnew : F<"throwingnew">;
299def editandcontinue : F<"editandcontinue">;
300def fastfail : F<"fastfail">;
301def kernel : F<"kernel">;
302def pdbcompress : F<"pdbcompress">;
303
304def delay : P_priv<"delay">;
305def errorreport : P_priv<"errorreport">;
306def idlout : P_priv<"idlout">;
307def ilk : P_priv<"ilk">;
308def ltcg_opt : P_priv<"ltcg">;
309def ltcgout : P_priv<"ltcgout">;
310def maxilksize : P_priv<"maxilksize">;
311def tlbid : P_priv<"tlbid">;
312def tlbout : P_priv<"tlbout">;
313def verbose_all : P_priv<"verbose">;
314def guardsym : P_priv<"guardsym">;
315