Skip to content

Commit 53e3d8a

Browse files
authored
[Driver][SYCL] Do not emit target not found warning for early images (#12035)
For any objects/libraries created with -fno-sycl-rdc -c, we should not emit the 'linked binaries do not contain expected target' warning diagnostic. Expected use model is to not provide any specific targets to allow consuming of these objects/libraries.
1 parent fab8e8c commit 53e3d8a

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6145,6 +6145,27 @@ class OffloadingActionBuilder final {
61456145
if (std::find(UniqueSections.begin(), UniqueSections.end(),
61466146
SectionTriple) != UniqueSections.end())
61476147
continue;
6148+
// If any section found is an 'image' based object that was created
6149+
// with the intention of not requiring the matching SYCL target, do
6150+
// not emit the diagnostic.
6151+
if (SyclTarget.TC->getTriple().isSPIR()) {
6152+
bool SectionFound = false;
6153+
for (auto Section : UniqueSections) {
6154+
if (SectionFound)
6155+
break;
6156+
SmallVector<std::string, 3> ArchList = {"spir64_gen", "spir64_fpga",
6157+
"spir64_x86_64"};
6158+
for (auto ArchStr : ArchList) {
6159+
std::string Arch(ArchStr + "_image");
6160+
if (Section.find(Arch) != std::string::npos) {
6161+
SectionFound = true;
6162+
break;
6163+
}
6164+
}
6165+
}
6166+
if (SectionFound)
6167+
continue;
6168+
}
61486169
// Didn't find any matches, return the full list for the diagnostic.
61496170
SmallString<128> ArchListStr;
61506171
int Cnt = 0;

clang/test/Driver/sycl-early-device-link.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,13 @@
121121
// RUN: %clangxx -fsycl --target=x86_64-unknown-linux-gnu -### \
122122
// RUN: %S/Inputs/SYCL/objgenimage.o %s 2>&1 \
123123
// RUN: | FileCheck %s -check-prefix=CONSUME_OBJ
124+
// CONSUME_OBJ-NOT: linked binaries do not contain expected
124125
// CONSUME_OBJ: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64_gen_image-unknown-unknown" "-input={{.*}}objgenimage.o" "-output=[[DEVICE_IMAGE_OBJ:.+\.o]]
125126
// CONSUME_OBJ: ld{{.*}} "[[DEVICE_IMAGE_OBJ]]"
126127

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

0 commit comments

Comments
 (0)