[clang] 20d253e - [LinkerWrapper] Fix linker-wrapper not working with host-LTO

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 13 09:32:17 PDT 2022


Author: Joseph Huber
Date: 2022-07-13T12:32:02-04:00
New Revision: 20d253e3bf69494e670ad529b311948a21caf783

URL: https://github.com/llvm/llvm-project/commit/20d253e3bf69494e670ad529b311948a21caf783
DIFF: https://github.com/llvm/llvm-project/commit/20d253e3bf69494e670ad529b311948a21caf783.diff

LOG: [LinkerWrapper] Fix linker-wrapper not working with host-LTO

Added: 
    

Modified: 
    clang/test/Driver/linker-wrapper.c
    clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/Driver/linker-wrapper.c b/clang/test/Driver/linker-wrapper.c
index 21a811e85a375..1c0b8b0293dec 100644
--- a/clang/test/Driver/linker-wrapper.c
+++ b/clang/test/Driver/linker-wrapper.c
@@ -11,6 +11,15 @@
 
 // NVPTX_LINK: nvlink{{.*}}-m64 -o {{.*}}.out -arch sm_70 {{.*}}.o {{.*}}.o
 
+// RUN: clang-offload-packager -o %t.out \
+// RUN:   --image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
+// RUN:   --image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o %t.o -fembed-offload-object=%t.out
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
+// RUN:   --linker-path=/usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=HOST_BC
+
+// HOST_BC: nvlink{{.*}}-m64 -o {{.*}}.out -arch sm_70 {{.*}}.o {{.*}}.o
+
 // RUN: clang-offload-packager -o %t.out \
 // RUN:   --image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
 // RUN:   --image=file=%S/Inputs/dummy-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 78a03d2091ce7..898fa71d30e35 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -336,7 +336,7 @@ Error extractFromBitcode(std::unique_ptr<MemoryBuffer> Buffer,
 
   // Extract offloading data from globals referenced by the
   // `llvm.embedded.object` metadata with the `.llvm.offloading` section.
-  auto *MD = M->getNamedMetadata("llvm.embedded.object");
+  auto *MD = M->getNamedMetadata("llvm.embedded.objects");
   if (!MD)
     return Error::success();
 


        


More information about the cfe-commits mailing list