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