Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6145,6 +6145,27 @@ class OffloadingActionBuilder final {
if (std::find(UniqueSections.begin(), UniqueSections.end(),
SectionTriple) != UniqueSections.end())
continue;
// If any section found is an 'image' based object that was created
// with the intention of not requiring the matching SYCL target, do
// not emit the diagnostic.
if (SyclTarget.TC->getTriple().isSPIR()) {
bool SectionFound = false;
for (auto Section : UniqueSections) {
if (SectionFound)
break;
SmallVector<std::string, 3> ArchList = {"spir64_gen", "spir64_fpga",
"spir64_x86_64"};
for (auto ArchStr : ArchList) {
std::string Arch(ArchStr + "_image");
if (Section.find(Arch) != std::string::npos) {
SectionFound = true;
break;
}
}
}
if (SectionFound)
continue;
}
// Didn't find any matches, return the full list for the diagnostic.
SmallString<128> ArchListStr;
int Cnt = 0;
Expand Down
2 changes: 2 additions & 0 deletions clang/test/Driver/sycl-early-device-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,13 @@
// RUN: %clangxx -fsycl --target=x86_64-unknown-linux-gnu -### \
// RUN: %S/Inputs/SYCL/objgenimage.o %s 2>&1 \
// RUN: | FileCheck %s -check-prefix=CONSUME_OBJ
// CONSUME_OBJ-NOT: linked binaries do not contain expected
// CONSUME_OBJ: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64_gen_image-unknown-unknown" "-input={{.*}}objgenimage.o" "-output=[[DEVICE_IMAGE_OBJ:.+\.o]]
// CONSUME_OBJ: ld{{.*}} "[[DEVICE_IMAGE_OBJ]]"

// RUN: %clangxx -fsycl --target=x86_64-unknown-linux-gnu -### \
// RUN: %S/Inputs/SYCL/libgenimage.a %s 2>&1 \
// RUN: | FileCheck %s -check-prefix=CONSUME_LIB
// CONSUME_LIB-NOT: linked binaries do not contain expected
// CONSUME_LIB: clang-offload-bundler{{.*}} "-type=aoo" "-targets=sycl-spir64_gen_image-unknown-unknown" "-input={{.*}}libgenimage.a" "-output=[[DEVICE_IMAGE_LIB:.+\.txt]]
// CONSUME_LIB: ld{{.*}} "@[[DEVICE_IMAGE_LIB]]"