Skip to content

[Driver][SYCL] Do not emit mismatch warning with -fsycl-force-target #17013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 17, 2025
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
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 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think passing %S/Inputs/SYCL/liblin64.a and ### is not necessary here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The passing of liblin64.a is necessary, it represents the binary that contains the spir64-unknown-unknown bundled fat object that should trigger the diagnostic due to -fsycl-targets=spir64_gen.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the documentation , my understanding is, when we invoke,

icx -fsycl -fsycl-targets=spir64_gen -fsycl-force-target=spir64

spir64 objects/archives will be extracted but spir64_gen targets will still compile.

I dont see the spir64 archive explicitly passed to the compiler.

Also, since we are checking if a diagnostic is being thrown or not, do we need to pass -### ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation doesn't show a full command line, it just demonstrates how the options work together - it probably should be updated to be a little clearer.

The use of -### ensures that only the driver is invoked here. Without it, we would run additional tools that aren't necessary since we are only checking a diagnostic from the driver.

// 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: