2017-09-12 01:02:59 +08:00
|
|
|
include "llvm/Option/OptParser.td"
|
|
|
|
|
|
|
|
class F<string name>: Flag<["--", "-"], name>;
|
|
|
|
class J<string name>: Joined<["--", "-"], name>;
|
|
|
|
class S<string name>: Separate<["--", "-"], name>;
|
|
|
|
|
2019-08-14 17:35:40 +08:00
|
|
|
multiclass Eq<string name, string help> {
|
|
|
|
def NAME: Separate<["--", "-"], name>;
|
|
|
|
def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>,
|
|
|
|
HelpText<help>;
|
|
|
|
}
|
|
|
|
|
|
|
|
multiclass EqLong<string name, string help> {
|
|
|
|
def NAME: Separate<["--"], name>;
|
|
|
|
def NAME # _eq: Joined<["--"], name # "=">, Alias<!cast<Separate>(NAME)>,
|
|
|
|
HelpText<help>;
|
|
|
|
}
|
|
|
|
|
2021-08-02 16:44:04 +08:00
|
|
|
multiclass EqNoHelp<string name> {
|
|
|
|
def NAME: Separate<["--", "-"], name>;
|
|
|
|
def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>;
|
|
|
|
}
|
|
|
|
|
2020-08-26 14:24:37 +08:00
|
|
|
multiclass B<string name, string help1, string help2> {
|
|
|
|
def NAME: Flag<["--", "-"], name>, HelpText<help1>;
|
|
|
|
def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>;
|
|
|
|
}
|
|
|
|
|
2021-08-12 04:41:24 +08:00
|
|
|
multiclass B_disable<string name, string help1, string help2> {
|
|
|
|
def NAME: Flag<["--", "-"], name>, HelpText<help1>;
|
|
|
|
def disable_ # NAME: Flag<["--", "-"], "disable-" # name>, HelpText<help2>;
|
|
|
|
}
|
|
|
|
|
2017-09-12 01:02:59 +08:00
|
|
|
def L: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">,
|
|
|
|
HelpText<"Add a directory to the library search path">;
|
2020-08-26 14:25:52 +08:00
|
|
|
defm allow_multiple_definition: B<"allow-multiple-definition",
|
|
|
|
"Allow multiple definitions",
|
|
|
|
"Do not allow multiple definitions (default)">;
|
2019-01-30 03:24:32 +08:00
|
|
|
def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries">;
|
|
|
|
def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">;
|
2020-12-31 05:02:01 +08:00
|
|
|
defm demangle: B<"demangle",
|
|
|
|
"Demangle symbol names (default)",
|
|
|
|
"Do not demangle symbol names">;
|
2020-04-26 05:49:44 +08:00
|
|
|
def disable_auto_import: F<"disable-auto-import">,
|
|
|
|
HelpText<"Don't automatically import data symbols from other DLLs without dllimport">;
|
|
|
|
def disable_runtime_pseudo_reloc: F<"disable-runtime-pseudo-reloc">,
|
|
|
|
HelpText<"Don't do automatic imports that require runtime fixups">;
|
[LLD] [COFF] Fix up missing stdcall decorations in MinGW mode
If linking directly against a DLL without an import library, the
DLL export symbols might not contain stdcall decorations.
If we have an undefined symbol with decoration, and we happen to have
a matching undecorated symbol (which either is lazy and can be loaded,
or already defined), then alias it against that instead.
This matches what's done in reverse, when we have a def file
declaring to export a symbol without decoration, but we only have
a defined decorated symbol. In that case we do a fuzzy match
(SymbolTable::findMangle). This case is more straightforward; if we
have a decorated undefined symbol, just strip the decoration and look
for the corresponding undecorated symbol name.
Add warnings and options for either silencing the warning or disabling
the whole feature, corresponding to how ld.bfd does it.
(This feature works for any symbol decoration mismatch, not only when
linking against a DLL directly; ld.bfd also tolerates it anywhere,
and also fixes up mismatches in the other direction, like
SymbolTable::findMangle, for any symbol, not only exports. But in
practice, at least for lld, it would primarily end up used for linking
against DLLs.)
Differential Revision: https://reviews.llvm.org/D104532
2021-06-18 02:51:37 +08:00
|
|
|
def disable_stdcall_fixup: F<"disable-stdcall-fixup">,
|
|
|
|
HelpText<"Don't resolve stdcall/fastcall/vectorcall to undecorated symbols">;
|
2021-08-12 04:41:24 +08:00
|
|
|
defm dynamicbase: B_disable<"dynamicbase", "Enable ASLR", "Disable ASLR">;
|
2020-04-26 05:49:44 +08:00
|
|
|
def enable_auto_import: F<"enable-auto-import">,
|
|
|
|
HelpText<"Automatically import data symbols from other DLLs where needed">;
|
|
|
|
def enable_runtime_pseudo_reloc: F<"enable-runtime-pseudo-reloc">,
|
|
|
|
HelpText<"Allow automatic imports that require runtime fixups">;
|
[LLD] [COFF] Fix up missing stdcall decorations in MinGW mode
If linking directly against a DLL without an import library, the
DLL export symbols might not contain stdcall decorations.
If we have an undefined symbol with decoration, and we happen to have
a matching undecorated symbol (which either is lazy and can be loaded,
or already defined), then alias it against that instead.
This matches what's done in reverse, when we have a def file
declaring to export a symbol without decoration, but we only have
a defined decorated symbol. In that case we do a fuzzy match
(SymbolTable::findMangle). This case is more straightforward; if we
have a decorated undefined symbol, just strip the decoration and look
for the corresponding undecorated symbol name.
Add warnings and options for either silencing the warning or disabling
the whole feature, corresponding to how ld.bfd does it.
(This feature works for any symbol decoration mismatch, not only when
linking against a DLL directly; ld.bfd also tolerates it anywhere,
and also fixes up mismatches in the other direction, like
SymbolTable::findMangle, for any symbol, not only exports. But in
practice, at least for lld, it would primarily end up used for linking
against DLLs.)
Differential Revision: https://reviews.llvm.org/D104532
2021-06-18 02:51:37 +08:00
|
|
|
def enable_stdcall_fixup: F<"enable-stdcall-fixup">,
|
|
|
|
HelpText<"Resolve stdcall/fastcall/vectorcall to undecorated symbols without warnings">;
|
2019-08-14 17:35:44 +08:00
|
|
|
defm entry: Eq<"entry", "Name of entry point symbol">, MetaVarName<"<entry>">;
|
2019-02-20 05:57:49 +08:00
|
|
|
def exclude_all_symbols: F<"exclude-all-symbols">,
|
|
|
|
HelpText<"Don't automatically export any symbols">;
|
2017-10-12 13:37:18 +08:00
|
|
|
def export_all_symbols: F<"export-all-symbols">,
|
|
|
|
HelpText<"Export all symbols even if a def file or dllexport attributes are used">;
|
2021-05-17 15:39:59 +08:00
|
|
|
defm fatal_warnings: B<"fatal-warnings",
|
|
|
|
"Treat warnings as errors",
|
|
|
|
"Do not treat warnings as errors (default)">;
|
2020-07-14 05:12:13 +08:00
|
|
|
defm file_alignment: Eq<"file-alignment", "Set file alignment">;
|
2020-08-26 14:24:37 +08:00
|
|
|
defm gc_sections: B<"gc-sections",
|
|
|
|
"Remove unused sections",
|
|
|
|
"Don't remove unused sections">;
|
2019-05-17 19:07:38 +08:00
|
|
|
def help: F<"help">, HelpText<"Print option help">;
|
2021-08-12 04:41:24 +08:00
|
|
|
defm high_entropy_va: B_disable<"high-entropy-va",
|
|
|
|
"Set the 'high entropy VA' flag", "Don't set the 'high entropy VA' flag">;
|
2021-08-02 16:44:04 +08:00
|
|
|
defm icf: Eq<"icf", "Identical code folding">;
|
|
|
|
defm image_base: Eq<"image-base", "Base address of the program">;
|
2020-08-26 14:24:37 +08:00
|
|
|
defm insert_timestamp: B<"insert-timestamp",
|
|
|
|
"Include PE header timestamp",
|
|
|
|
"Don't include PE header timestamp">;
|
2018-03-15 04:17:24 +08:00
|
|
|
def kill_at: F<"kill-at">, HelpText<"Remove @n from exported symbols">;
|
2017-09-12 04:54:51 +08:00
|
|
|
def l: JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">,
|
|
|
|
HelpText<"Root name of library to use">;
|
2017-09-12 01:02:59 +08:00
|
|
|
def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
|
2019-08-14 17:35:40 +08:00
|
|
|
defm major_os_version: EqLong<"major-os-version",
|
|
|
|
"Set the OS and subsystem major version">;
|
|
|
|
defm major_subsystem_version: EqLong<"major-subsystem-version",
|
|
|
|
"Set the OS and subsystem major version">;
|
|
|
|
defm map: Eq<"Map", "Output a linker map">;
|
|
|
|
defm minor_os_version: EqLong<"minor-os-version",
|
|
|
|
"Set the OS and subsystem minor version">;
|
|
|
|
defm minor_subsystem_version: EqLong<"minor-subsystem-version",
|
|
|
|
"Set the OS and subsystem minor version">;
|
2021-08-12 04:41:24 +08:00
|
|
|
defm no_seh: B_disable<"no-seh",
|
|
|
|
"Set the 'no SEH' flag in the executable", "Don't set the 'no SEH' flag">;
|
|
|
|
defm nxcompat: B_disable<"nxcompat",
|
|
|
|
"Set the 'nxcompat' flag in the executable", "Don't set the 'nxcompat' flag">;
|
2017-11-15 16:18:06 +08:00
|
|
|
def large_address_aware: Flag<["--"], "large-address-aware">,
|
|
|
|
HelpText<"Enable large addresses">;
|
2017-09-12 01:02:59 +08:00
|
|
|
def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
|
|
|
|
HelpText<"Path to file to write output">;
|
2019-08-14 17:35:44 +08:00
|
|
|
defm out_implib: Eq<"out-implib", "Import library name">;
|
|
|
|
defm output_def: Eq<"output-def", "Output def file">;
|
2020-07-14 05:12:13 +08:00
|
|
|
defm section_alignment: Eq<"section-alignment", "Set section alignment">;
|
2017-09-12 01:02:59 +08:00
|
|
|
def shared: F<"shared">, HelpText<"Build a shared object">;
|
2019-08-14 17:35:40 +08:00
|
|
|
defm subs: Eq<"subsystem", "Specify subsystem">;
|
2021-08-02 04:26:25 +08:00
|
|
|
defm stack: Eq<"stack", "Set size of the initial stack">;
|
2017-11-04 06:10:37 +08:00
|
|
|
def strip_all: F<"strip-all">,
|
|
|
|
HelpText<"Omit all symbol information from the output binary">;
|
2018-06-29 14:08:31 +08:00
|
|
|
def strip_debug: F<"strip-debug">,
|
|
|
|
HelpText<"Omit all debug information, but keep symbol information">;
|
2020-10-06 18:03:49 +08:00
|
|
|
defm reproduce: Eq<"reproduce",
|
|
|
|
"Write a tar file containing input files and command line options to reproduce link">;
|
|
|
|
defm require_defined: Eq<"require-defined",
|
|
|
|
"Force symbol to be added to symbol table as an undefined one">;
|
2021-08-12 04:41:24 +08:00
|
|
|
defm tsaware: B_disable<"tsaware",
|
|
|
|
"Set the 'Terminal Server aware' flag", "Don't set the 'Terminal Server aware' flag">;
|
2019-08-14 17:35:40 +08:00
|
|
|
defm undefined: Eq<"undefined", "Include symbol in the link, if available">;
|
2020-08-26 14:24:37 +08:00
|
|
|
defm whole_archive: B<"whole-archive",
|
|
|
|
"Include all object files for following archives",
|
|
|
|
"No longer include all object files for following archives">;
|
2019-05-17 19:07:42 +08:00
|
|
|
def v: Flag<["-"], "v">, HelpText<"Display the version number">;
|
2017-09-12 04:43:39 +08:00
|
|
|
def verbose: F<"verbose">, HelpText<"Verbose mode">;
|
2019-05-17 19:07:42 +08:00
|
|
|
def version: F<"version">, HelpText<"Display the version number and exit">;
|
2020-10-06 18:54:49 +08:00
|
|
|
defm wrap: Eq<"wrap", "Use wrapper functions for symbol">,
|
|
|
|
MetaVarName<"<symbol>">;
|
2017-09-12 04:43:39 +08:00
|
|
|
|
|
|
|
// LLD specific options
|
|
|
|
def _HASH_HASH_HASH : Flag<["-"], "###">,
|
|
|
|
HelpText<"Print (but do not run) the commands to run for this compilation">;
|
2019-04-19 21:50:43 +08:00
|
|
|
def appcontainer: F<"appcontainer">, HelpText<"Set the appcontainer flag in the executable">;
|
2019-08-14 17:35:40 +08:00
|
|
|
defm delayload: Eq<"delayload", "DLL to load only on demand">;
|
2021-08-02 16:44:04 +08:00
|
|
|
defm mllvm: EqNoHelp<"mllvm">;
|
2019-08-14 17:35:40 +08:00
|
|
|
defm pdb: Eq<"pdb", "Output PDB debug info file, chosen implicitly if the argument is empty">;
|
2020-05-24 17:29:16 +08:00
|
|
|
defm thinlto_cache_dir: EqLong<"thinlto-cache-dir",
|
|
|
|
"Path to ThinLTO cached object file directory">;
|
2021-08-02 16:44:04 +08:00
|
|
|
defm Xlink : Eq<"Xlink", "Pass <arg> to the COFF linker">, MetaVarName<"<arg>">;
|
2017-09-12 01:02:59 +08:00
|
|
|
|
|
|
|
// Alias
|
2021-05-18 04:12:22 +08:00
|
|
|
def alias_Bdynamic_call_shared: Flag<["-"], "call_shared">, Alias<Bdynamic>;
|
|
|
|
def alias_Bdynamic_dy: Flag<["-"], "dy">, Alias<Bdynamic>;
|
|
|
|
def alias_Bstatic_dn: Flag<["-"], "dn">, Alias<Bstatic>;
|
|
|
|
def alias_Bstatic_non_shared: Flag<["-"], "non_shared">, Alias<Bstatic>;
|
|
|
|
def alias_Bstatic_static: Flag<["-"], "static">, Alias<Bstatic>;
|
2017-09-12 01:02:59 +08:00
|
|
|
def alias_entry_e: JoinedOrSeparate<["-"], "e">, Alias<entry>;
|
2021-08-12 04:41:24 +08:00
|
|
|
def alias_no_dynamicbase: F<"no-dynamicbase">, Alias<disable_dynamicbase>;
|
2017-11-04 06:10:37 +08:00
|
|
|
def alias_strip_s: Flag<["-"], "s">, Alias<strip_all>;
|
2018-06-29 14:08:31 +08:00
|
|
|
def alias_strip_S: Flag<["-"], "S">, Alias<strip_debug>;
|
2019-08-14 17:35:44 +08:00
|
|
|
def alias_undefined_u: JoinedOrSeparate<["-"], "u">, Alias<undefined>;
|
2019-01-29 16:38:48 +08:00
|
|
|
|
|
|
|
// Ignored options
|
2019-01-30 03:24:32 +08:00
|
|
|
def: Joined<["-"], "O">;
|
2022-01-02 07:59:23 +08:00
|
|
|
def: F<"as-needed">;
|
2019-01-30 03:24:32 +08:00
|
|
|
def: F<"build-id">;
|
|
|
|
def: F<"disable-auto-image-base">;
|
|
|
|
def: F<"enable-auto-image-base">;
|
|
|
|
def: F<"end-group">;
|
|
|
|
def: Flag<["--"], "full-shutdown">;
|
2021-08-02 16:44:04 +08:00
|
|
|
defm: EqNoHelp<"major-image-version">;
|
|
|
|
defm: EqNoHelp<"minor-image-version">;
|
2021-05-15 04:46:49 +08:00
|
|
|
def: F<"no-undefined">;
|
2019-01-30 03:24:32 +08:00
|
|
|
def: F<"pic-executable">;
|
2021-08-02 16:44:04 +08:00
|
|
|
defm: EqNoHelp<"plugin">;
|
|
|
|
defm: EqNoHelp<"plugin-opt">;
|
|
|
|
defm: EqNoHelp<"sysroot">;
|
2019-01-30 03:24:32 +08:00
|
|
|
def: F<"start-group">;
|