summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Cain <bcain@quicinc.com>2024-11-29 16:42:44 -0600
committerTobias Hieta <tobias@hieta.se>2024-12-03 08:46:10 +0100
commitab4b5a2db582958af1ee308a790cfdb42bd24720 (patch)
tree8467510b01d45cef0a118bbe3d45fc90a5d084c3
parent876d0501d312b7303423fc4d3c388174a1465ca5 (diff)
[clang] recognize hexagon-*-ld.lld variants (#117338)llvmorg-19.1.5
If we create a cross toolchain with a ${triple}-ld.lld symlink, clang finds that symlink and when it uses it, it's not recognized as "lld". Let's resolve that symlink and consider it when determining lld-ness. For example, clang provides hexagon-link specific link arguments such as `-mcpu=hexagonv65` and `-march=hexagon` when hexagon-unknown-linux-musl-ld.lld is found. lld rejects this with the following error: hexagon-unknown-linux-musl-ld.lld: error: unknown emulation: cpu=hexagonv65 (cherry picked from commit 2dc0de753b6df83e35f3d98e0e6a26c95e3399c0)
-rw-r--r--clang/lib/Driver/ToolChains/Hexagon.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp
index 29781399cbab..be7851adecea 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -294,9 +294,10 @@ constructHexagonLinkArgs(Compilation &C, const JobAction &JA,
bool IncStartFiles = !Args.hasArg(options::OPT_nostartfiles);
bool IncDefLibs = !Args.hasArg(options::OPT_nodefaultlibs);
bool UseG0 = false;
- const char *Exec = Args.MakeArgString(HTC.GetLinkerPath());
- bool UseLLD = (llvm::sys::path::filename(Exec).equals_insensitive("ld.lld") ||
- llvm::sys::path::stem(Exec).equals_insensitive("ld.lld"));
+ bool UseLLD = false;
+ const char *Exec = Args.MakeArgString(HTC.GetLinkerPath(&UseLLD));
+ UseLLD = UseLLD || llvm::sys::path::filename(Exec).ends_with("ld.lld") ||
+ llvm::sys::path::stem(Exec).ends_with("ld.lld");
bool UseShared = IsShared && !IsStatic;
StringRef CpuVer = toolchains::HexagonToolChain::GetTargetCPUVersion(Args);