1include "llvm/Option/OptParser.td"
2
3class F<string name>: Flag<["--", "-"], name>;
4class J<string name>: Joined<["--", "-"], name>;
5class S<string name>: Separate<["--", "-"], name>;
6
7multiclass Eq<string name, string help> {
8  def NAME: Separate<["--", "-"], name>;
9  def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>,
10    HelpText<help>;
11}
12
13multiclass EqLong<string name, string help> {
14  def NAME: Separate<["--"], name>;
15  def NAME # _eq: Joined<["--"], name # "=">, Alias<!cast<Separate>(NAME)>,
16    HelpText<help>;
17}
18
19multiclass EqNoHelp<string name> {
20  def NAME: Separate<["--", "-"], name>;
21  def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>;
22}
23
24multiclass B<string name, string help1, string help2> {
25  def NAME: Flag<["--", "-"], name>, HelpText<help1>;
26  def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>;
27}
28
29multiclass B_disable<string name, string help1, string help2> {
30  def NAME: Flag<["--", "-"], name>, HelpText<help1>;
31  def disable_ # NAME: Flag<["--", "-"], "disable-" # name>, HelpText<help2>;
32}
33
34def L: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">,
35  HelpText<"Add a directory to the library search path">;
36defm allow_multiple_definition: B<"allow-multiple-definition",
37    "Allow multiple definitions",
38    "Do not allow multiple definitions (default)">;
39def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries">;
40def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">;
41defm demangle: B<"demangle",
42    "Demangle symbol names (default)",
43    "Do not demangle symbol names">;
44def disable_auto_import: F<"disable-auto-import">,
45    HelpText<"Don't automatically import data symbols from other DLLs without dllimport">;
46def disable_runtime_pseudo_reloc: F<"disable-runtime-pseudo-reloc">,
47    HelpText<"Don't do automatic imports that require runtime fixups">;
48def disable_stdcall_fixup: F<"disable-stdcall-fixup">,
49    HelpText<"Don't resolve stdcall/fastcall/vectorcall to undecorated symbols">;
50defm dynamicbase: B_disable<"dynamicbase", "Enable ASLR", "Disable ASLR">;
51def enable_auto_import: F<"enable-auto-import">,
52    HelpText<"Automatically import data symbols from other DLLs where needed">;
53def enable_runtime_pseudo_reloc: F<"enable-runtime-pseudo-reloc">,
54    HelpText<"Allow automatic imports that require runtime fixups">;
55def enable_stdcall_fixup: F<"enable-stdcall-fixup">,
56    HelpText<"Resolve stdcall/fastcall/vectorcall to undecorated symbols without warnings">;
57defm entry: Eq<"entry", "Name of entry point symbol">, MetaVarName<"<entry>">;
58def exclude_all_symbols: F<"exclude-all-symbols">,
59    HelpText<"Don't automatically export any symbols">;
60def export_all_symbols: F<"export-all-symbols">,
61    HelpText<"Export all symbols even if a def file or dllexport attributes are used">;
62defm fatal_warnings: B<"fatal-warnings",
63    "Treat warnings as errors",
64    "Do not treat warnings as errors (default)">;
65defm file_alignment: Eq<"file-alignment", "Set file alignment">;
66defm gc_sections: B<"gc-sections",
67    "Remove unused sections",
68    "Don't remove unused sections">;
69def help: F<"help">, HelpText<"Print option help">;
70defm high_entropy_va: B_disable<"high-entropy-va",
71    "Set the 'high entropy VA' flag", "Don't set the 'high entropy VA' flag">;
72defm icf: Eq<"icf", "Identical code folding">;
73defm image_base: Eq<"image-base", "Base address of the program">;
74defm insert_timestamp: B<"insert-timestamp",
75    "Include PE header timestamp",
76    "Don't include PE header timestamp">;
77def kill_at: F<"kill-at">, HelpText<"Remove @n from exported symbols">;
78def l: JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">,
79  HelpText<"Root name of library to use">;
80def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
81defm major_os_version: EqLong<"major-os-version",
82     "Set the OS and subsystem major version">;
83defm major_subsystem_version: EqLong<"major-subsystem-version",
84     "Set the OS and subsystem major version">;
85defm map: Eq<"Map", "Output a linker map">;
86defm minor_os_version: EqLong<"minor-os-version",
87     "Set the OS and subsystem minor version">;
88defm minor_subsystem_version: EqLong<"minor-subsystem-version",
89     "Set the OS and subsystem minor version">;
90defm no_seh: B_disable<"no-seh",
91     "Set the 'no SEH' flag in the executable", "Don't set the 'no SEH' flag">;
92defm nxcompat: B_disable<"nxcompat",
93    "Set the 'nxcompat' flag in the executable", "Don't set the 'nxcompat' flag">;
94def large_address_aware: Flag<["--"], "large-address-aware">,
95    HelpText<"Enable large addresses">;
96def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
97  HelpText<"Path to file to write output">;
98defm out_implib: Eq<"out-implib", "Import library name">;
99defm output_def: Eq<"output-def", "Output def file">;
100defm section_alignment: Eq<"section-alignment", "Set section alignment">;
101def shared: F<"shared">, HelpText<"Build a shared object">;
102defm subs: Eq<"subsystem", "Specify subsystem">;
103defm stack: Eq<"stack", "Set size of the initial stack">;
104def strip_all: F<"strip-all">,
105    HelpText<"Omit all symbol information from the output binary">;
106def strip_debug: F<"strip-debug">,
107    HelpText<"Omit all debug information, but keep symbol information">;
108defm reproduce: Eq<"reproduce",
109     "Write a tar file containing input files and command line options to reproduce link">;
110defm require_defined: Eq<"require-defined",
111     "Force symbol to be added to symbol table as an undefined one">;
112defm tsaware: B_disable<"tsaware",
113    "Set the 'Terminal Server aware' flag", "Don't set the 'Terminal Server aware' flag">;
114defm undefined: Eq<"undefined", "Include symbol in the link, if available">;
115defm whole_archive: B<"whole-archive",
116    "Include all object files for following archives",
117    "No longer include all object files for following archives">;
118def v: Flag<["-"], "v">, HelpText<"Display the version number">;
119def verbose: F<"verbose">, HelpText<"Verbose mode">;
120def version: F<"version">, HelpText<"Display the version number and exit">;
121defm wrap: Eq<"wrap", "Use wrapper functions for symbol">,
122     MetaVarName<"<symbol>">;
123
124// LLD specific options
125def _HASH_HASH_HASH : Flag<["-"], "###">,
126    HelpText<"Print (but do not run) the commands to run for this compilation">;
127def appcontainer: F<"appcontainer">, HelpText<"Set the appcontainer flag in the executable">;
128defm delayload: Eq<"delayload", "DLL to load only on demand">;
129defm mllvm: EqNoHelp<"mllvm">;
130defm pdb: Eq<"pdb", "Output PDB debug info file, chosen implicitly if the argument is empty">;
131defm thinlto_cache_dir: EqLong<"thinlto-cache-dir",
132  "Path to ThinLTO cached object file directory">;
133defm Xlink : Eq<"Xlink", "Pass <arg> to the COFF linker">, MetaVarName<"<arg>">;
134
135// Alias
136def alias_Bdynamic_call_shared: Flag<["-"], "call_shared">, Alias<Bdynamic>;
137def alias_Bdynamic_dy: Flag<["-"], "dy">, Alias<Bdynamic>;
138def alias_Bstatic_dn: Flag<["-"], "dn">, Alias<Bstatic>;
139def alias_Bstatic_non_shared: Flag<["-"], "non_shared">, Alias<Bstatic>;
140def alias_Bstatic_static: Flag<["-"], "static">, Alias<Bstatic>;
141def alias_entry_e: JoinedOrSeparate<["-"], "e">, Alias<entry>;
142def alias_no_dynamicbase: F<"no-dynamicbase">, Alias<disable_dynamicbase>;
143def alias_strip_s: Flag<["-"], "s">, Alias<strip_all>;
144def alias_strip_S: Flag<["-"], "S">, Alias<strip_debug>;
145def alias_undefined_u: JoinedOrSeparate<["-"], "u">, Alias<undefined>;
146
147// Ignored options
148def: Joined<["-"], "O">;
149def: F<"build-id">;
150def: F<"disable-auto-image-base">;
151def: F<"enable-auto-image-base">;
152def: F<"end-group">;
153def: Flag<["--"], "full-shutdown">;
154defm: EqNoHelp<"major-image-version">;
155defm: EqNoHelp<"minor-image-version">;
156def: F<"no-undefined">;
157def: F<"pic-executable">;
158defm: EqNoHelp<"plugin">;
159defm: EqNoHelp<"plugin-opt">;
160defm: EqNoHelp<"sysroot">;
161def: F<"start-group">;
162