https://github.com/pvelesko updated 
https://github.com/llvm/llvm-project/pull/216938

>From 607dab5767199b4eef74b2b718a73e778e783f17 Mon Sep 17 00:00:00 2001
From: Paulius Velesko <[email protected]>
Date: Wed, 14 Oct 2026 05:35:21 +0300
Subject: [PATCH] [LinkerWrapper] Use a four component triple for the host
 bundle entry

clang-offload-bundler requires every bundle entry ID to be
`<kind>-<arch>-<vendor>-<os>-<env>`. The linker wrapper normalized the
host entry with the default canonical form, which does not guarantee
four components, so
`--host-triple=x86_64-apple-macosx15.0.0` produced
`-targets=host-x86_64-apple-macosx15.0.0` and the bundler rejected it
with "Targets need to follow the format '<offload kind>-<target
triple>'".

Normalize it with `CanonicalForm::FOUR_IDENT`, as the driver already
does for the host entry it hands the bundler.
---
 .../clang-linker-wrapper/linker-wrapper-hip-host-triple.c | 8 ++++++++
 clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp   | 3 ++-
 2 files changed, 10 insertions(+), 1 deletion(-)
 create mode 100644 
clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper-hip-host-triple.c

diff --git 
a/clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper-hip-host-triple.c 
b/clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper-hip-host-triple.c
new file mode 100644
index 00000000000000..675fa06ddd41d7
--- /dev/null
+++ 
b/clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper-hip-host-triple.c
@@ -0,0 +1,8 @@
+// The host bundle entry must be a four component triple.
+
+// RUN: llvm-offload-binary -o %t.out \
+// RUN:   --image=file=%s,kind=hip,triple=amdgpu9.0a-amd-amdhsa,arch=gfx90a
+// RUN: clang-linker-wrapper --dry-run --host-triple=x86_64-apple-macosx15.0.0 
\
+// RUN:   --emit-fatbin-only %t.out -o %t.hipfb 2>&1 | FileCheck %s
+
+// CHECK: clang-offload-bundler{{.*}} 
-targets=host-x86_64-apple-macosx15.0.0-unknown,hip-amdgcn-amd-amdhsa--gfx90a
diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 069ac3d23c643f..3e262ff3219c01 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -451,7 +451,8 @@ fatbinary(ArrayRef<std::tuple<StringRef, StringRef, 
StringRef>> InputFiles,
   llvm::Triple HostTriple(
       Args.getLastArgValue(OPT_host_triple_EQ, sys::getDefaultTargetTriple()));
   SmallVector<StringRef> Targets = {
-      Saver.save("-targets=host-" + HostTriple.normalize())};
+      Saver.save("-targets=host-" +
+                 HostTriple.normalize(Triple::CanonicalForm::FOUR_IDENT))};
   for (const auto &[File, TripleRef, Arch] : InputFiles) {
     std::string NormalizedTriple =
         clang::normalizeForBundler(Triple(TripleRef), Arch);

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to