2015-07-25 05:03:07 +08:00
|
|
|
include "llvm/Option/OptParser.td"
|
|
|
|
|
2016-06-21 07:10:40 +08:00
|
|
|
// For options whose names are multiple letters, either one dash or
|
|
|
|
// two can precede the option name except those that start with 'o'.
|
2016-06-21 16:45:50 +08:00
|
|
|
class F<string name>: Flag<["--", "-"], name>;
|
|
|
|
class J<string name>: Joined<["--", "-"], name>;
|
|
|
|
class S<string name>: Separate<["--", "-"], name>;
|
|
|
|
class JS<string name>: JoinedOrSeparate<["--", "-"], name>;
|
2015-10-14 05:02:34 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">;
|
ELF: Implement --build-id.
This patch implements --build-id. After the linker creates an output file
in the memory buffer, it computes the FNV1 hash of the resulting file
and set the hash to the .note section as a build-id.
GNU ld and gold have the same feature, but their default choice of the
hash function is different. Their default is SHA1.
We made a deliberate choice to not use a secure hash function for the
sake of performance. Computing a secure hash is slow -- for example,
MD5 throughput is usually 400 MB/s or so. SHA1 is slower than that.
As a result, if you pass --build-id to gold, then the linker becomes about
10% slower than that without the option. We observed a similar degradation
in an experimental implementation of build-id for LLD. On the other hand,
we observed only 1-2% performance degradation with the FNV hash.
Since build-id is not for digital certificate or anything, we think that
a very small probability of collision is acceptable.
We considered using other signals such as using input file timestamps as
inputs to a secure hash function. But such signals would have an issue
with build reproducibility (if you build a binary from the same source
tree using the same toolchain, the build id should become the same.)
GNU linkers accepts --build-id=<style> option where style is one of
"MD5", "SHA1", or an arbitrary hex string. That option is out of scope
of this patch.
http://reviews.llvm.org/D18091
llvm-svn: 263292
2016-03-12 04:51:53 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def Bsymbolic_functions: F<"Bsymbolic-functions">,
|
|
|
|
HelpText<"Bind defined function symbols locally">;
|
2016-04-08 06:49:21 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries">;
|
|
|
|
|
|
|
|
def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">;
|
|
|
|
|
|
|
|
def build_id: F<"build-id">, HelpText<"Generate build ID note">;
|
|
|
|
|
|
|
|
def build_id_eq: J<"build-id=">, HelpText<"Generate build ID note">;
|
|
|
|
|
|
|
|
def L: JS<"L">, MetaVarName<"<dir>">,
|
2016-05-27 12:48:26 +08:00
|
|
|
HelpText<"Add a directory to the library search path">;
|
2015-09-12 06:42:45 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def O: J<"O">, HelpText<"Optimize output file size">;
|
|
|
|
|
|
|
|
def allow_multiple_definition: F<"allow-multiple-definition">,
|
|
|
|
HelpText<"Allow multiple definitions">;
|
|
|
|
|
|
|
|
def as_needed: F<"as-needed">,
|
|
|
|
HelpText<"Only set DT_NEEDED for shared libraries if used">;
|
2015-10-24 03:02:19 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def disable_new_dtags: F<"disable-new-dtags">,
|
|
|
|
HelpText<"Disable new dynamic tags">;
|
2015-09-23 07:38:23 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def discard_all: F<"discard-all">, HelpText<"Delete all local symbols">;
|
|
|
|
|
|
|
|
def discard_locals: F<"discard-locals">,
|
|
|
|
HelpText<"Delete temporary local symbols">;
|
|
|
|
|
|
|
|
def discard_none: F<"discard-none">,
|
|
|
|
HelpText<"Keep all symbols in the symbol table">;
|
|
|
|
|
|
|
|
def dynamic_linker: S<"dynamic-linker">,
|
2015-10-01 08:33:02 +08:00
|
|
|
HelpText<"Which dynamic linker to use">;
|
2015-09-26 03:24:57 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def dynamic_list: S<"dynamic-list">,
|
2016-04-14 02:51:11 +08:00
|
|
|
HelpText<"Read a list of dynamic symbols">;
|
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def eh_frame_hdr: F<"eh-frame-hdr">,
|
|
|
|
HelpText<"Request creation of .eh_frame_hdr section and PT_GNU_EH_FRAME segment header">;
|
2016-04-08 03:24:51 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def enable_new_dtags: F<"enable-new-dtags">,
|
|
|
|
HelpText<"Enable new dynamic tags">;
|
|
|
|
|
|
|
|
def end_lib: F<"end-lib">,
|
|
|
|
HelpText<"End a grouping of objects that should be treated as if they were together in an archive">;
|
|
|
|
|
|
|
|
def entry: S<"entry">, MetaVarName<"<entry>">,
|
2015-10-01 08:33:02 +08:00
|
|
|
HelpText<"Name of entry point symbol">;
|
2015-09-24 23:08:23 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def export_dynamic: F<"export-dynamic">,
|
|
|
|
HelpText<"Put symbols in the dynamic symbol table">;
|
2015-09-28 20:52:21 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def export_dynamic_symbol: S<"export-dynamic-symbol">,
|
2016-04-23 02:44:06 +08:00
|
|
|
HelpText<"Put a symbol in the dynamic symbol table">;
|
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def fini: S<"fini">, MetaVarName<"<symbol>">,
|
2015-10-05 18:29:46 +08:00
|
|
|
HelpText<"Specify a finalizer function">;
|
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def hash_style: S<"hash-style">,
|
2015-10-22 16:21:35 +08:00
|
|
|
HelpText<"Specify hash style (sysv, gnu or both)">;
|
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def help: F<"help">, HelpText<"Print option help">;
|
|
|
|
|
|
|
|
def icf: F<"icf=all">, HelpText<"Enable identical code folding">;
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def gc_sections: F<"gc-sections">,
|
|
|
|
HelpText<"Enable garbage collection of unused sections">;
|
|
|
|
|
|
|
|
def init: S<"init">, MetaVarName<"<symbol>">,
|
2015-10-05 18:29:46 +08:00
|
|
|
HelpText<"Specify an initializer function">;
|
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def l: JS<"l">, MetaVarName<"<libName>">,
|
2015-10-01 08:33:02 +08:00
|
|
|
HelpText<"Root name of library to use">;
|
2015-09-29 04:30:11 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def lto_O: J<"lto-O">, MetaVarName<"<opt-level>">,
|
2016-04-01 05:00:27 +08:00
|
|
|
HelpText<"Optimization level for LTO">;
|
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def m: JS<"m">, HelpText<"Set target emulation">;
|
|
|
|
|
|
|
|
def no_as_needed: F<"no-as-needed">,
|
|
|
|
HelpText<"Always DT_NEEDED for shared libraries">;
|
|
|
|
|
|
|
|
def no_demangle: F<"no-demangle">,
|
|
|
|
HelpText<"Do not demangle symbol names">;
|
|
|
|
|
|
|
|
def no_gnu_unique: F<"no-gnu-unique">,
|
|
|
|
HelpText<"Disable STB_GNU_UNIQUE symbol binding">;
|
|
|
|
|
|
|
|
def no_whole_archive: F<"no-whole-archive">,
|
|
|
|
HelpText<"Restores the default behavior of loading archive members">;
|
|
|
|
|
|
|
|
def noinhibit_exec: F<"noinhibit-exec">,
|
|
|
|
HelpText<"Retain the executable output file whenever it is still usable">;
|
2015-10-07 17:13:03 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def no_undefined: F<"no-undefined">,
|
|
|
|
HelpText<"Report unresolved symbols even if the linker is creating a shared library">;
|
2015-10-02 04:14:45 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
|
2015-10-01 08:33:02 +08:00
|
|
|
HelpText<"Path to file to write output">;
|
2015-09-28 20:52:21 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def pie: F<"pie">, HelpText<"Create a position independent executable">;
|
2015-12-10 17:12:18 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def print_gc_sections: F<"print-gc-sections">,
|
|
|
|
HelpText<"List removed unused sections">;
|
|
|
|
|
|
|
|
def reproduce: S<"reproduce">,
|
2016-04-26 08:22:24 +08:00
|
|
|
HelpText<"Dump linker invocation and input files for debugging">;
|
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def rpath: S<"rpath">, HelpText<"Add a DT_RUNPATH to the output">;
|
|
|
|
|
|
|
|
def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">;
|
|
|
|
|
|
|
|
def script: S<"script">, HelpText<"Read linker script">;
|
2015-09-28 20:52:21 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def shared: F<"shared">, HelpText<"Build a shared object">;
|
2015-11-13 02:54:15 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def soname: J<"soname=">, HelpText<"Set DT_SONAME">;
|
2015-10-11 11:53:36 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def start_lib: F<"start-lib">,
|
|
|
|
HelpText<"Start a grouping of objects that should be treated as if they were together in an archive">;
|
2015-09-28 23:01:59 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def strip_all: F<"strip-all">, HelpText<"Strip all symbols">;
|
2015-10-02 03:36:04 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def strip_debug: F<"strip-debug">, HelpText<"Strip debugging information">;
|
2016-04-08 05:04:51 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def sysroot: J<"sysroot=">, HelpText<"Set the system root">;
|
2015-10-01 08:33:02 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def threads: F<"threads">, HelpText<"Enable use of threads">;
|
2016-03-29 16:45:40 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def trace: F<"trace">, HelpText<"Print the names of the input files">;
|
|
|
|
|
2016-06-23 15:00:17 +08:00
|
|
|
def trace_symbol : J<"trace-symbol=">, HelpText<"Trace references to symbols">;
|
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def undefined: J<"undefined=">,
|
2015-10-05 17:43:57 +08:00
|
|
|
HelpText<"Force undefined symbol during linking">;
|
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def verbose: F<"verbose">, HelpText<"Verbose mode">;
|
|
|
|
|
|
|
|
def version: F<"version">, HelpText<"Display the version number">;
|
2016-02-28 11:18:07 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def version_script: S<"version-script">,
|
2016-04-23 04:21:26 +08:00
|
|
|
HelpText<"Read a version script">;
|
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def warn_common: F<"warn-common">,
|
|
|
|
HelpText<"Warn about duplicate common symbols">;
|
|
|
|
|
|
|
|
def whole_archive: F<"whole-archive">,
|
|
|
|
HelpText<"Force load of all members in a static library">;
|
2015-10-02 02:02:21 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def wrap: S<"wrap">, MetaVarName<"<symbol>">,
|
2016-01-08 01:20:07 +08:00
|
|
|
HelpText<"Use wrapper functions for symbol">;
|
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def z: JS<"z">, MetaVarName<"<option>">,
|
2015-10-07 23:00:21 +08:00
|
|
|
HelpText<"Linker option extensions">;
|
|
|
|
|
2015-10-01 08:33:02 +08:00
|
|
|
// Aliases
|
2016-06-21 16:45:50 +08:00
|
|
|
def alias_Bdynamic_call_shared: F<"call_shared">, Alias<Bdynamic>;
|
|
|
|
def alias_Bdynamic_dy: F<"dy">, Alias<Bdynamic>;
|
|
|
|
def alias_Bstatic_dn: F<"dn">, Alias<Bstatic>;
|
|
|
|
def alias_Bstatic_non_shared: F<"non_shared">, Alias<Bstatic>;
|
|
|
|
def alias_Bstatic_static: F<"static">, Alias<Bstatic>;
|
|
|
|
def alias_L__library_path: J<"library-path=">, Alias<L>;
|
|
|
|
def alias_discard_all_x: F<"x">, Alias<discard_all>;
|
|
|
|
def alias_discard_locals_X: F<"X">, Alias<discard_locals>;
|
|
|
|
def alias_dynamic_list: J<"dynamic-list=">, Alias<dynamic_list>;
|
|
|
|
def alias_entry_e: JS<"e">, Alias<entry>;
|
|
|
|
def alias_export_dynamic_E: F<"E">, Alias<export_dynamic>;
|
|
|
|
def alias_export_dynamic_symbol: J<"export-dynamic-symbol=">,
|
|
|
|
Alias<export_dynamic_symbol>;
|
|
|
|
def alias_fini_fini: J<"fini=">, Alias<fini>;
|
|
|
|
def alias_hash_style_hash_style: J<"hash-style=">, Alias<hash_style>;
|
|
|
|
def alias_init_init: J<"init=">, Alias<init>;
|
|
|
|
def alias_l__library: J<"library=">, Alias<l>;
|
|
|
|
def alias_o_output: Joined<["--"], "output=">, Alias<o>;
|
|
|
|
def alias_pie_pic_executable: F<"pic-executable">, Alias<pie>;
|
|
|
|
def alias_relocatable_r: F<"r">, Alias<relocatable>;
|
|
|
|
def alias_rpath_R: J<"R">, Alias<rpath>;
|
|
|
|
def alias_rpath_rpath: J<"rpath=">, Alias<rpath>;
|
|
|
|
def alias_script_T: JS<"T">, Alias<script>;
|
|
|
|
def alias_shared_Bshareable: F<"Bshareable">, Alias<shared>;
|
|
|
|
def alias_soname_h: JS<"h">, Alias<soname>;
|
|
|
|
def alias_soname_soname: S<"soname">, Alias<soname>;
|
|
|
|
def alias_strip_all: F<"s">, Alias<strip_all>;
|
|
|
|
def alias_strip_debug_S: F<"S">, Alias<strip_debug>;
|
|
|
|
def alias_trace: F<"t">, Alias<trace>;
|
2016-06-23 15:00:17 +08:00
|
|
|
def alias_trace_symbol_y : JS<"y">, Alias<trace_symbol>;
|
2016-06-21 16:45:50 +08:00
|
|
|
def alias_undefined_u: JoinedOrSeparate<["-"], "u">, Alias<undefined>;
|
|
|
|
def alias_wrap_wrap: J<"wrap=">, Alias<wrap>;
|
2015-10-01 08:24:54 +08:00
|
|
|
|
2015-11-14 02:56:07 +08:00
|
|
|
// Our symbol resolution algorithm handles symbols in archive files differently
|
2015-11-13 08:26:12 +08:00
|
|
|
// than traditional linkers, so we don't need --start-group and --end-group.
|
2015-11-14 02:56:07 +08:00
|
|
|
// These options are recongized for compatibility but ignored.
|
2016-06-21 16:45:50 +08:00
|
|
|
def end_group: F<"end-group">;
|
|
|
|
def end_group_paren: F<")">;
|
|
|
|
def start_group: F<"start-group">;
|
|
|
|
def start_group_paren: F<"(">;
|
2015-11-13 08:26:12 +08:00
|
|
|
|
2016-03-19 08:40:09 +08:00
|
|
|
// Ignore LTO plugin-related options.
|
|
|
|
// clang -flto passes -plugin and -plugin-opt to the linker. This is required
|
|
|
|
// for ld.gold and ld.bfd to get LTO working. But it's not for lld which doesn't
|
|
|
|
// rely on a plugin. Instead of detecting which linker is used on clang side we
|
|
|
|
// just ignore the option on lld side as it's easier. In fact, the linker could
|
|
|
|
// be called 'ld' and understanding which linker is used would require parsing of
|
|
|
|
// --version output.
|
2016-06-21 16:45:50 +08:00
|
|
|
def plugin: S<"plugin">;
|
|
|
|
def plugin_eq: J<"plugin=">;
|
|
|
|
def plugin_opt: S<"plugin-opt">;
|
|
|
|
def plugin_opt_eq: J<"plugin-opt=">;
|
2016-03-19 08:40:09 +08:00
|
|
|
|
2015-11-13 08:26:12 +08:00
|
|
|
// Options listed below are silently ignored for now for compatibility.
|
2016-06-21 16:45:50 +08:00
|
|
|
def allow_shlib_undefined: F<"allow-shlib-undefined">;
|
|
|
|
def define_common: F<"define-common">;
|
|
|
|
def detect_odr_violations: F<"detect-odr-violations">;
|
|
|
|
def fatal_warnings: F<"fatal-warnings">;
|
|
|
|
def no_add_needed: F<"no-add-needed">;
|
|
|
|
def no_allow_shlib_undefined: F<"no-allow-shlib-undefined">;
|
|
|
|
def no_copy_dt_needed_entries: F<"no-copy-dt-needed-entries">,
|
|
|
|
Alias<no_add_needed>;
|
|
|
|
def no_dynamic_linker: F<"no-dynamic-linker">;
|
|
|
|
def no_fatal_warnings: F<"no-fatal-warnings">;
|
|
|
|
def no_mmap_output_file: F<"no-mmap-output-file">;
|
|
|
|
def no_undefined_version: F<"no-undefined-version">;
|
|
|
|
def no_warn_common: F<"no-warn-common">;
|
|
|
|
def no_warn_mismatch: F<"no-warn-mismatch">;
|
|
|
|
def rpath_link: S<"rpath-link">;
|
|
|
|
def rpath_link_eq: J<"rpath-link=">;
|
2016-06-27 10:43:27 +08:00
|
|
|
def sort_common: F<"sort-common">;
|
2016-06-21 16:45:50 +08:00
|
|
|
def warn_execstack: F<"warn-execstack">;
|
|
|
|
def warn_shared_textrel: F<"warn-shared-textrel">;
|
|
|
|
def G: S<"G">;
|
2015-12-10 22:08:45 +08:00
|
|
|
|
|
|
|
// Aliases for ignored options
|
2016-06-21 16:45:50 +08:00
|
|
|
def alias_define_common_d: F<"d">, Alias<define_common>;
|
|
|
|
def alias_define_common_dc: F<"dc">, Alias<define_common>;
|
|
|
|
def alias_define_common_dp: F<"dp">, Alias<define_common>;
|
|
|
|
def alias_version_script_version_script: J<"version-script=">,
|
|
|
|
Alias<version_script>;
|
2016-03-10 04:01:08 +08:00
|
|
|
|
2016-04-16 06:38:10 +08:00
|
|
|
// LTO-related options.
|
2016-06-21 16:45:50 +08:00
|
|
|
def lto_jobs: J<"lto-jobs=">, HelpText<"Number of threads to run codegen">;
|
|
|
|
def lto_aa_pipeline: J<"lto-aa-pipeline=">,
|
2016-06-03 06:58:11 +08:00
|
|
|
HelpText<"AA pipeline to run during LTO. Used in conjunction with -lto-newpm-passes">;
|
2016-06-21 16:45:50 +08:00
|
|
|
def lto_newpm_passes: J<"lto-newpm-passes=">,
|
2016-05-16 03:29:38 +08:00
|
|
|
HelpText<"Passes to run during LTO">;
|
2016-06-21 16:45:50 +08:00
|
|
|
def disable_verify: F<"disable-verify">;
|
|
|
|
def mllvm: S<"mllvm">;
|
|
|
|
def save_temps: F<"save-temps">;
|