Remove the flag requirement for Bazel+MSVC users.

As discussed in https://github.com/protocolbuffers/protobuf/issues/20085, we were originally intending to drop support for this combination.  With Bazel's recent changes to virtual includes on windows though, we now have ~90 extra characters of runway.  This should be more than enough to continue supporting MSVC into the forseeable future.  Clang-cl support will be kept in place as an alternative on windows

PiperOrigin-RevId: 783798673
This commit is contained in:
Mike Kruskal 2025-07-16 10:02:58 -07:00 committed by Copybara-Service
parent 9a49efc45d
commit c6ba697d95
7 changed files with 1 additions and 49 deletions

View file

@ -427,7 +427,7 @@ jobs:
- name: Windows Bazel
os: windows-2022
cache_key: windows-2022-msvc-cl
bazel: test //src/... --config=msvc-cl --test_tag_filters=-conformance --build_tag_filters=-conformance --define=protobuf_allow_msvc=true
bazel: test //src/... --config=msvc-cl --test_tag_filters=-conformance --build_tag_filters=-conformance
- name: Windows Bazel clang-cl
os: windows-2022
cache_key: windows-2022-clang-cl

View file

@ -3,7 +3,6 @@ common --enable_platform_specific_config
build:linux --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
build:macos --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
build:windows --extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl --extra_execution_platforms=//:x64_windows-clang-cl
common:windows --cxxopt=/std:c++17 --host_cxxopt=/std:c++17 --enable_runfiles
build --experimental_remote_cache_eviction_retries=5

View file

@ -193,16 +193,3 @@ pkg_files(
strip_prefix = strip_prefix.from_root(""),
visibility = ["//visibility:public"],
)
platform(
name = "x64_windows-clang-cl",
constraint_values = [
"@platforms//cpu:x86_64",
"@platforms//os:windows",
# This is necessary for Bazel 7 compatibility with a MODULE.bazel file that still works in
# Bazel 8. Using cc_configure_extension from rules_cc produces a @local_config_cc
# repository that's not compatible with @bazel_tools//tools/cpp:clang-cl from before
# Bazel 8. See https://github.com/bazelbuild/rules_cc/issues/330.
"@rules_cc//cc/private/toolchain:clang-cl",
],
)

View file

@ -19,12 +19,7 @@ local_path_override(
)
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "rules_cc", version = "0.0.17")
bazel_dep(name = "rules_java", version = "8.6.1")
bazel_dep(name = "rules_pkg", version = "1.0.1")
bazel_dep(name = "rules_python", version = "1.4.1")
# For clang-cl configuration
cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure_extension")
use_repo(cc_configure, "local_config_cc")

View file

@ -33,16 +33,6 @@ local_repository(
path = "..",
)
# Bazel platform rules, for clang-cl.
http_archive(
name = "platforms",
sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz",
],
)
load("@com_google_protobuf//:protobuf_deps.bzl", "PROTOBUF_MAVEN_ARTIFACTS", "protobuf_deps")
protobuf_deps()
@ -59,12 +49,6 @@ load("@rules_python//python:repositories.bzl", "py_repositories")
py_repositories()
load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies", "rules_cc_toolchains")
rules_cc_dependencies()
rules_cc_toolchains()
load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
rules_jvm_external_deps()

View file

@ -22,12 +22,6 @@ cc_library(
"status_macros.h",
],
copts = COPTS,
defines = ["GOOGLE_PROTOBUF_USING_BAZEL=1"] + select({
"//build_defs:protobuf_allow_msvc": [
"GOOGLE_PROTOBUF_MSVC_BAZEL_OVERRIDE=1",
],
"//conditions:default": [],
}),
linkopts = LINK_OPTS,
strip_include_prefix = "/src",
deps = [

View file

@ -31,13 +31,6 @@
#include <byteswap.h> // IWYU pragma: export
#endif
#if defined(_MSC_VER) && !defined(__clang__) && \
defined(GOOGLE_PROTOBUF_USING_BAZEL) && \
!defined(GOOGLE_PROTOBUF_MSVC_BAZEL_OVERRIDE)
#error \
"Protobuf will be dropping support for MSVC + Bazel in 34.0. To continue using it until then, use the flag --define=protobuf_allow_msvc=true. For feedback or discussion, see github.com/protocolbuffers/protobuf/issues/20085."
#endif
// Legacy: some users reference these (internal-only) macros even though we
// don't need them any more.
#if defined(_MSC_VER) && defined(PROTOBUF_USE_DLLS)