@@ -81,6 +81,7 @@ bazel_dep(name = "rules_rust_prost", version = "0.73.0")
8181bazel_dep (name = "rules_shell" , version = "0.8.0" )
8282bazel_dep (name = "toml.bzl" , version = "0.4.1" )
8383bazel_dep (name = "toolchains_llvm" , version = "1.8.0" )
84+ bazel_dep (name = "toolchains_msvc" , version = "0.1.0" )
8485
8586bazel_dep (name = "rules_testing" , version = "0.9.0" , dev_dependency = True )
8687
@@ -261,6 +262,16 @@ use_repo(linux_headers_ext, "linux_headers", "linux_headers_aarch64", "linux_hea
261262## Compilers and toolchains ##
262263####################################
263264
265+ git_override (
266+ module_name = "toolchains_msvc" ,
267+ commit = "8e2aa4624bbb5a53a94f135e90995f307875d1ad" ,
268+ patch_strip = 1 ,
269+ # Adds MSBuild + the VC project system, and whole-tree filegroups, so MSBuild-driven
270+ # builds (CPython) can run against the same hermetic toolchain as rules_cc.
271+ patches = ["//bazel/patches:toolchains_msvc/0001-hermetic-msbuild-and-toolchain-trees.patch" ],
272+ remote = "https://github.com/Dragnalith/toolchains_msvc" ,
273+ )
274+
264275archive_override (
265276 module_name = "gcc_toolchain" ,
266277 patch_args = ["-p1" ],
@@ -361,20 +372,35 @@ winlibs_mingw_repository(
361372 url = "https://github.com/brechtsanders/winlibs_mingw/releases/download/14.2.0posix-19.1.7-12.0.0-msvcrt-r3/winlibs-x86_64-posix-seh-gcc-14.2.0-mingw-w64msvcrt-12.0.0-r3.zip" ,
362373)
363374
375+ # Hermetic MSVC + Windows SDK for rules_cc (cl/link), and MSBuild for CPython
376+ # (see deps/cpython/build_python.bat). MinGW stays the default Windows cc_toolchain.
377+ msvc_toolchain = use_extension ("@toolchains_msvc//:extensions.bzl" , "toolchain" )
378+ msvc_toolchain .toolchain_set (
379+ name = "default" ,
380+ # MSVC toolset version, not VS product version: VS 2022 17.14.x → 14.44
381+ # (see https://learn.microsoft.com/en-us/cpp/overview/compiler-versions).
382+ # toolchains_msvc only accepts 14.xx here, not 17.14.
383+ msvc_versions = ["14.44" ],
384+ # Win11 SDK 10.0.26100; toolchains_msvc uses the trailing build number only.
385+ winsdk_versions = ["26100" ],
386+ )
387+ use_repo (msvc_toolchain , "msvc_toolchains" )
388+
364389# TODO{agent-build}: Find a way to register platform-specific toolchains dynamically
365390register_toolchains (
366391 "@gcc_toolchain_x86_64//:cc_toolchain" ,
367392 "@gcc_toolchain_aarch64//:cc_toolchain" ,
368393 "@gcc_toolchain_armv7//:cc_toolchain" ,
369394 "@winlibs_mingw64//:mingw_cc_toolchain" ,
395+ "@msvc_toolchains//:all" ,
370396 "@llvm_toolchain//:all" , # last to avoid taking precedence over GCC toolchains
371397)
372398
373- # Visual Studio / MSBuild tooling, taken from the local installation
399+ # Host MSBuild for the DatadogInterop vcxproj only; CPython uses the hermetic
400+ # @msvc_toolchains//msbuild instead.
374401visual_studio (
375402 name = "visual_studio" ,
376403 path_variable = "VSTUDIO_ROOT" ,
377- version = "17.14.36717.8" , # 18.4.11612.150
378404)
379405
380406# =========================================
0 commit comments