Skip to content

Commit 1ffbe8c

Browse files
author
Vyacheslav Zakharin
committed
[clang-offload-wrapper] Disabled ELF offload notes embedding by default.
This change-set puts 93d08ac functionality under -add-omp-offload-notes switch that is OFF by default. CUDA toolchain is not able to handle ELF images with LLVMOMPOFFLOAD notes for unknown reason (see https://reviews.llvm.org/D99551#2950272). I disable the ELF notes embedding until the CUDA issue is triaged and resolved. Differential Revision: https://reviews.llvm.org/D108246
1 parent 8c2ff7b commit 1ffbe8c

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

clang/test/Driver/clang-offload-wrapper.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//
2020
// Check bitcode produced by the wrapper tool.
2121
//
22-
// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.bc %t.tgt 2>&1 | FileCheck %s --check-prefix ELF-WARNING
22+
// RUN: clang-offload-wrapper -add-omp-offload-notes -target=x86_64-pc-linux-gnu -o %t.wrapper.bc %t.tgt 2>&1 | FileCheck %s --check-prefix ELF-WARNING
2323
// RUN: llvm-dis %t.wrapper.bc -o - | FileCheck %s --check-prefix CHECK-IR
2424

2525
// ELF-WARNING: is not an ELF image, so notes cannot be added to it.
@@ -58,16 +58,16 @@
5858
// Check that clang-offload-wrapper adds LLVMOMPOFFLOAD notes
5959
// into the ELF offload images:
6060
// RUN: yaml2obj %S/Inputs/empty-elf-template.yaml -o %t.64le -DBITS=64 -DENCODING=LSB
61-
// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.elf64le.bc %t.64le
61+
// RUN: clang-offload-wrapper -add-omp-offload-notes -target=x86_64-pc-linux-gnu -o %t.wrapper.elf64le.bc %t.64le
6262
// RUN: llvm-dis %t.wrapper.elf64le.bc -o - | FileCheck %s --check-prefix OMPNOTES
6363
// RUN: yaml2obj %S/Inputs/empty-elf-template.yaml -o %t.64be -DBITS=64 -DENCODING=MSB
64-
// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.elf64be.bc %t.64be
64+
// RUN: clang-offload-wrapper -add-omp-offload-notes -target=x86_64-pc-linux-gnu -o %t.wrapper.elf64be.bc %t.64be
6565
// RUN: llvm-dis %t.wrapper.elf64be.bc -o - | FileCheck %s --check-prefix OMPNOTES
6666
// RUN: yaml2obj %S/Inputs/empty-elf-template.yaml -o %t.32le -DBITS=32 -DENCODING=LSB
67-
// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.elf32le.bc %t.32le
67+
// RUN: clang-offload-wrapper -add-omp-offload-notes -target=x86_64-pc-linux-gnu -o %t.wrapper.elf32le.bc %t.32le
6868
// RUN: llvm-dis %t.wrapper.elf32le.bc -o - | FileCheck %s --check-prefix OMPNOTES
6969
// RUN: yaml2obj %S/Inputs/empty-elf-template.yaml -o %t.32be -DBITS=32 -DENCODING=MSB
70-
// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.elf32be.bc %t.32be
70+
// RUN: clang-offload-wrapper -add-omp-offload-notes -target=x86_64-pc-linux-gnu -o %t.wrapper.elf32be.bc %t.32be
7171
// RUN: llvm-dis %t.wrapper.elf32be.bc -o - | FileCheck %s --check-prefix OMPNOTES
7272

7373
// There is no clean way for extracting the offload image

clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ static cl::opt<bool> SaveTemps(
7676
"This option forces print-out of the temporary files' names."),
7777
cl::Hidden);
7878

79+
static cl::opt<bool> AddOpenMPOffloadNotes(
80+
"add-omp-offload-notes",
81+
cl::desc("Add LLVMOMPOFFLOAD ELF notes to ELF device images."), cl::Hidden);
82+
7983
namespace {
8084

8185
class BinaryWrapper {
@@ -630,7 +634,7 @@ int main(int argc, const char **argv) {
630634
return 1;
631635
}
632636
std::unique_ptr<MemoryBuffer> Buffer(std::move(*BufOrErr));
633-
if (File != "-") {
637+
if (File != "-" && AddOpenMPOffloadNotes) {
634638
// Adding ELF notes for STDIN is not supported yet.
635639
Buffer = Wrapper.addELFNotes(std::move(Buffer), File);
636640
}

0 commit comments

Comments
 (0)