From 8d2d870247065a2a714dbc6496358964dd149ed4 Mon Sep 17 00:00:00 2001 From: Nick Sarnie Date: Sat, 9 Mar 2024 19:38:18 +0900 Subject: [PATCH] [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 --- clang/lib/Driver/ToolChains/SYCL.cpp | 9 ++++----- clang/test/Driver/sycl-no-rdc-win.cpp | 6 ++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index 03a88b9e89cf1..1beeda857857d 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -416,12 +416,11 @@ const char *SYCL::Linker::constructLLVMLinkCommand( auto isSYCLDeviceLib = [&](const InputInfo &II) { const ToolChain *HostTC = C.getSingleOffloadToolChain(); 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(); diff --git a/clang/test/Driver/sycl-no-rdc-win.cpp b/clang/test/Driver/sycl-no-rdc-win.cpp index d2f668f60ad55..02142c61f0603 100644 --- a/clang/test/Driver/sycl-no-rdc-win.cpp +++ b/clang/test/Driver/sycl-no-rdc-win.cpp @@ -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 \ No newline at end of file