Skip to content

Commit 62549db

Browse files
authored
[AMDGPU] Correctly determine the toolchain linker (#89803)
Summary: The AMDGPU toolchain simply took the short name to get the link job instead of using the common utilities that respect options like `-fuse-ld`. Any linker that isn't `ld.lld` will fail, however we should be able to override it.
1 parent af81d8e commit 62549db

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,7 @@ void amdgpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
617617
const InputInfoList &Inputs,
618618
const ArgList &Args,
619619
const char *LinkingOutput) const {
620-
621-
std::string Linker = getToolChain().GetProgramPath(getShortName());
620+
std::string Linker = getToolChain().GetLinkerPath();
622621
ArgStringList CmdArgs;
623622
CmdArgs.push_back("--no-undefined");
624623
CmdArgs.push_back("-shared");

clang/test/Driver/amdgpu-toolchain.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@
2424
// RUN: -L. -fconvergent-functions %s 2>&1 | FileCheck -check-prefix=MCPU %s
2525
// LTO: clang{{.*}} "-flto=full"{{.*}}"-fconvergent-functions"
2626
// MCPU: ld.lld{{.*}}"-L."{{.*}}"-plugin-opt=mcpu=gfx906"
27+
28+
// We do not suppor the BFD linker, but we should be able to override the
29+
// default even if it will error during linking.
30+
// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
31+
// RUN: -fuse-ld=bfd %s 2>&1 | FileCheck -check-prefixes=LD %s
32+
// LD: ld.bfd"

0 commit comments

Comments
 (0)