https://github.com/pvelesko updated https://github.com/llvm/llvm-project/pull/216938
>From dd122b90499e3e7944fa06c6cc01beafa8a6b2b9 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 keeps however many components the host triple was spelled with, 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. --- .../OffloadTools/clang-linker-wrapper/linker-wrapper.c | 8 ++++++++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper.c b/clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper.c index 550cab4b0604d..bb6e29c096715 100644 --- a/clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper.c +++ b/clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper.c @@ -133,6 +133,14 @@ __attribute__((visibility("protected"), used)) int x; // HIP: clang{{.*}} -o [[IMG_GFX908:.+]] -dumpdir a.out.amdgpu9.08.gfx908.img. --target=amdgpu9.08-amd-amdhsa -mcpu=gfx908 // HIP: clang-offload-bundler{{.*}}-type=o -bundle-align=4096 -compress -compression-level=6 -targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa--gfx90a,hip-amdgcn-amd-amdhsa--gfx908 -input={{/dev/null|NUL}} -input=[[IMG_GFX90A]] -input=[[IMG_GFX908]] -output={{.*}}.hipfb +// RUN: llvm-offload-binary -o %t.out \ +// RUN: --image=file=%t.elf.o,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 \ +// RUN: | FileCheck %s --check-prefix=HIP-HOST-TRIPLE + +// HIP-HOST-TRIPLE: clang-offload-bundler{{.*}} -targets=host-x86_64-apple-macosx15.0.0-unknown,hip-amdgcn-amd-amdhsa--gfx90a + // RUN: llvm-offload-binary -o %t.out \ // RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgpu9.08-amd-amdhsa,arch=gfx908 \ // RUN: --image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index 069ac3d23c643..3e262ff3219c0 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
