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