Skip to content

Commit 71a0980

Browse files
authored
[SYCL][opencl-aot][CMake][MSVC]: Wrap Linker flags for ICX (#15756)
From CMake 3.25+ linker options need to be wrapped for ICX on Windows. Use the `LINKER:` prefix, which expands to the correct option for ICX, and for the empty string for MSVC or clang-cl. See also LLVM RFC: https://discourse.llvm.org/t/rfc-cmake-linker-flags-need-wl-equivalent-for-intel-c-icx-on-windows/82446 Fixes: #15755
1 parent e20373d commit 71a0980

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

opencl/opencl-aot/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ add_llvm_tool(${OPENCL_AOT_PROJECT_NAME} ${TARGET_SOURCES})
1414

1515
if (WIN32)
1616
# 0x2000: exclude CWD from DLL loading path
17-
target_link_options(${OPENCL_AOT_PROJECT_NAME} PRIVATE "/DEPENDENTLOADFLAG:0x2000")
17+
target_link_options(${OPENCL_AOT_PROJECT_NAME} PRIVATE "LINKER:/DEPENDENTLOADFLAG:0x2000")
1818
endif()
1919

2020
if(NOT MSVC)

sycl/cmake/modules/SYCLUtils.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ include(CheckLinkerFlag)
77
# file as ${ARG_TARGET_NAME}.pdb in bin folder.
88
# NOTE: LLD does not currently support /PDBSTRIPPED so the PDB file is optional.
99
macro(add_stripped_pdb ARG_TARGET_NAME)
10-
check_linker_flag(CXX "/PDBSTRIPPED:${ARG_TARGET_NAME}.stripped.pdb"
10+
check_linker_flag(CXX "LINKER:/PDBSTRIPPED:${ARG_TARGET_NAME}.stripped.pdb"
1111
LINKER_SUPPORTS_PDBSTRIPPED)
1212
if(LINKER_SUPPORTS_PDBSTRIPPED)
1313
target_link_options(${ARG_TARGET_NAME}
14-
PRIVATE "/PDBSTRIPPED:${ARG_TARGET_NAME}.stripped.pdb")
14+
PRIVATE "LINKER:/PDBSTRIPPED:${ARG_TARGET_NAME}.stripped.pdb")
1515
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${ARG_TARGET_NAME}.stripped.pdb"
1616
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
1717
RENAME "${ARG_TARGET_NAME}.pdb"

sycl/source/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME)
9191
# Embed manifest into the sycl.dll where ur_win_proxy_loader.dll is described as sycl.dll's private dll and will always be loaded from the same directory.
9292
# 0x2000: LOAD_LIBRARY_SAFE_CURRENT_DIRS flag. Using this flag means that loading dependency DLLs (of sycl.dll)
9393
# from the current directory is only allowed if it is under a directory in the Safe load list.
94-
target_link_options(${LIB_NAME} PRIVATE /DEPENDENTLOADFLAG:0x2000 /MANIFEST:NO /MANIFEST:EMBED /MANIFESTINPUT:${CMAKE_CURRENT_SOURCE_DIR}/${MANIFEST_FILE_NAME})
94+
target_link_options(${LIB_NAME} PRIVATE "LINKER:/DEPENDENTLOADFLAG:0x2000" "LINKER:/MANIFEST:NO" "LINKER:/MANIFEST:EMBED" "LINKER:/MANIFESTINPUT:${CMAKE_CURRENT_SOURCE_DIR}/${MANIFEST_FILE_NAME}")
9595
endif()
9696

9797
target_compile_definitions(${LIB_OBJ_NAME} PRIVATE __SYCL_INTERNAL_API )

sycl/tools/sycl-ls/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ target_link_libraries(sycl-ls
1919
)
2020
if (WIN32)
2121
# 0x900: Search for the dependency DLLs only in the System32 directory and in the directory with sycl-ls.exe
22-
target_link_options(sycl-ls PRIVATE /DEPENDENTLOADFLAG:0x900)
22+
target_link_options(sycl-ls PRIVATE LINKER:/DEPENDENTLOADFLAG:0x900)
2323
endif()
2424
install(TARGETS sycl-ls
2525
RUNTIME DESTINATION "bin" COMPONENT sycl-ls)

sycl/ur_win_proxy_loader/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ if (MSVC)
6060
target_link_libraries(ur_win_proxy_loader PRIVATE shlwapi)
6161
# 0x2000: LOAD_LIBRARY_SAFE_CURRENT_DIRS flag. Using this flag means that loading dependency DLLs
6262
# from the current directory is only allowed if it is under a directory in the Safe load list.
63-
target_link_options(ur_win_proxy_loaderd PRIVATE /DEPENDENTLOADFLAG:0x2000)
64-
target_link_options(ur_win_proxy_loader PRIVATE /DEPENDENTLOADFLAG:0x2000)
63+
target_link_options(ur_win_proxy_loaderd PRIVATE LINKER:/DEPENDENTLOADFLAG:0x2000)
64+
target_link_options(ur_win_proxy_loader PRIVATE LINKER:/DEPENDENTLOADFLAG:0x2000)
6565
install(TARGETS ur_win_proxy_loaderd
6666
RUNTIME DESTINATION "bin" COMPONENT ur_win_proxy_loader)
6767
endif()

0 commit comments

Comments
 (0)