Skip to content

Commit 34092a3

Browse files
committed
[SYCL][Windows] Improve windows sycl.lib linking
This patch does two things, first it makes `-fsycl` ignore `-nostdlib` when linking the SYCL library. This is necessary because for Clang on Windows CMake will generate link commands using `-nostdlib` and explicitly list the system libraries, but of course it doesn't do it for SYCL, so we currently end up never linking the SYCL library when this is used. Ignoring `-nostdlib` for `-fsycl` on Windows seems like a reasonnable solution for this as this is also what is done for the OpenMP runtime libraries. See the CMake module: * https://github.com/Kitware/CMake/blob/aa2de7cd2a04699744a224ab84e0ca483559c5d3/Modules/Platform/Windows-Clang.cmake#L79 In addition this patch also adds a linker parameter to help clang find the `sycl.lib` file without requiring users to tweak their environments to link against it.
1 parent 43e713c commit 34092a3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clang/lib/Driver/ToolChains/MSVC.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,11 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
131131
CmdArgs.push_back("-defaultlib:oldnames");
132132
}
133133

134-
if ((!C.getDriver().IsCLMode() && !Args.hasArg(options::OPT_nostdlib) &&
135-
Args.hasArg(options::OPT_fsycl) &&
134+
if ((!C.getDriver().IsCLMode() && Args.hasArg(options::OPT_fsycl) &&
136135
!Args.hasArg(options::OPT_nolibsycl)) ||
137136
Args.hasArg(options::OPT_fsycl_host_compiler_EQ)) {
137+
CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
138+
TC.getDriver().Dir + "/../lib"));
138139
if (Args.hasArg(options::OPT__SLASH_MDd))
139140
CmdArgs.push_back("-defaultlib:sycld.lib");
140141
else

0 commit comments

Comments
 (0)