Skip to content

Commit 003c0fc

Browse files
authored
Update compiler options to meet binskim requirements (#9699)
* Update compiler options to meet binskim requirements To fix BA2028 and BA6002, use /guard:cast /d2CastGuardFailureMode:fastfail /GL and /GF compiler option. Tested successful build locally. * Update compiler options to meet binskim requirements Update the comment for better explantation
1 parent ce98b8f commit 003c0fc

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/CMake/nativeWin.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ if (MSVC)
4444
/Qspectre # compile with the Spectre mitigations switch
4545
/ZH:SHA_256 # enable secure source code hashing
4646
/guard:cf # enable compiler control guard feature (CFG) to prevent attackers from redirecting execution to unsafe locations
47+
$<$<NOT:$<CONFIG:Debug>>:/guard:cast> # enable cast guard to prevent type confusion
48+
$<$<NOT:$<CONFIG:Debug>>:/d2CastGuardFailureMode:fastfail> # fastfail mode for cast guard
4749
$<$<NOT:$<CONFIG:Debug>>:/GL> # enable whole program optimization
50+
$<$<NOT:$<CONFIG:Debug>>:/GF> # eliminate duplicate strings
4851
)
4952
add_link_options(
5053
/NODEFAULTLIB:libucrt$<$<CONFIG:Debug>:d>.lib # Hybrid CRT

0 commit comments

Comments
 (0)