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