Skip to content

Commit

Permalink
[Driver][SYCL] Do not emit mismatch warning with -fsycl-force-target (i…
Browse files Browse the repository at this point in the history
…ntel#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.
  • Loading branch information
mdtoguchi authored Feb 17, 2025
1 parent 311fdc4 commit 0dfb947
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 14 additions & 0 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6488,6 +6488,20 @@ class OffloadingActionBuilder final {
break;
}
}
// Use of -fsycl-force-target=triple forces the compiler to use the
// specified target triple when extracting device code from any of
// the given objects on the command line. If the target specified
// in -fsycl-force-target is found in a fat object, do not emit the
// target mismatch warning.
if (const Arg *ForceTarget = C.getInputArgs().getLastArg(
options::OPT_fsycl_force_target_EQ)) {
StringRef Val(ForceTarget->getValue());
llvm::Triple TT(C.getDriver().getSYCLDeviceTriple(Val));
if (TT.normalize() == Section) {
SectionFound = true;
break;
}
}
}
if (SectionFound)
continue;
Expand Down
5 changes: 4 additions & 1 deletion clang/test/Driver/sycl-target-mismatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen %S/Inputs/SYCL/liblin64.a \
// RUN: -Wno-sycl-target -### %s 2>&1 \
// RUN: | FileCheck %s -check-prefix=SPIR64_DIAG
// SPIR64_DIAG-NOT: linked binaries do not contain expected
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen %S/Inputs/SYCL/liblin64.a \
// RUN: -fsycl-force-target=spir64 -### %s 2>&1 \
// RUN: | FileCheck %s -check-prefix=SPIR64_DIAG
// SPIR64_DIAG-NOT: linked binaries do not contain expected {{.*}} target; found targets:

0 comments on commit 0dfb947

Please sign in to comment.