Skip to content

Enable BinSkim-compliant compile flags#2335

Merged
umangyadav merged 5 commits intodevelopfrom
enable_binskim_compliant_flags
May 8, 2026
Merged

Enable BinSkim-compliant compile flags#2335
umangyadav merged 5 commits intodevelopfrom
enable_binskim_compliant_flags

Conversation

@apwojcik
Copy link
Copy Markdown
Contributor

@apwojcik apwojcik commented Apr 8, 2026

PR from the series that is migrating changes from uai-develop to the develop branch.

The PR adds CMake options to enable compilation of rocMLIR on Windows with Spectre mitigated libraries and to add GuardControl to the resulting binaries required for the BinSkim analysis.

Also, it fixes a bug that prevents the rocMLIR compilation on Windows in the Release mode.

@apwojcik apwojcik requested a review from causten as a code owner April 8, 2026 11:57
@apwojcik apwojcik added bug Something isn't working windows uai labels Apr 8, 2026
@apwojcik apwojcik force-pushed the enable_binskim_compliant_flags branch 2 times, most recently from 78144b1 to 30b7d08 Compare April 8, 2026 12:02
@apwojcik apwojcik force-pushed the enable_binskim_compliant_flags branch from 30b7d08 to a251b4d Compare April 8, 2026 12:36
Comment thread CMakeLists.txt
add_compile_definitions(_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING)
endif()
endif()
set(LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "" FORCE)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Why is it forced to be OFF for all builds ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows, to enable assertions, LLVM forces _DEBUG even in Release builds (assert support macros and functions are not available in other build types than Debug). On the other hand, keeping only for Debug builds requires a lot of work. For the multi-config generators (such as MSVC), you cannot just use CMAKE_BUILD_TYPE because it is not used for them. One needs to use generator expressions, but the set() command does not evaluate the expression. It only stores a text as is in a variable.
The easiest way is to turn them off for all build types. BTW, by default, the Clang build scripts are setting assertions off, too.

Comment thread CMakeLists.txt
Comment on lines +55 to +65
add_compile_options(
-Wno-sign-compare
-Wno-covered-switch-default
-Wno-unused-result
-Wno-switch
-Wno-language-extension-token
-Wno-microsoft-enum-value
-Wno-undef
-Wno-deprecated-declarations
-Wno-cast-function-type-mismatch
-Wno-overlength-strings)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why all these warnings are being silenced ? It can suppress some useful debugging warnings/info

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are required only when compiled with Clang on Windows. With the Clang GNU command-line interface, specifically. We recently switched to Clang-Cl, and those may not be required. I will double-check and submit a PR to remove all that is not required from this list.
If we do not switch those warnings off, the screen is flooded with warning messages. It is very hard to sort out a real problem between them. Most of the warnings are due to GNU Clang using MSVC standard libraries, which are not 100% compatible with GNU Clang.

When compiled with MSVC (the default on Windows), those warnings are not presented.

Comment thread CMakeLists.txt
cmake_policy(SET CMP0057 NEW)

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
option(ROCMLIR_SILENCE_WARNINGS "Ignore certain warnings on Windows" ON)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silencing warnings by default doesn't seem like a good idea. Why is it done this way ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've done it because otherwise we'd be flooded with warnings when compiling with GNU Clang on Windows. I'll try with clang-cl (the Clang with MSVC interface) and let you know if we still need it.

@umangyadav umangyadav merged commit 2b34e1a into develop May 8, 2026
8 of 15 checks passed
@umangyadav umangyadav deleted the enable_binskim_compliant_flags branch May 8, 2026 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working uai windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants