Skip to content

Commit 9ff6bb8

Browse files
steveisokjkotasakoeplinger
authored
Enable control flow guard for mono on windows (#101293)
Resolves binskim warnings for the runtime and aot compilers on windows. Co-authored-by: Jan Kotas <jkotas@microsoft.com> Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
1 parent f021ccf commit 9ff6bb8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/mono/CMakeLists.txt

+7-5
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,14 @@ elseif(CLR_CMAKE_HOST_OS STREQUAL "windows")
272272
set(MONO_ZERO_LEN_ARRAY 1)
273273
set(INTERNAL_ZLIB 1)
274274
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") # statically link VC runtime library
275-
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/W4>) # set warning level 4
276-
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/WX>) # treat warnings as errors
277-
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4324>) # 'struct_name' : structure was padded due to __declspec(align())
278-
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/EHsc>) # set exception handling behavior
279-
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/FC>) # use full pathnames in diagnostics
275+
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/W4>) # set warning level 4
276+
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/WX>) # treat warnings as errors
277+
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4324>) # 'struct_name' : structure was padded due to __declspec(align())
278+
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/EHsc>) # set exception handling behavior
279+
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/FC>) # use full pathnames in diagnostics
280+
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/guard:cf>) # Enable control flow guard
280281
add_link_options(/STACK:0x800000) # set stack size to 8MB (default is 1MB)
282+
add_link_options(/guard:cf)
281283
if(CMAKE_BUILD_TYPE STREQUAL "Release")
282284
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Oi>) # enable intrinsics
283285
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/GF>) # enable string pooling

0 commit comments

Comments
 (0)