Skip to content

Commit

Permalink
[SYCL][Driver] Fix Windows CL SYCL device library detection logic (#1…
Browse files Browse the repository at this point in the history
…2947)

If it's no RDC, the extension will definitely be BC. We need to switch
the condition order.

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
  • Loading branch information
sarnex authored Mar 9, 2024
1 parent 200694b commit 8d2d870
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 4 additions & 5 deletions clang/lib/Driver/ToolChains/SYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,11 @@ const char *SYCL::Linker::constructLLVMLinkCommand(
auto isSYCLDeviceLib = [&](const InputInfo &II) {
const ToolChain *HostTC = C.getSingleOffloadToolChain<Action::OFK_Host>();
StringRef LibPostfix = ".o";
if (HostTC->getTriple().isWindowsMSVCEnvironment() &&
C.getDriver().IsCLMode())
LibPostfix = ".obj";
else if (isNoRDCDeviceCodeLink(II))
if (isNoRDCDeviceCodeLink(II))
LibPostfix = ".bc";

else if (HostTC->getTriple().isWindowsMSVCEnvironment() &&
C.getDriver().IsCLMode())
LibPostfix = ".obj";
std::string FileName = this->getToolChain().getInputFilename(II);
StringRef InputFilename = llvm::sys::path::filename(FileName);
const bool IsNVPTX = this->getToolChain().getTriple().isNVPTX();
Expand Down
6 changes: 6 additions & 0 deletions clang/test/Driver/sycl-no-rdc-win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@
// CHECK: 96: clang-offload-wrapper, {95}, object, (device-sycl)
// CHECK: 97: offload, "device-sycl (spir64-unknown-unknown)" {96}, object
// CHECK: 98: linker, {9, 19, 90, 97}, image, (host-sycl)

// RUN: %clang -### -fsycl -fno-sycl-rdc -c -fsycl-targets=spir64_gen --sysroot=%S/Inputs/SYCL-windows %t1.cpp 2>&1 | FileCheck -check-prefix=CHECK-EARLY %s
// RUN: %clang_cl -### -fsycl -fno-sycl-rdc -c -fsycl-targets=spir64_gen /clang:--sysroot=%S/Inputs/SYCL-windows %t1.cpp 2>&1 | FileCheck -check-prefix=CHECK-EARLY %s
// CHECK-EARLY: llvm-link{{.*}}
// CHECK-EARLY-NOT: -only-needed
// CHECK-EARLY: llvm-link{{.*}}-only-needed

0 comments on commit 8d2d870

Please sign in to comment.