From 440a8d4617857d67d47c8540ae5d4df37bf8fe72 Mon Sep 17 00:00:00 2001 From: Gergely Meszaros Date: Fri, 18 Oct 2024 07:20:18 -0700 Subject: [PATCH] [opencl-aot][sycl][CMake][MSVC]: Wrap Linker flags for ICX 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 --- opencl/opencl-aot/CMakeLists.txt | 2 +- sycl/cmake/modules/SYCLUtils.cmake | 4 ++-- sycl/source/CMakeLists.txt | 2 +- sycl/tools/sycl-ls/CMakeLists.txt | 2 +- sycl/ur_win_proxy_loader/CMakeLists.txt | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/opencl/opencl-aot/CMakeLists.txt b/opencl/opencl-aot/CMakeLists.txt index 7dc9d78001a5d..732da7b1e273c 100644 --- a/opencl/opencl-aot/CMakeLists.txt +++ b/opencl/opencl-aot/CMakeLists.txt @@ -14,7 +14,7 @@ add_llvm_tool(${OPENCL_AOT_PROJECT_NAME} ${TARGET_SOURCES}) if (WIN32) # 0x2000: exclude CWD from DLL loading path - target_link_options(${OPENCL_AOT_PROJECT_NAME} PRIVATE "/DEPENDENTLOADFLAG:0x2000") + target_link_options(${OPENCL_AOT_PROJECT_NAME} PRIVATE "LINKER:/DEPENDENTLOADFLAG:0x2000") endif() if(NOT MSVC) diff --git a/sycl/cmake/modules/SYCLUtils.cmake b/sycl/cmake/modules/SYCLUtils.cmake index f44b7c9d5ba7e..f469b26047605 100644 --- a/sycl/cmake/modules/SYCLUtils.cmake +++ b/sycl/cmake/modules/SYCLUtils.cmake @@ -7,11 +7,11 @@ include(CheckLinkerFlag) # file as ${ARG_TARGET_NAME}.pdb in bin folder. # NOTE: LLD does not currently support /PDBSTRIPPED so the PDB file is optional. macro(add_stripped_pdb ARG_TARGET_NAME) - check_linker_flag(CXX "/PDBSTRIPPED:${ARG_TARGET_NAME}.stripped.pdb" + check_linker_flag(CXX "LINKER:/PDBSTRIPPED:${ARG_TARGET_NAME}.stripped.pdb" LINKER_SUPPORTS_PDBSTRIPPED) if(LINKER_SUPPORTS_PDBSTRIPPED) target_link_options(${ARG_TARGET_NAME} - PRIVATE "/PDBSTRIPPED:${ARG_TARGET_NAME}.stripped.pdb") + PRIVATE "LINKER:/PDBSTRIPPED:${ARG_TARGET_NAME}.stripped.pdb") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${ARG_TARGET_NAME}.stripped.pdb" DESTINATION ${CMAKE_INSTALL_PREFIX}/bin RENAME "${ARG_TARGET_NAME}.pdb" diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 5e7cdead48f25..4ae6e665af588 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -84,7 +84,7 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) # 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. # 0x2000: LOAD_LIBRARY_SAFE_CURRENT_DIRS flag. Using this flag means that loading dependency DLLs (of sycl.dll) # from the current directory is only allowed if it is under a directory in the Safe load list. - target_link_options(${LIB_NAME} PRIVATE /DEPENDENTLOADFLAG:0x2000 /MANIFEST:NO /MANIFEST:EMBED /MANIFESTINPUT:${CMAKE_CURRENT_SOURCE_DIR}/${MANIFEST_FILE_NAME}) + target_link_options(${LIB_NAME} PRIVATE "LINKER:/DEPENDENTLOADFLAG:0x2000" "LINKER:/MANIFEST:NO" "LINKER:/MANIFEST:EMBED" "LINKER:/MANIFESTINPUT:${CMAKE_CURRENT_SOURCE_DIR}/${MANIFEST_FILE_NAME}") endif() target_compile_definitions(${LIB_OBJ_NAME} PRIVATE __SYCL_INTERNAL_API ) diff --git a/sycl/tools/sycl-ls/CMakeLists.txt b/sycl/tools/sycl-ls/CMakeLists.txt index 9d7db02efc1b7..b90bd972d3672 100644 --- a/sycl/tools/sycl-ls/CMakeLists.txt +++ b/sycl/tools/sycl-ls/CMakeLists.txt @@ -19,7 +19,7 @@ target_link_libraries(sycl-ls ) if (WIN32) # 0x900: Search for the dependency DLLs only in the System32 directory and in the directory with sycl-ls.exe - target_link_options(sycl-ls PRIVATE /DEPENDENTLOADFLAG:0x900) + target_link_options(sycl-ls PRIVATE LINKER:/DEPENDENTLOADFLAG:0x900) endif() install(TARGETS sycl-ls RUNTIME DESTINATION "bin" COMPONENT sycl-ls) diff --git a/sycl/ur_win_proxy_loader/CMakeLists.txt b/sycl/ur_win_proxy_loader/CMakeLists.txt index 107f01991f9da..bd720b5142e92 100644 --- a/sycl/ur_win_proxy_loader/CMakeLists.txt +++ b/sycl/ur_win_proxy_loader/CMakeLists.txt @@ -60,8 +60,8 @@ if (MSVC) target_link_libraries(ur_win_proxy_loader PRIVATE shlwapi) # 0x2000: LOAD_LIBRARY_SAFE_CURRENT_DIRS flag. Using this flag means that loading dependency DLLs # from the current directory is only allowed if it is under a directory in the Safe load list. - target_link_options(ur_win_proxy_loaderd PRIVATE /DEPENDENTLOADFLAG:0x2000) - target_link_options(ur_win_proxy_loader PRIVATE /DEPENDENTLOADFLAG:0x2000) + target_link_options(ur_win_proxy_loaderd PRIVATE LINKER:/DEPENDENTLOADFLAG:0x2000) + target_link_options(ur_win_proxy_loader PRIVATE LINKER:/DEPENDENTLOADFLAG:0x2000) install(TARGETS ur_win_proxy_loaderd RUNTIME DESTINATION "bin" COMPONENT ur_win_proxy_loader) endif()