Skip to content

Commit b757f43

Browse files
Maetveislisanna-dettwyler
authored andcommitted
Wrap linker flags on Windows for IntelLLVM
The Intel C++ compiler requires linker flags to be wrapped, because CMake passes them through the compiler driver. Prefix Linker options with `${CMAKE_CXX_LINKER_WRAPPER_FLAG}`. This variable is set to the option to pass a linker flag through the compiler driver by CMake. For MSVC and clang-cl or IntelLLVM pre cmake 3.25 this will be empty, so the patch will work in these cases too. Fixes: #205 Signed-off-by: Gergely Meszaros <[email protected]>
1 parent 65a95d9 commit b757f43

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ if(MSVC)
8888
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:cf")
8989
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DYNAMICBASE")
9090
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /DYNAMICBASE")
91-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DYNAMICBASE")
92-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /guard:cf")
91+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_CXX_LINKER_WRAPPER_FLAG}/DYNAMICBASE")
92+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_CXX_LINKER_WRAPPER_FLAG}/guard:cf")
9393
# enable Spectre Mitigation, not supported by clang-cl
9494
if((NOT CMAKE_CXX_COMPILER_ID STREQUAL Clang) AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL IntelLLVM))
9595
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qspectre")
@@ -138,10 +138,10 @@ if(MSVC)
138138

139139
# enable creation of PDB files for Release Builds
140140
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
141-
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
141+
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} ${CMAKE_CXX_LINKER_WRAPPER_FLAG}/DEBUG ${CMAKE_CXX_LINKER_WRAPPER_FLAG}/OPT:REF ${CMAKE_CXX_LINKER_WRAPPER_FLAG}/OPT:ICF")
142142

143143
# enable CET shadow stack
144-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /CETCOMPAT")
144+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_CXX_LINKER_WRAPPER_FLAG}/CETCOMPAT")
145145

146146
#Use of sccache with MSVC requires workaround of replacing /Zi with /Z7
147147
#https://github.com/mozilla/sccache

0 commit comments

Comments
 (0)