[clang] [clang] recognize hexagon-*-ld.lld variants (PR #117338)
Brian Cain via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 27 09:24:42 PST 2024
https://github.com/androm3da updated https://github.com/llvm/llvm-project/pull/117338
>From fa2c015073b1afa282d76c2c2b462fb84feeb688 Mon Sep 17 00:00:00 2001
From: Brian Cain <bcain at quicinc.com>
Date: Thu, 21 Nov 2024 19:46:04 -0800
Subject: [PATCH] [clang] recognize hexagon-*-ld.lld variants
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
consider it as lld as long as it ends in "ld.lld".
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
---
clang/lib/Driver/ToolChains/Hexagon.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp
index 29781399cbab44..be7851adecea66 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);
More information about the cfe-commits
mailing list