Skip to content

Align MSVC hardening with ONNX Runtime Spectre runtime-library handling - #3361

Merged
xadupre merged 3 commits into
mainfrom
copilot/xadupre-onnx-light-3347
Jul 11, 2026
Merged

Align MSVC hardening with ONNX Runtime Spectre runtime-library handling#3361
xadupre merged 3 commits into
mainfrom
copilot/xadupre-onnx-light-3347

Conversation

Copilot AI commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

ONNX_HARDENING=ON already enabled /Qspectre on MSVC, but it did not ensure the link step also picked the Spectre-mitigated CRT/STL libraries. This mirrors the relevant part of the upstream ONNX Runtime change so Windows hardening builds do not advertise Spectre mitigation while still linking the default runtime libraries.

  • MSVC hardening

    • adds CMake helpers to resolve the Spectre library directory from VCToolsInstallDir
    • normalizes target architecture names (x86, x64, arm, arm64, arm64ec)
    • when /Qspectre is active, prepends lib/spectre/<arch> to the linker search path
    • falls back from arm64ec to arm64 when that is how the toolset ships the Spectre libs
  • Failure mode

    • emits a targeted configure-time warning when /Qspectre is enabled but the Spectre-mitigated MSVC runtime libraries are not installed
  • Documentation

    • updates the C++ linking / hardening docs to describe the Windows-specific /Qspectre behavior

Example of the new behavior in the hardening path:

if(_onnx_light_msvc_spectre_lib_dir)
  list(APPEND _onnx_light_hardening_link_options
       "SHELL:/LIBPATH:\"${_onnx_light_msvc_spectre_lib_dir}\"")
endif()

Copilot AI and others added 2 commits July 11, 2026 12:30
Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Copilot AI changed the title [WIP] Resolve applicability to onnx-light for PR 29624 Align MSVC hardening with ONNX Runtime Spectre runtime-library handling Jul 11, 2026
Copilot AI requested a review from xadupre July 11, 2026 12:32
@xadupre
xadupre marked this pull request as ready for review July 11, 2026 12:37
@xadupre
xadupre merged commit c11f1da into main Jul 11, 2026
15 checks passed
@xadupre
xadupre deleted the copilot/xadupre-onnx-light-3347 branch July 11, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

does it apply to onnx-light: https://github.com/microsoft/onnxruntime/pull/29624

2 participants