File tree Expand file tree Collapse file tree 12 files changed +93
-3
lines changed
src/google/protobuf/stubs Expand file tree Collapse file tree 12 files changed +93
-3
lines changed Original file line number Diff line number Diff line change @@ -40,3 +40,8 @@ common --noenable_bzlmod
4040build --features=layering_check
4141
4242common --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1
43+
44+ common --enable_platform_specific_config
45+
46+ # Use clang-cl by default on Windows (see https://github.com/protocolbuffers/protobuf/issues/20085).
47+ build:windows --extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl --extra_execution_platforms=//build_defs:x64_windows-clang-cl --host_platform=//build_defs:x64_windows-clang-cl
Original file line number Diff line number Diff line change 5858 credentials : ${{ secrets.GAR_SERVICE_ACCOUNT }}
5959 bazel-cache : examples
6060 version : ${{ matrix.bazelversion }}
61- bash : cd examples && bazel build //... $BAZEL_FLAGS --subcommands -- verbose_failures --enable_bzlmod=${{ matrix.bzlmod }} --enable_workspace=${{ !matrix.bzlmod }} ${{ matrix.toolchain_resolution }}
61+ bash : cd examples && bazel build //... $BAZEL_FLAGS --verbose_failures --enable_bzlmod=${{ matrix.bzlmod }} --enable_workspace=${{ !matrix.bzlmod }} ${{ matrix.toolchain_resolution }}
Original file line number Diff line number Diff line change @@ -412,7 +412,11 @@ jobs:
412412 bazel : build --cpu=darwin_arm64 //src/... //third_party/utf8_range/... //conformance:conformance_framework_tests
413413 - name : Windows Bazel
414414 os : windows-2022
415- cache_key : windows-2022-bazel7
415+ cache_key : windows-2022-msvc-cl
416+ bazel : test //src/... @com_google_protobuf_examples//... --config=msvc-cl --test_tag_filters=-conformance --build_tag_filters=-conformance --define=protobuf_allow_msvc=true
417+ - name : Windows Bazel clang-cl
418+ os : windows-2022
419+ cache_key : windows-2022-clang-cl
416420 bazel : test //src/... @com_google_protobuf_examples//... --test_tag_filters=-conformance --build_tag_filters=-conformance
417421 name : ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} ${{ matrix.name }}
418422 runs-on : ${{ matrix.os }}
@@ -524,6 +528,7 @@ jobs:
524528 if : ${{ matrix.install-flags && (!matrix.continuous-only || inputs.continuous-run) }}
525529 uses : protocolbuffers/protobuf-ci/bash@v4
526530 with :
531+ bazel-version : 7.1.2
527532 credentials : ${{ secrets.GAR_SERVICE_ACCOUNT }}
528533 command : >-
529534 cmake . -DCMAKE_CXX_STANDARD=17 ${{ matrix.install-flags }}
@@ -550,6 +555,7 @@ jobs:
550555 uses : protocolbuffers/protobuf-ci/bash@v4
551556 with :
552557 credentials : ${{ secrets.GAR_SERVICE_ACCOUNT }}
558+ bazel-version : 7.1.2
553559 command : >-
554560 cmake . -DCMAKE_CXX_STANDARD=17 ${{ matrix.flags }}
555561 ${{ env.SCCACHE_CMAKE_FLAGS }} -Dprotobuf_ALLOW_CCACHE=ON
Original file line number Diff line number Diff line change 7474 - name : Run tests
7575 uses : protocolbuffers/protobuf-ci/bash@v4
7676 with :
77+ bazel-version : 7.1.2
7778 credentials : ${{ secrets.GAR_SERVICE_ACCOUNT }}
7879 command : |
7980 dotnet build csharp/src/Google.Protobuf.sln
Original file line number Diff line number Diff line change @@ -18,12 +18,36 @@ create_compiler_config_setting(
1818 value = "msvc-cl" ,
1919)
2020
21- # Caveat: clang-cl support in protobuf is only best-effort / untested for now.
2221create_compiler_config_setting (
2322 name = "config_clang_cl" ,
2423 value = "clang-cl" ,
2524)
2625
26+ platform (
27+ name = "x64_windows-clang-cl" ,
28+ constraint_values = [
29+ "@platforms//cpu:x86_64" ,
30+ "@platforms//os:windows" ,
31+ "@bazel_tools//tools/cpp:clang-cl" ,
32+ ],
33+ )
34+
35+ platform (
36+ name = "x64_windows-msvc-cl" ,
37+ constraint_values = [
38+ "@platforms//cpu:x86_64" ,
39+ "@platforms//os:windows" ,
40+ "@bazel_tools//tools/cpp:msvc" ,
41+ ],
42+ )
43+
44+ config_setting (
45+ name = "protobuf_allow_msvc" ,
46+ values = {
47+ "define" : "protobuf_allow_msvc=true" ,
48+ },
49+ )
50+
2751selects .config_setting_group (
2852 name = "config_msvc" ,
2953 match_any = [
Original file line number Diff line number Diff line change @@ -5,3 +5,7 @@ build --cxxopt=/std:c++17 --host_cxxopt=/std:c++17
55startup --output_user_root=C:/tmp --windows_enable_symlinks
66common --enable_runfiles
77
8+ build --extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl
9+ build:clang-cl --extra_execution_platforms=//build_defs:x64_windows-clang-cl --host_platform=//build_defs:x64_windows-clang-cl
10+ build:msvc-cl --extra_execution_platforms=//build_defs:x64_windows-msvc-cl --host_platform=//build_defs:x64_windows-msvc-cl
11+ build --config=clang-cl
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ common --enable_platform_specific_config
33build:linux --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
44build:macos --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
55
6+ build:windows --extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl --extra_execution_platforms=//:x64_windows-clang-cl
67common:windows --cxxopt=/std:c++17 --host_cxxopt=/std:c++17 --enable_runfiles
78
89build --experimental_remote_cache_eviction_retries=5
Original file line number Diff line number Diff line change @@ -185,3 +185,16 @@ pkg_files(
185185 strip_prefix = strip_prefix .from_root ("" ),
186186 visibility = ["//visibility:public" ],
187187)
188+
189+ platform (
190+ name = "x64_windows-clang-cl" ,
191+ constraint_values = [
192+ "@platforms//cpu:x86_64" ,
193+ "@platforms//os:windows" ,
194+ # This is necessary for Bazel 7 compatibility with a MODULE.bazel file that still works in
195+ # Bazel 8. Using cc_configure_extension from rules_cc produces a @local_config_cc
196+ # repository that's not compatible with @bazel_tools//tools/cpp:clang-cl from before
197+ # Bazel 8. See https://github.com/bazelbuild/rules_cc/issues/330.
198+ "@rules_cc//cc/private/toolchain:clang-cl" ,
199+ ],
200+ )
Original file line number Diff line number Diff line change @@ -7,7 +7,12 @@ local_path_override(
77)
88
99bazel_dep (name = "bazel_skylib" , version = "1.7.1" )
10+ bazel_dep (name = "platforms" , version = "0.0.10" )
1011bazel_dep (name = "rules_cc" , version = "0.0.17" )
1112bazel_dep (name = "rules_java" , version = "8.6.1" )
1213bazel_dep (name = "rules_pkg" , version = "1.0.1" )
1314bazel_dep (name = "rules_python" , version = "1.0.0" )
15+
16+ # For clang-cl configuration
17+ cc_configure = use_extension ("@rules_cc//cc:extensions.bzl" , "cc_configure_extension" )
18+ use_repo (cc_configure , "local_config_cc" )
Original file line number Diff line number Diff line change 11workspace (name = "com_google_protobuf_examples" )
22
3+ load ("@bazel_tools//tools/build_defs/repo:http.bzl" , "http_archive" )
4+
35# This protobuf repository is required for proto_library rule.
46# It provides the protocol compiler binary (i.e., protoc).
57#
@@ -26,6 +28,16 @@ local_repository(
2628 path = ".." ,
2729)
2830
31+ # Bazel platform rules, for clang-cl.
32+ http_archive (
33+ name = "platforms" ,
34+ sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee" ,
35+ urls = [
36+ "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz" ,
37+ "https://github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz" ,
38+ ],
39+ )
40+
2941load ("@com_google_protobuf//:protobuf_deps.bzl" , "protobuf_deps" )
3042
3143protobuf_deps ()
@@ -41,3 +53,9 @@ rules_java_toolchains()
4153load ("@rules_python//python:repositories.bzl" , "py_repositories" )
4254
4355py_repositories ()
56+
57+ load ("@rules_cc//cc:repositories.bzl" , "rules_cc_dependencies" , "rules_cc_toolchains" )
58+
59+ rules_cc_dependencies ()
60+
61+ rules_cc_toolchains ()
You can’t perform that action at this time.
0 commit comments