Enable Spectre-mitigated MSVC libs for BinSkim builds#29624
Open
tianleiwu wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This updates the Windows BinSkim-compliant build flags so
/Qspectrebuilds also link against the MSVC Spectre-mitigated CRT/STL static libraries./Qspectreonly affects ONNX Runtime's own object files; BinSkim BA2024 can still report violations when the default non-Spectrelibcmt.lib,libcpmt.lib, orlibvcruntime.libare linked into the final binary.Motivation and Context
Release validation reported BinSkim BA2024 (
EnableSpectreMitigations) warnings foronnxruntime.dlleven when ORT was built with--use_binskim_compliant_compile_flags. The warning identified MSVC runtime and STL static libraries as the non-mitigated modules. This change makes the build option select the Spectre-mitigated MSVC library directory when it is available from the Visual Studio toolset.Key Changes
get_msvc_spectre_lib_dir()to locate%VCToolsInstallDir%\lib\spectre\<arch>for the target Windows architecture./LIBPATH:<spectre-lib-dir>linker flag whenever Windows BinSkim flags enable/Qspectreand AddressSanitizer is not enabled.Testing
python3 -m ruff check tools/ci_build/build.pypython3 -m ruff format --check tools/ci_build/build.pylintrunner -a tools/ci_build/build.pywas also attempted. It found the repository config and applied no file changes, but the local environment could not execute the Ruff lintrunner adapters becausepythonis not available on PATH; the directpython3 -m ruffchecks above passed.