Skip to content

Commit 86a26c5

Browse files
Apply work-around for sycl-device-code-split to apply on Windows
In cmake 3.22 using target_link_options result in option inserted in LINK_FLAGS which places it after -link option and passed directly to the underlying linker where it is ignored. This is fixed in cmake 3.25 Also make sure to apply -fsycl-link-huge-device-code on Linux only, the option is not supported on Windows.
1 parent 13e83f4 commit 86a26c5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

dpctl/tensor/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ add_custom_target(_dpctl4pybind11_deps
1515
_sycl_event_copy_capi_include
1616
)
1717

18+
if(WIN32)
19+
if (${CMAKE_VERSION} VERSION_LESS "3.23")
20+
# this is a work-around for target_link_options inserting option after -link option, cause
21+
# linker to ignore it.
22+
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -fsycl-device-code-split=per_kernel")
23+
endif()
24+
endif()
25+
1826
set(python_module_name _tensor_impl)
1927
pybind11_add_module(${python_module_name} MODULE
2028
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/tensor_py.cpp
@@ -29,7 +37,10 @@ pybind11_add_module(${python_module_name} MODULE
2937
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/device_support_queries.cpp
3038
)
3139
target_link_options(${python_module_name} PRIVATE -fsycl-device-code-split=per_kernel)
32-
target_link_options(${python_module_name} PRIVATE -fsycl-link-huge-device-code)
40+
if(UNIX)
41+
# this option is support on Linux only
42+
target_link_options(${python_module_name} PRIVATE -fsycl-link-huge-device-code)
43+
endif()
3344
target_include_directories(${python_module_name}
3445
PRIVATE
3546
${CMAKE_CURRENT_SOURCE_DIR}/../include

0 commit comments

Comments
 (0)