2015-07-25 05:03:07 +08:00
|
|
|
include "llvm/Option/OptParser.td"
|
|
|
|
|
2020-05-05 05:42:36 +08:00
|
|
|
// Convenience classes for long options which only accept two dashes. For lld
|
|
|
|
// specific or newer long options, we prefer two dashes to avoid collision with
|
|
|
|
// short options. For many others, we have to accept both forms to be compatible
|
|
|
|
// with GNU ld.
|
|
|
|
class FF<string name> : Flag<["--"], name>;
|
|
|
|
class JJ<string name>: Joined<["--"], name>;
|
|
|
|
|
|
|
|
multiclass EEq<string name, string help> {
|
|
|
|
def NAME: Separate<["--"], name>;
|
|
|
|
def NAME # _eq: Joined<["--"], name # "=">, Alias<!cast<Separate>(NAME)>,
|
|
|
|
HelpText<help>;
|
|
|
|
}
|
|
|
|
|
2020-05-16 01:48:46 +08:00
|
|
|
multiclass BB<string name, string help1, string help2> {
|
|
|
|
def NAME: Flag<["--"], name>, HelpText<help1>;
|
|
|
|
def no_ # NAME: Flag<["--"], "no-" # name>, HelpText<help2>;
|
|
|
|
}
|
|
|
|
|
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>;
|
2015-10-14 05:02:34 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
multiclass Eq<string name, string help> {
|
2018-02-03 06:45:47 +08:00
|
|
|
def NAME: Separate<["--", "-"], name>;
|
2018-05-31 05:25:53 +08:00
|
|
|
def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>,
|
|
|
|
HelpText<help>;
|
2017-07-22 00:27:26 +08:00
|
|
|
}
|
|
|
|
|
2018-02-03 05:25:51 +08:00
|
|
|
multiclass B<string name, string help1, string help2> {
|
|
|
|
def NAME: Flag<["--", "-"], name>, HelpText<help1>;
|
|
|
|
def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText<help2>;
|
|
|
|
}
|
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm auxiliary: Eq<"auxiliary", "Set DT_AUXILIARY field to the specified name">;
|
2016-09-02 17:13:05 +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
|
|
|
|
2018-05-31 07:32:41 +08:00
|
|
|
def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries (default)">;
|
2016-06-21 16:45:50 +08:00
|
|
|
|
|
|
|
def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">;
|
|
|
|
|
2018-06-02 05:46:10 +08:00
|
|
|
def build_id: F<"build-id">, HelpText<"Alias for --build-id=fast">;
|
2016-06-21 16:45:50 +08:00
|
|
|
|
2018-06-02 05:46:10 +08:00
|
|
|
def build_id_eq: J<"build-id=">, HelpText<"Generate build ID note">,
|
2019-02-20 09:40:35 +08:00
|
|
|
MetaVarName<"[fast,md5,sha1,uuid,0x<hexstring>]">;
|
2016-06-21 16:45:50 +08:00
|
|
|
|
2018-05-31 22:04:21 +08:00
|
|
|
defm check_sections: B<"check-sections",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Check section addresses for overlaps (default)",
|
2018-02-03 06:24:06 +08:00
|
|
|
"Do not check section addresses for overlaps">;
|
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm compress_debug_sections:
|
2018-06-02 05:46:10 +08:00
|
|
|
Eq<"compress-debug-sections", "Compress DWARF debug sections">,
|
|
|
|
MetaVarName<"[none,zlib]">;
|
2017-04-17 16:58:12 +08:00
|
|
|
|
2018-06-02 05:46:10 +08:00
|
|
|
defm defsym: Eq<"defsym", "Define a symbol alias">, MetaVarName<"<symbol>=<value>">;
|
2017-04-26 18:40:02 +08:00
|
|
|
|
2020-05-16 01:48:46 +08:00
|
|
|
defm optimize_bb_jumps: BB<"optimize-bb-jumps",
|
2020-04-07 21:48:18 +08:00
|
|
|
"Remove direct jumps at the end to the next basic block",
|
|
|
|
"Do not remove any direct jumps at the end to the next basic block (default)">;
|
|
|
|
|
2018-10-17 01:13:01 +08:00
|
|
|
defm split_stack_adjust_size
|
|
|
|
: Eq<"split-stack-adjust-size",
|
|
|
|
"Specify adjustment to stack size when a split-stack function calls a "
|
|
|
|
"non-split-stack function">,
|
|
|
|
MetaVarName<"<value>">;
|
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm library_path:
|
|
|
|
Eq<"library-path", "Add a directory to the library search path">, MetaVarName<"<dir>">;
|
2015-09-12 06:42:45 +08:00
|
|
|
|
2017-08-25 02:34:44 +08:00
|
|
|
def O: JoinedOrSeparate<["-"], "O">, HelpText<"Optimize output file size">;
|
2016-06-21 16:45:50 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm Tbss: Eq<"Tbss", "Same as --section-start with .bss as the sectionname">;
|
2016-09-14 21:07:13 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm Tdata: Eq<"Tdata", "Same as --section-start with .data as the sectionname">;
|
2016-09-14 21:07:13 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm Ttext: Eq<"Ttext", "Same as --section-start with .text as the sectionname">;
|
2016-09-14 21:07:13 +08:00
|
|
|
|
2019-11-20 06:16:04 +08:00
|
|
|
def Ttext_segment: Separate<["-", "--"], "Ttext-segment">;
|
|
|
|
|
2018-02-06 08:45:15 +08:00
|
|
|
defm allow_multiple_definition: B<"allow-multiple-definition",
|
|
|
|
"Allow multiple definitions",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Do not allow multiple definitions (default)">;
|
2016-06-21 16:45:50 +08:00
|
|
|
|
[ELF] Support --{,no-}allow-shlib-undefined
Summary:
In ld.bfd/gold, --no-allow-shlib-undefined is the default when linking
an executable. This patch implements a check to error on undefined
symbols in a shared object, if all of its DT_NEEDED entries are seen.
Our approach resembles the one used in gold, achieves a good balance to
be useful but not too smart (ld.bfd traces all DSOs and emulates the
behavior of a dynamic linker to catch more cases).
The error is issued based on the symbol table, different from undefined
reference errors issued for relocations. It is most effective when there
are DSOs that were not linked with -z defs (e.g. when static sanitizers
runtime is used).
gold has a comment that some system libraries on GNU/Linux may have
spurious undefined references and thus system libraries should be
excluded (https://sourceware.org/bugzilla/show_bug.cgi?id=6811). The
story may have changed now but we make --allow-shlib-undefined the
default for now. Its interaction with -shared can be discussed in the
future.
Reviewers: ruiu, grimar, pcc, espindola
Reviewed By: ruiu
Subscribers: joerg, emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D57385
llvm-svn: 352826
2019-02-01 10:25:05 +08:00
|
|
|
defm allow_shlib_undefined: B<"allow-shlib-undefined",
|
2019-02-02 08:34:28 +08:00
|
|
|
"Allow unresolved references in shared libraries (default when linking a shared library)",
|
|
|
|
"Do not allow unresolved references in shared libraries (default when linking an executable)">;
|
[ELF] Support --{,no-}allow-shlib-undefined
Summary:
In ld.bfd/gold, --no-allow-shlib-undefined is the default when linking
an executable. This patch implements a check to error on undefined
symbols in a shared object, if all of its DT_NEEDED entries are seen.
Our approach resembles the one used in gold, achieves a good balance to
be useful but not too smart (ld.bfd traces all DSOs and emulates the
behavior of a dynamic linker to catch more cases).
The error is issued based on the symbol table, different from undefined
reference errors issued for relocations. It is most effective when there
are DSOs that were not linked with -z defs (e.g. when static sanitizers
runtime is used).
gold has a comment that some system libraries on GNU/Linux may have
spurious undefined references and thus system libraries should be
excluded (https://sourceware.org/bugzilla/show_bug.cgi?id=6811). The
story may have changed now but we make --allow-shlib-undefined the
default for now. Its interaction with -shared can be discussed in the
future.
Reviewers: ruiu, grimar, pcc, espindola
Reviewed By: ruiu
Subscribers: joerg, emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D57385
llvm-svn: 352826
2019-02-01 10:25:05 +08:00
|
|
|
|
2020-05-16 01:48:46 +08:00
|
|
|
defm apply_dynamic_relocs: BB<"apply-dynamic-relocs",
|
2018-07-31 01:36:38 +08:00
|
|
|
"Apply link-time values for dynamic relocations",
|
|
|
|
"Do not apply link-time values for dynamic relocations (default)">;
|
2018-02-05 18:15:08 +08:00
|
|
|
|
2020-05-16 01:48:46 +08:00
|
|
|
defm dependent_libraries: BB<"dependent-libraries",
|
[ELF] Implement Dependent Libraries Feature
This patch implements a limited form of autolinking primarily designed to allow
either the --dependent-library compiler option, or "comment lib" pragmas (
https://docs.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp?view=vs-2017) in
C/C++ e.g. #pragma comment(lib, "foo"), to cause an ELF linker to automatically
add the specified library to the link when processing the input file generated
by the compiler.
Currently this extension is unique to LLVM and LLD. However, care has been taken
to design this feature so that it could be supported by other ELF linkers.
The design goals were to provide:
- A simple linking model for developers to reason about.
- The ability to to override autolinking from the linker command line.
- Source code compatibility, where possible, with "comment lib" pragmas in other
environments (MSVC in particular).
Dependent library support is implemented differently for ELF platforms than on
the other platforms. Primarily this difference is that on ELF we pass the
dependent library specifiers directly to the linker without manipulating them.
This is in contrast to other platforms where they are mapped to a specific
linker option by the compiler. This difference is a result of the greater
variety of ELF linkers and the fact that ELF linkers tend to handle libraries in
a more complicated fashion than on other platforms. This forces us to defer
handling the specifiers to the linker.
In order to achieve a level of source code compatibility with other platforms
we have restricted this feature to work with libraries that meet the following
"reasonable" requirements:
1. There are no competing defined symbols in a given set of libraries, or
if they exist, the program owner doesn't care which is linked to their
program.
2. There may be circular dependencies between libraries.
The binary representation is a mergeable string section (SHF_MERGE,
SHF_STRINGS), called .deplibs, with custom type SHT_LLVM_DEPENDENT_LIBRARIES
(0x6fff4c04). The compiler forms this section by concatenating the arguments of
the "comment lib" pragmas and --dependent-library options in the order they are
encountered. Partial (-r, -Ur) links are handled by concatenating .deplibs
sections with the normal mergeable string section rules. As an example, #pragma
comment(lib, "foo") would result in:
.section ".deplibs","MS",@llvm_dependent_libraries,1
.asciz "foo"
For LTO, equivalent information to the contents of a the .deplibs section can be
retrieved by the LLD for bitcode input files.
LLD processes the dependent library specifiers in the following way:
1. Dependent libraries which are found from the specifiers in .deplibs sections
of relocatable object files are added when the linker decides to include that
file (which could itself be in a library) in the link. Dependent libraries
behave as if they were appended to the command line after all other options. As
a consequence the set of dependent libraries are searched last to resolve
symbols.
2. It is an error if a file cannot be found for a given specifier.
3. Any command line options in effect at the end of the command line parsing apply
to the dependent libraries, e.g. --whole-archive.
4. The linker tries to add a library or relocatable object file from each of the
strings in a .deplibs section by; first, handling the string as if it was
specified on the command line; second, by looking for the string in each of the
library search paths in turn; third, by looking for a lib<string>.a or
lib<string>.so (depending on the current mode of the linker) in each of the
library search paths.
5. A new command line option --no-dependent-libraries tells LLD to ignore the
dependent libraries.
Rationale for the above points:
1. Adding the dependent libraries last makes the process simple to understand
from a developers perspective. All linkers are able to implement this scheme.
2. Error-ing for libraries that are not found seems like better behavior than
failing the link during symbol resolution.
3. It seems useful for the user to be able to apply command line options which
will affect all of the dependent libraries. There is a potential problem of
surprise for developers, who might not realize that these options would apply
to these "invisible" input files; however, despite the potential for surprise,
this is easy for developers to reason about and gives developers the control
that they may require.
4. This algorithm takes into account all of the different ways that ELF linkers
find input files. The different search methods are tried by the linker in most
obvious to least obvious order.
5. I considered adding finer grained control over which dependent libraries were
ignored (e.g. MSVC has /nodefaultlib:<library>); however, I concluded that this
is not necessary: if finer control is required developers can fall back to using
the command line directly.
RFC thread: http://lists.llvm.org/pipermail/llvm-dev/2019-March/131004.html.
Differential Revision: https://reviews.llvm.org/D60274
llvm-svn: 360984
2019-05-17 11:44:15 +08:00
|
|
|
"Process dependent library specifiers from input files (default)",
|
|
|
|
"Ignore dependent library specifiers from input files">;
|
|
|
|
|
2018-02-03 05:25:51 +08:00
|
|
|
defm as_needed: B<"as-needed",
|
|
|
|
"Only set DT_NEEDED for shared libraries if used",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Always set DT_NEEDED for shared libraries (default)">;
|
2015-10-24 03:02:19 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm call_graph_ordering_file:
|
|
|
|
Eq<"call-graph-ordering-file", "Layout sections to optimize the given callgraph">;
|
2018-04-18 07:30:05 +08:00
|
|
|
|
2020-05-16 01:48:46 +08:00
|
|
|
defm call_graph_profile_sort: BB<"call-graph-profile-sort",
|
2018-10-26 07:15:23 +08:00
|
|
|
"Reorder sections with call graph profile (default)",
|
|
|
|
"Do not reorder sections with call graph profile">;
|
|
|
|
|
2017-07-21 02:17:55 +08:00
|
|
|
// -chroot doesn't have a help text because it is an internal option.
|
2018-05-31 05:25:53 +08:00
|
|
|
def chroot: Separate<["--", "-"], "chroot">;
|
2017-07-21 02:17:55 +08:00
|
|
|
|
2016-12-22 16:20:28 +08:00
|
|
|
def color_diagnostics: F<"color-diagnostics">,
|
2018-06-02 05:46:10 +08:00
|
|
|
HelpText<"Alias for --color-diagnostics=always">;
|
2016-12-22 16:20:28 +08:00
|
|
|
|
|
|
|
def color_diagnostics_eq: J<"color-diagnostics=">,
|
2018-06-02 05:46:10 +08:00
|
|
|
HelpText<"Use colors in diagnostics">,
|
|
|
|
MetaVarName<"[auto,always,never]">;
|
2016-11-26 04:27:32 +08:00
|
|
|
|
2018-03-15 04:29:45 +08:00
|
|
|
defm cref: B<"cref",
|
|
|
|
"Output cross reference table",
|
|
|
|
"Do not output cross reference table">;
|
|
|
|
|
2018-02-03 05:25:51 +08:00
|
|
|
defm define_common: B<"define-common",
|
|
|
|
"Assign space to common symbols",
|
|
|
|
"Do not assign space to common symbols">;
|
2017-01-24 11:41:20 +08:00
|
|
|
|
2018-02-03 05:25:51 +08:00
|
|
|
defm demangle: B<"demangle",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Demangle symbol names (default)",
|
2018-02-03 05:25:51 +08:00
|
|
|
"Do not demangle symbol names">;
|
2017-01-15 11:45:46 +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">,
|
2018-05-31 21:00:38 +08:00
|
|
|
HelpText<"Keep all symbols in the symbol table">;
|
2016-06-21 16:45:50 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm dynamic_linker: Eq<"dynamic-linker", "Which dynamic linker to use">;
|
2015-09-26 03:24:57 +08:00
|
|
|
|
2020-06-02 02:27:53 +08:00
|
|
|
defm dynamic_list : Eq<"dynamic-list",
|
|
|
|
"Read a list of dynamic symbols. (executable) Put matched non-local defined"
|
|
|
|
"symbols to the dynamic symbol table. (shared object) References to matched"
|
|
|
|
"non-local STV_DEFAULT symbols shouldn't be bound to definitions within the "
|
|
|
|
"shared object. Implies -Bsymbolic but does not set DF_SYMBOLIC">,
|
|
|
|
MetaVarName<"<file>">;
|
2016-04-14 02:51:11 +08:00
|
|
|
|
2018-02-03 05:25:51 +08:00
|
|
|
defm eh_frame_hdr: B<"eh-frame-hdr",
|
|
|
|
"Request creation of .eh_frame_hdr section and PT_GNU_EH_FRAME segment header",
|
|
|
|
"Do not create .eh_frame_hdr section">;
|
2016-04-08 03:24:51 +08:00
|
|
|
|
2017-02-09 00:18:10 +08:00
|
|
|
def emit_relocs: F<"emit-relocs">, HelpText<"Generate relocations in output">;
|
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def enable_new_dtags: F<"enable-new-dtags">,
|
2018-05-31 07:32:41 +08:00
|
|
|
HelpText<"Enable new dynamic tags (default)">;
|
2016-06-21 16:45:50 +08:00
|
|
|
|
Add --warn-backrefs to maintain compatibility with other linkers
I'm proposing a new command line flag, --warn-backrefs in this patch.
The flag and the feature proposed below don't exist in GNU linkers
nor the current lld.
--warn-backrefs is an option to detect reverse or cyclic dependencies
between static archives, and it can be used to keep your program
compatible with GNU linkers after you switch to lld. I'll explain the
feature and why you may find it useful below.
lld's symbol resolution semantics is more relaxed than traditional
Unix linkers. Therefore,
ld.lld foo.a bar.o
succeeds even if bar.o contains an undefined symbol that have to be
resolved by some object file in foo.a. Traditional Unix linkers
don't allow this kind of backward reference, as they visit each
file only once from left to right in the command line while
resolving all undefined symbol at the moment of visiting.
In the above case, since there's no undefined symbol when a linker
visits foo.a, no files are pulled out from foo.a, and because the
linker forgets about foo.a after visiting, it can't resolve
undefined symbols that could have been resolved otherwise.
That lld accepts more relaxed form means (besides it makes more
sense) that you can accidentally write a command line or a build
file that works only with lld, even if you have a plan to
distribute it to wider users who may be using GNU linkers. With
--check-library-dependency, you can detect a library order that
doesn't work with other Unix linkers.
The option is also useful to detect cyclic dependencies between
static archives. Again, lld accepts
ld.lld foo.a bar.a
even if foo.a and bar.a depend on each other. With --warn-backrefs
it is handled as an error.
Here is how the option works. We assign a group ID to each file. A
file with a smaller group ID can pull out object files from an
archive file with an equal or greater group ID. Otherwise, it is a
reverse dependency and an error.
A file outside --{start,end}-group gets a fresh ID when
instantiated. All files within the same --{start,end}-group get the
same group ID. E.g.
ld.lld A B --start-group C D --end-group E
A and B form group 0, C, D and their member object files form group
1, and E forms group 2. I think that you can see how this group
assignment rule simulates the traditional linker's semantics.
Differential Revision: https://reviews.llvm.org/D45195
llvm-svn: 329636
2018-04-10 07:05:48 +08:00
|
|
|
def end_group: F<"end-group">,
|
|
|
|
HelpText<"Ignored for compatibility with GNU unless you pass --warn-backrefs">;
|
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def end_lib: F<"end-lib">,
|
|
|
|
HelpText<"End a grouping of objects that should be treated as if they were together in an archive">;
|
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm entry: Eq<"entry", "Name of entry point symbol">,
|
2017-07-22 00:27:26 +08:00
|
|
|
MetaVarName<"<entry>">;
|
2015-09-24 23:08:23 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm error_limit:
|
|
|
|
Eq<"error-limit", "Maximum number of errors to emit before stopping (0 = no limit)">;
|
2016-11-24 02:15:37 +08:00
|
|
|
|
2017-03-24 02:16:42 +08:00
|
|
|
def error_unresolved_symbols: F<"error-unresolved-symbols">,
|
2017-01-26 10:19:20 +08:00
|
|
|
HelpText<"Report unresolved symbols as errors">;
|
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm exclude_libs: Eq<"exclude-libs", "Exclude static libraries from automatic export">;
|
2017-06-21 23:36:24 +08:00
|
|
|
|
2020-05-16 01:48:46 +08:00
|
|
|
defm execute_only: BB<"execute-only",
|
2018-09-26 05:39:08 +08:00
|
|
|
"Mark executable sections unreadable",
|
[AArch64] Support execute-only LOAD segments.
Summary:
This adds an LLD flag to mark executable LOAD segments execute-only for AArch64 targets.
In AArch64 the expectation is that code is execute-only compatible, so this just adds a linker option to enforce this.
Patch by: ivanlozano (Ivan Lozano)
Reviewers: srhines, echristo, peter.smith, eugenis, javed.absar, espindola, ruiu
Reviewed By: ruiu
Subscribers: dokyungs, emaste, arichardson, kristof.beyls, llvm-commits
Differential Revision: https://reviews.llvm.org/D49456
llvm-svn: 338271
2018-07-31 01:02:46 +08:00
|
|
|
"Mark executable sections readable (default)">;
|
|
|
|
|
2018-02-03 05:25:51 +08:00
|
|
|
defm export_dynamic: B<"export-dynamic",
|
|
|
|
"Put symbols in the dynamic symbol table",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Do not put symbols in the dynamic symbol table (default)">;
|
2015-09-28 20:52:21 +08:00
|
|
|
|
2020-06-02 02:27:53 +08:00
|
|
|
defm export_dynamic_symbol : EEq<"export-dynamic-symbol",
|
|
|
|
"(executable) Put matched symbols in the dynamic symbol table. "
|
|
|
|
"(shared object) References to matched non-local STV_DEFAULT symbols "
|
|
|
|
"shouldn't be bound to definitions within the shared object. "
|
|
|
|
"Does not imply -Bsymbolic.">,
|
|
|
|
MetaVarName<"glob">;
|
2016-04-23 02:44:06 +08:00
|
|
|
|
2018-02-03 05:25:51 +08:00
|
|
|
defm fatal_warnings: B<"fatal-warnings",
|
|
|
|
"Treat warnings as errors",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Do not treat warnings as errors (default)">;
|
2016-07-04 21:43:12 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm filter: Eq<"filter", "Set DT_FILTER field to the specified name">;
|
2017-07-17 17:43:18 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm fini: Eq<"fini", "Specify a finalizer function">, MetaVarName<"<symbol>">;
|
2015-10-05 18:29:46 +08:00
|
|
|
|
2017-12-05 23:59:05 +08:00
|
|
|
def fix_cortex_a53_843419: F<"fix-cortex-a53-843419">,
|
|
|
|
HelpText<"Apply fixes for AArch64 Cortex-A53 erratum 843419">;
|
|
|
|
|
2019-09-16 17:38:38 +08:00
|
|
|
def fix_cortex_a8: F<"fix-cortex-a8">,
|
|
|
|
HelpText<"Apply fixes for ARM Cortex-A8 erratum 657417">;
|
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm format: Eq<"format", "Change the input format of the inputs following this option">,
|
2018-06-02 05:46:10 +08:00
|
|
|
MetaVarName<"[default,elf,binary]">;
|
2016-09-10 06:08:04 +08:00
|
|
|
|
2018-02-03 05:25:51 +08:00
|
|
|
defm gc_sections: B<"gc-sections",
|
|
|
|
"Enable garbage collection of unused sections",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Disable garbage collection of unused sections (default)">;
|
2016-09-07 19:43:18 +08:00
|
|
|
|
2020-05-16 01:48:46 +08:00
|
|
|
defm gdb_index: BB<"gdb-index",
|
2018-02-03 05:25:51 +08:00
|
|
|
"Generate .gdb_index section",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Do not generate .gdb_index section (default)">;
|
2016-10-20 17:19:48 +08:00
|
|
|
|
2020-05-16 01:48:46 +08:00
|
|
|
defm gnu_unique: BB<"gnu-unique",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Enable STB_GNU_UNIQUE symbol binding (default)",
|
2018-02-03 05:44:06 +08:00
|
|
|
"Disable STB_GNU_UNIQUE symbol binding">;
|
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm hash_style: Eq<"hash-style", "Specify hash style (sysv, gnu or both)">;
|
2015-10-22 16:21:35 +08:00
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def help: F<"help">, HelpText<"Print option help">;
|
|
|
|
|
2017-08-10 05:32:38 +08:00
|
|
|
def icf_all: F<"icf=all">, HelpText<"Enable identical code folding">;
|
|
|
|
|
2018-07-19 06:49:31 +08:00
|
|
|
def icf_safe: F<"icf=safe">, HelpText<"Enable safe identical code folding">;
|
|
|
|
|
2018-05-31 07:32:41 +08:00
|
|
|
def icf_none: F<"icf=none">, HelpText<"Disable identical code folding (default)">;
|
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
|
|
|
|
2018-01-10 09:37:36 +08:00
|
|
|
def ignore_function_address_equality: F<"ignore-function-address-equality">,
|
|
|
|
HelpText<"lld can break the address equality of functions">;
|
|
|
|
|
|
|
|
def ignore_data_address_equality: F<"ignore-data-address-equality">,
|
|
|
|
HelpText<"lld can break the address equality of data">;
|
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm image_base: Eq<"image-base", "Set the base address">;
|
2016-07-13 03:37:53 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm init: Eq<"init", "Specify an initializer function">,
|
2017-07-22 00:27:26 +08:00
|
|
|
MetaVarName<"<symbol>">;
|
2015-10-05 18:29:46 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm just_symbols: Eq<"just-symbols", "Just link symbols">;
|
2018-03-07 05:25:37 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm keep_unique: Eq<"keep-unique", "Do not fold this symbol during ICF">;
|
2018-05-15 16:57:21 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm library: Eq<"library", "Root name of library to use">,
|
2017-07-22 00:27:26 +08:00
|
|
|
MetaVarName<"<libName>">;
|
2015-09-29 04:30:11 +08:00
|
|
|
|
2016-06-30 16:43:23 +08:00
|
|
|
def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
|
2016-06-21 16:45:50 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm Map: Eq<"Map", "Print a link map to the specified file">;
|
2017-01-14 05:05:46 +08:00
|
|
|
|
2018-02-03 05:25:51 +08:00
|
|
|
defm merge_exidx_entries: B<"merge-exidx-entries",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Enable merging .ARM.exidx entries (default)",
|
2018-02-03 05:25:51 +08:00
|
|
|
"Disable merging .ARM.exidx entries">;
|
2017-12-15 19:09:41 +08:00
|
|
|
|
2020-05-16 01:48:46 +08:00
|
|
|
defm mmap_output_file: BB<"mmap-output-file",
|
[LLD][ELF] Support --[no-]mmap-output-file with F_no_mmap
Summary:
Add a flag `F_no_mmap` to `FileOutputBuffer` to support
`--[no-]mmap-output-file` in ELF LLD. LLD currently explicitly ignores
this flag for compatibility with GNU ld and gold.
We need this flag to speed up link time for large binaries in certain
scenarios. When we link some of our larger binaries we find that LLD
takes 50+ GB of memory, which causes memory pressure. The memory
pressure causes the VM to flush dirty pages of the output file to disk.
This is normally okay, since we should be flushing cold pages. However,
when using BtrFS with compression we need to write 128KB at a time when
we flush a page. If any page in that 128KB block is written again, then
it must be flushed a second time, and so on. Since LLD doesn't write
sequentially this causes write amplification. The same 128KB block will
end up being flushed multiple times, causing the linker to many times
more IO than necessary. We've observed 3-5x faster builds with
-no-mmap-output-file when we hit this scenario.
The bad scenario only applies to compressed filesystems, which group
together multiple pages into a single compressed block. I've tested
BtrFS, but the problem will be present for any compressed filesystem
on Linux, since it is caused by the VM.
Silently ignoring --no-mmap-output-file caused a silent regression when
we switched from gold to lld. We pass --no-mmap-output-file to fix this
edge case, but since lld silently ignored the flag we didn't realize it
wasn't being respected.
Benchmark building a 9 GB binary that exposes this edge case. I linked 3
times with --mmap-output-file and 3 times with --no-mmap-output-file and
took the average. The machine has 24 cores @ 2.4 GHz, 112 GB of RAM,
BtrFS mounted with -compress-force=zstd, and an 80% full disk.
| Mode | Time |
|---------|-------|
| mmap | 894 s |
| no mmap | 126 s |
When compression is disabled, BtrFS performs just as well with and
without mmap on this benchmark.
I was unable to reproduce the regression with any binaries in
lld-speed-test.
Reviewed By: ruiu, MaskRay
Differential Revision: https://reviews.llvm.org/D69294
2019-10-30 06:46:22 +08:00
|
|
|
"Mmap the output file for writing (default)",
|
|
|
|
"Do not mmap the output file for writing">;
|
|
|
|
|
2019-05-14 00:01:26 +08:00
|
|
|
def nmagic: F<"nmagic">, MetaVarName<"<magic>">,
|
|
|
|
HelpText<"Do not page align sections, link against static libraries.">;
|
|
|
|
|
2016-09-03 03:20:33 +08:00
|
|
|
def nostdlib: F<"nostdlib">,
|
|
|
|
HelpText<"Only search directories specified on the command line">;
|
|
|
|
|
2016-11-26 04:27:32 +08:00
|
|
|
def no_color_diagnostics: F<"no-color-diagnostics">,
|
|
|
|
HelpText<"Do not use colors in diagnostics">;
|
|
|
|
|
2017-02-24 16:26:18 +08:00
|
|
|
def no_dynamic_linker: F<"no-dynamic-linker">,
|
|
|
|
HelpText<"Inhibit output of .interp section">;
|
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
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
|
|
|
|
2019-05-14 00:01:26 +08:00
|
|
|
def no_nmagic: F<"no-nmagic">, MetaVarName<"<magic>">,
|
|
|
|
HelpText<"Page align sections (default)">;
|
|
|
|
|
2018-02-06 03:14:03 +08:00
|
|
|
def no_omagic: F<"no-omagic">, MetaVarName<"<magic>">,
|
2019-05-14 00:01:26 +08:00
|
|
|
HelpText<"Do not set the text data sections to be writable, page align sections (default)">;
|
2017-11-01 10:04:43 +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-08-25 17:05:47 +08:00
|
|
|
def oformat: Separate<["--"], "oformat">, MetaVarName<"<format>">,
|
|
|
|
HelpText<"Specify the binary format for the output object file">;
|
2016-08-25 18:39:04 +08:00
|
|
|
|
2020-05-05 05:42:36 +08:00
|
|
|
def omagic: FF<"omagic">, MetaVarName<"<magic>">,
|
2019-05-14 00:01:26 +08:00
|
|
|
HelpText<"Set the text and data sections to be readable and writable, do not page align sections, link against static libraries">;
|
2016-11-29 17:43:51 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm orphan_handling:
|
|
|
|
Eq<"orphan-handling", "Control how orphan sections are handled when linker script used">;
|
2017-10-25 23:20:30 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm pack_dyn_relocs:
|
2018-06-02 05:46:10 +08:00
|
|
|
Eq<"pack-dyn-relocs", "Pack dynamic relocations in the given format">,
|
2018-07-10 04:08:55 +08:00
|
|
|
MetaVarName<"[none,android,relr,android+relr]">;
|
|
|
|
|
2020-05-16 01:48:46 +08:00
|
|
|
defm use_android_relr_tags: BB<"use-android-relr-tags",
|
2018-07-19 01:19:17 +08:00
|
|
|
"Use SHT_ANDROID_RELR / DT_ANDROID_RELR* tags instead of SHT_RELR / DT_RELR*",
|
|
|
|
"Use SHT_RELR / DT_RELR* tags (default)">;
|
2017-10-28 01:49:40 +08:00
|
|
|
|
2019-01-16 20:09:13 +08:00
|
|
|
def pic_veneer: F<"pic-veneer">,
|
|
|
|
HelpText<"Always generate position independent thunks (veneers)">;
|
|
|
|
|
2018-02-03 05:25:51 +08:00
|
|
|
defm pie: B<"pie",
|
|
|
|
"Create a position independent executable",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Do not create a position independent executable (default)">;
|
2015-12-10 17:12:18 +08:00
|
|
|
|
2018-02-03 05:25:51 +08:00
|
|
|
defm print_gc_sections: B<"print-gc-sections",
|
|
|
|
"List removed unused sections",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Do not list removed unused sections (default)">;
|
2016-06-21 16:45:50 +08:00
|
|
|
|
2018-02-03 05:25:51 +08:00
|
|
|
defm print_icf_sections: B<"print-icf-sections",
|
|
|
|
"List identical folded sections",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Do not list identical folded sections (default)">;
|
2018-02-02 00:00:46 +08:00
|
|
|
|
2020-04-28 10:30:09 +08:00
|
|
|
def print_archive_stats: J<"print-archive-stats=">,
|
|
|
|
HelpText<"Write archive usage statistics to the specified file. "
|
|
|
|
"Print the numbers of members and fetched members for each archive">;
|
|
|
|
|
2019-03-28 07:52:22 +08:00
|
|
|
defm print_symbol_order: Eq<"print-symbol-order",
|
2019-10-29 09:41:38 +08:00
|
|
|
"Print a symbol order specified by --call-graph-ordering-file into the specified file">;
|
2019-03-28 07:52:22 +08:00
|
|
|
|
2018-05-31 21:00:25 +08:00
|
|
|
def pop_state: F<"pop-state">,
|
|
|
|
HelpText<"Undo the effect of -push-state">;
|
|
|
|
|
|
|
|
def push_state: F<"push-state">,
|
|
|
|
HelpText<"Save the current state of -as-needed, -static and -whole-archive">;
|
|
|
|
|
2017-01-15 10:52:34 +08:00
|
|
|
def print_map: F<"print-map">,
|
|
|
|
HelpText<"Print a link map to the standard output">;
|
|
|
|
|
2019-08-23 22:41:25 +08:00
|
|
|
defm reproduce: Eq<"reproduce", "Write a tar file containing input files and command line options to reproduce link">;
|
2016-04-26 08:22:24 +08:00
|
|
|
|
2020-05-16 01:48:46 +08:00
|
|
|
defm rosegment: BB<"rosegment",
|
2020-04-30 08:31:35 +08:00
|
|
|
"Put read-only non-executable sections in their own segment (default)",
|
|
|
|
"Do not put read-only non-executable sections in their own segment">;
|
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm rpath: Eq<"rpath", "Add a DT_RUNPATH to the output">;
|
2016-06-21 16:45:50 +08:00
|
|
|
|
|
|
|
def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">;
|
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm retain_symbols_file:
|
|
|
|
Eq<"retain-symbols-file", "Retain only the symbols listed in the file">,
|
2017-07-22 00:27:26 +08:00
|
|
|
MetaVarName<"<file>">;
|
2016-12-20 02:00:52 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm script: Eq<"script", "Read linker script">;
|
2015-09-28 20:52:21 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm section_start: Eq<"section-start", "Set address of section">,
|
|
|
|
MetaVarName<"<address>">;
|
2016-09-14 21:07:13 +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
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm soname: Eq<"soname", "Set DT_SONAME">;
|
2015-10-11 11:53:36 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm sort_section:
|
|
|
|
Eq<"sort-section", "Specifies sections sorting rule when linkerscript is used">;
|
2016-09-17 04:21:55 +08:00
|
|
|
|
Add --warn-backrefs to maintain compatibility with other linkers
I'm proposing a new command line flag, --warn-backrefs in this patch.
The flag and the feature proposed below don't exist in GNU linkers
nor the current lld.
--warn-backrefs is an option to detect reverse or cyclic dependencies
between static archives, and it can be used to keep your program
compatible with GNU linkers after you switch to lld. I'll explain the
feature and why you may find it useful below.
lld's symbol resolution semantics is more relaxed than traditional
Unix linkers. Therefore,
ld.lld foo.a bar.o
succeeds even if bar.o contains an undefined symbol that have to be
resolved by some object file in foo.a. Traditional Unix linkers
don't allow this kind of backward reference, as they visit each
file only once from left to right in the command line while
resolving all undefined symbol at the moment of visiting.
In the above case, since there's no undefined symbol when a linker
visits foo.a, no files are pulled out from foo.a, and because the
linker forgets about foo.a after visiting, it can't resolve
undefined symbols that could have been resolved otherwise.
That lld accepts more relaxed form means (besides it makes more
sense) that you can accidentally write a command line or a build
file that works only with lld, even if you have a plan to
distribute it to wider users who may be using GNU linkers. With
--check-library-dependency, you can detect a library order that
doesn't work with other Unix linkers.
The option is also useful to detect cyclic dependencies between
static archives. Again, lld accepts
ld.lld foo.a bar.a
even if foo.a and bar.a depend on each other. With --warn-backrefs
it is handled as an error.
Here is how the option works. We assign a group ID to each file. A
file with a smaller group ID can pull out object files from an
archive file with an equal or greater group ID. Otherwise, it is a
reverse dependency and an error.
A file outside --{start,end}-group gets a fresh ID when
instantiated. All files within the same --{start,end}-group get the
same group ID. E.g.
ld.lld A B --start-group C D --end-group E
A and B form group 0, C, D and their member object files form group
1, and E forms group 2. I think that you can see how this group
assignment rule simulates the traditional linker's semantics.
Differential Revision: https://reviews.llvm.org/D45195
llvm-svn: 329636
2018-04-10 07:05:48 +08:00
|
|
|
def start_group: F<"start-group">,
|
|
|
|
HelpText<"Ignored for compatibility with GNU unless you pass --warn-backrefs">;
|
|
|
|
|
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
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm symbol_ordering_file:
|
|
|
|
Eq<"symbol-ordering-file", "Layout sections to place symbols in the order specified by symbol ordering file">;
|
2016-11-10 17:05:20 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm sysroot: Eq<"sysroot", "Set the system root">;
|
2015-10-01 08:33:02 +08:00
|
|
|
|
2016-08-02 03:28:13 +08:00
|
|
|
def target1_rel: F<"target1-rel">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_REL32">;
|
|
|
|
|
2018-05-31 07:32:41 +08:00
|
|
|
def target1_abs: F<"target1-abs">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_ABS32 (default)">;
|
2016-08-02 03:28:13 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm target2:
|
|
|
|
Eq<"target2", "Interpret R_ARM_TARGET2 as <type>, where <type> is one of rel, abs, or got-rel">,
|
2017-07-22 00:27:26 +08:00
|
|
|
MetaVarName<"<type>">;
|
2016-10-18 02:12:24 +08:00
|
|
|
|
[lld][COFF][ELF][WebAssembly] Replace --[no-]threads /threads[:no] with --threads={1,2,...} /threads:{1,2,...}
--no-threads is a name copied from gold.
gold has --no-thread, --thread-count and several other --thread-count-*.
There are needs to customize the number of threads (running several lld
processes concurrently or customizing the number of LTO threads).
Having a single --threads=N is a straightforward replacement of gold's
--no-threads + --thread-count.
--no-threads is used rarely. So just delete --no-threads instead of
keeping it for compatibility for a while.
If --threads= is specified (ELF,wasm; COFF /threads: is similar),
--thinlto-jobs= defaults to --threads=,
otherwise all available hardware threads are used.
There is currently no way to override a --threads={1,2,...}. It is still
a debate whether we should use --threads=all.
Reviewed By: rnk, aganea
Differential Revision: https://reviews.llvm.org/D76885
2020-03-18 03:40:19 +08:00
|
|
|
defm threads
|
|
|
|
: Eq<"threads",
|
|
|
|
"Number of threads. '1' disables multi-threading. By default all "
|
|
|
|
"available hardware threads are used">;
|
2016-03-29 16:45:40 +08:00
|
|
|
|
2020-01-29 00:05:13 +08:00
|
|
|
def time_trace: F<"time-trace">, HelpText<"Record time trace">;
|
|
|
|
def time_trace_file_eq: J<"time-trace-file=">, HelpText<"Specify time trace output file">;
|
|
|
|
|
|
|
|
defm time_trace_granularity: Eq<"time-trace-granularity",
|
|
|
|
"Minimum time granularity (in microseconds) traced by time profiler">;
|
|
|
|
|
2018-09-20 08:26:44 +08:00
|
|
|
defm toc_optimize : B<"toc-optimize",
|
|
|
|
"(PowerPC64) Enable TOC related optimizations (default)",
|
|
|
|
"(PowerPC64) Disable TOC related optimizations">;
|
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def trace: F<"trace">, HelpText<"Print the names of the input files">;
|
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm trace_symbol: Eq<"trace-symbol", "Trace references to symbols">;
|
2016-06-23 15:00:17 +08:00
|
|
|
|
2018-06-02 05:46:10 +08:00
|
|
|
defm undefined: Eq<"undefined", "Force undefined symbol during linking">,
|
|
|
|
MetaVarName<"<symbol>">;
|
2015-10-05 17:43:57 +08:00
|
|
|
|
2019-06-14 22:00:59 +08:00
|
|
|
defm undefined_glob: Eq<"undefined-glob", "Force undefined symbol during linking">,
|
|
|
|
MetaVarName<"<pattern>">;
|
|
|
|
|
[LLD] Add support for --unique option
Summary:
Places orphan sections into a unique output section. This prevents the merging of orphan sections of the same name.
Matches behaviour of GNU ld --unique. --unique=pattern is not implemented.
Motivated user case shown in the test has 2 local symbols as they would appear if C++ source has been compiled with -ffunction-sections. The merging of these sections in the case of a partial link (-r) may limit the effectiveness of -gc-sections of a subsequent link.
Reviewers: espindola, jhenderson, bd1976llvm, edd, andrewng, JonChesterfield, MaskRay, grimar, ruiu, psmith
Reviewed By: MaskRay, grimar
Subscribers: emaste, arichardson, MaskRay, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D75536
2020-03-09 23:43:20 +08:00
|
|
|
def unique: F<"unique">, HelpText<"Creates a separate output section for every orphan input section">;
|
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm unresolved_symbols:
|
|
|
|
Eq<"unresolved-symbols", "Determine how to handle unresolved symbols">;
|
2018-02-03 05:44:06 +08:00
|
|
|
|
|
|
|
defm undefined_version: B<"undefined-version",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Allow unused version in version script (default)",
|
2018-02-03 05:44:06 +08:00
|
|
|
"Report version scripts that refer undefined symbols">;
|
2016-06-29 20:35:04 +08:00
|
|
|
|
2018-06-02 05:46:10 +08:00
|
|
|
defm rsp_quoting: Eq<"rsp-quoting", "Quoting style for response files">,
|
|
|
|
MetaVarName<"[posix,windows]">;
|
2016-07-07 05:24:34 +08:00
|
|
|
|
2016-11-20 02:14:24 +08:00
|
|
|
def v: Flag<["-"], "v">, HelpText<"Display the version number">;
|
|
|
|
|
2016-06-21 16:45:50 +08:00
|
|
|
def verbose: F<"verbose">, HelpText<"Verbose mode">;
|
|
|
|
|
2016-11-20 02:14:24 +08:00
|
|
|
def version: F<"version">, HelpText<"Display the version number and exit">;
|
2016-02-28 11:18:07 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm version_script: Eq<"version-script", "Read a version script">;
|
2016-04-23 04:21:26 +08:00
|
|
|
|
2020-05-16 01:48:46 +08:00
|
|
|
defm warn_backrefs: BB<"warn-backrefs",
|
Add --warn-backrefs to maintain compatibility with other linkers
I'm proposing a new command line flag, --warn-backrefs in this patch.
The flag and the feature proposed below don't exist in GNU linkers
nor the current lld.
--warn-backrefs is an option to detect reverse or cyclic dependencies
between static archives, and it can be used to keep your program
compatible with GNU linkers after you switch to lld. I'll explain the
feature and why you may find it useful below.
lld's symbol resolution semantics is more relaxed than traditional
Unix linkers. Therefore,
ld.lld foo.a bar.o
succeeds even if bar.o contains an undefined symbol that have to be
resolved by some object file in foo.a. Traditional Unix linkers
don't allow this kind of backward reference, as they visit each
file only once from left to right in the command line while
resolving all undefined symbol at the moment of visiting.
In the above case, since there's no undefined symbol when a linker
visits foo.a, no files are pulled out from foo.a, and because the
linker forgets about foo.a after visiting, it can't resolve
undefined symbols that could have been resolved otherwise.
That lld accepts more relaxed form means (besides it makes more
sense) that you can accidentally write a command line or a build
file that works only with lld, even if you have a plan to
distribute it to wider users who may be using GNU linkers. With
--check-library-dependency, you can detect a library order that
doesn't work with other Unix linkers.
The option is also useful to detect cyclic dependencies between
static archives. Again, lld accepts
ld.lld foo.a bar.a
even if foo.a and bar.a depend on each other. With --warn-backrefs
it is handled as an error.
Here is how the option works. We assign a group ID to each file. A
file with a smaller group ID can pull out object files from an
archive file with an equal or greater group ID. Otherwise, it is a
reverse dependency and an error.
A file outside --{start,end}-group gets a fresh ID when
instantiated. All files within the same --{start,end}-group get the
same group ID. E.g.
ld.lld A B --start-group C D --end-group E
A and B form group 0, C, D and their member object files form group
1, and E forms group 2. I think that you can see how this group
assignment rule simulates the traditional linker's semantics.
Differential Revision: https://reviews.llvm.org/D45195
llvm-svn: 329636
2018-04-10 07:05:48 +08:00
|
|
|
"Warn about backward symbol references to fetch archive members",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Do not warn about backward symbol references to fetch archive members (default)">;
|
Add --warn-backrefs to maintain compatibility with other linkers
I'm proposing a new command line flag, --warn-backrefs in this patch.
The flag and the feature proposed below don't exist in GNU linkers
nor the current lld.
--warn-backrefs is an option to detect reverse or cyclic dependencies
between static archives, and it can be used to keep your program
compatible with GNU linkers after you switch to lld. I'll explain the
feature and why you may find it useful below.
lld's symbol resolution semantics is more relaxed than traditional
Unix linkers. Therefore,
ld.lld foo.a bar.o
succeeds even if bar.o contains an undefined symbol that have to be
resolved by some object file in foo.a. Traditional Unix linkers
don't allow this kind of backward reference, as they visit each
file only once from left to right in the command line while
resolving all undefined symbol at the moment of visiting.
In the above case, since there's no undefined symbol when a linker
visits foo.a, no files are pulled out from foo.a, and because the
linker forgets about foo.a after visiting, it can't resolve
undefined symbols that could have been resolved otherwise.
That lld accepts more relaxed form means (besides it makes more
sense) that you can accidentally write a command line or a build
file that works only with lld, even if you have a plan to
distribute it to wider users who may be using GNU linkers. With
--check-library-dependency, you can detect a library order that
doesn't work with other Unix linkers.
The option is also useful to detect cyclic dependencies between
static archives. Again, lld accepts
ld.lld foo.a bar.a
even if foo.a and bar.a depend on each other. With --warn-backrefs
it is handled as an error.
Here is how the option works. We assign a group ID to each file. A
file with a smaller group ID can pull out object files from an
archive file with an equal or greater group ID. Otherwise, it is a
reverse dependency and an error.
A file outside --{start,end}-group gets a fresh ID when
instantiated. All files within the same --{start,end}-group get the
same group ID. E.g.
ld.lld A B --start-group C D --end-group E
A and B form group 0, C, D and their member object files form group
1, and E forms group 2. I think that you can see how this group
assignment rule simulates the traditional linker's semantics.
Differential Revision: https://reviews.llvm.org/D45195
llvm-svn: 329636
2018-04-10 07:05:48 +08:00
|
|
|
|
[ELF] Add --warn-backrefs-exclude=<glob>
D77522 changed --warn-backrefs to not warn for linking sandwich
problems (-ldef1 -lref -ldef2). This removed lots of false positives.
However, glibc still has some problems. libc.a defines some symbols
which are normally in libm.a and libpthread.a, e.g. __isnanl/raise.
For a linking order `-lm -lpthread -lc`, I have seen:
```
// different resolutions: GNU ld/gold select libc.a(s_isnan.o) as the definition
backward reference detected: __isnanl in libc.a(printf_fp.o) refers to libm.a(m_isnanl.o)
// different resolutions: GNU ld/gold select libc.a(raise.o) as the definition
backward reference detected: raise in libc.a(abort.o) refers to libpthread.a(pt-raise.o)
```
To facilitate deployment of --warn-backrefs, add --warn-backrefs-exclude= so that
certain known issues (which may be impractical to fix) can be whitelisted.
Deliberate choices:
* Not a comma-separated list (`--warn-backrefs-exclude=liba.a,libb.a`).
-Wl, splits the argument at commas, so we cannot use commas.
--export-dynamic-symbol is similar.
* Not in the style of `--warn-backrefs='*' --warn-backrefs=-liba.a`.
We just need exclusion, not inclusion. For easier build system
integration, we should avoid order dependency. With the current
scheme, we enable --warn-backrefs, and indivial libraries can add
--warn-backrefs-exclude=<glob> to their LDFLAGS.
Reviewed By: psmith
Differential Revision: https://reviews.llvm.org/D77512
2020-04-05 12:31:36 +08:00
|
|
|
defm warn_backrefs_exclude
|
|
|
|
: Eq<"warn-backrefs-exclude",
|
|
|
|
"Glob describing an archive (or an object file within --start-lib) "
|
|
|
|
"which should be ignored for --warn-backrefs.">,
|
|
|
|
MetaVarName<"<glob>">;
|
|
|
|
|
2018-02-06 08:45:15 +08:00
|
|
|
defm warn_common: B<"warn-common",
|
|
|
|
"Warn about duplicate common symbols",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Do not warn about duplicate common symbols (default)">;
|
2016-06-21 16:45:50 +08:00
|
|
|
|
2020-05-16 01:48:46 +08:00
|
|
|
defm warn_ifunc_textrel: BB<"warn-ifunc-textrel",
|
Introduce a flag to warn when ifunc symbols are used with text relocations.
Summary:
This patch adds a new flag, --warn-ifunc-textrel, to work around a glibc bug. When a code with ifunc symbols is used to produce an object file with text relocations, lld always succeeds. However, if that object file is linked using an old version of glibc, the resultant binary just crashes with segmentation fault when it is run (The bug is going to be corrected as of glibc 2.19).
Since there is no way to tell beforehand what library the object file will be linked against in the future, there does not seem to be a fool-proof way for lld to give an error only in cases where the binary will crash. So, with this change (dated 2018-09-25), lld starts to give a warning, contingent on a new command line flag that does not have a gnu counter part. The default value for --warn-ifunc-textrel is false, so lld behaviour will not change unless the user explicitly asks lld to give a warning. Users that link with a glibc library with version 2.19 or newer, or does not use ifunc symbols, or does not generate object files with text relocations do not need to take any action. Other users may consider to start passing warn-ifunc-textrel to lld to get early warnings.
Reviewers: ruiu, espindola
Reviewed By: ruiu
Subscribers: grimar, MaskRay, markj, emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D52430
llvm-svn: 343628
2018-10-03 04:30:22 +08:00
|
|
|
"Warn about using ifunc symbols with text relocations",
|
|
|
|
"Do not warn about using ifunc symbols with text relocations (default)">;
|
|
|
|
|
2020-05-16 01:48:46 +08:00
|
|
|
defm warn_symbol_ordering: BB<"warn-symbol-ordering",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Warn about problems with the symbol ordering file (default)",
|
2018-02-14 21:36:22 +08:00
|
|
|
"Do not warn about problems with the symbol ordering file">;
|
|
|
|
|
2017-03-24 02:16:42 +08:00
|
|
|
def warn_unresolved_symbols: F<"warn-unresolved-symbols">,
|
2017-01-26 10:19:20 +08:00
|
|
|
HelpText<"Report unresolved symbols as warnings">;
|
|
|
|
|
2018-02-03 05:25:51 +08:00
|
|
|
defm whole_archive: B<"whole-archive",
|
|
|
|
"Force load of all members in a static library",
|
2018-05-31 07:32:41 +08:00
|
|
|
"Do not force load of all members in a static library (default)">;
|
2015-10-02 02:02:21 +08:00
|
|
|
|
2018-05-31 05:25:53 +08:00
|
|
|
defm wrap: Eq<"wrap", "Use wrapper functions for symbol">,
|
2018-06-02 05:46:10 +08:00
|
|
|
MetaVarName<"<symbol>=<symbol>">;
|
2016-01-08 01:20:07 +08:00
|
|
|
|
2016-06-30 16:43:23 +08:00
|
|
|
def z: JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">,
|
2015-10-07 23:00:21 +08:00
|
|
|
HelpText<"Linker option extensions">;
|
|
|
|
|
2019-07-17 22:54:02 +08:00
|
|
|
def visual_studio_diagnostics_format : F<"vs-diagnostics">,
|
2019-10-29 09:41:38 +08:00
|
|
|
HelpText<"Format diagnostics for Visual Studio compatibility">;
|
2019-07-17 22:54:02 +08:00
|
|
|
|
2015-10-01 08:33:02 +08:00
|
|
|
// Aliases
|
2018-06-01 04:46:22 +08:00
|
|
|
def: Separate<["-"], "f">, Alias<auxiliary>, HelpText<"Alias for --auxiliary">;
|
|
|
|
def: F<"call_shared">, Alias<Bdynamic>, HelpText<"Alias for --Bdynamic">;
|
|
|
|
def: F<"dy">, Alias<Bdynamic>, HelpText<"Alias for --Bdynamic">;
|
|
|
|
def: F<"dn">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
|
|
|
|
def: F<"non_shared">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
|
|
|
|
def: F<"static">, Alias<Bstatic>, HelpText<"Alias for --Bstatic">;
|
|
|
|
def: Flag<["-"], "d">, Alias<define_common>, HelpText<"Alias for --define-common">;
|
|
|
|
def: F<"dc">, Alias<define_common>, HelpText<"Alias for --define-common">;
|
|
|
|
def: F<"dp">, Alias<define_common>, HelpText<"Alias for --define-common">;
|
|
|
|
def: Flag<["-"], "x">, Alias<discard_all>, HelpText<"Alias for --discard-all">;
|
|
|
|
def: Flag<["-"], "X">, Alias<discard_locals>, HelpText<"Alias for --discard-locals">;
|
|
|
|
def: Flag<["-"], "q">, Alias<emit_relocs>, HelpText<"Alias for --emit-relocs">;
|
|
|
|
def: Flag<["-"], ")">, Alias<end_group>, HelpText<"Alias for --end-group">;
|
|
|
|
def: JoinedOrSeparate<["-"], "e">, Alias<entry>, HelpText<"Alias for --entry">;
|
|
|
|
def: Flag<["-"], "E">, Alias<export_dynamic>, HelpText<"Alias for --export-dynamic">;
|
|
|
|
def: Separate<["-"], "F">, Alias<filter>, HelpText<"Alias for --filter">;
|
|
|
|
def: Separate<["-"], "b">, Alias<format>, HelpText<"Alias for --format">;
|
|
|
|
def: JoinedOrSeparate<["-"], "l">, Alias<library>, HelpText<"Alias for --library">;
|
|
|
|
def: JoinedOrSeparate<["-"], "L">, Alias<library_path>, HelpText<"Alias for --library-path">;
|
|
|
|
def: F<"no-pic-executable">, Alias<no_pie>, HelpText<"Alias for --no-pie">;
|
2019-05-14 00:01:26 +08:00
|
|
|
def: Flag<["-"], "n">, Alias<nmagic>, HelpText<"Alias for --nmagic">;
|
2018-06-01 04:46:22 +08:00
|
|
|
def: Flag<["-"], "N">, Alias<omagic>, HelpText<"Alias for --omagic">;
|
|
|
|
def: Joined<["--"], "output=">, Alias<o>, HelpText<"Alias for -o">;
|
|
|
|
def: Separate<["--"], "output">, Alias<o>, HelpText<"Alias for -o">;
|
|
|
|
def: F<"pic-executable">, Alias<pie>, HelpText<"Alias for --pie">;
|
|
|
|
def: Flag<["-"], "M">, Alias<print_map>, HelpText<"Alias for --print-map">;
|
|
|
|
def: Flag<["-"], "r">, Alias<relocatable>, HelpText<"Alias for --relocatable">;
|
|
|
|
def: JoinedOrSeparate<["-"], "R">, Alias<rpath>, HelpText<"Alias for --rpath">;
|
|
|
|
def: JoinedOrSeparate<["-"], "T">, Alias<script>, HelpText<"Alias for --script">;
|
|
|
|
def: F<"Bshareable">, Alias<shared>, HelpText<"Alias for --shared">;
|
|
|
|
def: JoinedOrSeparate<["-"], "h">, Alias<soname>, HelpText<"Alias for --soname">;
|
|
|
|
def: Flag<["-"], "(">, Alias<start_group>, HelpText<"Alias for --start-group">;
|
|
|
|
def: Flag<["-"], "s">, Alias<strip_all>, HelpText<"Alias for --strip-all">;
|
|
|
|
def: Flag<["-"], "S">, Alias<strip_debug>, HelpText<"Alias for --strip-debug">;
|
|
|
|
def: Flag<["-"], "t">, Alias<trace>, HelpText<"Alias for --trace">;
|
2019-11-20 06:16:04 +08:00
|
|
|
def: Joined<["-", "--"], "Ttext-segment=">, Alias<Ttext_segment>;
|
2018-06-01 04:46:22 +08:00
|
|
|
def: JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>, HelpText<"Alias for --trace-symbol">;
|
|
|
|
def: JoinedOrSeparate<["-"], "u">, Alias<undefined>, HelpText<"Alias for --undefined">;
|
|
|
|
def: Flag<["-"], "V">, Alias<version>, HelpText<"Alias for --version">;
|
2015-10-01 08:24:54 +08:00
|
|
|
|
2017-04-30 21:44:52 +08:00
|
|
|
// LTO-related options.
|
2020-05-05 05:42:36 +08:00
|
|
|
def lto_aa_pipeline: JJ<"lto-aa-pipeline=">,
|
2017-04-30 21:44:52 +08:00
|
|
|
HelpText<"AA pipeline to run during LTO. Used in conjunction with -lto-newpm-passes">;
|
2020-05-05 05:42:36 +08:00
|
|
|
def lto_debug_pass_manager: FF<"lto-debug-pass-manager">,
|
2018-04-10 01:56:07 +08:00
|
|
|
HelpText<"Debug new pass manager">;
|
2020-05-05 05:42:36 +08:00
|
|
|
def lto_emit_asm: FF<"lto-emit-asm">,
|
[lld] Support --lto-emit-asm and --plugin-opt=emit-asm
Summary: The switch --plugin-opt=emit-asm can be used with the gold linker to dump the final assembly code generated by LTO in a user-friendly way. Unfortunately it doesn't work with lld. I'm hooking it up with lld. With that switch, lld emits assembly code into the output file (specified by -o) and if there are multiple input files, each of their assembly code will be emitted into a separate file named by suffixing the output file name with a unique number, respectively. The linking then stops after generating those assembly files.
Reviewers: espindola, wenlei, tejohnson, MaskRay, grimar
Reviewed By: tejohnson, MaskRay, grimar
Subscribers: pcc, emaste, inglorion, arichardson, hiraditya, MaskRay, steven_wu, dexonsmith, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D77231
2020-04-02 01:01:23 +08:00
|
|
|
HelpText<"Emit assembly code">;
|
2020-05-05 05:42:36 +08:00
|
|
|
def lto_new_pass_manager: FF<"lto-new-pass-manager">,
|
2018-04-10 01:56:07 +08:00
|
|
|
HelpText<"Use new pass manager">;
|
2020-05-05 05:42:36 +08:00
|
|
|
def lto_newpm_passes: JJ<"lto-newpm-passes=">,
|
2017-04-30 21:44:52 +08:00
|
|
|
HelpText<"Passes to run during LTO">;
|
2020-05-05 05:42:36 +08:00
|
|
|
def lto_O: JJ<"lto-O">, MetaVarName<"<opt-level>">,
|
2018-05-30 13:01:07 +08:00
|
|
|
HelpText<"Optimization level for LTO">;
|
2020-05-05 05:42:36 +08:00
|
|
|
def lto_partitions: JJ<"lto-partitions=">,
|
2017-04-30 21:44:52 +08:00
|
|
|
HelpText<"Number of LTO codegen partitions">;
|
2020-05-05 05:42:36 +08:00
|
|
|
def lto_cs_profile_generate: FF<"lto-cs-profile-generate">,
|
2019-10-29 09:41:38 +08:00
|
|
|
HelpText<"Perform context sensitive PGO instrumentation">;
|
2020-05-05 05:42:36 +08:00
|
|
|
def lto_cs_profile_file: JJ<"lto-cs-profile-file=">,
|
2019-03-12 06:51:38 +08:00
|
|
|
HelpText<"Context sensitive profile file path">;
|
2020-05-05 05:42:36 +08:00
|
|
|
def lto_obj_path_eq: JJ<"lto-obj-path=">;
|
|
|
|
def lto_sample_profile: JJ<"lto-sample-profile=">,
|
2018-04-10 01:56:07 +08:00
|
|
|
HelpText<"Sample profile file path">;
|
2020-05-05 05:42:36 +08:00
|
|
|
def lto_whole_program_visibility: FF<"lto-whole-program-visibility">,
|
2020-01-25 04:24:18 +08:00
|
|
|
HelpText<"Asserts that the LTO link has whole program visibility">;
|
2017-04-30 21:44:52 +08:00
|
|
|
def disable_verify: F<"disable-verify">;
|
2018-05-31 05:25:53 +08:00
|
|
|
defm mllvm: Eq<"mllvm", "Additional arguments to forward to LLVM's option processing">;
|
2017-04-30 21:44:52 +08:00
|
|
|
def opt_remarks_filename: Separate<["--"], "opt-remarks-filename">,
|
|
|
|
HelpText<"YAML output file for optimization remarks">;
|
2019-03-13 05:22:27 +08:00
|
|
|
def opt_remarks_passes: Separate<["--"], "opt-remarks-passes">,
|
|
|
|
HelpText<"Regex for the passes that need to be serialized to the output file">;
|
2020-05-05 05:42:36 +08:00
|
|
|
def opt_remarks_with_hotness: FF<"opt-remarks-with-hotness">,
|
2018-01-10 20:55:14 +08:00
|
|
|
HelpText<"Include hotness information in the optimization remarks file">;
|
2019-06-18 00:06:00 +08:00
|
|
|
def opt_remarks_format: Separate<["--"], "opt-remarks-format">,
|
|
|
|
HelpText<"The format used for serializing remarks (default: YAML)">;
|
2017-04-30 21:44:52 +08:00
|
|
|
def save_temps: F<"save-temps">;
|
2020-05-05 05:42:36 +08:00
|
|
|
def lto_basicblock_sections: JJ<"lto-basicblock-sections=">,
|
2020-04-07 21:48:18 +08:00
|
|
|
HelpText<"Enable basic block sections for LTO">;
|
2020-05-16 01:48:46 +08:00
|
|
|
defm lto_unique_bb_section_names: BB<"lto-unique-bb-section-names",
|
2020-04-07 21:48:18 +08:00
|
|
|
"Give unique names to every basic block section for LTO",
|
|
|
|
"Do not give unique names to every basic block section for LTO (default)">;
|
2020-05-05 05:42:36 +08:00
|
|
|
def shuffle_sections: JJ<"shuffle-sections=">, MetaVarName<"<seed>">,
|
2020-02-20 05:19:58 +08:00
|
|
|
HelpText<"Shuffle input sections using the given seed. If 0, use a random seed">;
|
2020-05-05 05:42:36 +08:00
|
|
|
def thinlto_cache_dir: JJ<"thinlto-cache-dir=">,
|
2017-04-30 21:44:52 +08:00
|
|
|
HelpText<"Path to ThinLTO cached object file directory">;
|
2020-05-05 05:42:36 +08:00
|
|
|
defm thinlto_cache_policy: EEq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">;
|
|
|
|
def thinlto_emit_imports_files: FF<"thinlto-emit-imports-files">;
|
|
|
|
def thinlto_index_only: FF<"thinlto-index-only">;
|
|
|
|
def thinlto_index_only_eq: JJ<"thinlto-index-only=">;
|
|
|
|
def thinlto_jobs: JJ<"thinlto-jobs=">,
|
[lld][COFF][ELF][WebAssembly] Replace --[no-]threads /threads[:no] with --threads={1,2,...} /threads:{1,2,...}
--no-threads is a name copied from gold.
gold has --no-thread, --thread-count and several other --thread-count-*.
There are needs to customize the number of threads (running several lld
processes concurrently or customizing the number of LTO threads).
Having a single --threads=N is a straightforward replacement of gold's
--no-threads + --thread-count.
--no-threads is used rarely. So just delete --no-threads instead of
keeping it for compatibility for a while.
If --threads= is specified (ELF,wasm; COFF /threads: is similar),
--thinlto-jobs= defaults to --threads=,
otherwise all available hardware threads are used.
There is currently no way to override a --threads={1,2,...}. It is still
a debate whether we should use --threads=all.
Reviewed By: rnk, aganea
Differential Revision: https://reviews.llvm.org/D76885
2020-03-18 03:40:19 +08:00
|
|
|
HelpText<"Number of ThinLTO jobs. Default to --threads=">;
|
2020-05-05 05:42:36 +08:00
|
|
|
def thinlto_object_suffix_replace_eq: JJ<"thinlto-object-suffix-replace=">;
|
|
|
|
def thinlto_prefix_replace_eq: JJ<"thinlto-prefix-replace=">;
|
2020-05-22 04:19:44 +08:00
|
|
|
def thinlto_single_module_eq: JJ<"thinlto-single-module=">,
|
|
|
|
HelpText<"Specific a single module to compile in ThinLTO mode, for debugging only">;
|
2017-04-30 21:44:52 +08:00
|
|
|
|
2020-04-03 00:25:21 +08:00
|
|
|
def: J<"plugin-opt=O">, Alias<lto_O>, HelpText<"Alias for --lto-O">;
|
2018-06-01 04:46:22 +08:00
|
|
|
def: F<"plugin-opt=debug-pass-manager">,
|
2020-04-03 00:25:21 +08:00
|
|
|
Alias<lto_debug_pass_manager>, HelpText<"Alias for --lto-debug-pass-manager">;
|
|
|
|
def: F<"plugin-opt=disable-verify">, Alias<disable_verify>, HelpText<"Alias for --disable-verify">;
|
2018-07-17 01:55:48 +08:00
|
|
|
def plugin_opt_dwo_dir_eq: J<"plugin-opt=dwo_dir=">,
|
|
|
|
HelpText<"Directory to store .dwo files when LTO and debug fission are used">;
|
[lld] Support --lto-emit-asm and --plugin-opt=emit-asm
Summary: The switch --plugin-opt=emit-asm can be used with the gold linker to dump the final assembly code generated by LTO in a user-friendly way. Unfortunately it doesn't work with lld. I'm hooking it up with lld. With that switch, lld emits assembly code into the output file (specified by -o) and if there are multiple input files, each of their assembly code will be emitted into a separate file named by suffixing the output file name with a unique number, respectively. The linking then stops after generating those assembly files.
Reviewers: espindola, wenlei, tejohnson, MaskRay, grimar
Reviewed By: tejohnson, MaskRay, grimar
Subscribers: pcc, emaste, inglorion, arichardson, hiraditya, MaskRay, steven_wu, dexonsmith, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D77231
2020-04-02 01:01:23 +08:00
|
|
|
def plugin_opt_emit_asm: F<"plugin-opt=emit-asm">,
|
|
|
|
Alias<lto_emit_asm>, HelpText<"Alias for --lto-emit-asm">;
|
2018-12-15 05:58:49 +08:00
|
|
|
def plugin_opt_emit_llvm: F<"plugin-opt=emit-llvm">;
|
2020-04-03 00:25:21 +08:00
|
|
|
def: J<"plugin-opt=jobs=">, Alias<thinlto_jobs>, HelpText<"Alias for --thinlto-jobs">;
|
|
|
|
def: J<"plugin-opt=lto-partitions=">, Alias<lto_partitions>, HelpText<"Alias for --lto-partitions">;
|
2018-05-22 10:53:11 +08:00
|
|
|
def plugin_opt_mcpu_eq: J<"plugin-opt=mcpu=">;
|
2018-06-01 04:46:22 +08:00
|
|
|
def: F<"plugin-opt=new-pass-manager">,
|
2020-04-03 00:25:21 +08:00
|
|
|
Alias<lto_new_pass_manager>, HelpText<"Alias for --lto-new-pass-manager">;
|
2019-03-12 06:51:38 +08:00
|
|
|
def: F<"plugin-opt=cs-profile-generate">,
|
2020-04-03 00:25:21 +08:00
|
|
|
Alias<lto_cs_profile_generate>, HelpText<"Alias for --lto-cs-profile-generate">;
|
2019-03-12 06:51:38 +08:00
|
|
|
def: J<"plugin-opt=cs-profile-path=">,
|
2020-04-03 00:25:21 +08:00
|
|
|
Alias<lto_cs_profile_file>, HelpText<"Alias for --lto-cs-profile-file">;
|
[ELF] accept thinlto options without --plugin-opt= prefix
Summary:
When support for ThinLTO was first added to lld, the options that
control it were prefixed with --plugin-opt= for compatibility with
an existing implementation as a linker plugin. This change enables
shorter versions of the options to be used, as follows:
New Existing
-thinlto-emit-imports-files --plugin-opt=thinlto-emit-imports-files
-thinlto-index-only --plugin-opt=thinlto-index-only
-thinlto-index-only= --plugin-opt=thinlto-index-only=
-thinlto-object-suffix-replace= --plugin-opt=thinlto-object-suffix-replace=
-thinlto-prefix-replace= --plugin-opt=thinlto-prefix-replace=
-lto-obj-path= --plugin-opt=obj-path=
The options with the --plugin-opt= prefix have been retained as aliases
for the shorter variants so that they continue to be accepted.
Reviewers: tejohnson, ruiu, espindola
Reviewed By: ruiu
Subscribers: emaste, arichardson, MaskRay, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67782
llvm-svn: 372798
2019-09-25 09:19:48 +08:00
|
|
|
def: J<"plugin-opt=obj-path=">,
|
|
|
|
Alias<lto_obj_path_eq>,
|
2020-04-03 00:25:21 +08:00
|
|
|
HelpText<"Alias for --lto-obj-path=">;
|
2018-06-01 04:46:22 +08:00
|
|
|
def: J<"plugin-opt=sample-profile=">,
|
2020-04-03 00:25:21 +08:00
|
|
|
Alias<lto_sample_profile>, HelpText<"Alias for --lto-sample-profile">;
|
|
|
|
def: F<"plugin-opt=save-temps">, Alias<save_temps>, HelpText<"Alias for --save-temps">;
|
[ELF] accept thinlto options without --plugin-opt= prefix
Summary:
When support for ThinLTO was first added to lld, the options that
control it were prefixed with --plugin-opt= for compatibility with
an existing implementation as a linker plugin. This change enables
shorter versions of the options to be used, as follows:
New Existing
-thinlto-emit-imports-files --plugin-opt=thinlto-emit-imports-files
-thinlto-index-only --plugin-opt=thinlto-index-only
-thinlto-index-only= --plugin-opt=thinlto-index-only=
-thinlto-object-suffix-replace= --plugin-opt=thinlto-object-suffix-replace=
-thinlto-prefix-replace= --plugin-opt=thinlto-prefix-replace=
-lto-obj-path= --plugin-opt=obj-path=
The options with the --plugin-opt= prefix have been retained as aliases
for the shorter variants so that they continue to be accepted.
Reviewers: tejohnson, ruiu, espindola
Reviewed By: ruiu
Subscribers: emaste, arichardson, MaskRay, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67782
llvm-svn: 372798
2019-09-25 09:19:48 +08:00
|
|
|
def: F<"plugin-opt=thinlto-emit-imports-files">,
|
|
|
|
Alias<thinlto_emit_imports_files>,
|
2020-04-03 00:25:21 +08:00
|
|
|
HelpText<"Alias for --thinlto-emit-imports-files">;
|
[ELF] accept thinlto options without --plugin-opt= prefix
Summary:
When support for ThinLTO was first added to lld, the options that
control it were prefixed with --plugin-opt= for compatibility with
an existing implementation as a linker plugin. This change enables
shorter versions of the options to be used, as follows:
New Existing
-thinlto-emit-imports-files --plugin-opt=thinlto-emit-imports-files
-thinlto-index-only --plugin-opt=thinlto-index-only
-thinlto-index-only= --plugin-opt=thinlto-index-only=
-thinlto-object-suffix-replace= --plugin-opt=thinlto-object-suffix-replace=
-thinlto-prefix-replace= --plugin-opt=thinlto-prefix-replace=
-lto-obj-path= --plugin-opt=obj-path=
The options with the --plugin-opt= prefix have been retained as aliases
for the shorter variants so that they continue to be accepted.
Reviewers: tejohnson, ruiu, espindola
Reviewed By: ruiu
Subscribers: emaste, arichardson, MaskRay, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67782
llvm-svn: 372798
2019-09-25 09:19:48 +08:00
|
|
|
def: F<"plugin-opt=thinlto-index-only">,
|
|
|
|
Alias<thinlto_index_only>,
|
2020-04-03 00:25:21 +08:00
|
|
|
HelpText<"Alias for --thinlto-index-only">;
|
[ELF] accept thinlto options without --plugin-opt= prefix
Summary:
When support for ThinLTO was first added to lld, the options that
control it were prefixed with --plugin-opt= for compatibility with
an existing implementation as a linker plugin. This change enables
shorter versions of the options to be used, as follows:
New Existing
-thinlto-emit-imports-files --plugin-opt=thinlto-emit-imports-files
-thinlto-index-only --plugin-opt=thinlto-index-only
-thinlto-index-only= --plugin-opt=thinlto-index-only=
-thinlto-object-suffix-replace= --plugin-opt=thinlto-object-suffix-replace=
-thinlto-prefix-replace= --plugin-opt=thinlto-prefix-replace=
-lto-obj-path= --plugin-opt=obj-path=
The options with the --plugin-opt= prefix have been retained as aliases
for the shorter variants so that they continue to be accepted.
Reviewers: tejohnson, ruiu, espindola
Reviewed By: ruiu
Subscribers: emaste, arichardson, MaskRay, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67782
llvm-svn: 372798
2019-09-25 09:19:48 +08:00
|
|
|
def: J<"plugin-opt=thinlto-index-only=">,
|
|
|
|
Alias<thinlto_index_only_eq>,
|
2020-04-03 00:25:21 +08:00
|
|
|
HelpText<"Alias for --thinlto-index-only=">;
|
[ELF] accept thinlto options without --plugin-opt= prefix
Summary:
When support for ThinLTO was first added to lld, the options that
control it were prefixed with --plugin-opt= for compatibility with
an existing implementation as a linker plugin. This change enables
shorter versions of the options to be used, as follows:
New Existing
-thinlto-emit-imports-files --plugin-opt=thinlto-emit-imports-files
-thinlto-index-only --plugin-opt=thinlto-index-only
-thinlto-index-only= --plugin-opt=thinlto-index-only=
-thinlto-object-suffix-replace= --plugin-opt=thinlto-object-suffix-replace=
-thinlto-prefix-replace= --plugin-opt=thinlto-prefix-replace=
-lto-obj-path= --plugin-opt=obj-path=
The options with the --plugin-opt= prefix have been retained as aliases
for the shorter variants so that they continue to be accepted.
Reviewers: tejohnson, ruiu, espindola
Reviewed By: ruiu
Subscribers: emaste, arichardson, MaskRay, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67782
llvm-svn: 372798
2019-09-25 09:19:48 +08:00
|
|
|
def: J<"plugin-opt=thinlto-object-suffix-replace=">,
|
|
|
|
Alias<thinlto_object_suffix_replace_eq>,
|
2020-04-03 00:25:21 +08:00
|
|
|
HelpText<"Alias for --thinlto-object-suffix-replace=">;
|
[ELF] accept thinlto options without --plugin-opt= prefix
Summary:
When support for ThinLTO was first added to lld, the options that
control it were prefixed with --plugin-opt= for compatibility with
an existing implementation as a linker plugin. This change enables
shorter versions of the options to be used, as follows:
New Existing
-thinlto-emit-imports-files --plugin-opt=thinlto-emit-imports-files
-thinlto-index-only --plugin-opt=thinlto-index-only
-thinlto-index-only= --plugin-opt=thinlto-index-only=
-thinlto-object-suffix-replace= --plugin-opt=thinlto-object-suffix-replace=
-thinlto-prefix-replace= --plugin-opt=thinlto-prefix-replace=
-lto-obj-path= --plugin-opt=obj-path=
The options with the --plugin-opt= prefix have been retained as aliases
for the shorter variants so that they continue to be accepted.
Reviewers: tejohnson, ruiu, espindola
Reviewed By: ruiu
Subscribers: emaste, arichardson, MaskRay, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67782
llvm-svn: 372798
2019-09-25 09:19:48 +08:00
|
|
|
def: J<"plugin-opt=thinlto-prefix-replace=">,
|
|
|
|
Alias<thinlto_prefix_replace_eq>,
|
2020-04-03 00:25:21 +08:00
|
|
|
HelpText<"Alias for --thinlto-prefix-replace=">;
|
2018-05-22 10:53:11 +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.
|
2018-06-02 05:51:21 +08:00
|
|
|
defm plugin: Eq<"plugin", "Ignored for compatibility with GNU linkers">;
|
2016-03-19 08:40:09 +08:00
|
|
|
|
2020-04-15 05:17:29 +08:00
|
|
|
def plugin_opt_eq_minus: J<"plugin-opt=-">,
|
|
|
|
HelpText<"Specify an LLVM option for compatibility with LLVMgold.so">;
|
|
|
|
def: J<"plugin-opt=thinlto">;
|
|
|
|
|
|
|
|
// Ignore GCC collect2 LTO plugin related options. Note that we don't support
|
|
|
|
// GCC LTO, but GCC collect2 passes these options even in non-LTO mode.
|
|
|
|
def: J<"plugin-opt=-fresolution=">;
|
|
|
|
def: J<"plugin-opt=-pass-through=">;
|
|
|
|
// This may be either an unhandled LLVMgold.so feature or GCC passed
|
|
|
|
// -plugin-opt=path/to/{liblto_plugin.so,lto-wrapper}
|
|
|
|
def plugin_opt_eq : J<"plugin-opt=">;
|
2018-05-22 10:53:11 +08:00
|
|
|
|
2015-11-13 08:26:12 +08:00
|
|
|
// Options listed below are silently ignored for now for compatibility.
|
2018-05-31 22:10:37 +08:00
|
|
|
def: F<"detect-odr-violations">;
|
|
|
|
def: Flag<["-"], "g">;
|
|
|
|
def: F<"long-plt">;
|
|
|
|
def: F<"no-add-needed">;
|
|
|
|
def: F<"no-copy-dt-needed-entries">;
|
|
|
|
def: F<"no-ctors-in-init-array">;
|
|
|
|
def: F<"no-keep-memory">;
|
2019-02-25 18:48:31 +08:00
|
|
|
def: F<"no-pipeline-knowledge">;
|
2020-07-08 00:47:08 +08:00
|
|
|
def: F<"no-relax">;
|
2018-05-31 22:10:37 +08:00
|
|
|
def: F<"no-warn-mismatch">;
|
2019-02-25 18:48:31 +08:00
|
|
|
def: Flag<["-"], "p">;
|
2018-06-01 03:37:04 +08:00
|
|
|
def: Separate<["--", "-"], "rpath-link">;
|
2018-05-31 22:10:37 +08:00
|
|
|
def: J<"rpath-link=">;
|
[PPC32] Improve the 32-bit PowerPC port
Many -static/-no-pie/-shared/-pie applications linked against glibc or musl
should work with this patch. This also helps FreeBSD PowerPC64 to migrate
their lib32 (PR40888).
* Fix default image base and max page size.
* Support new-style Secure PLT (see below). Old-style BSS PLT is not
implemented, so it is not suitable for FreeBSD rtld now because it doesn't
support Secure PLT yet.
* Support more initial relocation types:
R_PPC_ADDR32, R_PPC_REL16*, R_PPC_LOCAL24PC, R_PPC_PLTREL24, and R_PPC_GOT16.
The addend of R_PPC_PLTREL24 is special: it decides the call stub PLT type
but it should be ignored for the computation of target symbol VA.
* Support GNU ifunc
* Support .glink used for lazy PLT resolution in glibc
* Add a new thunk type: PPC32PltCallStub that is similar to PPC64PltCallStub.
It is used by R_PPC_REL24 and R_PPC_PLTREL24.
A PLT stub used in -fPIE/-fPIC usually loads an address relative to
.got2+0x8000 (-fpie/-fpic code uses _GLOBAL_OFFSET_TABLE_ relative
addresses).
Two .got2 sections in two object files have different addresses, thus a PLT stub
can't be shared by two object files. To handle this incompatibility,
change the parameters of Thunk::isCompatibleWith to
`const InputSection &, const Relocation &`.
PowerPC psABI specified an old-style .plt (BSS PLT) that is both
writable and executable. Linkers don't make separate RW- and RWE segments,
which causes all initially writable memory (think .data) executable.
This is a big security concern so a new PLT scheme (secure PLT) was developed to
address the security issue.
TLS will be implemented in D62940.
glibc older than ~2012 requires .rela.dyn to include .rela.plt, it can
not handle the DT_RELA+DT_RELASZ == DT_JMPREL case correctly. A hack
(not included in this patch) in LinkerScript.cpp addOrphanSections() to
work around the issue:
if (Config->EMachine == EM_PPC) {
// Older glibc assumes .rela.dyn includes .rela.plt
Add(In.RelaDyn);
if (In.RelaPlt->isLive() && !In.RelaPlt->Parent)
In.RelaDyn->getParent()->addSection(In.RelaPlt);
}
Reviewed By: ruiu
Differential Revision: https://reviews.llvm.org/D62464
llvm-svn: 362721
2019-06-07 01:03:00 +08:00
|
|
|
def: F<"secure-plt">;
|
2018-05-31 22:10:37 +08:00
|
|
|
def: F<"sort-common">;
|
|
|
|
def: F<"stats">;
|
|
|
|
def: F<"warn-execstack">;
|
|
|
|
def: F<"warn-once">;
|
|
|
|
def: F<"warn-shared-textrel">;
|
|
|
|
def: F<"EB">;
|
|
|
|
def: F<"EL">;
|
|
|
|
def: JoinedOrSeparate<["-"], "G">;
|
|
|
|
def: F<"Qy">;
|
2018-06-11 15:24:31 +08:00
|
|
|
|
|
|
|
// Hidden option used for testing MIPS multi-GOT implementation.
|
|
|
|
defm mips_got_size:
|
|
|
|
Eq<"mips-got-size", "Max size of a single MIPS GOT. 0x10000 by default.">,
|
|
|
|
Flags<[HelpHidden]>;
|