aboutsummaryrefslogtreecommitdiff
path: root/lld/lib
diff options
context:
space:
mode:
authorBrian Gesiak <modocache@gmail.com>2018-06-13 18:59:14 +0000
committerBrian Gesiak <modocache@gmail.com>2018-06-13 18:59:14 +0000
commit4fcebf6cf6ec69afe2f3bd8e9d81c93be9668b38 (patch)
tree855ec2ab6df2e06733ff8aed24d5ef8709b82036 /lld/lib
parent7bec57300c799632d282d67916745b6d20a12e6f (diff)
downloadllvm-project-4fcebf6cf6ec69afe2f3bd8e9d81c93be9668b38.tar.gz
[Darwin] Do not error on '-lto_library' option
Summary: Any invocation of `clang -fuse-ld=lld` that results in a link command on a macOS host currently fails, because the Darwin lld driver does not recognize the `-lto_library` option that Clang passes it. Fix the error by having the Darwin driver ignore the option. The Clang driver's macOS toolchain is written such that it will always pass the `-lto_library` option to the linker invocation on a macOS host. And although the DarwinLdDriver is written to ignore any unknown arguments, because `-lto_library` begins with `-l`, the DarwinLdDriver interprets it as a library search command, for a library named "to_library". When the DarwinLdDriver is unable to find a library specified via `-l`, it exits with a hard error. This causes any invocation of `clang -fuse-ld=lld` that results in a link command on a macOS host to fail with an error. To fix the issue, I considered two alternatives: 1. Modify the Clang Darwin toolchain to only pass `-lto_library` if lld is *not* being used. lld doesn't support LTO on Darwin anyway, so it can't use the option. However, I opted against this because, if and when lld *does* support LTO on Darwin, I'll have to make another commit to Clang in order to get it to pass the option to lld again. 2. Modify the Darwin lld driver to ignore the `-lto_library` option. Just in case users may take this to mean LTO is supported, I also added a warning. If and when lld supports LTO on Darwin, the same commit that adds support for this option can remove the warning. Option (2) seemed better to me, and is the rationale behind this commit. Test Plan: check-lld Reviewers: ruiu, smeenai, pcc Reviewed By: smeenai Subscribers: JDevlieghere, pcc, mehdi_amini, inglorion, steven_wu, llvm-commits Differential Revision: https://reviews.llvm.org/D47994 llvm-svn: 334641
Diffstat (limited to 'lld/lib')
-rw-r--r--lld/lib/Driver/DarwinLdOptions.td4
1 files changed, 4 insertions, 0 deletions
diff --git a/lld/lib/Driver/DarwinLdOptions.td b/lld/lib/Driver/DarwinLdOptions.td
index e5581111391f..3bbde8bf1c1c 100644
--- a/lld/lib/Driver/DarwinLdOptions.td
+++ b/lld/lib/Driver/DarwinLdOptions.td
@@ -231,6 +231,10 @@ def error_limit : Separate<["-", "--"], "error-limit">,
MetaVarName<"<number>">,
HelpText<"Maximum number of errors to emit before stopping (0 = no limit)">;
+// Ignored options
+def lto_library : Separate<["-"], "lto_library">,
+ MetaVarName<"<path>">,
+ HelpText<"Ignored for compatibility with other linkers">;
// Obsolete options
def grp_obsolete : OptionGroup<"obsolete">, HelpText<"OBSOLETE OPTIONS">;