Update microsoft_gsl from v4.0.0 to v4.2.1 (fixes C4875 deprecation)#28527
Merged
Conversation
… warning - Update cmake/deps.txt to GSL v4.2.1 with new SHA1 hash - Remove old 1064.patch (NVCC fix already in v4.2.1) - Add new 1213.patch to stringify GSL_SUPPRESS argument for MSVC (fixes C4875) - Simplify cmake logic: apply patch unconditionally instead of only for CUDA builds Agent-Logs-Url: https://github.com/microsoft/onnxruntime/sessions/b6e307d7-d812-4703-86a0-68fa0175e1f4 Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update microsoft_gsl dependency to pick up GSL_SUPPRESS fix
Update microsoft_gsl from v4.0.0 to v4.2.1 (fixes C4875 deprecation)
May 15, 2026
Contributor
|
@copilot Shall we lock the version of ms-gsl to 4.2.1 in cmake/vcpkg.json? That's for vcpkg. |
Agent-Logs-Url: https://github.com/microsoft/onnxruntime/sessions/c0daf98d-77e6-4b65-b575-71621bc421d6 Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
Contributor
Author
tianleiwu
approved these changes
May 20, 2026
Contributor
tianleiwu
left a comment
There was a problem hiding this comment.
APPROVE — Clean, well-motivated dependency upgrade. Verified that:
- GSL v4.2.1 includes the NVCC guard fix upstream (1064.patch removal is correct)
- The
include/gsl/assertheader is now the sole location of theGSL_SUPPRESSmacro definition (no separate copy inbyteanymore) - The 1213.patch context lines match the actual v4.2.1 source
- Removing the
if(onnxruntime_USE_CUDA)conditional is correct since the stringify fix applies to all MSVC builds - The vcpkg version constraint is properly structured
No correctness, security, or performance concerns. One minor suggestion inline.
kpkbandi
approved these changes
May 29, 2026
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
Upgrades
microsoft_gslto v4.2.1 and patchesGSL_SUPPRESSto stringify its argument for MSVC, fixing the C4875 deprecation warning in VC++ 18.6.0.cmake/deps.txt— Bump to v4.2.1cmake/patches/gsl/1064.patch— Removed; the NVCC guard (!defined(__NVCC__)) is already upstream in v4.2.1cmake/patches/gsl/1213.patch— New patch:[[gsl::suppress(x)]]→[[gsl::suppress(#x)]]for MSVC, matching upstream microsoft/GSL@543d0dd (PR export proper syntax for GSL_SUPPRESS for new VS GSL#1213)cmake/external/onnxruntime_external_deps.cmake— Removed theif(onnxruntime_USE_CUDA)conditional around the patch; the stringify fix applies to all MSVC builds, not just CUDAcmake/vcpkg.json— Added"version>=": "4.2.1"constraint forms-gslto ensure vcpkg builds also pick up a version that includes the NVCC guard fixMotivation and Context
GSL v4.0.0's
GSL_SUPPRESSmacro passes a non-string-literal to[[gsl::suppress()]]. VC++ 18.6.0 deprecates this form (C4875), and a future MSVC release will remove it entirely, breaking the build. The warning fires on essentially every translation unit viacapture.h/narrow.h.The upstream fix (stringify via
#x) hasn't shipped in a GSL release yet, so a local patch is still needed until a future GSL release includes it.