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