From 7bd1da828b8b55b2f21b5ebe25f2eaf88b6a10f8 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Tue, 3 May 2022 20:13:11 +0000 Subject: [PATCH 1/6] Remove duplicate java generated code --- java/kotlin/generate-sources-build.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/java/kotlin/generate-sources-build.xml b/java/kotlin/generate-sources-build.xml index b78bc0ba7..6963f3717 100644 --- a/java/kotlin/generate-sources-build.xml +++ b/java/kotlin/generate-sources-build.xml @@ -3,7 +3,6 @@ - From a1fca10ddc2c758cafaa6891d4ef971b8a0d06b0 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Wed, 4 May 2022 16:02:12 -0400 Subject: [PATCH 2/6] Use PROTOBUF_CONSTEXPR instead of constexpr for kRepHeaderSize. (#9885) Fixes "no matching function for call to 'CalculateReserveSize'" compiler errors with older clang versions. --- src/google/protobuf/port_def.inc | 2 +- src/google/protobuf/repeated_field.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 315c775e2..dcb0ff758 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -655,7 +655,7 @@ #define PROTOBUF_CONSTEXPR constexpr #else #define PROTOBUF_CONSTINIT -#define PROTOBUF_CONSTEXPR inline +#define PROTOBUF_CONSTEXPR #endif // Some globals with an empty non-trivial destructor are annotated with diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index d82e135ae..3fb734e5c 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -346,7 +346,7 @@ class RepeatedField final { int total_size_; // Pad the Rep after arena allow for power-of-two byte sizes when // sizeof(Element) > sizeof(Arena*). eg for 16-byte objects. - static constexpr size_t kRepHeaderSize = + static PROTOBUF_CONSTEXPR const size_t kRepHeaderSize = sizeof(Arena*) < sizeof(Element) ? sizeof(Element) : sizeof(Arena*); struct Rep { Arena* arena; From 3c5ad8c52450f8089143eaf8f971d99a3ae8a818 Mon Sep 17 00:00:00 2001 From: "David L. Jones" Date: Wed, 4 May 2022 13:38:16 -0700 Subject: [PATCH 3/6] Remove references to //:composer.json and JS compiler. (#9910) --- BUILD.bazel | 9 --------- pkg/BUILD.bazel | 5 +---- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 335261439..86cc1ce06 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1569,15 +1569,6 @@ pkg_files( visibility = ["//pkg:__pkg__"], ) -# Additional files for PHP -pkg_files( - name = "php_dist_files", - srcs = [ - "composer.json", - ], - visibility = ["//pkg:__pkg__"], -) - # Python runtime pkg_files( name = "python_dist_files", diff --git a/pkg/BUILD.bazel b/pkg/BUILD.bazel index c5ed05e0f..a197c74ec 100644 --- a/pkg/BUILD.bazel +++ b/pkg/BUILD.bazel @@ -211,7 +211,6 @@ pkg_filegroup( name = "php_srcs", srcs = [ ":dist_common", - "//:php_dist_files", "//php:dist_files", ], ) @@ -339,11 +338,9 @@ gen_automake_file_lists( "//csharp:dist_files": "dist_csharp2", "//:objectivec_dist_files": "dist_objectivec", "//objectivec:dist_files": "dist_objectivec2", - "//:php_dist_files": "dist_php", - "//php:dist_files": "dist_php2", + "//php:dist_files": "dist_php", "//:python_dist_files": "dist_python", "//ruby:dist_files": "dist_ruby", - "//js:dist_files": "dist_js", }, ) From a3193ed5ee7d42cd5d9d84586b9cfdd310b85743 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Wed, 4 May 2022 23:17:07 +0000 Subject: [PATCH 4/6] Fix spelling error --- src/google/protobuf/compiler/cpp/helpers.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/google/protobuf/compiler/cpp/helpers.cc b/src/google/protobuf/compiler/cpp/helpers.cc index b29962fd8..ac8d4ebff 100644 --- a/src/google/protobuf/compiler/cpp/helpers.cc +++ b/src/google/protobuf/compiler/cpp/helpers.cc @@ -574,7 +574,7 @@ std::string FieldMemberName(const FieldDescriptor* field, bool split) { if (field->real_containing_oneof() == nullptr) { return StrCat(prefix, split_prefix, FieldName(field), "_"); } - // Oneof fields are enver split. + // Oneof fields are never split. GOOGLE_CHECK(!split); return StrCat(prefix, field->containing_oneof()->name(), "_.", FieldName(field), "_"); From df00695437bcfa3abbbfb3b00aa4baf60fea46d7 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Wed, 4 May 2022 23:43:54 +0000 Subject: [PATCH 5/6] Remove unused ShouldVerifyInt32() function --- src/google/protobuf/compiler/cpp/helpers.cc | 57 --------------------- 1 file changed, 57 deletions(-) diff --git a/src/google/protobuf/compiler/cpp/helpers.cc b/src/google/protobuf/compiler/cpp/helpers.cc index ac8d4ebff..79800f135 100644 --- a/src/google/protobuf/compiler/cpp/helpers.cc +++ b/src/google/protobuf/compiler/cpp/helpers.cc @@ -202,63 +202,6 @@ inline VerifySimpleType VerifyInt32TypeToVerifyCustom(VerifyInt32Type t) { static_cast(VerifyInt32Type::kCustom)]; } -// Returns one of int32 verification types: kNever, kCustom, kAlways. -// -// We need to verify int32 encoding to detect non-canonical encoding (5B for -// negative int32) and fallback to eager parsing. -// -// kNever skips int32 check because there is no int32 field. kAlways -// unconditionally verifies int32 encoding because all or almost varint fields -// are int32. Otherwise, kCustom verifies int32 encoding only on exact field -// number match. Note the following tweaks: -// --uint32 very likely causes false positives. Having one requires kCustom. -// --kCustom may be cheap enough if all int32 fields fit into a bitmask. -// --Otherwise, try always check if X% of varint fields are int32. -VerifyInt32Type ShouldVerifyInt32(const Descriptor* descriptor) { - int num_int32 = 0; - int num_int32_big_number = 0; - int num_uint32 = 0; - int num_other_varint = 0; - - for (const auto* field : FieldRange(descriptor)) { - switch (field->type()) { - case FieldDescriptor::TYPE_INT32: - ++num_int32; - if (field->number() > 64) ++num_int32_big_number; - break; - case FieldDescriptor::TYPE_UINT32: - ++num_uint32; - ++num_other_varint; - break; - default: - if (internal::WireFormat::WireTypeForFieldType(field->type()) == - internal::WireFormatLite::WIRETYPE_VARINT) { - ++num_other_varint; - } - break; - } - } - - // If there is no int32 fields, no need to check int32 encoding. - if (num_int32 == 0) return VerifyInt32Type::kNever; - - // If all varint fields are int32, *always* check int32 encoding. - if (num_other_varint == 0) return VerifyInt32Type::kAlways; - - // Negative uint32 encoding will cause fallback eager parsing as it appears - // non-canonical encoding. Also, if all int32 fields fit into a 64 bit mask, - // checking bitmask is affordable. Try exact match in these cases. - if (num_uint32 > 0 || num_int32_big_number == 0) { - return VerifyInt32Type::kCustom; - } - - // If a given varint is likely int32, we should just always check. Let's use - // an arbitrary threshold of 75% (#int32 / #varints). - constexpr int kLikelyInt32Pct = 75; - return (100 * num_int32) / (num_int32 + num_other_varint) >= kLikelyInt32Pct - ? VerifyInt32Type::kAlways - : VerifyInt32Type::kCustom; -} } // namespace From 67823fe8dc7d57ca33689817c233dcf4f177fa4b Mon Sep 17 00:00:00 2001 From: "David L. Jones" Date: Wed, 4 May 2022 17:30:23 -0700 Subject: [PATCH 6/6] [Bazel] Fix broken build rules or mark them manual (#9913) * Fix filename for unittest_gen_import.proto. * Add 'manual' tags to jvm_export rules so they aren't selected by wildcard * Run buildifier --- BUILD.bazel | 72 ++++++++++++++++++++---------------- java/core/BUILD.bazel | 2 + java/kotlin-lite/BUILD.bazel | 1 + java/kotlin/BUILD.bazel | 1 + java/util/BUILD.bazel | 1 + 5 files changed, 45 insertions(+), 32 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 86cc1ce06..cc623aac7 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -801,10 +801,13 @@ cc_test( "src/google/protobuf/**/*", # Files for csharp_bootstrap_unittest.cc. "conformance/**/*", - ]) + glob([ - # Files for csharp_bootstrap_unittest.cc. - "csharp/src/**/*", - ], allow_empty=True), + ]) + glob( + [ + # Files for csharp_bootstrap_unittest.cc. + "csharp/src/**/*", + ], + allow_empty = True, + ), includes = [ "src/", ], @@ -1020,10 +1023,6 @@ py_proto_library( py_library( name = "protobuf_python", - deps = [ - ":well_known_types_py_pb2", - ":python_srcs", - ], data = select({ "//conditions:default": [], ":use_fast_cpp_protos": [ @@ -1031,6 +1030,10 @@ py_library( ":python/google/protobuf/pyext/_message.so", ], }), + deps = [ + ":python_srcs", + ":well_known_types_py_pb2", + ], ) # Copy the test proto files from src/google/protobuf to @@ -1058,8 +1061,8 @@ py_proto_library( default_runtime = "", protoc = ":protoc", srcs_version = "PY2AND3", - deps = [":well_known_types_py_pb2"], visibility = ["//visibility:public"], + deps = [":well_known_types_py_pb2"], ) py_proto_library( @@ -1072,8 +1075,8 @@ py_proto_library( default_runtime = ":protobuf_python", protoc = ":protoc", srcs_version = "PY2AND3", - deps = [":python_common_test_protos"], visibility = ["//visibility:public"], + deps = [":python_common_test_protos"], ) py_library( @@ -1139,12 +1142,14 @@ proto_lang_toolchain( alias( name = "objectivec", actual = "//objectivec", + tags = ["manual"], visibility = ["//visibility:public"], ) alias( name = "protobuf_objc", actual = "//objectivec", + tags = ["manual"], visibility = ["//visibility:public"], ) @@ -1155,7 +1160,7 @@ alias( genrule( name = "generated_protos", srcs = ["src/google/protobuf/unittest_import.proto"], - outs = ["unittest_gen.proto"], + outs = ["unittest_gen_import.proto"], cmd = "cat $(SRCS) | sed 's|google/|src/google/|' > $(OUTS)", ) @@ -1474,28 +1479,31 @@ internal_gen_kt_protos( # Files included in all source distributions pkg_files( name = "common_dist_files", - srcs = glob([ - "*.bzl", - "cmake/*.cmake", - "cmake/*.in", - "editors/*", + srcs = glob( + [ + "*.bzl", + "cmake/*.cmake", + "cmake/*.in", + "editors/*", - # Several of these files are generated by autogen.sh, so using - # glob() lets us ignore them if they are missing. (This is not good - # practice, though.) - "Makefile.in", - "aclocal.m4", - "ar-lib", - "compile", - "config*", - "depcomp", - "install-sh", - "ltmain.sh", - "m4/*.m4", - "missing", - "protobuf*.pc.in", - "test-driver", - ], allow_empty = True) + [ + # Several of these files are generated by autogen.sh, so using + # glob() lets us ignore them if they are missing. (This is not good + # practice, though.) + "Makefile.in", + "aclocal.m4", + "ar-lib", + "compile", + "config*", + "depcomp", + "install-sh", + "ltmain.sh", + "m4/*.m4", + "missing", + "protobuf*.pc.in", + "test-driver", + ], + allow_empty = True, + ) + [ "BUILD.bazel", "CHANGES.txt", "CMakeLists.txt", diff --git a/java/core/BUILD.bazel b/java/core/BUILD.bazel index 60be80719..e36a38e7f 100644 --- a/java/core/BUILD.bazel +++ b/java/core/BUILD.bazel @@ -121,6 +121,7 @@ java_export( resources = [ "//:lite_well_known_protos", ], + tags = ["manual"], runtime_deps = [":lite"], ) @@ -156,6 +157,7 @@ java_export( resources = [ "//:well_known_protos", ], + tags = ["manual"], runtime_deps = [":core"], ) diff --git a/java/kotlin-lite/BUILD.bazel b/java/kotlin-lite/BUILD.bazel index 47b02c2ae..09f0decff 100644 --- a/java/kotlin-lite/BUILD.bazel +++ b/java/kotlin-lite/BUILD.bazel @@ -37,6 +37,7 @@ kt_jvm_export( maven_coordinates = "com.google.protobuf:protobuf-kotlin-lite:%s" % PROTOBUF_JAVA_VERSION, pom_template = "//java/kotlin-lite:pom_template.xml", resources = ["//:well_known_protos"], + tags = ["manual"], runtime_deps = [ ":lite_extensions", ":well_known_protos_kotlin_lite", diff --git a/java/kotlin/BUILD.bazel b/java/kotlin/BUILD.bazel index a3cf83d46..859b86ba3 100644 --- a/java/kotlin/BUILD.bazel +++ b/java/kotlin/BUILD.bazel @@ -59,6 +59,7 @@ kt_jvm_export( maven_coordinates = "com.google.protobuf:protobuf-kotlin:%s" % PROTOBUF_JAVA_VERSION, pom_template = "//java/kotlin:pom_template.xml", resources = ["//:well_known_protos"], + tags = ["manual"], runtime_deps = [ ":bytestring_lib", ":full_extensions", diff --git a/java/util/BUILD.bazel b/java/util/BUILD.bazel index bea3099da..e3804fb97 100644 --- a/java/util/BUILD.bazel +++ b/java/util/BUILD.bazel @@ -27,6 +27,7 @@ java_export( deploy_env = ["//java/core"], maven_coordinates = "com.google.protobuf:protobuf-java-util:%s" % PROTOBUF_JAVA_VERSION, pom_template = "pom_template.xml", + tags = ["manual"], visibility = ["//java:__pkg__"], runtime_deps = [":util"], )