Skip to content

Commit 78144b1

Browse files
committed
Enable BinSkim-compliant compile flags
1 parent cdf4447 commit 78144b1

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,50 @@ endif()
2525
# Set policy CMP0057 to support IN_LIST operators
2626
cmake_policy(SET CMP0057 NEW)
2727

28+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
29+
option(ROCMLIR_SILENCE_WARNINGS "Ignore certain warnings on Windows" ON)
30+
option(ROCMLIR_USE_BINSKIM_COMPLIANT_COMPILE_FLAGS "Prepare rocMLIR for BinSkim Binary Analyzer" OFF)
31+
option(ROCMLIR_USE_SPECTRE_MITIGATED_LIBRARIES "Use Spectre-mitigated libraries" OFF)
32+
if(MSVC AND MSVC_VERSION GREATER_EQUAL 1900)
33+
if(ROCMLIR_USE_BINSKIM_COMPLIANT_COMPILE_FLAGS)
34+
message(STATUS "Control Flow Guard enabled")
35+
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/guard:cf>)
36+
add_link_options(/guard:cf /DYNAMICBASE)
37+
endif()
38+
if(ROCMLIR_USE_SPECTRE_MITIGATED_LIBRARIES AND MSVC AND MSVC_VERSION GREATER_EQUAL 1900)
39+
message(STATUS "Using Spectre-mitigated libraries")
40+
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Qspectre>)
41+
endif()
42+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
43+
if(ROCMLIR_USE_BINSKIM_COMPLIANT_COMPILE_FLAGS)
44+
message(STATUS "Control Flow Guard enabled (Clang)")
45+
add_compile_options("$<$<COMPILE_LANGUAGE:C,CXX>:SHELL:-Xclang -cfguard>")
46+
add_link_options(-Wl,-guard:cf)
47+
endif()
48+
if(ROCMLIR_USE_SPECTRE_MITIGATED_LIBRARIES)
49+
message(WARNING "Spectre mitigated libraries are yet not available for Clang in this project.")
50+
endif()
51+
endif()
52+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
53+
add_compile_options(-fms-extensions -fms-compatibility -fdelayed-template-parsing)
54+
if(ROCMLIR_SILENCE_WARNINGS)
55+
add_compile_options(
56+
-Wno-sign-compare
57+
-Wno-covered-switch-default
58+
-Wno-unused-result
59+
-Wno-switch
60+
-Wno-language-extension-token
61+
-Wno-microsoft-enum-value
62+
-Wno-undef
63+
-Wno-deprecated-declarations
64+
-Wno-cast-function-type-mismatch
65+
-Wno-overlength-strings)
66+
add_compile_definitions(_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING)
67+
endif()
68+
endif()
69+
set(LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "" FORCE)
70+
endif()
71+
2872
#
2973
# Seperate linking jobs from compiling
3074
# Too many concurrent linking jobs can break the build

mlir/lib/Dialect/Rock/Transforms/AlignTiling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ void LinalgAlignRewriter::notifyMatchFailure(
399399
});
400400
#ifdef NDEBUG
401401
std::ignore = loc;
402-
std::ignore reasonCallback;
402+
std::ignore = reasonCallback;
403403
#endif
404404
}
405405

0 commit comments

Comments
 (0)