diff --git a/.github/workflows/test_cpp.yml b/.github/workflows/test_cpp.yml index 220a6ba25f..113154fa83 100644 --- a/.github/workflows/test_cpp.yml +++ b/.github/workflows/test_cpp.yml @@ -40,10 +40,6 @@ jobs: - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/sanitize:8.0.1-b77fdae6d4771789dfc66a56bf8d806354e8011a - targets: //pkg/... //src/... //third_party/utf8_range/... //conformance:conformance_framework_tests # Override cases with custom images - - config: { name: "Bazel7", flags: --cxxopt="-Wno-self-assign-overloaded" } - cache_key: Bazel7bzlmod - image: "us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:7.6.1-e0df73e51131ccaf53451355d22577f377357604" - targets: "//src/... //third_party/utf8_range/..." - config: { name: "Bazel8", flags: --cxxopt="-Wno-self-assign-overloaded" } cache_key: Bazel8 image: "us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:8.0.1-e78301df86b3e4c46ec9ac4d98be00e19305d8f3" diff --git a/.github/workflows/test_java.yml b/.github/workflows/test_java.yml index 1882655f76..c45aa7c886 100644 --- a/.github/workflows/test_java.yml +++ b/.github/workflows/test_java.yml @@ -44,10 +44,6 @@ jobs: cache_key: '17' image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:8.0.1-17-168f9c9d015a0fa16611e1e9eede796fe9bfbb69 targets: //java/... //java/internal:java_version //compatibility/... - - name: Bazel7 - cache_key: 'bazel7bzlmod' - image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:7.6.1-e0df73e51131ccaf53451355d22577f377357604 - targets: //java/... //java/internal:java_version //compatibility/... # TODO: b/395623141 - restore this test once runtime uses / emulates aarch64. # - name: aarch64 # cache_key: 'aarch64' diff --git a/MODULE.bazel b/MODULE.bazel index 3031932f7f..a99de23097 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -44,14 +44,6 @@ bazel_dep(name = "rules_license", version = "1.0.0") bazel_dep(name = "rules_pkg", version = "1.0.1") bazel_dep(name = "rules_python", version = "1.6.0") -# Pin to rules_proto to 7.1.0 to avoid toolchain incompatibilities when -# --incompatible_enable_proto_toolchain_resolution=true in Bazel 7. -# rules_proto 7.0.2 from deps incorrectly rules_proto's toolchain_type but protobuf's toolchain, but -# 7.1.0 uses protobuf's toolchain and toolchain_type. -# TODO: Restore to dev_dependency once Bazel 7 is dropped. -# rules_proto is needed for @com_google_protobuf_v25 used in //compatibility/... tests -bazel_dep(name = "rules_proto", version = "7.1.0") - bazel_dep(name = "rules_rust", version = "0.63.0", dev_dependency = True) bazel_dep(name = "rules_ruby", version = "0.17.3", dev_dependency = True) diff --git a/README.md b/README.md index 3e79e3b615..40e88ba96f 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ release commits. ### Bazel with Bzlmod Protobuf supports -[Bzlmod](https://bazel.build/external/module) with Bazel 7 +. +[Bzlmod](https://bazel.build/external/module) with Bazel 8 +. Users should specify a dependency on protobuf in their MODULE.bazel file as follows. diff --git a/WORKSPACE b/WORKSPACE index 99fce5417f..9b1b344042 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,13 +1,5 @@ workspace(name = "com_google_protobuf") -# An explicit self-reference to work around changes in Bazel 7.0 -# See https://github.com/bazelbuild/bazel/issues/19973#issuecomment-1787814450 -# buildifier: disable=duplicated-name -local_repository( - name = "com_google_protobuf", - path = ".", -) - load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # Load common dependencies first to ensure we use the correct version diff --git a/bazel/cc_proto_library.bzl b/bazel/cc_proto_library.bzl index d135ac26ac..a96ffcf4a0 100644 --- a/bazel/cc_proto_library.bzl +++ b/bazel/cc_proto_library.bzl @@ -9,9 +9,4 @@ load("//bazel/private/oss:cc_proto_library.bzl", _cc_proto_library = "cc_proto_library") -def cc_proto_library(**kwattrs): - # Only use Starlark rules when they are removed from Bazel - if not hasattr(native, "cc_proto_library"): - _cc_proto_library(**kwattrs) - else: - native.cc_proto_library(**kwattrs) # buildifier: disable=native-cc-proto +cc_proto_library = _cc_proto_library diff --git a/bazel/java_lite_proto_library.bzl b/bazel/java_lite_proto_library.bzl index a49f737ef4..90ff08c776 100644 --- a/bazel/java_lite_proto_library.bzl +++ b/bazel/java_lite_proto_library.bzl @@ -9,9 +9,4 @@ load("//bazel/private:java_lite_proto_library.bzl", _java_lite_proto_library = "java_lite_proto_library") -def java_lite_proto_library(**kwattrs): - # Only use Starlark rules when they are removed from Bazel - if not hasattr(native, "java_lite_proto_library"): - _java_lite_proto_library(**kwattrs) - else: - native.java_lite_proto_library(**kwattrs) # buildifier: disable=native-java-lite-proto +java_lite_proto_library = _java_lite_proto_library diff --git a/bazel/java_proto_library.bzl b/bazel/java_proto_library.bzl index 93e1d16339..8754a35e81 100644 --- a/bazel/java_proto_library.bzl +++ b/bazel/java_proto_library.bzl @@ -9,9 +9,4 @@ load("//bazel/private:java_proto_library.bzl", _java_proto_library = "java_proto_library") -def java_proto_library(**kwattrs): - # Only use Starlark rules when they are removed from Bazel - if not hasattr(native, "java_proto_library"): - _java_proto_library(**kwattrs) - else: - native.java_proto_library(**kwattrs) # buildifier: disable=native-java-proto +java_proto_library = _java_proto_library diff --git a/bazel/private/oss/cc_proto_library.bzl b/bazel/private/oss/cc_proto_library.bzl index e51545011e..d230941628 100644 --- a/bazel/private/oss/cc_proto_library.bzl +++ b/bazel/private/oss/cc_proto_library.bzl @@ -59,14 +59,8 @@ def _aspect_impl(target, ctx): if should_generate_code: if len(proto_info.direct_sources) != 0: - # Bazel 7 didn't expose cc_proto_library_source_suffixes used by Kythe - # gradually falling back to .pb.cc - if type(get_flag_value(ctx, "cc_proto_library_source_suffixes")) == "builtin_function_or_method": - source_suffixes = [".pb.cc"] - header_suffixes = [".pb.h"] - else: - source_suffixes = get_flag_value(ctx, "cc_proto_library_source_suffixes") - header_suffixes = get_flag_value(ctx, "cc_proto_library_header_suffixes") + source_suffixes = get_flag_value(ctx, "cc_proto_library_source_suffixes") + header_suffixes = get_flag_value(ctx, "cc_proto_library_header_suffixes") sources = _get_output_files(ctx.actions, proto_info, source_suffixes) headers = _get_output_files(ctx.actions, proto_info, header_suffixes) header_provider = _ProtoCcHeaderInfo(headers = depset(headers)) diff --git a/bazel/private/oss/toolchains/BUILD.bazel b/bazel/private/oss/toolchains/BUILD.bazel index 1449b61d52..06eda96056 100644 --- a/bazel/private/oss/toolchains/BUILD.bazel +++ b/bazel/private/oss/toolchains/BUILD.bazel @@ -46,32 +46,6 @@ toolchain( toolchain_type = "//bazel/private:python_toolchain_type", ) -# Following toolchain registrations are for builtin Bazel 7 rules -# which defined them in other repositories. -toolchain( - name = "cc_source_toolchain_bazel7", - exec_compatible_with = [], - target_compatible_with = [], - toolchain = "//:cc_toolchain", - toolchain_type = "@rules_cc//cc/proto:toolchain_type", -) - -toolchain( - name = "java_source_toolchain_bazel7", - exec_compatible_with = [], - target_compatible_with = [], - toolchain = "//java/core:toolchain", - toolchain_type = "@rules_java//java/proto:toolchain_type", -) - -toolchain( - name = "javalite_source_toolchain_bazel7", - exec_compatible_with = [], - target_compatible_with = [], - toolchain = "//java/lite:toolchain", - toolchain_type = "@rules_java//java/proto:lite_toolchain_type", -) - filegroup( name = "for_bazel_tests", testonly = True, diff --git a/bazel/proto_library.bzl b/bazel/proto_library.bzl index 289f605c61..1a79e0a919 100644 --- a/bazel/proto_library.bzl +++ b/bazel/proto_library.bzl @@ -9,10 +9,4 @@ load("//bazel/private:proto_library_rule.bzl", _proto_library = "proto_library") -def proto_library(**kwattrs): - # Only use Starlark rules when they are removed from Bazel. - if not hasattr(native, "proto_library"): - _proto_library(**kwattrs) - else: - # On older Bazel versions keep using native rules, so that mismatch in ProtoInfo doesn't happen - native.proto_library(**kwattrs) # buildifier: disable=native-proto +proto_library = _proto_library diff --git a/bazel/tests/protobuf_test_proto_library.bzl b/bazel/tests/protobuf_test_proto_library.bzl deleted file mode 100644 index 57af34fcde..0000000000 --- a/bazel/tests/protobuf_test_proto_library.bzl +++ /dev/null @@ -1,20 +0,0 @@ -"""This module defines a wrapper around proto_library for Bazel versions that do not support certain attributes yet.""" - -load("//bazel:proto_library.bzl", "proto_library") - -def protobuf_test_proto_library(**kwattrs): - """ - Creates a proto library, handling any attributes that are not supported by the proto_library rule. - - Args: - **kwattrs: Additional arguments to pass to the proto_library rule. - """ - kwargs = dict(kwattrs) - - # TODO: Bazel 7's proto_library rule does not support option_deps, so we handle it by putting it in deps instead. - if "option_deps" in kwargs and hasattr(native, "proto_library"): - deps = kwargs.pop("deps", []) - option_deps = kwargs.pop("option_deps") - kwargs["deps"] = depset(deps + option_deps).to_list() - - proto_library(**kwargs) diff --git a/ci/common.bazelrc b/ci/common.bazelrc index 879f7d4ef4..1571a12a99 100644 --- a/ci/common.bazelrc +++ b/ci/common.bazelrc @@ -34,11 +34,6 @@ build:ubsan --copt=-fno-sanitize=function --copt=-fno-sanitize=vptr # Abseil passes nullptr to memcmp with 0 size build:ubsan --copt=-fno-sanitize=nonnull-attribute -# Workaround Bazel 7 remote cache issues. -# See https://github.com/bazelbuild/bazel/issues/20161 -build --experimental_remote_cache_eviction_retries=5 -build --remote_download_outputs=all - # Build with all --incompatible flags that we can. This helps us prepare for # upcoming breaking changes in Bazel. This list was generated for Bazel 6 by # running bazelisk with the --migrate flag and filtering out all flags that diff --git a/java/core/BUILD.bazel b/java/core/BUILD.bazel index c6143b24e9..3d7ea4db97 100644 --- a/java/core/BUILD.bazel +++ b/java/core/BUILD.bazel @@ -7,10 +7,6 @@ load("//bazel:cc_proto_library.bzl", "cc_proto_library") load("//bazel:java_lite_proto_library.bzl", "java_lite_proto_library") load("//bazel:java_proto_library.bzl", "java_proto_library") load("//bazel:proto_library.bzl", "proto_library") -load( - "//bazel/tests:protobuf_test_proto_library.bzl", - "protobuf_test_proto_library", -) load("//bazel/toolchains:proto_lang_toolchain.bzl", "proto_lang_toolchain") load("//build_defs:java_opts.bzl", "protobuf_java_export", "protobuf_java_library", "protobuf_versioned_java_library") load("//conformance:defs.bzl", "conformance_test") @@ -345,7 +341,7 @@ proto_lang_toolchain( visibility = ["//visibility:public"], ) -protobuf_test_proto_library( +proto_library( name = "java_test_protos", srcs = glob([ "src/test/proto/**/*.proto", diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl index fa48d218d3..92320d30f6 100644 --- a/protobuf_deps.bzl +++ b/protobuf_deps.bzl @@ -53,17 +53,6 @@ def _github_archive(repo, commit, **kwargs): def protobuf_deps(): """Loads common dependencies needed to compile the protobuf library.""" - # Pin rules_proto since Bazel 7 otherwise depends on rules_proto 5.3.0-21.7 which is missing - # @rules_proto//proto:toolchain_type used by Bazel. - # 6.0.0 would at least require users to add `register_toolchains` for rules_proto - # TODO: Remove once Bazel 7 is no longer supported. - if not native.existing_rule("rules_proto"): - http_archive( - name = "rules_proto", - sha256 = "14a225870ab4e91869652cfd69ef2028277fc1dc4910d65d353b62d6e0ae21f4", - strip_prefix = "rules_proto-7.1.0", - url = "https://github.com/bazelbuild/rules_proto/releases/download/7.1.0/rules_proto-7.1.0.tar.gz", - ) if not native.existing_rule("bazel_features"): http_archive( name = "bazel_features", diff --git a/src/google/protobuf/BUILD.bazel b/src/google/protobuf/BUILD.bazel index bf02a276f8..bbdc70338b 100644 --- a/src/google/protobuf/BUILD.bazel +++ b/src/google/protobuf/BUILD.bazel @@ -6,10 +6,6 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix") load("//bazel:cc_proto_library.bzl", "cc_proto_library") load("//bazel:proto_library.bzl", "proto_library") -load( - "//bazel/tests:protobuf_test_proto_library.bzl", - "protobuf_test_proto_library", -) load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS") load("//upb/bazel:upb_c_proto_library.bzl", "upb_c_proto_library") load("//upb/bazel:upb_minitable_proto_library.bzl", "upb_minitable_proto_library") @@ -1154,7 +1150,7 @@ filegroup( visibility = ["//:__subpackages__"], ) -protobuf_test_proto_library( +proto_library( name = "test_protos", srcs = [ "any_test.proto", @@ -1296,7 +1292,7 @@ cc_proto_library( deps = [":unittest_features_proto"], ) -protobuf_test_proto_library( +proto_library( name = "generic_test_protos", srcs = [":test_proto_srcs"], option_deps = [ @@ -1322,7 +1318,7 @@ protobuf_test_proto_library( ], ) -protobuf_test_proto_library( +proto_library( name = "generic_test_editions_protos", srcs = [":test_proto_editions_srcs"], option_deps = [ @@ -1432,7 +1428,7 @@ proto_library( ], ) -protobuf_test_proto_library( +proto_library( name = "unittest_import_option_proto", srcs = ["unittest_import_option.proto"], option_deps = [