Skip to content

Commit 8d2d870

Browse files
authored
[SYCL][Driver] Fix Windows CL SYCL device library detection logic (#12947)
If it's no RDC, the extension will definitely be BC. We need to switch the condition order. Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 200694b commit 8d2d870

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,12 +416,11 @@ const char *SYCL::Linker::constructLLVMLinkCommand(
416416
auto isSYCLDeviceLib = [&](const InputInfo &II) {
417417
const ToolChain *HostTC = C.getSingleOffloadToolChain<Action::OFK_Host>();
418418
StringRef LibPostfix = ".o";
419-
if (HostTC->getTriple().isWindowsMSVCEnvironment() &&
420-
C.getDriver().IsCLMode())
421-
LibPostfix = ".obj";
422-
else if (isNoRDCDeviceCodeLink(II))
419+
if (isNoRDCDeviceCodeLink(II))
423420
LibPostfix = ".bc";
424-
421+
else if (HostTC->getTriple().isWindowsMSVCEnvironment() &&
422+
C.getDriver().IsCLMode())
423+
LibPostfix = ".obj";
425424
std::string FileName = this->getToolChain().getInputFilename(II);
426425
StringRef InputFilename = llvm::sys::path::filename(FileName);
427426
const bool IsNVPTX = this->getToolChain().getTriple().isNVPTX();

clang/test/Driver/sycl-no-rdc-win.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,9 @@
3232
// CHECK: 96: clang-offload-wrapper, {95}, object, (device-sycl)
3333
// CHECK: 97: offload, "device-sycl (spir64-unknown-unknown)" {96}, object
3434
// CHECK: 98: linker, {9, 19, 90, 97}, image, (host-sycl)
35+
36+
// 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
37+
// 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
38+
// CHECK-EARLY: llvm-link{{.*}}
39+
// CHECK-EARLY-NOT: -only-needed
40+
// CHECK-EARLY: llvm-link{{.*}}-only-needed

0 commit comments

Comments
 (0)