Skip to content

Add opt-in /Os for Windows Release builds - #8998

Open
Alex Sepkowski (alsepkow) wants to merge 1 commit into
microsoft:mainfrom
alsepkow:user/alsepkow/windows-release-size-option
Open

Alex Sepkowski (alsepkow) wants to merge 1 commit into
microsoft:mainfrom
alsepkow:user/alsepkow/windows-release-size-option

Conversation

@alsepkow

@alsepkow Alex Sepkowski (alsepkow) commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Add an opt-in size preference for Windows Release builds.

Change

  • Add DXC_OPTIMIZE_FOR_SIZE, defaulting to OFF.
  • When enabled, append /Os to the C and C++ Release flags on MSVC.

/Os is used alongside /O2: Release builds remain fully optimized, while MSVC favors smaller generated code when an optimization involves a choice between code size and execution speed.

Validation

  • Configured an x64 build with Visual Studio 18 2026 and DXC_OPTIMIZE_FOR_SIZE=ON.
  • Verified the generated Release llvm-tblgen.vcxproj contains Optimization=MaxSpeed and FavorSizeOrSpeed=Size, confirming /O2 remains enabled while /Os supplies the size preference.
  • A/B build and package stages completed for x86, x64, and ARM64. Confirmed a reduced binary size and no test failures.

Assisted-By: Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@alsepkow
Alex Sepkowski (alsepkow) marked this pull request as ready for review October 2, 2026 01:37
Copilot AI balanced review requested due to automatic review settings October 2, 2026 01:37
@alsepkow Alex Sepkowski (alsepkow) changed the title [Win] Add opt-in /Os for Release builds Add opt-in /Os for Windows Release builds Oct 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The scoped CMake changes correctly preserve /O2 while adding the requested opt-in size preference.

Review effort: Balanced
Findings: None

What changed in this PR

Adds an optional MSVC size preference for Windows Release builds without changing default behavior.

Changes:

  • Adds the DXC_OPTIMIZE_FOR_SIZE CMake option, defaulting to OFF.
  • Appends /Os to Release C and C++ flags when enabled.
File Description
CMakeLists.txt Defines the opt-in size optimization setting.
cmake/​modules/​HandleLLVMOptions.cmake Applies /Os to MSVC Release builds.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

2 participants