Skip to content

Update microsoft_gsl from v4.0.0 to v4.2.1 (fixes C4875 deprecation)#28527

Merged
tianleiwu merged 4 commits into
mainfrom
copilot/update-microsoft-gsl-dependency
May 29, 2026
Merged

Update microsoft_gsl from v4.0.0 to v4.2.1 (fixes C4875 deprecation)#28527
tianleiwu merged 4 commits into
mainfrom
copilot/update-microsoft-gsl-dependency

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

Description

Upgrades microsoft_gsl to v4.2.1 and patches GSL_SUPPRESS to stringify its argument for MSVC, fixing the C4875 deprecation warning in VC++ 18.6.0.

  • cmake/deps.txt — Bump to v4.2.1
  • cmake/patches/gsl/1064.patch — Removed; the NVCC guard (!defined(__NVCC__)) is already upstream in v4.2.1
  • cmake/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 the if(onnxruntime_USE_CUDA) conditional around the patch; the stringify fix applies to all MSVC builds, not just CUDA
  • cmake/vcpkg.json — Added "version>=": "4.2.1" constraint for ms-gsl to ensure vcpkg builds also pick up a version that includes the NVCC guard fix

Motivation and Context

GSL v4.0.0's GSL_SUPPRESS macro 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 via capture.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.

… 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
Copilot AI requested a review from tianleiwu May 15, 2026 22:53
@tianleiwu
Copy link
Copy Markdown
Contributor

@copilot Shall we lock the version of ms-gsl to 4.2.1 in cmake/vcpkg.json? That's for vcpkg.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 16, 2026

@copilot Shall we lock the version of ms-gsl to 4.2.1 in cmake/vcpkg.json? That's for vcpkg.

Good call. Added "version>=": "4.2.1" for ms-gsl in cmake/vcpkg.json in 4f19084.

@tianleiwu tianleiwu marked this pull request as ready for review May 20, 2026 06:34
Copy link
Copy Markdown
Contributor

@tianleiwu tianleiwu left a comment

Choose a reason for hiding this comment

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

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/assert header is now the sole location of the GSL_SUPPRESS macro definition (no separate copy in byte anymore)
  • 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.

Comment thread cmake/external/onnxruntime_external_deps.cmake
@tianleiwu tianleiwu enabled auto-merge (squash) May 29, 2026 23:21
@tianleiwu tianleiwu merged commit 3114651 into main May 29, 2026
98 of 100 checks passed
@tianleiwu tianleiwu deleted the copilot/update-microsoft-gsl-dependency branch May 29, 2026 23:36
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.

Update microsoft_gsl dependency to pick up GSL_SUPPRESS fix (C4875 deprecation in VC++ 18.6.0)

3 participants