2013-04-05 02:59:24 +08:00
|
|
|
include "llvm/Option/OptParser.td"
|
|
|
|
|
2013-07-19 09:02:49 +08:00
|
|
|
|
2013-04-05 02:59:24 +08:00
|
|
|
// output kinds
|
2013-07-19 09:02:49 +08:00
|
|
|
def grp_kind : OptionGroup<"outs">, HelpText<"OUTPUT KIND">;
|
2013-09-04 08:24:35 +08:00
|
|
|
def relocatable : Flag<["-"], "r">,
|
2014-08-16 06:42:46 +08:00
|
|
|
HelpText<"Create relocatable object file">, Group<grp_kind>;
|
2013-09-04 08:24:35 +08:00
|
|
|
def static : Flag<["-"], "static">,
|
2014-08-16 06:42:46 +08:00
|
|
|
HelpText<"Create static executable">, Group<grp_kind>;
|
2013-09-04 08:24:35 +08:00
|
|
|
def dynamic : Flag<["-"], "dynamic">,
|
2014-08-16 06:42:46 +08:00
|
|
|
HelpText<"Create dynamic executable (default)">,Group<grp_kind>;
|
2013-09-04 08:24:35 +08:00
|
|
|
def dylib : Flag<["-"], "dylib">,
|
2014-08-16 06:42:46 +08:00
|
|
|
HelpText<"Create dynamic library">, Group<grp_kind>;
|
2013-09-04 08:24:35 +08:00
|
|
|
def bundle : Flag<["-"], "bundle">,
|
2014-08-16 06:42:46 +08:00
|
|
|
HelpText<"Create dynamic bundle">, Group<grp_kind>;
|
2013-09-04 08:24:35 +08:00
|
|
|
def execute : Flag<["-"], "execute">,
|
2014-08-16 06:42:46 +08:00
|
|
|
HelpText<"Create main executable (default)">, Group<grp_kind>;
|
2013-09-04 08:24:35 +08:00
|
|
|
def preload : Flag<["-"], "preload">,
|
2014-08-16 06:42:46 +08:00
|
|
|
HelpText<"Create binary for use with embedded systems">, Group<grp_kind>;
|
2013-07-19 09:02:49 +08:00
|
|
|
|
|
|
|
// optimizations
|
|
|
|
def grp_opts : OptionGroup<"opts">, HelpText<"OPTIMIZATIONS">;
|
|
|
|
def dead_strip : Flag<["-"], "dead_strip">,
|
2014-08-16 06:42:46 +08:00
|
|
|
HelpText<"Remove unreference code and data">, Group<grp_opts>;
|
2013-09-04 08:24:35 +08:00
|
|
|
def macosx_version_min : Separate<["-"], "macosx_version_min">,
|
2014-08-16 06:42:46 +08:00
|
|
|
MetaVarName<"<version>">,
|
|
|
|
HelpText<"Minimum Mac OS X version">, Group<grp_opts>;
|
2013-09-04 08:24:35 +08:00
|
|
|
def ios_version_min : Separate<["-"], "ios_version_min">,
|
2014-08-16 06:42:46 +08:00
|
|
|
MetaVarName<"<version>">,
|
|
|
|
HelpText<"Minimum iOS version">, Group<grp_opts>;
|
2014-10-04 08:19:56 +08:00
|
|
|
def iphoneos_version_min : Separate<["-"], "iphoneos_version_min">,
|
|
|
|
Alias<ios_version_min>;
|
2013-09-04 08:24:35 +08:00
|
|
|
def ios_simulator_version_min : Separate<["-"], "ios_simulator_version_min">,
|
2014-08-16 06:42:46 +08:00
|
|
|
MetaVarName<"<version>">,
|
|
|
|
HelpText<"Minimum iOS simulator version">, Group<grp_opts>;
|
2016-02-04 07:39:05 +08:00
|
|
|
def sdk_version : Separate<["-"], "sdk_version">,
|
|
|
|
MetaVarName<"<version>">,
|
|
|
|
HelpText<"SDK version">, Group<grp_opts>;
|
2016-02-04 10:45:23 +08:00
|
|
|
def source_version : Separate<["-"], "source_version">,
|
|
|
|
MetaVarName<"<version>">,
|
|
|
|
HelpText<"Source version">, Group<grp_opts>;
|
2016-02-04 06:28:29 +08:00
|
|
|
def version_load_command : Flag<["-"], "version_load_command">,
|
|
|
|
HelpText<"Force generation of a version load command">, Group<grp_opts>;
|
|
|
|
def no_version_load_command : Flag<["-"], "no_version_load_command">,
|
|
|
|
HelpText<"Disable generation of a version load command">, Group<grp_opts>;
|
2016-02-09 09:38:13 +08:00
|
|
|
def function_starts : Flag<["-"], "function_starts">,
|
|
|
|
HelpText<"Force generation of a function starts load command">,
|
|
|
|
Group<grp_opts>;
|
|
|
|
def no_function_starts : Flag<["-"], "no_function_starts">,
|
|
|
|
HelpText<"Disable generation of a function starts load command">,
|
|
|
|
Group<grp_opts>;
|
2016-02-09 10:10:39 +08:00
|
|
|
def data_in_code_info : Flag<["-"], "data_in_code_info">,
|
|
|
|
HelpText<"Force generation of a data in code load command">,
|
|
|
|
Group<grp_opts>;
|
|
|
|
def no_data_in_code_info : Flag<["-"], "no_data_in_code_info">,
|
|
|
|
HelpText<"Disable generation of a data in code load command">,
|
|
|
|
Group<grp_opts>;
|
2013-09-04 08:24:35 +08:00
|
|
|
def mllvm : Separate<["-"], "mllvm">,
|
2014-08-16 06:42:46 +08:00
|
|
|
MetaVarName<"<option>">,
|
|
|
|
HelpText<"Options to pass to LLVM during LTO">, Group<grp_opts>;
|
2014-08-21 09:59:11 +08:00
|
|
|
def exported_symbols_list : Separate<["-"], "exported_symbols_list">,
|
|
|
|
MetaVarName<"<file-path>">,
|
|
|
|
HelpText<"Restricts which symbols will be exported">, Group<grp_opts>;
|
|
|
|
def exported_symbol : Separate<["-"], "exported_symbol">,
|
|
|
|
MetaVarName<"<symbol>">,
|
|
|
|
HelpText<"Restricts which symbols will be exported">, Group<grp_opts>;
|
|
|
|
def unexported_symbols_list : Separate<["-"], "unexported_symbols_list">,
|
|
|
|
MetaVarName<"<file-path>">,
|
|
|
|
HelpText<"Lists symbols that should not be exported">, Group<grp_opts>;
|
|
|
|
def unexported_symbol : Separate<["-"], "unexported_symbol">,
|
|
|
|
MetaVarName<"<symbol>">,
|
|
|
|
HelpText<"A symbol which should not be exported">, Group<grp_opts>;
|
|
|
|
def keep_private_externs : Flag<["-"], "keep_private_externs">,
|
|
|
|
HelpText<"Private extern (hidden) symbols should not be transformed "
|
|
|
|
"into local symbols">, Group<grp_opts>;
|
2014-11-08 05:01:21 +08:00
|
|
|
def order_file : Separate<["-"], "order_file">,
|
|
|
|
MetaVarName<"<file-path>">,
|
|
|
|
HelpText<"re-order and move specified symbols to start of their section">,
|
|
|
|
Group<grp_opts>;
|
2015-09-29 04:25:14 +08:00
|
|
|
def flat_namespace : Flag<["-"], "flat_namespace">,
|
|
|
|
HelpText<"Resolves symbols in any (transitively) linked dynamic libraries. "
|
|
|
|
"Source libraries are not recorded: dyld will re-search all "
|
|
|
|
"images at runtime and use the first definition found.">,
|
|
|
|
Group<grp_opts>;
|
|
|
|
def twolevel_namespace : Flag<["-"], "twolevel_namespace">,
|
|
|
|
HelpText<"Resolves symbols in listed libraries only. Source libraries are "
|
|
|
|
"recorded in the symbol table.">,
|
|
|
|
Group<grp_opts>;
|
|
|
|
def undefined : Separate<["-"], "undefined">,
|
|
|
|
MetaVarName<"<undefined>">,
|
|
|
|
HelpText<"Determines how undefined symbols are handled.">,
|
|
|
|
Group<grp_opts>;
|
2016-02-02 07:56:23 +08:00
|
|
|
def no_objc_category_merging : Flag<["-"], "no_objc_category_merging">,
|
|
|
|
HelpText<"Disables the optimisation which merges Objective-C categories "
|
|
|
|
"on a class in to the class itself.">,
|
|
|
|
Group<grp_opts>;
|
2013-07-19 09:02:49 +08:00
|
|
|
|
|
|
|
// main executable options
|
|
|
|
def grp_main : OptionGroup<"opts">, HelpText<"MAIN EXECUTABLE OPTIONS">;
|
2014-08-16 06:42:46 +08:00
|
|
|
def entry : Separate<["-"], "e">,
|
|
|
|
MetaVarName<"<entry-name>">,
|
|
|
|
HelpText<"entry symbol name">,Group<grp_main>;
|
2014-09-09 08:17:52 +08:00
|
|
|
def pie : Flag<["-"], "pie">,
|
|
|
|
HelpText<"Create Position Independent Executable (for ASLR)">,
|
|
|
|
Group<grp_main>;
|
|
|
|
def no_pie : Flag<["-"], "no_pie">,
|
|
|
|
HelpText<"Do not create Position Independent Executable">,
|
|
|
|
Group<grp_main>;
|
2015-05-21 06:10:50 +08:00
|
|
|
def stack_size : Separate<["-"], "stack_size">,
|
|
|
|
HelpText<"Specifies the maximum stack size for the main thread in a program. "
|
|
|
|
"Must be a page-size multiple. (default=8Mb)">,
|
|
|
|
Group<grp_main>;
|
2016-01-23 05:13:24 +08:00
|
|
|
def export_dynamic : Flag<["-"], "export_dynamic">,
|
|
|
|
HelpText<"Preserves all global symbols in main executables during LTO">,
|
|
|
|
Group<grp_main>;
|
2013-04-05 02:59:24 +08:00
|
|
|
|
2013-07-19 09:02:49 +08:00
|
|
|
// dylib executable options
|
|
|
|
def grp_dylib : OptionGroup<"opts">, HelpText<"DYLIB EXECUTABLE OPTIONS">;
|
2013-09-11 07:55:14 +08:00
|
|
|
def install_name : Separate<["-"], "install_name">,
|
2014-08-16 06:42:46 +08:00
|
|
|
MetaVarName<"<path>">,
|
|
|
|
HelpText<"The dylib's install name">, Group<grp_dylib>;
|
2013-09-11 07:55:14 +08:00
|
|
|
def mark_dead_strippable_dylib : Flag<["-"], "mark_dead_strippable_dylib">,
|
2014-08-16 06:42:46 +08:00
|
|
|
HelpText<"Marks the dylib as having no side effects during initialization">,
|
|
|
|
Group<grp_dylib>;
|
2013-09-11 07:55:14 +08:00
|
|
|
def compatibility_version : Separate<["-"], "compatibility_version">,
|
2014-08-16 06:42:46 +08:00
|
|
|
MetaVarName<"<version>">,
|
|
|
|
HelpText<"The dylib's compatibility version">, Group<grp_dylib>;
|
2013-09-11 07:55:14 +08:00
|
|
|
def current_version : Separate<["-"], "current_version">,
|
2014-08-16 06:42:46 +08:00
|
|
|
MetaVarName<"<version>">,
|
|
|
|
HelpText<"The dylib's current version">, Group<grp_dylib>;
|
2013-09-11 07:55:14 +08:00
|
|
|
|
|
|
|
// dylib executable options - compatibility aliases
|
|
|
|
def dylib_install_name : Separate<["-"], "dylib_install_name">,
|
2014-08-16 06:42:46 +08:00
|
|
|
Alias<install_name>;
|
|
|
|
def dylib_compatibility_version : Separate<["-"], "dylib_compatibility_version">,
|
|
|
|
MetaVarName<"<version>">, Alias<compatibility_version>;
|
2013-09-11 07:55:14 +08:00
|
|
|
def dylib_current_version : Separate<["-"], "dylib_current_version">,
|
2014-08-16 06:42:46 +08:00
|
|
|
MetaVarName<"<version>">, Alias<current_version>;
|
2013-09-11 07:55:14 +08:00
|
|
|
|
|
|
|
// bundle executable options
|
|
|
|
def grp_bundle : OptionGroup<"opts">, HelpText<"BUNDLE EXECUTABLE OPTIONS">;
|
|
|
|
def bundle_loader : Separate<["-"], "bundle_loader">,
|
2014-08-16 06:42:46 +08:00
|
|
|
MetaVarName<"<path>">,
|
|
|
|
HelpText<"The executable that will be loading this Mach-O bundle">,
|
|
|
|
Group<grp_bundle>;
|
2013-04-05 02:59:24 +08:00
|
|
|
|
2013-07-19 09:02:49 +08:00
|
|
|
// library options
|
|
|
|
def grp_libs : OptionGroup<"libs">, HelpText<"LIBRARY OPTIONS">;
|
2014-07-10 19:46:08 +08:00
|
|
|
def L : JoinedOrSeparate<["-"], "L">,
|
2014-08-16 06:42:46 +08:00
|
|
|
MetaVarName<"<dir>">,
|
|
|
|
HelpText<"Add directory to library search path">, Group<grp_libs>;
|
2014-08-15 06:20:41 +08:00
|
|
|
def F : JoinedOrSeparate<["-"], "F">,
|
2014-08-16 06:42:46 +08:00
|
|
|
MetaVarName<"<dir>">,
|
|
|
|
HelpText<"Add directory to framework search path">, Group<grp_libs>;
|
2014-07-10 19:46:13 +08:00
|
|
|
def Z : Flag<["-"], "Z">,
|
|
|
|
HelpText<"Do not search standard directories for libraries or frameworks">;
|
2013-07-19 09:02:49 +08:00
|
|
|
def all_load : Flag<["-"], "all_load">,
|
2014-08-16 06:42:46 +08:00
|
|
|
HelpText<"Forces all members of all static libraries to be loaded">,
|
|
|
|
Group<grp_libs>;
|
2014-11-07 03:33:57 +08:00
|
|
|
def force_load : Separate<["-"], "force_load">,
|
|
|
|
MetaVarName<"<library-path>">,
|
|
|
|
HelpText<"Forces all members of specified static libraries to be loaded">,
|
|
|
|
Group<grp_libs>;
|
2014-08-16 06:42:46 +08:00
|
|
|
def syslibroot : Separate<["-"], "syslibroot">, MetaVarName<"<dir>">,
|
|
|
|
HelpText<"Add path to SDK to all absolute library search paths">,
|
|
|
|
Group<grp_libs>;
|
2014-07-10 19:21:06 +08:00
|
|
|
|
|
|
|
// Input options
|
|
|
|
def l : Joined<["-"], "l">,
|
2014-08-16 06:42:46 +08:00
|
|
|
MetaVarName<"<libname>">,
|
|
|
|
HelpText<"Base name of library searched for in -L directories">;
|
2014-10-17 03:31:28 +08:00
|
|
|
def upward_l : Joined<["-"], "upward-l">,
|
|
|
|
MetaVarName<"<libname>">,
|
|
|
|
HelpText<"Base name of upward library searched for in -L directories">;
|
2014-08-15 06:20:41 +08:00
|
|
|
def framework : Separate<["-"], "framework">,
|
2014-08-16 06:42:46 +08:00
|
|
|
MetaVarName<"<name>">,
|
|
|
|
HelpText<"Base name of framework searched for in -F directories">;
|
2014-10-17 03:31:28 +08:00
|
|
|
def upward_framework : Separate<["-"], "upward_framework">,
|
|
|
|
MetaVarName<"<name>">,
|
|
|
|
HelpText<"Base name of upward framework searched for in -F directories">;
|
|
|
|
def upward_library : Separate<["-"], "upward_library">,
|
|
|
|
MetaVarName<"<path>">,
|
|
|
|
HelpText<"path to upward dylib to link with">;
|
2014-08-16 03:53:41 +08:00
|
|
|
def filelist : Separate<["-"], "filelist">,
|
2014-08-16 06:42:46 +08:00
|
|
|
MetaVarName<"<path>">,
|
|
|
|
HelpText<"file containing paths to input files">;
|
2014-08-16 03:53:41 +08:00
|
|
|
|
2013-09-04 08:24:35 +08:00
|
|
|
|
2014-05-15 05:32:21 +08:00
|
|
|
// test case options
|
2014-07-10 19:21:06 +08:00
|
|
|
def print_atoms : Flag<["-"], "print_atoms">,
|
2014-08-16 06:42:46 +08:00
|
|
|
HelpText<"Emit output as yaml atoms">;
|
2014-08-16 03:53:41 +08:00
|
|
|
def test_file_usage : Flag<["-"], "test_file_usage">,
|
2014-08-16 06:42:46 +08:00
|
|
|
HelpText<"Only files specified by -file_exists are considered to exist. "
|
|
|
|
"Print which files would be used">;
|
2014-07-10 19:21:06 +08:00
|
|
|
def path_exists : Separate<["-"], "path_exists">,
|
2014-08-16 06:42:46 +08:00
|
|
|
MetaVarName<"<path>">,
|
|
|
|
HelpText<"Used with -test_file_usage to declare a path">;
|
2014-07-10 19:21:06 +08:00
|
|
|
|
2013-04-05 02:59:24 +08:00
|
|
|
|
2013-07-19 09:02:49 +08:00
|
|
|
// general options
|
2014-08-16 06:42:46 +08:00
|
|
|
def output : Separate<["-"], "o">,
|
|
|
|
MetaVarName<"<path>">,
|
|
|
|
HelpText<"Output file path">;
|
|
|
|
def arch : Separate<["-"], "arch">,
|
|
|
|
MetaVarName<"<arch-name>">,
|
|
|
|
HelpText<"Architecture to link">;
|
2014-07-30 08:58:06 +08:00
|
|
|
def sectalign : MultiArg<["-"], "sectalign", 3>,
|
2014-08-16 06:42:46 +08:00
|
|
|
MetaVarName<"<segname> <sectname> <alignment>">,
|
2015-10-24 16:20:51 +08:00
|
|
|
HelpText<"Alignment for segment/section">;
|
|
|
|
def sectcreate : MultiArg<["-"], "sectcreate", 3>,
|
|
|
|
MetaVarName<"<segname> <sectname> <file>">,
|
|
|
|
HelpText<"Create section <segname>/<sectname> from contents of <file>">;
|
2014-09-10 18:39:57 +08:00
|
|
|
def image_base : Separate<["-"], "image_base">;
|
2014-09-11 15:56:20 +08:00
|
|
|
def seg1addr : Separate<["-"], "seg1addr">, Alias<image_base>;
|
2014-10-01 07:15:39 +08:00
|
|
|
def demangle : Flag<["-"], "demangle">,
|
|
|
|
HelpText<"Demangles symbol names in errors and warnings">;
|
2014-10-04 08:16:13 +08:00
|
|
|
def dependency_info : Separate<["-"], "dependency_info">,
|
|
|
|
MetaVarName<"<file>">,
|
|
|
|
HelpText<"Write binary list of files used during link">;
|
2014-11-06 11:03:42 +08:00
|
|
|
def S : Flag<["-"], "S">,
|
|
|
|
HelpText<"Remove debug information (STABS or DWARF) from the output file">;
|
2014-12-19 05:33:38 +08:00
|
|
|
def rpath : Separate<["-"], "rpath">,
|
|
|
|
MetaVarName<"<path>">,
|
|
|
|
HelpText<"Add path to the runpath search path list for image being created">;
|
2014-09-11 15:56:20 +08:00
|
|
|
|
2014-08-01 02:19:03 +08:00
|
|
|
def t : Flag<["-"], "t">,
|
|
|
|
HelpText<"Print the names of the input files as ld processes them">;
|
2014-08-14 07:55:41 +08:00
|
|
|
def v : Flag<["-"], "v">,
|
|
|
|
HelpText<"Print linker information">;
|
2018-06-12 10:34:04 +08:00
|
|
|
def error_limit : Separate<["-", "--"], "error-limit">,
|
|
|
|
MetaVarName<"<number>">,
|
|
|
|
HelpText<"Maximum number of errors to emit before stopping (0 = no limit)">;
|
|
|
|
|
[Darwin] Do not error on '-lto_library' option
Summary:
Any invocation of `clang -fuse-ld=lld` that results in a link command
on a macOS host currently fails, because the Darwin lld driver does not
recognize the `-lto_library` option that Clang passes it. Fix the error
by having the Darwin driver ignore the option.
The Clang driver's macOS toolchain is written such that it will always
pass the `-lto_library` option to the linker invocation on a macOS host.
And although the DarwinLdDriver is written to ignore any unknown arguments,
because `-lto_library` begins with `-l`, the DarwinLdDriver interprets it
as a library search command, for a library named "to_library". When the
DarwinLdDriver is unable to find a library specified via `-l`, it exits
with a hard error. This causes any invocation of `clang -fuse-ld=lld`
that results in a link command on a macOS host to fail with an error.
To fix the issue, I considered two alternatives:
1. Modify the Clang Darwin toolchain to only pass `-lto_library` if lld
is *not* being used. lld doesn't support LTO on Darwin anyway, so it
can't use the option. However, I opted against this because, if and
when lld *does* support LTO on Darwin, I'll have to make another
commit to Clang in order to get it to pass the option to lld again.
2. Modify the Darwin lld driver to ignore the `-lto_library` option.
Just in case users may take this to mean LTO is supported, I also
added a warning. If and when lld supports LTO on Darwin, the same
commit that adds support for this option can remove the warning.
Option (2) seemed better to me, and is the rationale behind this commit.
Test Plan: check-lld
Reviewers: ruiu, smeenai, pcc
Reviewed By: smeenai
Subscribers: JDevlieghere, pcc, mehdi_amini, inglorion, steven_wu, llvm-commits
Differential Revision: https://reviews.llvm.org/D47994
llvm-svn: 334641
2018-06-14 02:59:14 +08:00
|
|
|
// Ignored options
|
|
|
|
def lto_library : Separate<["-"], "lto_library">,
|
|
|
|
MetaVarName<"<path>">,
|
|
|
|
HelpText<"Ignored for compatibility with other linkers">;
|
2014-08-22 02:57:42 +08:00
|
|
|
|
|
|
|
// Obsolete options
|
|
|
|
def grp_obsolete : OptionGroup<"obsolete">, HelpText<"OBSOLETE OPTIONS">;
|
|
|
|
def single_module : Flag<["-"], "single_module">,
|
|
|
|
HelpText<"Default for dylibs">, Group<grp_obsolete>;
|
|
|
|
def multi_module : Flag<["-"], "multi_module">,
|
|
|
|
HelpText<"Unsupported way to build dylibs">, Group<grp_obsolete>;
|
2016-01-16 01:39:02 +08:00
|
|
|
def objc_gc_compaction : Flag<["-"], "objc_gc_compaction">,
|
|
|
|
HelpText<"Unsupported ObjC GC option">, Group<grp_obsolete>;
|
|
|
|
def objc_gc : Flag<["-"], "objc_gc">,
|
|
|
|
HelpText<"Unsupported ObjC GC option">, Group<grp_obsolete>;
|
|
|
|
def objc_gc_only : Flag<["-"], "objc_gc_only">,
|
|
|
|
HelpText<"Unsupported ObjC GC option">, Group<grp_obsolete>;
|