summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorWilliam R. Dieter <william.r.dieter@intel.com>2021-10-19 15:30:00 -0700
committerBrad King <brad.king@kitware.com>2022-01-14 08:57:03 -0500
commit79921fb00c9ae584adf6c2163b4b3e34dadff17c (patch)
tree13caf8823df3a604d2275a2d6a20101f2b26ea90 /Modules
parent50cfe54402ef30ff308b545c0e277ee8636124f9 (diff)
downloadcmake-79921fb00c9ae584adf6c2163b4b3e34dadff17c.tar.gz
IntelLLVM: Set linker to compiler driver for Windows
For IntelLLVM, linking with the compiler driver is preferred over using the linker directly. This is especially true when doing offload to a target accelerator, which can produce object files that the regular linker will not handle properly. Windows-IntelLLVM relies on Windows-MSVC.cmake for many definitions. This commit does not change that, but does override the MSVC defaults for linking executables, shared libraries, and static libraries so that CMake will use the compiler driver instead of the linker. Signed-off-by: William R. Dieter <william.r.dieter@intel.com>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/Platform/Windows-IntelLLVM.cmake13
1 files changed, 13 insertions, 0 deletions
diff --git a/Modules/Platform/Windows-IntelLLVM.cmake b/Modules/Platform/Windows-IntelLLVM.cmake
index b9ea037996..4687beecc3 100644
--- a/Modules/Platform/Windows-IntelLLVM.cmake
+++ b/Modules/Platform/Windows-IntelLLVM.cmake
@@ -12,6 +12,19 @@ include(Platform/Windows-MSVC)
macro(__windows_compiler_intel lang)
__windows_compiler_msvc(${lang})
+ # For DPCPP other offload cases, some link flags need to go to the compiler
+ # driver and others need to go to the linker. Pass the compiler linking flags
+ # in CMAKE_${lang}_LINK_FLAGS and linker flags in LINK_FLAGS
+ set(CMAKE_${lang}_LINK_EXECUTABLE
+ "${_CMAKE_VS_LINK_EXE}<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} <CMAKE_${lang}_LINK_FLAGS> <OBJECTS> ${CMAKE_START_TEMP_FILE} /link /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
+ set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
+ "${_CMAKE_VS_LINK_DLL}<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} <CMAKE_${lang}_LINK_FLAGS> <OBJECTS> ${CMAKE_START_TEMP_FILE} -LD -link /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <LINK_FLAGS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
+ if (NOT "${lang}" STREQUAL "Fortran" OR CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 2022.1)
+ # The Fortran driver does not support -fuse-ld=llvm-lib before compiler version 2022.1
+ set(CMAKE_${lang}_CREATE_STATIC_LIBRARY
+ "<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} <CMAKE_${lang}_LINK_FLAGS> <OBJECTS> ${CMAKE_START_TEMP_FILE} -fuse-ld=llvm-lib -o <TARGET> -link <LINK_FLAGS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
+ endif()
+
set(CMAKE_DEPFILE_FLAGS_${lang} "-QMMD -QMT <DEP_TARGET> -QMF <DEP_FILE>")
set(CMAKE_${lang}_DEPFILE_FORMAT gcc)
endmacro()