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

[SYCL][Driver] Fix Windows CL SYCL device library detection logic #12947

Merged
merged 2 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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())
Comment on lines +421 to +422
Copy link
Contributor

Choose a reason for hiding this comment

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

I know that this was already there - but it seems redundant. Would this be sufficient?

Suggested change
else if (HostTC->getTriple().isWindowsMSVCEnvironment() &&
C.getDriver().IsCLMode())
else if (HostTC->getTriple().isWindowsMSVCEnvironment())

Copy link
Contributor Author

@sarnex sarnex Mar 8, 2024

Choose a reason for hiding this comment

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

Do we always use CL mode on windows for all possible compiler executables (icpx, dpcpp, clang, etc)? I thought some of them had different effects (like even with the same oneapi install, calling icpx vs clang++ in the compiler folder would set different flags like fastmath/inining/etc, and I thought CL mode might be one of them). If Windows doesn't always use CL mode or if we aren't sure I would prefer not to change this in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

CL mode is tied to clang-cl, which is used on Windows in general. It also implies MSVC based targets (even when invoked on Linux). But of course, you can target MSVC with clang++ if you wanted, and vice-versa. Usage of clang++ on Windows also implies MSVC. I think this may cause a disconnect here. I'm fine with leaving it here and looking into an update later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, let me know if I should make an internal tracker for followup.

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, "host-sycl (x86_64-pc-windows-msvc)" {{{.*}}}, "device-sycl (spir64-unknown-unknown)" {90}, "device-sycl (spir64-unknown-unknown)" {96}, image

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