Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMakeLists.txt: Check the Windows SDK version #2729

Merged
merged 3 commits into from
May 24, 2022

Conversation

StephanTLavavej
Copy link
Member

@StephanTLavavej StephanTLavavej commented May 18, 2022

Toolset update #2714 began requiring the Windows 11 SDK 22000 to build and test the STL. Although it's mentioned in the README, if a contributor misses this dependency, the resulting error message is incomprehensible (as @miscco discovered). @strega-nil-ms suggested adding a build check.

Fortunately, the Windows SDK provides a macro to identify itself, WDK_NTDDI_VERSION. (Unlike NTDDI_VERSION, this is not subject to user overrides.) It's present in the default WinSDK, where it was set to "Vibranium", whereas in the latest WinSDK, it's set to "Cobalt":

  • C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\sdkddkver.h
    • #define WDK_NTDDI_VERSION NTDDI_WIN10_VB /* ABRACADABRA_WIN10_VB */
  • C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\shared\sdkddkver.h
    • #define WDK_NTDDI_VERSION NTDDI_WIN10_CO

I've tested this by changing my installed WinSDK. Here's the user experience:

❌ Windows 10 SDK 19041, failure:

C:\GitHub\STL>cmake -G Ninja -S . -B out\build\x64
-- The CXX compiler identification is MSVC 19.33.31424.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.33.31424/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test WINDOWS_SDK_VERSION_CHECK
-- Performing Test WINDOWS_SDK_VERSION_CHECK - Failed
CMake Error at CMakeLists.txt:15 (message):
  The STL must be built with the Windows 11 SDK (10.0.22000.0) or later.
  Make sure it's available by selecting it in the Individual Components tab
  of the VS Installer.


-- Configuring incomplete, errors occurred!
See also "C:/GitHub/STL/out/build/x64/CMakeFiles/CMakeOutput.log".
See also "C:/GitHub/STL/out/build/x64/CMakeFiles/CMakeError.log".

✅ Windows 11 SDK 22000, success:

C:\GitHub\STL>cmake -G Ninja -S . -B out\build\x64
-- The CXX compiler identification is MSVC 19.33.31424.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.33.31424/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test WINDOWS_SDK_VERSION_CHECK
-- Performing Test WINDOWS_SDK_VERSION_CHECK - Success
-- Searching for VS clang-format
-- Searching for VS clang-format - found
-- Boost.Math: standalone mode ON
-- Found Python: C:/Users/stl/AppData/Local/Programs/Python/Python310/python.exe (found suitable version "3.10.4", minimum required is "3.9") found components: Interpreter
-- Configuring done
-- Generating done
-- Build files have been written to: C:/GitHub/STL/out/build/x64

@StephanTLavavej StephanTLavavej added the build Related to the build system label May 18, 2022
@StephanTLavavej StephanTLavavej requested a review from a team as a code owner May 18, 2022 23:41
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
Copy link
Member

@barcharcraz barcharcraz left a comment

Choose a reason for hiding this comment

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

OK I can't think of a better way to do this, I don't like the compiler checks though, as they are slow.

@StephanTLavavej
Copy link
Member Author

Regarding slowness, I measured the cost with:

"C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Auxiliary\Build\vcvars64.bat"
pushd C:\GitHub\STL
git clean -x -d -f
pwsh
Measure-Command { cmake -G Ninja -S . -B out\build\x64 | Out-Default }

I compared main and this branch, and averaged 3 runs. (Note that this excludes the time to clean etc.)

  • main took 3779 ms on average (raw times 3796.2115, 3731.3771, 3809.0518).
  • winsdk-check took 3924 ms on average (raw times 3930.953, 3918.3531, 3921.5556).

Thus this costs ~145 ms on my i7-10700.

@StephanTLavavej StephanTLavavej self-assigned this May 21, 2022
@StephanTLavavej
Copy link
Member Author

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit dae6092 into microsoft:main May 24, 2022
@StephanTLavavej StephanTLavavej deleted the winsdk-check branch May 24, 2022 00:57
fsb4000 pushed a commit to fsb4000/STL that referenced this pull request Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Related to the build system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants