From c6ba697d950f9277594646bd4dcb280eda6c2ba9 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Wed, 16 Jul 2025 10:02:58 -0700 Subject: [PATCH] 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 --- .github/workflows/test_cpp.yml | 2 +- examples/.bazelrc | 1 - examples/BUILD.bazel | 13 ------------- examples/MODULE.bazel | 5 ----- examples/WORKSPACE | 16 ---------------- src/google/protobuf/stubs/BUILD.bazel | 6 ------ src/google/protobuf/stubs/port.h | 7 ------- 7 files changed, 1 insertion(+), 49 deletions(-) diff --git a/.github/workflows/test_cpp.yml b/.github/workflows/test_cpp.yml index 1584eeaea0..6a44a974c4 100644 --- a/.github/workflows/test_cpp.yml +++ b/.github/workflows/test_cpp.yml @@ -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 diff --git a/examples/.bazelrc b/examples/.bazelrc index 8c49fd990b..7873d890ec 100644 --- a/examples/.bazelrc +++ b/examples/.bazelrc @@ -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 diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel index 7c8276ad0b..87ef598cb6 100644 --- a/examples/BUILD.bazel +++ b/examples/BUILD.bazel @@ -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", - ], -) diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel index 292274f0e0..e50f1396a4 100644 --- a/examples/MODULE.bazel +++ b/examples/MODULE.bazel @@ -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") diff --git a/examples/WORKSPACE b/examples/WORKSPACE index 7cf8b5aef9..c79527c414 100644 --- a/examples/WORKSPACE +++ b/examples/WORKSPACE @@ -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() diff --git a/src/google/protobuf/stubs/BUILD.bazel b/src/google/protobuf/stubs/BUILD.bazel index 95bc0152ad..1811b452c5 100644 --- a/src/google/protobuf/stubs/BUILD.bazel +++ b/src/google/protobuf/stubs/BUILD.bazel @@ -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 = [ diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index eb3d8eb3ed..cd4025f6ae 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -31,13 +31,6 @@ #include // 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)