Skip to content

Commit 0dfb947

Browse files
authored
[Driver][SYCL] Do not emit mismatch warning with -fsycl-force-target (#17013)
The use of -fsycl-force-target=arg allows for a user to override the default target triple that is used to unbundle device objects from the fat objects. A diagnostic warning is emitted to inform the user that the expected target values within the given objects is not found. This diagnostic is not valid when -fsycl-force-target is used with the matching target value. Avoid emitting this warning when the -fsycl-force-target=arg matches what is found in the incoming objects.
1 parent 311fdc4 commit 0dfb947

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6488,6 +6488,20 @@ class OffloadingActionBuilder final {
64886488
break;
64896489
}
64906490
}
6491+
// Use of -fsycl-force-target=triple forces the compiler to use the
6492+
// specified target triple when extracting device code from any of
6493+
// the given objects on the command line. If the target specified
6494+
// in -fsycl-force-target is found in a fat object, do not emit the
6495+
// target mismatch warning.
6496+
if (const Arg *ForceTarget = C.getInputArgs().getLastArg(
6497+
options::OPT_fsycl_force_target_EQ)) {
6498+
StringRef Val(ForceTarget->getValue());
6499+
llvm::Triple TT(C.getDriver().getSYCLDeviceTriple(Val));
6500+
if (TT.normalize() == Section) {
6501+
SectionFound = true;
6502+
break;
6503+
}
6504+
}
64916505
}
64926506
if (SectionFound)
64936507
continue;

clang/test/Driver/sycl-target-mismatch.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@
2222
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen %S/Inputs/SYCL/liblin64.a \
2323
// RUN: -Wno-sycl-target -### %s 2>&1 \
2424
// RUN: | FileCheck %s -check-prefix=SPIR64_DIAG
25-
// SPIR64_DIAG-NOT: linked binaries do not contain expected
25+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen %S/Inputs/SYCL/liblin64.a \
26+
// RUN: -fsycl-force-target=spir64 -### %s 2>&1 \
27+
// RUN: | FileCheck %s -check-prefix=SPIR64_DIAG
28+
// SPIR64_DIAG-NOT: linked binaries do not contain expected {{.*}} target; found targets:

0 commit comments

Comments
 (0)