Skip to content

Commit

Permalink
Enable control flow guard for mono on windows (dotnet#101293)
Browse files Browse the repository at this point in the history
Resolves binskim warnings for the runtime and aot compilers on windows.

Co-authored-by: Jan Kotas <[email protected]>
Co-authored-by: Alexander Köplinger <[email protected]>
  • Loading branch information
3 people authored and matouskozak committed Apr 30, 2024
1 parent 7e5706d commit 358e8a6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,14 @@ elseif(CLR_CMAKE_HOST_OS STREQUAL "windows")
set(MONO_ZERO_LEN_ARRAY 1)
set(INTERNAL_ZLIB 1)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") # statically link VC runtime library
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/W4>) # set warning level 4
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/WX>) # treat warnings as errors
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4324>) # 'struct_name' : structure was padded due to __declspec(align())
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/EHsc>) # set exception handling behavior
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/FC>) # use full pathnames in diagnostics
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/W4>) # set warning level 4
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/WX>) # treat warnings as errors
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4324>) # 'struct_name' : structure was padded due to __declspec(align())
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/EHsc>) # set exception handling behavior
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/FC>) # use full pathnames in diagnostics
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/guard:cf>) # Enable control flow guard
add_link_options(/STACK:0x800000) # set stack size to 8MB (default is 1MB)
add_link_options(/guard:cf)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Oi>) # enable intrinsics
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/GF>) # enable string pooling
Expand Down

0 comments on commit 358e8a6

Please sign in to comment.