Support thread-safe local statics#44
Merged
Merged
Conversation
1ba034b to
3e6844e
Compare
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.
Summary
/Zc:threadSafeInit-opt-out from CMake, installed CMake package settings, and NuGet MSBuild targets.thread_localstorage.nuget.exe, allow an explicit Visual Studio major version override, and avoid copying stale test build directories.Why
MSVC's thread-safe local static initialization emits compiler TLS accesses such as
_Init_thread_epochlookups through the TLS vector. Kernel drivers do not have a normal user-mode TEB TLS vector, so the previous/Zc:threadSafeInit-workaround disabled the compiler feature. This change initializes a driver-wide compiler TLS image from the PE TLS template and installs that TLS slot vector on each processor so the compiler-managed static-local initialization path works.This is intentionally not claiming full C++
thread_localsupport. The docs still call out true per-thread TLS as unsupported.Validation
test/cmake/driver/build_2022_x64Debug and confirmed the generated test driver contains a TLS directory and_Init_thread_*local-static codegen.function-local static initialized successfullyand all 8 GoogleTest tests passed.10.0.22000.0.crtsys.0.1.17.nupkgwithnuget.exe pack.-VisualStudioMajorVersion 16.Notes
The packaging step still emits the existing non-fatal NU5128 warning for the native package, and driver links still show the existing libcntpr duplicate-symbol
/FORCEwarnings.