[PATCH] D134063: [clang] Make --ld-path= work with -fuse-ld=lld
Nico Weber via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 23 06:04:45 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG31142c429053: [clang] Make --ld-path= work with -fuse-ld=lld (authored by thakis).
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134063/new/
https://reviews.llvm.org/D134063
Files:
clang/lib/Driver/ToolChain.cpp
clang/test/Driver/darwin-ld-demangle-lld.c
Index: clang/test/Driver/darwin-ld-demangle-lld.c
===================================================================
--- clang/test/Driver/darwin-ld-demangle-lld.c
+++ clang/test/Driver/darwin-ld-demangle-lld.c
@@ -1,8 +1,12 @@
// With -fuse-ld=lld, -demangle is always passed to the linker on Darwin.
// REQUIRES: shell
-// RUN: %clang --target=x86_64-apple-darwin -### \
-// RUN: -fuse-ld=lld -B%S/Inputs/lld -mlinker-version=0 %s 2>&1 \
+// RUN: %clang --target=x86_64-apple-darwin -### -fuse-ld=lld \
+// RUN: -B%S/Inputs/lld -mlinker-version=0 %s 2>&1 \
+// RUN: | FileCheck %s
+
+// RUN: %clang --target=x86_64-apple-darwin -### -fuse-ld=lld \
+// RUN: --ld-path=%S/Inputs/lld/ld64.lld -mlinker-version=0 %s 2>&1 \
// RUN: | FileCheck %s
// CHECK: "-demangle"
Index: clang/lib/Driver/ToolChain.cpp
===================================================================
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -621,13 +621,18 @@
// --ld-path= takes precedence over -fuse-ld= and specifies the executable
// name. -B, COMPILER_PATH and PATH and consulted if the value does not
// contain a path component separator.
+ // -fuse-ld=lld can be used with --ld-path= to inform clang that the binary
+ // that --ld-path= points to is lld.
if (const Arg *A = Args.getLastArg(options::OPT_ld_path_EQ)) {
std::string Path(A->getValue());
if (!Path.empty()) {
if (llvm::sys::path::parent_path(Path).empty())
Path = GetProgramPath(A->getValue());
- if (llvm::sys::fs::can_execute(Path))
+ if (llvm::sys::fs::can_execute(Path)) {
+ if (LinkerIsLLD)
+ *LinkerIsLLD = UseLinker == "lld";
return std::string(Path);
+ }
}
getDriver().Diag(diag::err_drv_invalid_linker_name) << A->getAsString(Args);
return GetProgramPath(getDefaultLinker());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134063.462462.patch
Type: text/x-patch
Size: 1874 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220923/e49e83f2/attachment.bin>
More information about the cfe-commits
mailing list