[clang] [Clang] Permit '--target=amdgcn--' for binaries (PR #191451)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 10 09:00:15 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Joseph Huber (jhuber6)
<details>
<summary>Changes</summary>
Summary:
We always accepted `--target=amdgcn--` to create IR object files but it
doesn't allow creating actual binaries without user intervention. This
is because it would fall-through to the GCC toolchain which does not
know how to handle AMGCN / AMDGPU targets. This PR just adds a single
line to handle it, which effectively allows this as a 'bare' target.
Perhaps the argument could be made that AMDGPU should not support
anything but strictly HSA because it has many assumptions in the
compiler itself, such as implicit arguments, but I feel like it is
relatively harmless to support this case if users decide they really do
not need it.
---
Full diff: https://github.com/llvm/llvm-project/pull/191451.diff
3 Files Affected:
- (modified) clang/lib/Driver/Driver.cpp (+4)
- (modified) clang/test/Driver/amdgpu-features.c (+2-2)
- (modified) clang/test/Driver/amdgpu-toolchain.c (+4)
``````````diff
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e3e4485c73690..c66b5915917d4 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -7198,6 +7198,10 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
case llvm::Triple::csky:
TC = std::make_unique<toolchains::CSKYToolChain>(*this, Target, Args);
break;
+ case llvm::Triple::amdgcn:
+ case llvm::Triple::r600:
+ TC = std::make_unique<toolchains::AMDGPUToolChain>(*this, Target, Args);
+ break;
default:
if (toolchains::BareMetal::handlesTarget(Target))
TC = std::make_unique<toolchains::BareMetal>(*this, Target, Args);
diff --git a/clang/test/Driver/amdgpu-features.c b/clang/test/Driver/amdgpu-features.c
index 864744db203e9..c756b91379180 100644
--- a/clang/test/Driver/amdgpu-features.c
+++ b/clang/test/Driver/amdgpu-features.c
@@ -10,8 +10,8 @@
// RUN: %clang -### --target=amdgcn-amdhsa -mcpu=gfx908:sramecc- -nogpulib %s 2>&1 | FileCheck --check-prefix=NO-SRAM-ECC %s
// NO-SRAM-ECC: "-target-feature" "-sramecc"
-// RUN: %clang -### -target amdgcn -mcpu=gfx90A -mtgsplit %s 2>&1 | FileCheck --check-prefix=TGSPLIT %s
-// RUN: %clang -### -target amdgcn -mcpu=gfx90A -mno-tgsplit %s 2>&1 | FileCheck --check-prefix=NO-TGSPLIT %s
+// RUN: %clang -### -target amdgcn -mcpu=gfx90a -mtgsplit %s 2>&1 | FileCheck --check-prefix=TGSPLIT %s
+// RUN: %clang -### -target amdgcn -mcpu=gfx90a -mno-tgsplit %s 2>&1 | FileCheck --check-prefix=NO-TGSPLIT %s
// TGSPLIT: "-target-feature" "+tgsplit"
// NO-TGSPLIT: "-target-feature" "-tgsplit"
diff --git a/clang/test/Driver/amdgpu-toolchain.c b/clang/test/Driver/amdgpu-toolchain.c
index 2a48ca6bb7670..0693263947543 100644
--- a/clang/test/Driver/amdgpu-toolchain.c
+++ b/clang/test/Driver/amdgpu-toolchain.c
@@ -4,10 +4,14 @@
// RUN: %clang -### -g --target=amdgcn-amd-amdpal -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
// RUN: %clang -### --target=amdgcn-mesa-mesa3d -x assembler -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=AS_LINK %s
// RUN: %clang -### -g --target=amdgcn-mesa-mesa3d -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
+// RUN: %clang -### --target=amdgcn-- -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=BARE %s
+// RUN: %clang -### -g --target=amdgcn-- -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
// AS_LINK: "-cc1as"
// AS_LINK: ld.lld{{.*}} "--no-undefined" "-shared"
+// BARE: ld.lld{{.*}} "--no-undefined" "-shared"
+
// DWARF_VER: "-dwarf-version=5"
// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
``````````
</details>
https://github.com/llvm/llvm-project/pull/191451
More information about the cfe-commits
mailing list