protobuf
protobuf copied to clipboard
Breaking Change: Dropping support for Bazel+MSVC
This issue is a placeholder for gathering feedback on an upcoming breaking change
Due to persistent issues with MSVC's path length limits, we've decided to drop support for Bazel in 34.0. Starting in 30.0, you will need to explicitly set a flag --define=protobuf_allow_msvc=true to use this combination. Our recommended alternative is clang-cl, which we will officially support going forward.
If you're not using Protobuf-C++ and you've hit this issue purely because you need to build protoc from source, just use the opt-out flag for now. We will be releasing a prebuilt protoc toolchain by 34.0, which should decouple you from this.
I maintain the ray bazel build for windows. Ray uses protobuf and many other components. How can I tell the monolithic bazel build of ray "use clang-cl for protobuf only"?
A bit more context: ray uses bazel 6.5.0 and is slow to upgrade. It also has boost as a component, boost uses assembly files that do not build with clang-cl.
Please reconsider dropping support. While I am well aware that supporting Bazel+MSVC is frustrating, Protobuf is a transitive dependency of a massive number of projects, and especially a large fraction of Google-owned open source projects, including gRPC, TensorFlow, Google Cloud C++ SDK, TensorStore, etc. This change will force a very large number of projects to stop supporting MSVC with Bazel, and may prevent some from building with Windows at all.
Building with a mixed toolchain (MSVC for some targets, clang-cl for others) within a workspace is unlikely to be practical anyway, but given that the issues tend to be with headers it is unlikely to help even if it were practical.
As mentioned in https://protobuf.dev/news/2025-07-16/, we've decided to cancel this plan due to Bazel's recent improvements on windows. They will be using substantially less of the limited path length for virtual includes, which should give us more than enough room to avoid future issues.
The flag is no longer required in our 32.0 release, and we will remove the flag entirely in a later breaking release.
Just to be clear, to actually build protobuf v32 with MSVC, you'll also need Bazel 8.4.0 and rules_cc 0.1.4, otherwise you'll likely encounter a "file not found" error caused by the long path issue.