xref: /freebsd/contrib/llvm-project/lld/COFF/Options.td (revision 6966ac055c3b7a39266fb982493330df7a097997)
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// Boolean flag which can be suffixed by ":no". Using it unsuffixed turns the
13// flag on and using it suffixed by ":no" turns it off.
14multiclass B<string name, string help_on, string help_off> {
15  def "" : F<name>, HelpText<help_on>;
16  def _no : F<name#":no">, HelpText<help_off>;
17}
18
19def align   : P<"align", "Section alignment">;
20def aligncomm : P<"aligncomm", "Set common symbol alignment">;
21def alternatename : P<"alternatename", "Define weak alias">;
22def base    : P<"base", "Base address of the program">;
23def color_diagnostics: Flag<["--"], "color-diagnostics">,
24  HelpText<"Use colors in diagnostics">;
25def color_diagnostics_eq: Joined<["--"], "color-diagnostics=">,
26  HelpText<"Use colors in diagnostics; one of 'always', 'never', 'auto'">;
27def defaultlib : P<"defaultlib", "Add the library to the list of input files">;
28def delayload : P<"delayload", "Delay loaded DLL name">;
29def entry   : P<"entry", "Name of entry point symbol">;
30def errorlimit : P<"errorlimit",
31    "Maximum number of errors to emit before stopping (0 = no limit)">;
32def export  : P<"export", "Export a function">;
33// No help text because /failifmismatch is not intended to be used by the user.
34def failifmismatch : P<"failifmismatch", "">;
35def filealign : P<"filealign", "Section alignment in the output file">;
36def functionpadmin : F<"functionpadmin">;
37def functionpadmin_opt : P<"functionpadmin", "Prepares an image for hotpatching">;
38def guard   : P<"guard", "Control flow guard">;
39def heap    : P<"heap", "Size of the heap">;
40def ignore : P<"ignore", "Specify warning codes to ignore">;
41def implib  : P<"implib", "Import library name">;
42def lib : F<"lib">,
43    HelpText<"Act like lib.exe; must be first argument if present">;
44def libpath : P<"libpath", "Additional library search path">;
45def linkrepro : P<"linkrepro", "Dump linker invocation and input files for debugging">;
46def lldltocache : P<"lldltocache", "Path to ThinLTO cached object file directory">;
47def lldltocachepolicy : P<"lldltocachepolicy", "Pruning policy for the ThinLTO cache">;
48def lldsavetemps : F<"lldsavetemps">,
49    HelpText<"Save temporary files instead of deleting them">;
50def machine : P<"machine", "Specify target platform">;
51def merge   : P<"merge", "Combine sections">;
52def mllvm   : P<"mllvm", "Options to pass to LLVM">;
53def nodefaultlib : P<"nodefaultlib", "Remove a default library">;
54def opt     : P<"opt", "Control optimizations">;
55def order   : P<"order", "Put functions in order">;
56def out     : P<"out", "Path to file to write output">;
57def natvis : P<"natvis", "Path to natvis file to embed in the PDB">;
58def no_color_diagnostics: F<"no-color-diagnostics">,
59  HelpText<"Do not use colors in diagnostics">;
60def pdb : P<"pdb", "PDB file path">;
61def pdbaltpath : P<"pdbaltpath", "PDB file path to embed in the image">;
62def section : P<"section", "Specify section attributes">;
63def stack   : P<"stack", "Size of the stack">;
64def stub    : P<"stub", "Specify DOS stub file">;
65def subsystem : P<"subsystem", "Specify subsystem">;
66def timestamp : P<"timestamp", "Specify the PE header timestamp">;
67def version : P<"version", "Specify a version number in the PE header">;
68def wholearchive_file : P<"wholearchive", "Include all object files from this archive">;
69
70def disallowlib : Joined<["/", "-", "/?", "-?"], "disallowlib:">,
71    Alias<nodefaultlib>;
72
73def manifest : F<"manifest">, HelpText<"Create .manifest file">;
74def manifest_colon : P<
75    "manifest",
76    "NO disables manifest output; EMBED[,ID=#] embeds manifest as resource in the image">;
77def manifestuac : P<"manifestuac", "User access control">;
78def manifestfile : P<"manifestfile", "Manifest output path, with /manifest">;
79def manifestdependency : P<
80    "manifestdependency",
81    "Attributes for <dependency> element in manifest file; implies /manifest">;
82def manifestinput : P<
83    "manifestinput",
84    "Additional manifest inputs; only valid with /manifest:embed">;
85
86// We cannot use multiclass P because class name "incl" is different
87// from its command line option name. We do this because "include" is
88// a reserved keyword in tablegen.
89def incl : Joined<["/", "-", "/?", "-?"], "include:">,
90    HelpText<"Force symbol to be added to symbol table as undefined one">;
91
92// "def" is also a keyword.
93def deffile : Joined<["/", "-", "/?", "-?"], "def:">,
94    HelpText<"Use module-definition file">;
95
96def debug : F<"debug">, HelpText<"Embed a symbol table in the image">;
97def debug_opt : P<"debug", "Embed a symbol table in the image with option">;
98def debugtype : P<"debugtype", "Debug Info Options">;
99def dll : F<"dll">, HelpText<"Create a DLL">;
100def driver : P<"driver", "Generate a Windows NT Kernel Mode Driver">;
101def nodefaultlib_all : F<"nodefaultlib">,
102    HelpText<"Remove all default libraries">;
103def noentry : F<"noentry">,
104    HelpText<"Don't add reference to DllMainCRTStartup; only valid with /dll">;
105def profile : F<"profile">;
106def repro : F<"Brepro">,
107    HelpText<"Use a hash of the executable as the PE header timestamp">;
108def swaprun : P<"swaprun",
109  "Comma-separated list of 'cd' or 'net'">;
110def swaprun_cd : F<"swaprun:cd">, Alias<swaprun>, AliasArgs<["cd"]>,
111  HelpText<"Make loader run output binary from swap instead of from CD">;
112def swaprun_net : F<"swaprun:net">, Alias<swaprun>, AliasArgs<["net"]>,
113  HelpText<"Make loader run output binary from swap instead of from network">;
114def verbose : F<"verbose">;
115def wholearchive_flag : F<"wholearchive">;
116
117def force : F<"force">,
118    HelpText<"Allow undefined and multiply defined symbols when creating executables">;
119def force_unresolved : F<"force:unresolved">,
120    HelpText<"Allow undefined symbols when creating executables">;
121def force_multiple : F<"force:multiple">,
122    HelpText<"Allow multiply defined symbols when creating executables">;
123def force_multipleres : F<"force:multipleres">,
124    HelpText<"Allow multiply defined resources when creating executables">;
125defm WX : B<"WX", "Treat warnings as errors", "Don't treat warnings as errors">;
126
127defm allowbind : B<"allowbind", "Enable DLL binding (default)",
128                   "Disable DLL binding">;
129defm allowisolation : B<"allowisolation", "Enable DLL isolation (default)",
130                        "Disable DLL isolation">;
131defm appcontainer : B<"appcontainer",
132                      "Image can only be run in an app container",
133                      "Image can run outside an app container (default)">;
134defm dynamicbase : B<"dynamicbase", "Enable ASLR (default unless /fixed)",
135                     "Disable ASLR (default when /fixed)">;
136defm fixed : B<"fixed", "Disable base relocations",
137               "Enable base relocations (default)">;
138defm highentropyva : B<"highentropyva",
139                       "Enable 64-bit ASLR (default on 64-bit)",
140                       "Disable 64-bit ASLR">;
141defm incremental : B<"incremental",
142                     "Keep original import library if contents are unchanged",
143                     "Overwrite import library even if contents are unchanged">;
144defm integritycheck : B<"integritycheck",
145                        "Set FORCE_INTEGRITY bit in PE header",
146                        "No effect (default)">;
147defm largeaddressaware : B<"largeaddressaware",
148                           "Enable large addresses (default on 64-bit)",
149                           "Disable large addresses (default on 32-bit)">;
150defm nxcompat : B<"nxcompat", "Enable data execution prevention (default)",
151                  "Disable data execution provention">;
152defm safeseh : B<"safeseh",
153                 "Produce an image with Safe Exception Handler (only for x86)",
154                 "Don't produce an image with Safe Exception Handler">;
155defm tsaware  : B<"tsaware",
156                  "Create Terminal Server aware executable (default)",
157                  "Create non-Terminal Server aware executable">;
158
159def help : F<"help">;
160
161// /?? and -?? must be before /? and -? to not confuse lib/Options.
162def help_q : Flag<["/??", "-??", "/?", "-?"], "">, Alias<help>;
163
164// LLD extensions
165def exclude_all_symbols : F<"exclude-all-symbols">;
166def export_all_symbols : F<"export-all-symbols">;
167defm demangle : B<"demangle",
168    "Demangle symbols in output (default)",
169    "Do not demangle symbols in output">;
170def include_optional : Joined<["/", "-", "/?", "-?"], "includeoptional:">,
171    HelpText<"Add symbol as undefined, but allow it to remain undefined">;
172def kill_at : F<"kill-at">;
173def lldmingw : F<"lldmingw">;
174def output_def : Joined<["/", "-", "/?", "-?"], "output-def:">;
175def pdb_source_path : P<"pdbsourcepath",
176                        "Base path used to make relative source file path absolute in PDB">;
177def rsp_quoting : Joined<["--"], "rsp-quoting=">,
178  HelpText<"Quoting style for response files, 'windows' (default) or 'posix'">;
179def thinlto_emit_imports_files :
180    F<"thinlto-emit-imports-files">,
181    HelpText<"Emit .imports files with -thinlto-index-only">;
182def thinlto_index_only :
183    F<"thinlto-index-only">,
184    HelpText<"Instead of linking, emit ThinLTO index files">;
185def thinlto_index_only_arg : P<
186    "thinlto-index-only",
187    "-thinlto-index-only and also write native module names to file">;
188def thinlto_object_suffix_replace : P<
189    "thinlto-object-suffix-replace",
190    "'old;new' replace old suffix with new suffix in ThinLTO index">;
191def thinlto_prefix_replace: P<
192    "thinlto-prefix-replace",
193    "'old;new' replace old prefix with new prefix in ThinLTO outputs">;
194def dash_dash_version : Flag<["--"], "version">,
195  HelpText<"Print version information">;
196defm threads: B<"threads",
197    "Run the linker multi-threaded (default)",
198    "Do not run the linker multi-threaded">;
199
200// Flags for debugging
201def lldmap : F<"lldmap">;
202def lldmap_file : Joined<["/", "-", "/?", "-?"], "lldmap:">;
203def show_timing : F<"time">;
204def summary : F<"summary">;
205
206//==============================================================================
207// The flags below do nothing. They are defined only for link.exe compatibility.
208//==============================================================================
209
210class QF<string name> : Joined<["/", "-", "/?", "-?"], name#":">;
211
212def ignoreidl : F<"ignoreidl">;
213def nologo : F<"nologo">;
214def throwingnew : F<"throwingnew">;
215def editandcontinue : F<"editandcontinue">;
216def fastfail : F<"fastfail">;
217
218def delay : QF<"delay">;
219def errorreport : QF<"errorreport">;
220def idlout : QF<"idlout">;
221def maxilksize : QF<"maxilksize">;
222def tlbid : QF<"tlbid">;
223def tlbout : QF<"tlbout">;
224def verbose_all : QF<"verbose">;
225def guardsym : QF<"guardsym">;
226