Add /sdl compiler flag for SDL compliance#121510
Merged
Conversation
…Compression.Native Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add SDL switch for native binaries
Add SDL linker switches to System.Globalization.Native and System.IO.Compression.Native
Nov 10, 2025
jkotas
reviewed
Nov 10, 2025
Removed individual SDL linker switches from CMakeLists.txt files and instead added the /sdl compiler flag globally in eng/native/configurecompiler.cmake. This approach is cleaner and applies the SDL checks to all MSVC builds from a central location. Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copilot
AI
changed the title
Add SDL linker switches to System.Globalization.Native and System.IO.Compression.Native
Add /sdl compiler flag for SDL compliance
Nov 10, 2025
agocke
reviewed
Nov 11, 2025
The /sdl flag is a superset of /GS, so the explicit /GS flag is redundant and can be removed. Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Member
|
@copilot Delete |
The /sdl flag automatically enables SDL-required warnings as errors (C4055, C4146, C4242, C4244, C4267, C4302, C4308, C4509, C4510, C4532, C4533, C4610, C4611, C4700, C4701, C4703, C4789, C4995, C4996), so these explicit /we options are no longer needed. Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Contributor
Author
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds the /sdl compiler flag to enable comprehensive Security Development Lifecycle (SDL) checks for all MSVC builds. The /sdl flag provides a superset of security features that includes buffer security checks (/GS), making the explicit /GS flag redundant.
- Added
/sdlflag globally ineng/native/configurecompiler.cmakefor all MSVC C/CXX compilations - Removed the now-redundant
/GSflag since/sdlalready includes buffer security checks
jkotas
approved these changes
Nov 11, 2025
AaronRobinsonMSFT
approved these changes
Nov 11, 2025
This was referenced Nov 11, 2025
Open
Member
|
/ba-g android timeouts |
jkotas
pushed a commit
that referenced
this pull request
Nov 20, 2025
Re-enables specific MSVC compiler warnings as error so that we continue to meet SDL requirements. Addresses regression introduced by #121510.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Add /sdl compiler flag for SDL compliance
This PR adds the
/sdlcompiler flag to enable SDL (Security Development Lifecycle) checks for all MSVC builds and removes redundant flags that are now subsumed by/sdl.Summary
/sdlflag to central MSVC configuration in eng/native/configurecompiler.cmake/GSflag (subsumed by/sdl)/wewarning options (subsumed by/sdl)Changes
Added the
/sdlcompiler flag globally ineng/native/configurecompiler.cmakefor all MSVC C/CXX compilations, and removed redundant flags:/GSflag (buffer security checks) - included in/sdl/wewarning options (SDL-required warnings as errors) - included in/sdlImplementation
The
/sdlflag:/GS(buffer security checks) functionalityNet Changes
/sdlflag)/GSflag + 19/weoptions + 3 comment lines + 1 empty line)This simplifies the configuration while maintaining full SDL compliance through the comprehensive
/sdlflag.Why
/sdlinstead of individual switches?Individual switches like
/DYNAMICBASE,/NXCOMPAT, and/HIGHENTROPYVAare already enabled by default in modern MSVC toolchains. The/sdlcompiler flag provides comprehensive SDL compliance by enabling additional compile-time checks and warnings, eliminating the need for explicit/GSand numerous/weoptions.Note:
/GUARD:CF(Control Flow Guard) is already applied globally viaconfigurecompiler.cmake.Fixes #121509
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.