Skip to content
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

[Driver][SYCL] Do not perform link step with -fsycl-link-targets #13004

Merged
merged 1 commit into from
Mar 19, 2024
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
7 changes: 4 additions & 3 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5047,8 +5047,6 @@ class OffloadingActionBuilder final {
// action or fat binary.
SYCLDeviceActions.clear();

for (auto SDA : SYCLDeviceActions)
SYCLLinkBinaryList.push_back(SDA);
if (WrapDeviceOnlyBinary)
return ABRT_Success;
auto *Link =
Expand Down Expand Up @@ -7512,9 +7510,12 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
}

// Add a link action if necessary.
// When offloading with -fsycl-link-targets, no link action is processed
// as we stop at the spirv-translation step.
Arg *FinalPhaseArg;
if (!UseNewOffloadingDriver &&
getFinalPhase(Args, &FinalPhaseArg) == phases::Link) {
getFinalPhase(Args, &FinalPhaseArg) == phases::Link &&
!Args.hasArg(options::OPT_fsycl_link_targets_EQ)) {
if (LinkerInputs.empty() && DeviceAOTLinkerInputs.empty())
OffloadBuilder->appendDeviceLinkActions(Actions);

Expand Down
8 changes: 8 additions & 0 deletions clang/test/Driver/sycl-link-add-targets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@
// CHK-LINK-TARGETS-UB: 2: linker, {1}, image, (device-sycl)
// CHK-LINK-TARGETS-UB: 3: llvm-spirv, {2}, image, (device-sycl)
// CHK-LINK-TARGETS-UB: 4: offload, "device-sycl (spir64-unknown-unknown)" {3}, image
// CHK-LINK-TARGETS-UB-NOT: offload

// RUN: %clangxx -ccc-print-bindings --target=x86_64-unknown-linux-gnu \
// RUN: -fsycl -o checkme.out -fsycl-link-targets=spir64 %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-LINK-TARGETS-BINDINGS %s
// CHK-LINK-TARGETS-BINDINGS: "spir64-unknown-unknown" - "clang", inputs: [{{.*}}], output: "[[IR_OUTPUT_BC:.+\.bc]]"
// CHK-LINK-TARGETS-BINDINGS: "spir64-unknown-unknown" - "SYCL::Linker", inputs: ["[[IR_OUTPUT_BC]]"], output: "[[LLVM_LINK_OUTPUT:.+\.out]]"
// CHK-LINK-TARGETS-BINDINGS: "spir64-unknown-unknown" - "SPIR-V translator", inputs: ["[[LLVM_LINK_OUTPUT]]"], output: "checkme.out"

/// Check -fsycl-link-targets=<triple> behaviors unbundle multiple objects
// RUN: touch %t-a.o
Expand Down
Loading