diff --git a/.bazelrc b/.bazelrc
index 732859d082..554440cfe3 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -1 +1 @@
-build --cxxopt=-std=c++14
\ No newline at end of file
+build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
diff --git a/.github/workflows/generated_cmake.yml b/.github/workflows/generated_cmake.yml
index 91dcd4f1e7..640bd137ec 100644
--- a/.github/workflows/generated_cmake.yml
+++ b/.github/workflows/generated_cmake.yml
@@ -1,24 +1,29 @@
-name: Generated CMake File Lists
+name: Generate CMake File Lists
on:
- - push
- - pull_request
+ push:
+ branches:
+ - main
+ - '[0-9]+.x'
+ # The 21.x branch predates support for auto-generation of the CMake file
+ # lists, so we make sure to exclude it.
+ - '!21.x'
jobs:
cmake:
+ if: github.repository == 'protocolbuffers/protobuf'
runs-on: ubuntu-latest
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
steps:
- - uses: actions/checkout@v2
- - name: Set up Bazel read-only caching
- run: echo "BAZEL_CACHE_AUTH=--remote_upload_local_results=false" >> $GITHUB_ENV
- - name: Generate CMake files
- run: cd ${{ github.workspace }} && bazel build //pkg:gen_src_file_lists --test_output=errors $BAZEL_CACHE $BAZEL_CACHE_AUTH
- - name: Compare to Golden file
- run: diff -du bazel-bin/pkg/src_file_lists.cmake src/file_lists.cmake
- - name: Report
- run: echo "::error file=cmake/update_file_lists.sh::CMake files are stale, please run cmake/update_file_lists.sh"
- if: failure()
+ - uses: actions/checkout@v3
+ with:
+ # Note: this token has an expiration date, so if the workflow starts
+ # failing then you may need to generate a fresh token.
+ token: ${{ secrets.BOT_ACCESS_TOKEN }}
+ - name: Configure name and email address in Git
+ run: cd ${{ github.workspace }} && git config user.name "Protobuf Team Bot" && git config user.email "protobuf-team-bot@google.com"
+ - name: Commit and push update
+ run: cd ${{ github.workspace }} && ./cmake/push_auto_update.sh
diff --git a/BUILD.bazel b/BUILD.bazel
index 67cd2dbfc4..b63b7bf984 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -294,18 +294,8 @@ alias(
proto_lang_toolchain(
name = "cc_toolchain",
blacklisted_protos = [
- "@com_google_protobuf//:any_proto",
- "@com_google_protobuf//:api_proto",
"@com_google_protobuf//:compiler_plugin_proto",
"@com_google_protobuf//:descriptor_proto",
- "@com_google_protobuf//:duration_proto",
- "@com_google_protobuf//:empty_proto",
- "@com_google_protobuf//:field_mask_proto",
- "@com_google_protobuf//:source_context_proto",
- "@com_google_protobuf//:struct_proto",
- "@com_google_protobuf//:timestamp_proto",
- "@com_google_protobuf//:type_proto",
- "@com_google_protobuf//:wrappers_proto",
],
command_line = "--cpp_out=$(OUT)",
runtime = ":protobuf",
diff --git a/CHANGES.txt b/CHANGES.txt
index 8cd58aa13b..2dc86330a3 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -43,6 +43,11 @@
Compiler
* Print full path name of source .proto file on error
+2022-09-13 version 21.6 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
+
+C++
+* Reduce memory consumption of MessageSet parsing
+
2022-08-09 version 21.5 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
PHP
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6f9b7517f3..dead8be84a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,6 +19,10 @@ endif()
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
+# Honor visibility properties for all target types.
+if(POLICY CMP0063)
+ cmake_policy(SET CMP0063 NEW)
+endif()
# Project
project(protobuf C CXX)
@@ -32,15 +36,32 @@ if(protobuf_DEPRECATED_CMAKE_SUBDIRECTORY_USAGE)
get_filename_component(protobuf_SOURCE_DIR ${protobuf_SOURCE_DIR} DIRECTORY)
endif()
-# Add c++14 flags
-if (CYGWIN)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14")
-else()
+# Add C++14 flags
+if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
+endif()
+if(CYGWIN)
+ string(REGEX_MATCH "-std=gnu\\+\\+([0-9]+)" _protobuf_CXX_STD "${CMAKE_CXX_FLAGS}")
+endif()
+if(NOT _protobuf_CXX_STD)
+ set(_protobuf_CXX_STD "${CMAKE_CXX_STANDARD}")
+endif()
+if(_protobuf_CXX_STD LESS "14")
+ message(FATAL_ERROR "Protocol Buffers requires at least C++14, but is configured for C++${_protobuf_CXX_STD}")
+endif()
+if(CYGWIN)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++${_protobuf_CXX_STD}")
+else()
+ set(CMAKE_CXX_STANDARD ${_protobuf_CXX_STD})
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
+# For -fvisibility=hidden and -fvisibility-inlines-hidden
+set(CMAKE_C_VISIBILITY_PRESET hidden)
+set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
+
# The Intel compiler isn't able to deal with noinline member functions of
# template classes defined in headers. As such it spams the output with
# warning #2196: routine is both "inline" and "noinline"
diff --git a/Protobuf.podspec b/Protobuf.podspec
index eb87a8f81a..b3e843485e 100644
--- a/Protobuf.podspec
+++ b/Protobuf.podspec
@@ -5,7 +5,7 @@
# dependent projects use the :git notation to refer to the library.
Pod::Spec.new do |s|
s.name = 'Protobuf'
- s.version = '3.21.5'
+ s.version = '3.21.6'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
s.homepage = 'https://github.com/protocolbuffers/protobuf'
s.license = 'BSD-3-Clause'
diff --git a/conformance/README.md b/conformance/README.md
index 2f62f0ff90..8569a6a7b3 100644
--- a/conformance/README.md
+++ b/conformance/README.md
@@ -81,7 +81,7 @@ Ruby:
JRuby:
$ [[ $(ruby --version) == "jruby"* ]] || echo "Switch to Java Ruby!"
- $ bazel test //ruby:conformance_test --define=ruby_platform=java \
+ $ bazel test //ruby:conformance_test_jruby --define=ruby_platform=java \
--action_env=PATH --action_env=GEM_PATH --action_env=GEM_HOME
Testing other Protocol Buffer implementations
diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec
index 5b71f9f040..096d0a47c1 100644
--- a/csharp/Google.Protobuf.Tools.nuspec
+++ b/csharp/Google.Protobuf.Tools.nuspec
@@ -5,7 +5,7 @@
Google Protocol Buffers tools
Tools for Protocol Buffers - Google's data interchange format.
See project site for more info.
- 3.21.5
+ 3.21.6
Google Inc.
protobuf-packages
https://github.com/protocolbuffers/protobuf/blob/main/LICENSE
diff --git a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
index b5d6c0bbe3..c03b326c08 100644
--- a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
+++ b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
@@ -576,6 +576,10 @@ namespace Google.Protobuf
[TestCase("-3.402823e38", -3.402823e38f)]
[TestCase("1.5e1", 15f)]
[TestCase("15e-1", 1.5f)]
+ [TestCase("3.4028235e38", float.MaxValue)]
+ [TestCase("-3.4028235e38", float.MinValue)]
+ [TestCase("3.4028235e+38", float.MaxValue)]
+ [TestCase("-3.4028235e+38", float.MinValue)]
public void NumberToFloat_Valid(string jsonValue, float expectedParsedValue)
{
string json = "{ \"singleFloat\": " + jsonValue + "}";
@@ -584,8 +588,10 @@ namespace Google.Protobuf
}
[Test]
- [TestCase("3.402824e38", typeof(InvalidProtocolBufferException))]
- [TestCase("-3.402824e38", typeof(InvalidProtocolBufferException))]
+ [TestCase("3.4028236e38", typeof(InvalidProtocolBufferException))]
+ [TestCase("-3.4028236e38", typeof(InvalidProtocolBufferException))]
+ [TestCase("3.4028236e+38", typeof(InvalidProtocolBufferException))]
+ [TestCase("-3.4028236e+38", typeof(InvalidProtocolBufferException))]
[TestCase("1,0", typeof(InvalidJsonException))]
[TestCase("1.0.0", typeof(InvalidJsonException))]
[TestCase("+1", typeof(InvalidJsonException))]
diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj
index eb5df6fa4d..af93a2c6d9 100644
--- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj
+++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj
@@ -4,7 +4,7 @@
C# runtime library for Protocol Buffers - Google's data interchange format.
Copyright 2015, Google Inc.
Google Protocol Buffers
- 3.21.5
+ 3.21.6
10.0
Google Inc.
netstandard1.1;netstandard2.0;net45;net50
diff --git a/csharp/src/Google.Protobuf/JsonParser.cs b/csharp/src/Google.Protobuf/JsonParser.cs
index 3575e2529e..6cb98d6e24 100644
--- a/csharp/src/Google.Protobuf/JsonParser.cs
+++ b/csharp/src/Google.Protobuf/JsonParser.cs
@@ -642,19 +642,15 @@ namespace Google.Protobuf
{
return float.NaN;
}
- if (value > float.MaxValue || value < float.MinValue)
+ float converted = (float) value;
+ // If the value is out of range of float, the cast representation will be infinite.
+ // If the original value was infinite as well, that's fine - we'll return the 32-bit
+ // version (with the correct sign).
+ if (float.IsInfinity(converted) && !double.IsInfinity(value))
{
- if (double.IsPositiveInfinity(value))
- {
- return float.PositiveInfinity;
- }
- if (double.IsNegativeInfinity(value))
- {
- return float.NegativeInfinity;
- }
throw new InvalidProtocolBufferException($"Value out of range: {value}");
}
- return (float) value;
+ return converted;
case FieldType.Enum:
CheckInteger(value);
// Just return it as an int, and let the CLR convert it.
diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs
index c290558135..e252372edd 100644
--- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs
@@ -6641,6 +6641,10 @@ namespace Google.Protobuf.Reflection {
private bool mapEntry_;
///
+ /// NOTE: Do not set the option in .proto files. Always use the maps syntax
+ /// instead. The option should only be implicitly set by the proto compiler
+ /// parser.
+ ///
/// Whether the message is an automatically generated map entry type for the
/// maps field.
///
@@ -6658,10 +6662,6 @@ namespace Google.Protobuf.Reflection {
/// use a native map in the target language to hold the keys and values.
/// The reflection APIs in such implementations still need to work as
/// if the field is a repeated message field.
- ///
- /// NOTE: Do not set the option in .proto files. Always use the maps syntax
- /// instead. The option should only be implicitly set by the proto compiler
- /// parser.
///
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
diff --git a/docs/options.md b/docs/options.md
index dc19688235..87f7dca50b 100644
--- a/docs/options.md
+++ b/docs/options.md
@@ -344,3 +344,7 @@ with info about your project (name and website) so we can add an entry for you.
1. mypy-protobuf
* Website: https://github.com/nipunn1313/mypy-protobuf
* Extension: 1151-1154
+
+1. Pigweed protobuf compiler
+ * Website: https://pigweed.dev/pw_protobuf
+ * Extension: 1155
diff --git a/examples/.bazelrc b/examples/.bazelrc
new file mode 100644
index 0000000000..554440cfe3
--- /dev/null
+++ b/examples/.bazelrc
@@ -0,0 +1 @@
+build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
diff --git a/java/README.md b/java/README.md
index 3a022f0929..6a23c0d9e8 100644
--- a/java/README.md
+++ b/java/README.md
@@ -23,7 +23,7 @@ If you are using Maven, use the following:
com.google.protobuf
protobuf-java
- 3.21.5
+ 3.21.6
```
@@ -37,7 +37,7 @@ protobuf-java-util package:
com.google.protobuf
protobuf-java-util
- 3.21.5
+ 3.21.6
```
@@ -45,7 +45,7 @@ protobuf-java-util package:
If you are using Gradle, add the following to your `build.gradle` file's dependencies:
```
- implementation 'com.google.protobuf:protobuf-java:3.21.5'
+ implementation 'com.google.protobuf:protobuf-java:3.21.6'
```
Again, be sure to check that the version number matches (or is newer than) the version number of protoc that you are using.
diff --git a/java/bom/pom.xml b/java/bom/pom.xml
index 4504729f9c..1196d3685c 100644
--- a/java/bom/pom.xml
+++ b/java/bom/pom.xml
@@ -4,7 +4,7 @@
com.google.protobuf
protobuf-bom
- 3.21.5
+ 3.21.6
pom
Protocol Buffers [BOM]
diff --git a/java/core/pom.xml b/java/core/pom.xml
index 9315004516..7e5e8df1d7 100644
--- a/java/core/pom.xml
+++ b/java/core/pom.xml
@@ -4,7 +4,7 @@
com.google.protobuf
protobuf-parent
- 3.21.5
+ 3.21.6
protobuf-java
diff --git a/java/core/src/main/java/com/google/protobuf/TextFormat.java b/java/core/src/main/java/com/google/protobuf/TextFormat.java
index 7fba30a04e..aa1cc34a6a 100644
--- a/java/core/src/main/java/com/google/protobuf/TextFormat.java
+++ b/java/core/src/main/java/com/google/protobuf/TextFormat.java
@@ -61,7 +61,6 @@ public final class TextFormat {
private static final String DEBUG_STRING_SILENT_MARKER = "\t ";
-
/**
* Outputs a textual representation of the Protocol Message supplied into the parameter output.
* (This representation is the new version of the classic "ProtocolPrinter" output from the
@@ -739,9 +738,9 @@ public final class TextFormat {
// Groups must be serialized with their original capitalization.
generator.print(field.getMessageType().getName());
} else {
- generator.print(field.getName());
- }
+ generator.print(field.getName());
}
+ }
if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
generator.print(" {");
@@ -1836,16 +1835,16 @@ public final class TextFormat {
extension = target.findExtensionByName(extensionRegistry, name);
if (extension == null) {
- String message =
- (tokenizer.getPreviousLine() + 1)
- + ":"
- + (tokenizer.getPreviousColumn() + 1)
- + ":\t"
- + type.getFullName()
- + ".["
- + name
- + "]";
- unknownFields.add(new UnknownField(message, UnknownField.Type.EXTENSION));
+ String message =
+ (tokenizer.getPreviousLine() + 1)
+ + ":"
+ + (tokenizer.getPreviousColumn() + 1)
+ + ":\t"
+ + type.getFullName()
+ + ".["
+ + name
+ + "]";
+ unknownFields.add(new UnknownField(message, UnknownField.Type.EXTENSION));
} else {
if (extension.descriptor.getContainingType() != type) {
throw tokenizer.parseExceptionPreviousToken(
diff --git a/java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto b/java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto
index 4ec968819b..95ab8c06d4 100644
--- a/java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto
+++ b/java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto
@@ -125,6 +125,3 @@ message ReservedAsMapFieldWithEnumValue {
// null is not a 'reserved word' per se but as a literal needs similar care
map null = 10;
}
-package map_for_proto2_lite_test;
-option java_package = "map_lite_test";
-option optimize_for = LITE_RUNTIME;
diff --git a/java/kotlin-lite/pom.xml b/java/kotlin-lite/pom.xml
index 03f28f5901..52bc1b3675 100644
--- a/java/kotlin-lite/pom.xml
+++ b/java/kotlin-lite/pom.xml
@@ -4,7 +4,7 @@
com.google.protobuf
protobuf-parent
- 3.21.5
+ 3.21.6
protobuf-kotlin-lite
diff --git a/java/kotlin/pom.xml b/java/kotlin/pom.xml
index 5fefa8157c..bc935c8c23 100644
--- a/java/kotlin/pom.xml
+++ b/java/kotlin/pom.xml
@@ -4,7 +4,7 @@
com.google.protobuf
protobuf-parent
- 3.21.5
+ 3.21.6
protobuf-kotlin
diff --git a/java/lite.md b/java/lite.md
index 2445ec3a88..6f003ed543 100644
--- a/java/lite.md
+++ b/java/lite.md
@@ -29,7 +29,7 @@ protobuf Java Lite runtime. If you are using Maven, include the following:
com.google.protobuf
protobuf-javalite
- 3.21.5
+ 3.21.6
```
diff --git a/java/lite/pom.xml b/java/lite/pom.xml
index c5ef4abc0d..ba65f5cbf4 100644
--- a/java/lite/pom.xml
+++ b/java/lite/pom.xml
@@ -4,7 +4,7 @@
com.google.protobuf
protobuf-parent
- 3.21.5
+ 3.21.6
protobuf-javalite
diff --git a/java/pom.xml b/java/pom.xml
index f8083c430a..197e7cd584 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -4,7 +4,7 @@
com.google.protobuf
protobuf-parent
- 3.21.5
+ 3.21.6
pom
Protocol Buffers [Parent]
diff --git a/java/util/pom.xml b/java/util/pom.xml
index 987163247d..0f02bb84df 100644
--- a/java/util/pom.xml
+++ b/java/util/pom.xml
@@ -4,7 +4,7 @@
com.google.protobuf
protobuf-parent
- 3.21.5
+ 3.21.6
protobuf-java-util
diff --git a/kokoro/linux/32-bit/test_php.sh b/kokoro/linux/32-bit/test_php.sh
index 3770b84af3..739467b20c 100644
--- a/kokoro/linux/32-bit/test_php.sh
+++ b/kokoro/linux/32-bit/test_php.sh
@@ -36,9 +36,13 @@ build_php_c() {
test_php_c
}
-cmake .
-cmake --build . --target protoc -- -j20
+mkdir build
+pushd build
+cmake ..
+cmake --build . -- -j20
+ctest --verbose --parallel 20
export PROTOC=$(pwd)/protoc
+popd
build_php 7.0
build_php 7.1
@@ -49,3 +53,6 @@ build_php_c 7.4
build_php_c 7.1-zts
build_php_c 7.2-zts
build_php_c 7.5-zts
+
+# Cleanup after CMake build
+rm -rf build
diff --git a/kokoro/linux/bazel/common.cfg b/kokoro/linux/bazel/common.cfg
index 6d35d8bbaa..cd41cb2cb8 100644
--- a/kokoro/linux/bazel/common.cfg
+++ b/kokoro/linux/bazel/common.cfg
@@ -6,7 +6,7 @@ timeout_mins: 15
env_vars {
key: "BAZEL_TARGETS"
- value: "//src/..."
+ value: "//src/... @com_google_protobuf_examples//..."
}
action {
diff --git a/kokoro/linux/cmake/build.sh b/kokoro/linux/cmake/build.sh
index 523253da25..ee06d95cf9 100755
--- a/kokoro/linux/cmake/build.sh
+++ b/kokoro/linux/cmake/build.sh
@@ -19,7 +19,7 @@ docker run \
--cidfile $tmpfile \
-v $GIT_REPO_ROOT:/workspace \
$CONTAINER_IMAGE \
- /test.sh -Dprotobuf_BUILD_CONFORMANCE=ON
+ /test.sh -Dprotobuf_BUILD_CONFORMANCE=ON -Dprotobuf_BUILD_EXAMPLES=ON
# Save logs for Kokoro
docker cp \
diff --git a/kokoro/macos/ruby31/build.sh b/kokoro/macos/ruby31/build.sh
index 57914bd060..6e4beda2cc 100644
--- a/kokoro/macos/ruby31/build.sh
+++ b/kokoro/macos/ruby31/build.sh
@@ -5,6 +5,9 @@
# Change to repo root
cd $(dirname $0)/../../..
+# Fix locale issues in Monterey.
+export LC_ALL=en_US.UTF-8
+
# Prepare worker environment to run tests
KOKORO_INSTALL_RVM=yes
source kokoro/macos/prepare_build_macos_rc
diff --git a/kokoro/release/ruby/macos/ruby/ruby_build_environment.sh b/kokoro/release/ruby/macos/ruby/ruby_build_environment.sh
index ae973fce43..4002d6d1f7 100755
--- a/kokoro/release/ruby/macos/ruby/ruby_build_environment.sh
+++ b/kokoro/release/ruby/macos/ruby/ruby_build_environment.sh
@@ -2,6 +2,10 @@
set -ex
+# Fix permissions
+sudo chown -R $(whoami) $HOME/.rvm/
+sudo chown -R $(whoami) /Library/Ruby/
+
set +ex # rvm script is very verbose and exits with errorcode
# Fix permissions
diff --git a/kokoro/windows/bazel/build.bat b/kokoro/windows/bazel/build.bat
index 0b2ba9fc13..55fba16579 100644
--- a/kokoro/windows/bazel/build.bat
+++ b/kokoro/windows/bazel/build.bat
@@ -24,7 +24,7 @@ bazel %BAZEL_STARTUP% build //:protoc //:protobuf //:protobuf_lite %BAZEL_FLAGS%
@rem TODO(b/241484899) Enable conformance tests on windows.
bazel %BAZEL_STARTUP% test %BAZEL_FLAGS% ^
--test_tag_filters=-conformance --build_tag_filters=-conformance ^
- //src/... || goto :error
+ //src/... @com_google_protobuf_examples//... || goto :error
goto :EOF
diff --git a/kokoro/windows/cmake/build.bat b/kokoro/windows/cmake/build.bat
index 29d012ba1c..d24e635d24 100644
--- a/kokoro/windows/cmake/build.bat
+++ b/kokoro/windows/cmake/build.bat
@@ -6,13 +6,14 @@ call kokoro\windows\prepare_build_win64.bat || goto :error
@rem TODO(b/241475022) Use docker to guarantee better stability.
@rem TODO(b/241484899) Run conformance tests in windows.
-md build -ea 0
-md %KOKORO_ARTIFACTS_DIR%\logs -ea 0
+md build
+md %KOKORO_ARTIFACTS_DIR%\logs
cd build
cmake .. ^
-G "Visual Studio 15 2017" -A x64 ^
+ -Dprotobuf_BUILD_EXAMPLES=ON ^
-Dprotobuf_BUILD_CONFORMANCE=OFF ^
-Dprotobuf_WITH_ZLIB=OFF ^
-Dprotobuf_TEST_XML_OUTDIR=%KOKORO_ARTIFACTS_DIR%\logs\ || goto :error
diff --git a/kokoro/windows/cmake_install/build.bat b/kokoro/windows/cmake_install/build.bat
index 5392f9e664..c5878de338 100644
--- a/kokoro/windows/cmake_install/build.bat
+++ b/kokoro/windows/cmake_install/build.bat
@@ -6,8 +6,8 @@ call kokoro\windows\prepare_build_win64.bat || goto :error
@rem TODO(b/241475022) Use docker to guarantee better stability.
@rem TODO(b/241484899) Run conformance tests in windows.
-md build -ea 0
-md %KOKORO_ARTIFACTS_DIR%\logs -ea 0
+md build
+md %KOKORO_ARTIFACTS_DIR%\logs
cd build
diff --git a/kokoro/windows/cmake_nmake/build.bat b/kokoro/windows/cmake_nmake/build.bat
index a0807714fc..7b03678dbc 100644
--- a/kokoro/windows/cmake_nmake/build.bat
+++ b/kokoro/windows/cmake_nmake/build.bat
@@ -6,8 +6,8 @@ call kokoro\windows\prepare_build_win64.bat || goto :error
@rem TODO(b/241475022) Use docker to guarantee better stability.
@rem TODO(b/241484899) Run conformance tests in windows.
-md build -ea 0
-md %KOKORO_ARTIFACTS_DIR%\logs -ea 0
+md build
+md %KOKORO_ARTIFACTS_DIR%\logs
cd build
diff --git a/kokoro/windows/cmake_shared/build.bat b/kokoro/windows/cmake_shared/build.bat
index bcd5244608..d4bb2b16ee 100644
--- a/kokoro/windows/cmake_shared/build.bat
+++ b/kokoro/windows/cmake_shared/build.bat
@@ -6,8 +6,8 @@ call kokoro\windows\prepare_build_win64.bat || goto :error
@rem TODO(b/241475022) Use docker to guarantee better stability.
@rem TODO(b/241484899) Run conformance tests in windows.
-md build -ea 0
-md %KOKORO_ARTIFACTS_DIR%\logs -ea 0
+md build
+md %KOKORO_ARTIFACTS_DIR%\logs
cd build
diff --git a/objectivec/GPBCodedInputStream.h b/objectivec/GPBCodedInputStream.h
index 1886ccf61b..b7e1c7e6ab 100644
--- a/objectivec/GPBCodedInputStream.h
+++ b/objectivec/GPBCodedInputStream.h
@@ -30,8 +30,9 @@
#import
+#import "GPBExtensionRegistry.h"
+
@class GPBMessage;
-@class GPBExtensionRegistry;
NS_ASSUME_NONNULL_BEGIN
@@ -184,7 +185,7 @@ CF_EXTERN_C_END
* extensions for message.
**/
- (void)readMessage:(GPBMessage *)message
- extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
+ extensionRegistry:(nullable id)extensionRegistry;
/**
* Reads and discards a single field, given its tag value.
diff --git a/objectivec/GPBCodedInputStream.m b/objectivec/GPBCodedInputStream.m
index c459391e08..25dde75320 100644
--- a/objectivec/GPBCodedInputStream.m
+++ b/objectivec/GPBCodedInputStream.m
@@ -434,7 +434,7 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
- (void)readGroup:(int32_t)fieldNumber
message:(GPBMessage *)message
- extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
+ extensionRegistry:(id)extensionRegistry {
CheckRecursionLimit(&state_);
++state_.recursionDepth;
[message mergeFromCodedInputStream:self extensionRegistry:extensionRegistry];
@@ -454,7 +454,7 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
}
- (void)readMessage:(GPBMessage *)message
- extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
+ extensionRegistry:(id)extensionRegistry {
CheckRecursionLimit(&state_);
int32_t length = ReadRawVarint32(&state_);
size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length);
@@ -466,7 +466,7 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
}
- (void)readMapEntry:(id)mapDictionary
- extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
+ extensionRegistry:(id)extensionRegistry
field:(GPBFieldDescriptor *)field
parentMessage:(GPBMessage *)parentMessage {
CheckRecursionLimit(&state_);
diff --git a/objectivec/GPBCodedInputStream_PackagePrivate.h b/objectivec/GPBCodedInputStream_PackagePrivate.h
index 43ec6e79b2..cdfb0dcc3f 100644
--- a/objectivec/GPBCodedInputStream_PackagePrivate.h
+++ b/objectivec/GPBCodedInputStream_PackagePrivate.h
@@ -61,7 +61,7 @@ typedef struct GPBCodedInputStreamState {
// support for older data.
- (void)readGroup:(int32_t)fieldNumber
message:(GPBMessage *)message
- extensionRegistry:(GPBExtensionRegistry *)extensionRegistry;
+ extensionRegistry:(id)extensionRegistry;
// Reads a group field value from the stream and merges it into the given
// UnknownFieldSet.
@@ -70,7 +70,7 @@ typedef struct GPBCodedInputStreamState {
// Reads a map entry.
- (void)readMapEntry:(id)mapDictionary
- extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
+ extensionRegistry:(id)extensionRegistry
field:(GPBFieldDescriptor *)field
parentMessage:(GPBMessage *)parentMessage;
@end
diff --git a/objectivec/GPBDictionary.m b/objectivec/GPBDictionary.m
index 187a97092f..77642c27f9 100644
--- a/objectivec/GPBDictionary.m
+++ b/objectivec/GPBDictionary.m
@@ -386,7 +386,7 @@ BOOL GPBDictionaryIsInitializedInternalHelper(NSDictionary *dict, GPBFieldDescri
static void ReadValue(GPBCodedInputStream *stream,
GPBGenericValue *valueToFill,
GPBDataType type,
- GPBExtensionRegistry *registry,
+ idregistry,
GPBFieldDescriptor *field) {
switch (type) {
case GPBDataTypeBool:
@@ -454,7 +454,7 @@ static void ReadValue(GPBCodedInputStream *stream,
void GPBDictionaryReadEntry(id mapDictionary,
GPBCodedInputStream *stream,
- GPBExtensionRegistry *registry,
+ idregistry,
GPBFieldDescriptor *field,
GPBMessage *parentMessage) {
GPBDataType keyDataType = field.mapKeyDataType;
diff --git a/objectivec/GPBDictionary_PackagePrivate.h b/objectivec/GPBDictionary_PackagePrivate.h
index 15e4283264..d494b7ee88 100644
--- a/objectivec/GPBDictionary_PackagePrivate.h
+++ b/objectivec/GPBDictionary_PackagePrivate.h
@@ -34,7 +34,7 @@
@class GPBCodedInputStream;
@class GPBCodedOutputStream;
-@class GPBExtensionRegistry;
+@protocol GPBExtensionRegistry;
@class GPBFieldDescriptor;
@protocol GPBDictionaryInternalsProtocol
@@ -493,7 +493,7 @@ BOOL GPBDictionaryIsInitializedInternalHelper(NSDictionary *dict,
// Helper to read a map instead.
void GPBDictionaryReadEntry(id mapDictionary, GPBCodedInputStream *stream,
- GPBExtensionRegistry *registry,
+ idregistry,
GPBFieldDescriptor *field,
GPBMessage *parentMessage);
diff --git a/objectivec/GPBExtensionInternals.h b/objectivec/GPBExtensionInternals.h
index 2b980aefa4..854b57fe89 100644
--- a/objectivec/GPBExtensionInternals.h
+++ b/objectivec/GPBExtensionInternals.h
@@ -34,12 +34,12 @@
@class GPBCodedInputStream;
@class GPBCodedOutputStream;
-@class GPBExtensionRegistry;
+@protocol GPBExtensionRegistry;
void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension,
BOOL isPackedOnStream,
GPBCodedInputStream *input,
- GPBExtensionRegistry *extensionRegistry,
+ idextensionRegistry,
GPBMessage *message);
size_t GPBComputeExtensionSerializedSizeIncludingTag(
diff --git a/objectivec/GPBExtensionInternals.m b/objectivec/GPBExtensionInternals.m
index bacec5740a..b74591e0a0 100644
--- a/objectivec/GPBExtensionInternals.m
+++ b/objectivec/GPBExtensionInternals.m
@@ -40,7 +40,7 @@
static id NewSingleValueFromInputStream(GPBExtensionDescriptor *extension,
GPBCodedInputStream *input,
- GPBExtensionRegistry *extensionRegistry,
+ idextensionRegistry,
GPBMessage *existingValue)
__attribute__((ns_returns_retained));
@@ -273,7 +273,7 @@ static void WriteArrayIncludingTagsToCodedOutputStream(
void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension,
BOOL isPackedOnStream,
GPBCodedInputStream *input,
- GPBExtensionRegistry *extensionRegistry,
+ idextensionRegistry,
GPBMessage *message) {
GPBExtensionDescription *description = extension->description_;
GPBCodedInputStreamState *state = &input->state_;
@@ -334,7 +334,7 @@ size_t GPBComputeExtensionSerializedSizeIncludingTag(
// Note that this returns a retained value intentionally.
static id NewSingleValueFromInputStream(GPBExtensionDescriptor *extension,
GPBCodedInputStream *input,
- GPBExtensionRegistry *extensionRegistry,
+ idextensionRegistry,
GPBMessage *existingValue) {
GPBExtensionDescription *description = extension->description_;
GPBCodedInputStreamState *state = &input->state_;
diff --git a/objectivec/GPBExtensionRegistry.h b/objectivec/GPBExtensionRegistry.h
index d79632d28b..b1850568d9 100644
--- a/objectivec/GPBExtensionRegistry.h
+++ b/objectivec/GPBExtensionRegistry.h
@@ -41,6 +41,24 @@ NS_ASSUME_NONNULL_BEGIN
* GPBExtensionRegistry in which you have registered any extensions that you
* want to be able to parse. Otherwise, those extensions will just be treated
* like unknown fields.
+ **/
+@protocol GPBExtensionRegistry
+
+/**
+ * Looks for the extension registered for the given field number on a given
+ * GPBDescriptor.
+ *
+ * @param descriptor The descriptor to look for a registered extension on.
+ * @param fieldNumber The field number of the extension to look for.
+ *
+ * @return The registered GPBExtensionDescriptor or nil if none was found.
+ **/
+- (nullable GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor
+ fieldNumber:(NSInteger)fieldNumber;
+@end
+
+/**
+ * A concrete implementation of `GPBExtensionRegistry`.
*
* The *Root classes provide `+extensionRegistry` for the extensions defined
* in a given file *and* all files it imports. You can also create a
@@ -54,7 +72,7 @@ NS_ASSUME_NONNULL_BEGIN
* MyMessage *msg = [MyMessage parseData:data extensionRegistry:registry error:&parseError];
* ```
**/
-@interface GPBExtensionRegistry : NSObject
+@interface GPBExtensionRegistry : NSObject
/**
* Adds the given GPBExtensionDescriptor to this registry.
@@ -70,18 +88,6 @@ NS_ASSUME_NONNULL_BEGIN
**/
- (void)addExtensions:(GPBExtensionRegistry *)registry;
-/**
- * Looks for the extension registered for the given field number on a given
- * GPBDescriptor.
- *
- * @param descriptor The descriptor to look for a registered extension on.
- * @param fieldNumber The field number of the extension to look for.
- *
- * @return The registered GPBExtensionDescriptor or nil if none was found.
- **/
-- (nullable GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor
- fieldNumber:(NSInteger)fieldNumber;
-
@end
NS_ASSUME_NONNULL_END
diff --git a/objectivec/GPBMessage.h b/objectivec/GPBMessage.h
index 01253a4afc..f80778bc39 100644
--- a/objectivec/GPBMessage.h
+++ b/objectivec/GPBMessage.h
@@ -31,12 +31,12 @@
#import
#import "GPBBootstrap.h"
+#import "GPBExtensionRegistry.h"
@class GPBDescriptor;
@class GPBCodedInputStream;
@class GPBCodedOutputStream;
@class GPBExtensionDescriptor;
-@class GPBExtensionRegistry;
@class GPBFieldDescriptor;
@class GPBUnknownFieldSet;
@@ -147,7 +147,7 @@ CF_EXTERN_C_END
* @return A new instance of the generated class.
**/
+ (nullable instancetype)parseFromData:(NSData *)data
- extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
+ extensionRegistry:(nullable id)extensionRegistry
error:(NSError **)errorPtr;
/**
@@ -171,7 +171,7 @@ CF_EXTERN_C_END
**/
+ (nullable instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
- (nullable GPBExtensionRegistry *)extensionRegistry
+ (nullable id)extensionRegistry
error:(NSError **)errorPtr;
/**
@@ -196,7 +196,7 @@ CF_EXTERN_C_END
**/
+ (nullable instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
- (nullable GPBExtensionRegistry *)extensionRegistry
+ (nullable id)extensionRegistry
error:(NSError **)errorPtr;
/**
@@ -239,7 +239,7 @@ CF_EXTERN_C_END
* @return An initialized instance of the generated class.
**/
- (nullable instancetype)initWithData:(NSData *)data
- extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
+ extensionRegistry:(nullable id)extensionRegistry
error:(NSError **)errorPtr;
/**
@@ -264,7 +264,7 @@ CF_EXTERN_C_END
**/
- (nullable instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
- (nullable GPBExtensionRegistry *)extensionRegistry
+ (nullable id)extensionRegistry
error:(NSError **)errorPtr;
/**
@@ -278,7 +278,7 @@ CF_EXTERN_C_END
* unsuccessful.
**/
- (void)mergeFromData:(NSData *)data
- extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
+ extensionRegistry:(nullable id)extensionRegistry;
/**
* Merges the fields from another message (of the same type) into this
diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m
index ee94dee8ed..b293604608 100644
--- a/objectivec/GPBMessage.m
+++ b/objectivec/GPBMessage.m
@@ -881,7 +881,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
- (instancetype)initWithData:(NSData *)data
- extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
+ extensionRegistry:(id)extensionRegistry
error:(NSError **)errorPtr {
if ((self = [self init])) {
@try {
@@ -912,7 +912,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
- (instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
- (GPBExtensionRegistry *)extensionRegistry
+ (id)extensionRegistry
error:(NSError **)errorPtr {
if ((self = [self init])) {
@try {
@@ -1973,7 +1973,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
#pragma mark - mergeFrom
- (void)mergeFromData:(NSData *)data
- extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
+ extensionRegistry:(id)extensionRegistry {
GPBCodedInputStream *input = [[GPBCodedInputStream alloc] initWithData:data];
[self mergeFromCodedInputStream:input extensionRegistry:extensionRegistry];
[input checkLastTagWas:0];
@@ -1983,7 +1983,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
#pragma mark - mergeDelimitedFrom
- (void)mergeDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
- extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
+ extensionRegistry:(id)extensionRegistry {
GPBCodedInputStreamState *state = &input->state_;
if (GPBCodedInputStreamIsAtEnd(state)) {
return;
@@ -2003,7 +2003,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
+ (instancetype)parseFromData:(NSData *)data
- extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
+ extensionRegistry:(id)extensionRegistry
error:(NSError **)errorPtr {
return [[[self alloc] initWithData:data
extensionRegistry:extensionRegistry
@@ -2011,7 +2011,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
+ (instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input
- extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
+ extensionRegistry:(id)extensionRegistry
error:(NSError **)errorPtr {
return
[[[self alloc] initWithCodedInputStream:input
@@ -2023,7 +2023,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
+ (instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
- (GPBExtensionRegistry *)extensionRegistry
+ (id)extensionRegistry
error:(NSError **)errorPtr {
GPBMessage *message = [[[self alloc] init] autorelease];
@try {
@@ -2065,7 +2065,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
- (void)parseMessageSet:(GPBCodedInputStream *)input
- extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
+ extensionRegistry:(id)extensionRegistry {
uint32_t typeId = 0;
NSData *rawBytes = nil;
GPBExtensionDescriptor *extension = nil;
@@ -2117,7 +2117,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
- (BOOL)parseUnknownField:(GPBCodedInputStream *)input
- extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
+ extensionRegistry:(id)extensionRegistry
tag:(uint32_t)tag {
GPBWireFormat wireType = GPBWireFormatGetTagWireType(tag);
int32_t fieldNumber = GPBWireFormatGetTagFieldNumber(tag);
@@ -2170,7 +2170,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
static void MergeSingleFieldFromCodedInputStream(
GPBMessage *self, GPBFieldDescriptor *field, GPBFileSyntax syntax,
- GPBCodedInputStream *input, GPBExtensionRegistry *extensionRegistry) {
+ GPBCodedInputStream *input, idextensionRegistry) {
GPBDataType fieldDataType = GPBGetFieldDataType(field);
switch (fieldDataType) {
#define CASE_SINGLE_POD(NAME, TYPE, FUNC_TYPE) \
@@ -2306,7 +2306,7 @@ static void MergeRepeatedPackedFieldFromCodedInputStream(
static void MergeRepeatedNotPackedFieldFromCodedInputStream(
GPBMessage *self, GPBFieldDescriptor *field, GPBFileSyntax syntax,
- GPBCodedInputStream *input, GPBExtensionRegistry *extensionRegistry) {
+ GPBCodedInputStream *input, idextensionRegistry) {
GPBCodedInputStreamState *state = &input->state_;
id genericArray = GetOrCreateArrayIvarWithField(self, field);
switch (GPBGetFieldDataType(field)) {
@@ -2371,7 +2371,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
}
- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input
- extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
+ extensionRegistry:(id)extensionRegistry {
GPBDescriptor *descriptor = [self descriptor];
GPBFileSyntax syntax = descriptor.file.syntax;
GPBCodedInputStreamState *state = &input->state_;
diff --git a/objectivec/GPBMessage_PackagePrivate.h b/objectivec/GPBMessage_PackagePrivate.h
index ca10983b3c..a8755a29ce 100644
--- a/objectivec/GPBMessage_PackagePrivate.h
+++ b/objectivec/GPBMessage_PackagePrivate.h
@@ -78,13 +78,13 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
// or zero for EOF.
// NOTE: This will throw if there is an error while parsing.
- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input
- extensionRegistry:(GPBExtensionRegistry *)extensionRegistry;
+ extensionRegistry:(id)extensionRegistry;
// Parses the next delimited message of this type from the input and merges it
// with this message.
- (void)mergeDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
- (GPBExtensionRegistry *)extensionRegistry;
+ (id)extensionRegistry;
- (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data;
diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml
index ccf1d414fd..4f0b8b4277 100644
--- a/php/ext/google/protobuf/package.xml
+++ b/php/ext/google/protobuf/package.xml
@@ -10,11 +10,11 @@
protobuf-packages@google.com
yes
- 2022-08-09
-
+ 2022-09-13
+
- 3.21.5
- 3.21.5
+ 3.21.6
+ 3.21.6
stable
@@ -1403,5 +1403,20 @@ G A release.
+
+
+ 3.21.6
+ 3.21.6
+
+
+ stable
+ stable
+
+ 2022-09-13
+
+ BSD-3-Clause
+
+
+
diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h
index 836bb8b74e..4f14ab526a 100644
--- a/php/ext/google/protobuf/protobuf.h
+++ b/php/ext/google/protobuf/protobuf.h
@@ -127,7 +127,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_setter, 0, 0, 1)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
-#define PHP_PROTOBUF_VERSION "3.21.5"
+#define PHP_PROTOBUF_VERSION "3.21.6"
// ptr -> PHP object cache. This is a weak map that caches lazily-created
// wrapper objects around upb types:
diff --git a/php/generate_descriptor_protos.sh b/php/generate_descriptor_protos.sh
index 1a600abc63..0e5be35e24 100755
--- a/php/generate_descriptor_protos.sh
+++ b/php/generate_descriptor_protos.sh
@@ -5,7 +5,9 @@
set -e
-PROTOC=$(realpath protoc)
+if [[ -z "${PROTOC}" ]]; then
+ PROTOC=$(realpath protoc)
+fi
if [ ! -f $PROTOC ]; then
bazel build -c opt //:protoc
PROTOC=$(realpath bazel-bin/protoc)
diff --git a/php/generate_test_protos.sh b/php/generate_test_protos.sh
index 565c7ec1cd..6d06f959b9 100755
--- a/php/generate_test_protos.sh
+++ b/php/generate_test_protos.sh
@@ -4,7 +4,9 @@ set -ex
cd `dirname $0`/..
-PROTOC=$(pwd)/protoc
+if [[ -z "${PROTOC}" ]]; then
+ PROTOC=$(pwd)/protoc
+fi
if [ ! -f $PROTOC ]; then
bazel build -c opt //:protoc
PROTOC=$(pwd)/bazel-bin/protoc
diff --git a/php/src/Google/Protobuf/Internal/MessageOptions.php b/php/src/Google/Protobuf/Internal/MessageOptions.php
index 5c6158019c..96e6f5291e 100644
--- a/php/src/Google/Protobuf/Internal/MessageOptions.php
+++ b/php/src/Google/Protobuf/Internal/MessageOptions.php
@@ -53,6 +53,9 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
*/
protected $deprecated = null;
/**
+ * NOTE: Do not set the option in .proto files. Always use the maps syntax
+ * instead. The option should only be implicitly set by the proto compiler
+ * parser.
* Whether the message is an automatically generated map entry type for the
* maps field.
* For maps fields:
@@ -68,9 +71,6 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
* use a native map in the target language to hold the keys and values.
* The reflection APIs in such implementations still need to work as
* if the field is a repeated message field.
- * NOTE: Do not set the option in .proto files. Always use the maps syntax
- * instead. The option should only be implicitly set by the proto compiler
- * parser.
*
* Generated from protobuf field optional bool map_entry = 7;
*/
@@ -114,6 +114,9 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
* for the message, or it will be completely ignored; in the very least,
* this is a formalization for deprecating messages.
* @type bool $map_entry
+ * NOTE: Do not set the option in .proto files. Always use the maps syntax
+ * instead. The option should only be implicitly set by the proto compiler
+ * parser.
* Whether the message is an automatically generated map entry type for the
* maps field.
* For maps fields:
@@ -129,9 +132,6 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
* use a native map in the target language to hold the keys and values.
* The reflection APIs in such implementations still need to work as
* if the field is a repeated message field.
- * NOTE: Do not set the option in .proto files. Always use the maps syntax
- * instead. The option should only be implicitly set by the proto compiler
- * parser.
* @type array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $uninterpreted_option
* The parser stores options it doesn't recognize here. See above.
* }
@@ -288,6 +288,9 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
}
/**
+ * NOTE: Do not set the option in .proto files. Always use the maps syntax
+ * instead. The option should only be implicitly set by the proto compiler
+ * parser.
* Whether the message is an automatically generated map entry type for the
* maps field.
* For maps fields:
@@ -303,9 +306,6 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
* use a native map in the target language to hold the keys and values.
* The reflection APIs in such implementations still need to work as
* if the field is a repeated message field.
- * NOTE: Do not set the option in .proto files. Always use the maps syntax
- * instead. The option should only be implicitly set by the proto compiler
- * parser.
*
* Generated from protobuf field optional bool map_entry = 7;
* @return bool
@@ -326,6 +326,9 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
}
/**
+ * NOTE: Do not set the option in .proto files. Always use the maps syntax
+ * instead. The option should only be implicitly set by the proto compiler
+ * parser.
* Whether the message is an automatically generated map entry type for the
* maps field.
* For maps fields:
@@ -341,9 +344,6 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
* use a native map in the target language to hold the keys and values.
* The reflection APIs in such implementations still need to work as
* if the field is a repeated message field.
- * NOTE: Do not set the option in .proto files. Always use the maps syntax
- * instead. The option should only be implicitly set by the proto compiler
- * parser.
*
* Generated from protobuf field optional bool map_entry = 7;
* @param bool $var
diff --git a/pkg/BUILD.bazel b/pkg/BUILD.bazel
index 812224c0e9..65dc37c0c6 100644
--- a/pkg/BUILD.bazel
+++ b/pkg/BUILD.bazel
@@ -365,7 +365,8 @@ cc_dist_library(
}),
tags = ["manual"],
deps = [
- "//src/google/protobuf",
+ "//src/google/protobuf:wkt_cc_proto",
+ "//src/google/protobuf:protobuf_nowkt",
"//src/google/protobuf:arena",
"//src/google/protobuf:protobuf_lite",
"//src/google/protobuf/compiler:importer",
diff --git a/protobuf_version.bzl b/protobuf_version.bzl
index 253aaac46d..fdd9b5fe57 100644
--- a/protobuf_version.bzl
+++ b/protobuf_version.bzl
@@ -1,3 +1,3 @@
-PROTOC_VERSION = '21.5'
-PROTOBUF_JAVA_VERSION = '3.21.5'
-PROTOBUF_PYTHON_VERSION = '4.21.5'
+PROTOC_VERSION = '21.6'
+PROTOBUF_JAVA_VERSION = '3.21.6'
+PROTOBUF_PYTHON_VERSION = '4.21.6'
diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml
index c863376dfc..19e700d4d3 100644
--- a/protoc-artifacts/pom.xml
+++ b/protoc-artifacts/pom.xml
@@ -8,7 +8,7 @@
com.google.protobuf
protoc
- 3.21.5
+ 3.21.6
pom
Protobuf Compiler
diff --git a/python/google/protobuf/json_format.py b/python/google/protobuf/json_format.py
index 5024ed89d7..f35a432126 100644
--- a/python/google/protobuf/json_format.py
+++ b/python/google/protobuf/json_format.py
@@ -109,7 +109,8 @@ def MessageToJson(
names as defined in the .proto file. If False, convert the field
names to lowerCamelCase.
indent: The JSON object will be pretty-printed with this indent level.
- An indent level of 0 or negative will only insert newlines.
+ An indent level of 0 or negative will only insert newlines. If the
+ indent level is None, no newlines will be inserted.
sort_keys: If True, then the output will be sorted by field names.
use_integers_for_enums: If true, print integers instead of enum names.
descriptor_pool: A Descriptor Pool for resolving types. If None use the
diff --git a/python/google/protobuf/pyext/descriptor.cc b/python/google/protobuf/pyext/descriptor.cc
index fc83acf01a..fc97b0fa6c 100644
--- a/python/google/protobuf/pyext/descriptor.cc
+++ b/python/google/protobuf/pyext/descriptor.cc
@@ -58,6 +58,37 @@
: 0) \
: PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
+#if PY_VERSION_HEX < 0x030900B1 && !defined(PYPY_VERSION)
+static PyCodeObject* PyFrame_GetCode(PyFrameObject *frame)
+{
+ Py_INCREF(frame->f_code);
+ return frame->f_code;
+}
+
+static PyFrameObject* PyFrame_GetBack(PyFrameObject *frame)
+{
+ Py_XINCREF(frame->f_back);
+ return frame->f_back;
+}
+#endif
+
+#if PY_VERSION_HEX < 0x030B00A7 && !defined(PYPY_VERSION)
+static PyObject* PyFrame_GetLocals(PyFrameObject *frame)
+{
+ if (PyFrame_FastToLocalsWithError(frame) < 0) {
+ return NULL;
+ }
+ Py_INCREF(frame->f_locals);
+ return frame->f_locals;
+}
+
+static PyObject* PyFrame_GetGlobals(PyFrameObject *frame)
+{
+ Py_INCREF(frame->f_globals);
+ return frame->f_globals;
+}
+#endif
+
namespace google {
namespace protobuf {
namespace python {
@@ -96,48 +127,66 @@ bool _CalledFromGeneratedFile(int stacklevel) {
// This check is not critical and is somewhat difficult to implement correctly
// in PyPy.
PyFrameObject* frame = PyEval_GetFrame();
+ PyCodeObject* frame_code = nullptr;
+ PyObject* frame_globals = nullptr;
+ PyObject* frame_locals = nullptr;
+ bool result = false;
+
if (frame == nullptr) {
- return false;
+ goto exit;
}
+ Py_INCREF(frame);
while (stacklevel-- > 0) {
- frame = frame->f_back;
+ PyFrameObject* next_frame = PyFrame_GetBack(frame);
+ Py_DECREF(frame);
+ frame = next_frame;
if (frame == nullptr) {
- return false;
+ goto exit;
}
}
- if (frame->f_code->co_filename == nullptr) {
- return false;
+ frame_code = PyFrame_GetCode(frame);
+ if (frame_code->co_filename == nullptr) {
+ goto exit;
}
char* filename;
Py_ssize_t filename_size;
- if (PyString_AsStringAndSize(frame->f_code->co_filename,
+ if (PyString_AsStringAndSize(frame_code->co_filename,
&filename, &filename_size) < 0) {
// filename is not a string.
PyErr_Clear();
- return false;
+ goto exit;
}
if ((filename_size < 3) ||
(strcmp(&filename[filename_size - 3], ".py") != 0)) {
// Cython's stack does not have .py file name and is not at global module
// scope.
- return true;
+ result = true;
+ goto exit;
}
if (filename_size < 7) {
// filename is too short.
- return false;
+ goto exit;
}
if (strcmp(&filename[filename_size - 7], "_pb2.py") != 0) {
// Filename is not ending with _pb2.
- return false;
+ goto exit;
}
- if (frame->f_globals != frame->f_locals) {
+ frame_globals = PyFrame_GetGlobals(frame);
+ frame_locals = PyFrame_GetLocals(frame);
+ if (frame_globals != frame_locals) {
// Not at global module scope
- return false;
+ goto exit;
}
#endif
- return true;
+ result = true;
+exit:
+ Py_XDECREF(frame_globals);
+ Py_XDECREF(frame_locals);
+ Py_XDECREF(frame_code);
+ Py_XDECREF(frame);
+ return result;
}
// If the calling code is not a _pb2.py file, raise AttributeError.
diff --git a/python/google/protobuf/pyext/map_container.cc b/python/google/protobuf/pyext/map_container.cc
index 5d287d3da2..76c4d888a2 100644
--- a/python/google/protobuf/pyext/map_container.cc
+++ b/python/google/protobuf/pyext/map_container.cc
@@ -45,7 +45,6 @@
#include "google/protobuf/pyext/message_factory.h"
#include "google/protobuf/pyext/repeated_composite_container.h"
#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
-#include "util/gtl/map_util.h"
namespace google {
namespace protobuf {
diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc
index ca36458531..ebad6b4b4a 100644
--- a/python/google/protobuf/pyext/message.cc
+++ b/python/google/protobuf/pyext/message.cc
@@ -42,7 +42,7 @@
#include
#include
-#include "google/protobuf/stubs/strutil.h"
+#include "absl/strings/match.h"
#ifndef PyVarObject_HEAD_INIT
#define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size,
@@ -70,11 +70,11 @@
#include "google/protobuf/pyext/unknown_field_set.h"
#include "google/protobuf/pyext/unknown_fields.h"
#include "google/protobuf/util/message_differencer.h"
+#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/io/strtod.h"
#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
-#include "util/gtl/map_util.h"
// clang-format off
#include "google/protobuf/port_def.inc"
@@ -410,7 +410,7 @@ static PyObject* GetClassAttribute(CMessageClass *self, PyObject* name) {
Py_ssize_t attr_size;
static const char kSuffix[] = "_FIELD_NUMBER";
if (PyString_AsStringAndSize(name, &attr, &attr_size) >= 0 &&
- HasSuffixString(absl::string_view(attr, attr_size), kSuffix)) {
+ absl::EndsWith(absl::string_view(attr, attr_size), kSuffix)) {
std::string field_name(attr, attr_size - sizeof(kSuffix) + 1);
LowerString(&field_name);
@@ -2678,22 +2678,22 @@ CMessage* CMessage::BuildSubMessageFromPointer(
if (!this->child_submessages) {
this->child_submessages = new CMessage::SubMessagesMap();
}
- CMessage* cmsg = gtl::FindPtrOrNull(
- *this->child_submessages, sub_message);
- if (cmsg) {
- Py_INCREF(cmsg);
- } else {
- cmsg = cmessage::NewEmptyMessage(message_class);
+ auto it = this->child_submessages->find(sub_message);
+ if (it != this->child_submessages->end()) {
+ Py_INCREF(it->second);
+ return it->second;
+ }
- if (cmsg == nullptr) {
- return nullptr;
- }
- cmsg->message = sub_message;
- Py_INCREF(this);
- cmsg->parent = this;
- cmsg->parent_field_descriptor = field_descriptor;
- cmessage::SetSubmessage(this, cmsg);
+ CMessage* cmsg = cmessage::NewEmptyMessage(message_class);
+
+ if (cmsg == nullptr) {
+ return nullptr;
}
+ cmsg->message = sub_message;
+ Py_INCREF(this);
+ cmsg->parent = this;
+ cmsg->parent_field_descriptor = field_descriptor;
+ cmessage::SetSubmessage(this, cmsg);
return cmsg;
}
@@ -2701,11 +2701,10 @@ CMessage* CMessage::MaybeReleaseSubMessage(Message* sub_message) {
if (!this->child_submessages) {
return nullptr;
}
- CMessage* released = gtl::FindPtrOrNull(
- *this->child_submessages, sub_message);
- if (!released) {
- return nullptr;
- }
+ auto it = this->child_submessages->find(sub_message);
+ if (it == this->child_submessages->end()) return nullptr;
+ CMessage* released = it->second;
+
// The target message will now own its content.
Py_CLEAR(released->parent);
released->parent_field_descriptor = nullptr;
diff --git a/python/google/protobuf/pyext/repeated_composite_container.cc b/python/google/protobuf/pyext/repeated_composite_container.cc
index c813e32221..a191670876 100644
--- a/python/google/protobuf/pyext/repeated_composite_container.cc
+++ b/python/google/protobuf/pyext/repeated_composite_container.cc
@@ -46,7 +46,6 @@
#include "google/protobuf/pyext/message.h"
#include "google/protobuf/pyext/message_factory.h"
#include "google/protobuf/pyext/scoped_pyobject_ptr.h"
-#include "util/gtl/map_util.h"
namespace google {
namespace protobuf {
diff --git a/python/google/protobuf/text_format.py b/python/google/protobuf/text_format.py
index 2b794287ae..57696f04f9 100644
--- a/python/google/protobuf/text_format.py
+++ b/python/google/protobuf/text_format.py
@@ -1013,6 +1013,8 @@ class _Parser(object):
if not tokenizer.TryConsume(','):
tokenizer.TryConsume(';')
+
+ def _LogSilentMarker(self, field_name):
pass
def _DetectSilentMarker(self, tokenizer, field_name):
diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec
index 3d776fecea..9dc373ca3b 100644
--- a/ruby/google-protobuf.gemspec
+++ b/ruby/google-protobuf.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "google-protobuf"
- s.version = "3.21.5"
+ s.version = "3.21.6"
git_tag = "v#{s.version.to_s.sub('.rc.', '-rc')}" # Converts X.Y.Z.rc.N to vX.Y.Z-rcN, used for the git tag
s.licenses = ["BSD-3-Clause"]
s.summary = "Protocol Buffers"
diff --git a/ruby/pom.xml b/ruby/pom.xml
index d56c99d785..4e07f84022 100644
--- a/ruby/pom.xml
+++ b/ruby/pom.xml
@@ -9,7 +9,7 @@
com.google.protobuf.jruby
protobuf-jruby
- 3.21.5
+ 3.21.6
Protocol Buffer JRuby native extension
Protocol Buffers are a way of encoding structured data in an efficient yet
@@ -76,7 +76,7 @@
com.google.protobuf
protobuf-java-util
- 3.21.5
+ 3.21.6
org.jruby
diff --git a/src/file_lists.cmake b/src/file_lists.cmake
index 220ffe0cb3..be3d61ee14 100644
--- a/src/file_lists.cmake
+++ b/src/file_lists.cmake
@@ -11,10 +11,18 @@ endif()
# //pkg:protobuf
set(libprotobuf_srcs
- ${protobuf_SOURCE_DIR}/src/google/protobuf/any.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/any.pb.cc
- ${protobuf_SOURCE_DIR}/src/google/protobuf/any_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/api.pb.cc
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/duration.pb.cc
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/empty.pb.cc
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/field_mask.pb.cc
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/source_context.pb.cc
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/struct.pb.cc
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/timestamp.pb.cc
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/type.pb.cc
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/wrappers.pb.cc
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/any.cc
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/any_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/arena.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/arena_config.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/arenastring.cc
@@ -24,12 +32,9 @@ set(libprotobuf_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_database.cc
- ${protobuf_SOURCE_DIR}/src/google/protobuf/duration.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/dynamic_message.cc
- ${protobuf_SOURCE_DIR}/src/google/protobuf/empty.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set_heavy.cc
- ${protobuf_SOURCE_DIR}/src/google/protobuf/field_mask.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_enum_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_bases.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_reflection.cc
@@ -58,16 +63,12 @@ set(libprotobuf_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_ptr_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/service.cc
- ${protobuf_SOURCE_DIR}/src/google/protobuf/source_context.pb.cc
- ${protobuf_SOURCE_DIR}/src/google/protobuf/struct.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/bytestream.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/common.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/stringprintf.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/structurally_valid.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/strutil.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/text_format.cc
- ${protobuf_SOURCE_DIR}/src/google/protobuf/timestamp.pb.cc
- ${protobuf_SOURCE_DIR}/src/google/protobuf/type.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/unknown_field_set.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/delimited_message_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/field_comparator.cc
@@ -91,14 +92,21 @@ set(libprotobuf_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/util/type_resolver_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_lite.cc
- ${protobuf_SOURCE_DIR}/src/google/protobuf/wrappers.pb.cc
)
# //pkg:protobuf
set(libprotobuf_hdrs
- ${protobuf_SOURCE_DIR}/src/google/protobuf/any.h
${protobuf_SOURCE_DIR}/src/google/protobuf/any.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/api.pb.h
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/duration.pb.h
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/empty.pb.h
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/field_mask.pb.h
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/source_context.pb.h
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/struct.pb.h
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/timestamp.pb.h
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/type.pb.h
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/wrappers.pb.h
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/any.h
${protobuf_SOURCE_DIR}/src/google/protobuf/arena.h
${protobuf_SOURCE_DIR}/src/google/protobuf/arena_config.h
${protobuf_SOURCE_DIR}/src/google/protobuf/arena_impl.h
@@ -109,15 +117,12 @@ set(libprotobuf_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.h
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_database.h
- ${protobuf_SOURCE_DIR}/src/google/protobuf/duration.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/dynamic_message.h
- ${protobuf_SOURCE_DIR}/src/google/protobuf/empty.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/endian.h
${protobuf_SOURCE_DIR}/src/google/protobuf/explicitly_constructed.h
${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set.h
${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set_inl.h
${protobuf_SOURCE_DIR}/src/google/protobuf/field_access_listener.h
- ${protobuf_SOURCE_DIR}/src/google/protobuf/field_mask.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_enum_reflection.h
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_enum_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_bases.h
@@ -158,8 +163,6 @@ set(libprotobuf_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_ptr_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/service.h
- ${protobuf_SOURCE_DIR}/src/google/protobuf/source_context.pb.h
- ${protobuf_SOURCE_DIR}/src/google/protobuf/struct.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/bytestream.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/callback.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/common.h
@@ -172,8 +175,6 @@ set(libprotobuf_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/stringprintf.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/strutil.h
${protobuf_SOURCE_DIR}/src/google/protobuf/text_format.h
- ${protobuf_SOURCE_DIR}/src/google/protobuf/timestamp.pb.h
- ${protobuf_SOURCE_DIR}/src/google/protobuf/type.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/unknown_field_set.h
${protobuf_SOURCE_DIR}/src/google/protobuf/util/delimited_message_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/util/field_comparator.h
@@ -202,7 +203,6 @@ set(libprotobuf_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/util/type_resolver_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format.h
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_lite.h
- ${protobuf_SOURCE_DIR}/src/google/protobuf/wrappers.pb.h
)
# //pkg:protobuf_lite
@@ -456,6 +456,7 @@ set(libprotoc_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_message_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_nsobject_methods.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_oneof.h
+ ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_options.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/php/php_generator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/plugin.h
diff --git a/src/google/protobuf/BUILD.bazel b/src/google/protobuf/BUILD.bazel
index 7a6fc12db6..91aaab9e30 100644
--- a/src/google/protobuf/BUILD.bazel
+++ b/src/google/protobuf/BUILD.bazel
@@ -81,6 +81,57 @@ proto_library(
strip_import_prefix = "/src",
)
+# Generate code for the well-known types on demand.
+# This needs to be done in a separate genrule because we publish protoc and the
+# C++ runtime with the WKT code linked in. We need to use a stripped down
+# compiler and runtime library to generate them, and cc_proto_library doesn't
+# support swapping out the compiler binary (even though a custom runtime can
+# be passed to proto_lang_toolchain).
+#
+# TODO(b/246826624) We still check in generated pb.h and pb.cc files purely to
+# support CMake builds. These aren't used at all by Bazel and will be removed
+# in the future once CMake can generate them too.
+
+WELL_KNOWN_TYPES = [
+ "any",
+ "api",
+ "duration",
+ "empty",
+ "field_mask",
+ "source_context",
+ "struct",
+ "timestamp",
+ "type",
+ "wrappers",
+]
+
+genrule(
+ name = "gen_wkt_cc_sources",
+ srcs = [wkt + ".proto" for wkt in WELL_KNOWN_TYPES],
+ exec_tools = ["//src/google/protobuf/compiler:protoc_nowkt"],
+ outs =
+ [wkt + ".pb.h" for wkt in WELL_KNOWN_TYPES] +
+ [wkt + ".pb.cc" for wkt in WELL_KNOWN_TYPES],
+ cmd = """
+ $(execpath //src/google/protobuf/compiler:protoc_nowkt) \
+ --cpp_out=$(RULEDIR)/../.. \
+ --proto_path=$$(dirname $$(dirname $$(dirname $(location any.proto)))) \
+ $(SRCS)
+ """,
+ visibility = ["//visibility:private"],
+)
+
+cc_library(
+ name = "wkt_cc_proto",
+ srcs = [wkt + ".pb.cc" for wkt in WELL_KNOWN_TYPES],
+ hdrs = [wkt + ".pb.h" for wkt in WELL_KNOWN_TYPES],
+ deps = [":protobuf_nowkt"],
+ copts = COPTS,
+ include_prefix = "google/protobuf",
+ linkopts = LINK_OPTS,
+ visibility = ["//pkg:__pkg__"],
+)
+
# Built-in runtime types
proto_library(
@@ -211,19 +262,14 @@ cc_library(
)
cc_library(
- name = "protobuf",
+ name = "protobuf_nowkt",
srcs = [
"any.cc",
- "any.pb.cc",
- "api.pb.cc",
"descriptor.cc",
"descriptor.pb.cc",
"descriptor_database.cc",
- "duration.pb.cc",
"dynamic_message.cc",
- "empty.pb.cc",
"extension_set_heavy.cc",
- "field_mask.pb.cc",
"generated_message_bases.cc",
"generated_message_reflection.cc",
"generated_message_tctable_full.cc",
@@ -232,26 +278,16 @@ cc_library(
"message.cc",
"reflection_ops.cc",
"service.cc",
- "source_context.pb.cc",
- "struct.pb.cc",
"text_format.cc",
- "timestamp.pb.cc",
- "type.pb.cc",
"unknown_field_set.cc",
"wire_format.cc",
- "wrappers.pb.cc",
],
hdrs = [
- "any.pb.h",
- "api.pb.h",
"descriptor.h",
"descriptor.pb.h",
"descriptor_database.h",
- "duration.pb.h",
"dynamic_message.h",
- "empty.pb.h",
"field_access_listener.h",
- "field_mask.pb.h",
"generated_enum_reflection.h",
"generated_message_bases.h",
"generated_message_reflection.h",
@@ -265,25 +301,19 @@ cc_library(
"reflection_internal.h",
"reflection_ops.h",
"service.h",
- "source_context.pb.h",
- "struct.pb.h",
"text_format.h",
- "timestamp.pb.h",
- "type.pb.h",
"unknown_field_set.h",
"wire_format.h",
- "wrappers.pb.h",
],
copts = COPTS,
include_prefix = "google/protobuf",
linkopts = LINK_OPTS,
visibility = [
- "//:__pkg__",
"//pkg:__pkg__",
"//src/google/protobuf:__subpackages__",
],
deps = [
- ":protobuf_lite",
+ ":protobuf_lite",
"//src/google/protobuf/io",
"//src/google/protobuf/io:gzip_stream",
"//src/google/protobuf/io:printer",
@@ -300,6 +330,22 @@ cc_library(
],
)
+cc_library(
+ name = "protobuf",
+ deps = [
+ ":protobuf_nowkt",
+ ":wkt_cc_proto",
+ ],
+ copts = COPTS,
+ include_prefix = "google/protobuf",
+ linkopts = LINK_OPTS,
+ visibility = [
+ "//:__pkg__",
+ "//pkg:__pkg__",
+ "//src/google/protobuf:__subpackages__",
+ ],
+)
+
# This provides just the header files for use in projects that need to build
# shared libraries for dynamic loading. This target is available until Bazel
# adds native support for such use cases.
diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h
index 8347eada75..8075234381 100644
--- a/src/google/protobuf/any.pb.h
+++ b/src/google/protobuf/any.pb.h
@@ -13,7 +13,7 @@
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION
+#if 3021006 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
diff --git a/src/google/protobuf/any_lite.cc b/src/google/protobuf/any_lite.cc
index fb812d70fe..a15d19fa09 100644
--- a/src/google/protobuf/any_lite.cc
+++ b/src/google/protobuf/any_lite.cc
@@ -29,7 +29,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
-#include "google/protobuf/stubs/strutil.h"
+#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
#include "google/protobuf/any.h"
#include "google/protobuf/arenastring.h"
@@ -72,7 +72,7 @@ bool AnyMetadata::InternalIs(absl::string_view type_name) const {
absl::string_view type_url = type_url_->Get();
return type_url.size() >= type_name.size() + 1 &&
type_url[type_url.size() - type_name.size() - 1] == '/' &&
- HasSuffixString(type_url, type_name);
+ absl::EndsWith(type_url, type_name);
}
bool ParseAnyTypeUrl(absl::string_view type_url, std::string* url_prefix,
diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h
index c26209da77..726c959345 100644
--- a/src/google/protobuf/api.pb.h
+++ b/src/google/protobuf/api.pb.h
@@ -13,7 +13,7 @@
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
-#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION
+#if 3021006 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc
index 0eb8cc9016..4b4b19e325 100644
--- a/src/google/protobuf/arena.cc
+++ b/src/google/protobuf/arena.cc
@@ -105,7 +105,7 @@ class GetDeallocator {
size_t* space_allocated_;
};
-SerialArena::SerialArena(Block* b, ThreadSafeArena& parent)
+SerialArena::SerialArena(ArenaBlock* b, ThreadSafeArena& parent)
: parent_(parent), space_allocated_(b->size()) {
set_head(b);
set_ptr(b->Pointer(kBlockHeaderSize + ThreadSafeArena::kSerialArenaSize));
@@ -117,13 +117,13 @@ SerialArena* SerialArena::New(Memory mem, ThreadSafeArena& parent) {
ThreadSafeArenaStats::RecordAllocateStats(parent.arena_stats_.MutableStats(),
/*used=*/0, /*allocated=*/mem.size,
/*wasted=*/0);
- auto b = new (mem.ptr) Block{nullptr, mem.size};
+ auto b = new (mem.ptr) ArenaBlock{nullptr, mem.size};
return new (b->Pointer(kBlockHeaderSize)) SerialArena(b, parent);
}
template
SerialArena::Memory SerialArena::Free(Deallocator deallocator) {
- Block* b = head();
+ ArenaBlock* b = head();
Memory mem = {b, b->size()};
while (b->next) {
b = b->next; // We must first advance before deleting this block
@@ -179,7 +179,7 @@ void SerialArena::AllocateNewBlock(size_t n) {
ThreadSafeArenaStats::RecordAllocateStats(parent_.arena_stats_.MutableStats(),
/*used=*/used,
/*allocated=*/mem.size, wasted);
- set_head(new (mem.ptr) Block{head(), mem.size});
+ set_head(new (mem.ptr) ArenaBlock{head(), mem.size});
set_ptr(head()->Pointer(kBlockHeaderSize));
limit_ = head()->Pointer(head()->size());
@@ -199,7 +199,7 @@ uint64_t SerialArena::SpaceUsed() const {
const uint64_t current_block_size = head()->size();
uint64_t space_used = std::min(
static_cast(
- ptr() - const_cast(head())->Pointer(kBlockHeaderSize)),
+ ptr() - const_cast(head())->Pointer(kBlockHeaderSize)),
current_block_size);
space_used += space_used_.load(std::memory_order_relaxed);
// Remove the overhead of the SerialArena itself.
@@ -208,7 +208,7 @@ uint64_t SerialArena::SpaceUsed() const {
}
void SerialArena::CleanupList() {
- Block* b = head();
+ ArenaBlock* b = head();
b->cleanup_nodes = limit_;
do {
char* limit = reinterpret_cast(
diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h
index 4bc39948e3..d3dec65170 100644
--- a/src/google/protobuf/arena.h
+++ b/src/google/protobuf/arena.h
@@ -252,9 +252,6 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
inline ~Arena() {}
- // TODO(protobuf-team): Fix callers to use constructor and delete this method.
- void Init(const ArenaOptions&) {}
-
// API to create proto2 message objects on the arena. If the arena passed in
// is nullptr, then a heap allocated object is returned. Type T must be a
// message defined in a .proto file with cc_enable_arenas set to true,
diff --git a/src/google/protobuf/arena_impl.h b/src/google/protobuf/arena_impl.h
index 2eb6c505ad..b8969a52ca 100644
--- a/src/google/protobuf/arena_impl.h
+++ b/src/google/protobuf/arena_impl.h
@@ -90,6 +90,29 @@ inline PROTOBUF_ALWAYS_INLINE void* AlignTo(void* p, size_t a) {
}
}
+// Arena blocks are variable length malloc-ed objects. The following structure
+// describes the common header for all blocks.
+struct ArenaBlock {
+ ArenaBlock(ArenaBlock* next, size_t size)
+ : next(next), cleanup_nodes(nullptr), relaxed_size(size) {
+ GOOGLE_DCHECK_GT(size, sizeof(ArenaBlock));
+ }
+
+ char* Pointer(size_t n) {
+ GOOGLE_DCHECK(n <= size());
+ return reinterpret_cast(this) + n;
+ }
+
+ size_t size() const { return relaxed_size.load(std::memory_order_relaxed); }
+
+ ArenaBlock* const next;
+ void* cleanup_nodes;
+
+ private:
+ const std::atomic relaxed_size;
+ // data follows
+};
+
namespace cleanup {
template
@@ -545,29 +568,8 @@ class PROTOBUF_EXPORT SerialArena {
template
Memory Free(Deallocator deallocator);
- // Blocks are variable length malloc-ed objects. The following structure
- // describes the common header for all blocks.
- struct Block {
- Block(Block* next, size_t size)
- : next(next), cleanup_nodes(nullptr), relaxed_size(size) {}
-
- char* Pointer(size_t n) {
- GOOGLE_DCHECK(n <= size());
- return reinterpret_cast(this) + n;
- }
-
- size_t size() const { return relaxed_size.load(std::memory_order_relaxed); }
-
- Block* const next;
- void* cleanup_nodes;
-
- private:
- const std::atomic relaxed_size;
- // data follows
- };
-
ThreadSafeArena& parent_;
- std::atomic head_; // Head of linked list of blocks.
+ std::atomic head_; // Head of linked list of blocks.
std::atomic space_used_{0}; // Necessary for metrics.
std::atomic space_allocated_;
@@ -577,9 +579,11 @@ class PROTOBUF_EXPORT SerialArena {
std::atomic ptr_;
// Helper getters/setters to handle relaxed operations on atomic variables.
- Block* head() { return head_.load(std::memory_order_relaxed); }
- const Block* head() const { return head_.load(std::memory_order_relaxed); }
- void set_head(Block* head) {
+ ArenaBlock* head() { return head_.load(std::memory_order_relaxed); }
+ const ArenaBlock* head() const {
+ return head_.load(std::memory_order_relaxed);
+ }
+ void set_head(ArenaBlock* head) {
return head_.store(head, std::memory_order_relaxed);
}
char* ptr() { return ptr_.load(std::memory_order_relaxed); }
@@ -604,7 +608,8 @@ class PROTOBUF_EXPORT SerialArena {
CachedBlock** cached_blocks_ = nullptr;
// Constructor is private as only New() should be used.
- inline SerialArena(Block* b, ThreadSafeArena& parent);
+ inline SerialArena(ArenaBlock* b, ThreadSafeArena& parent);
+
void* AllocateAlignedFallback(size_t n);
void* AllocateAlignedWithCleanupFallback(size_t n, size_t align,
void (*destructor)(void*));
@@ -612,7 +617,7 @@ class PROTOBUF_EXPORT SerialArena {
void AllocateNewBlock(size_t n);
public:
- static constexpr size_t kBlockHeaderSize = AlignUpTo8(sizeof(Block));
+ static constexpr size_t kBlockHeaderSize = AlignUpTo8(sizeof(ArenaBlock));
};
// Tag type used to invoke the constructor of message-owned arena.
diff --git a/src/google/protobuf/compiler/BUILD.bazel b/src/google/protobuf/compiler/BUILD.bazel
index 62e0d3992a..50901c3c11 100644
--- a/src/google/protobuf/compiler/BUILD.bazel
+++ b/src/google/protobuf/compiler/BUILD.bazel
@@ -11,7 +11,7 @@ load(
)
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//build_defs:arch_tests.bzl", "aarch64_test", "x86_64_test")
-load("//build_defs:cpp_opts.bzl", "COPTS")
+load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS", "PROTOC_LINK_OPTS")
proto_library(
name = "plugin_proto",
@@ -37,7 +37,7 @@ cc_library(
include_prefix = "google/protobuf/compiler",
visibility = ["//visibility:public"],
deps = [
- "//src/google/protobuf",
+ "//src/google/protobuf:protobuf_nowkt",
"@com_google_absl//absl/strings",
],
)
@@ -59,7 +59,7 @@ cc_library(
include_prefix = "google/protobuf/compiler",
visibility = ["//visibility:public"],
deps = [
- "//:protobuf",
+ "//src/google/protobuf:protobuf_nowkt",
"@com_google_absl//absl/strings",
],
)
@@ -82,26 +82,22 @@ cc_library(
deps = [
":code_generator",
":importer",
- "//:protobuf",
+ "//src/google/protobuf:protobuf_nowkt",
"@com_google_absl//absl/strings",
],
)
cc_library(
- name = "protoc_lib",
+ name = "protoc_lib_nowkt",
srcs = [
"main.cc",
],
copts = COPTS,
- visibility = [
- "//:__pkg__",
- "//pkg:__pkg__",
- ],
deps = [
":code_generator",
":command_line_interface",
":importer",
- "//:protobuf",
+ "//src/google/protobuf:protobuf_nowkt",
"//src/google/protobuf/compiler/cpp",
"//src/google/protobuf/compiler/csharp",
"//src/google/protobuf/compiler/java",
@@ -112,6 +108,29 @@ cc_library(
],
)
+cc_binary(
+ name = "protoc_nowkt",
+ copts = COPTS,
+ linkopts = LINK_OPTS + PROTOC_LINK_OPTS,
+ visibility = [
+ "//src/google/protobuf:__pkg__",
+ ],
+ deps = [":protoc_lib_nowkt"],
+)
+
+cc_library(
+ name = "protoc_lib",
+ copts = COPTS,
+ visibility = [
+ "//:__pkg__",
+ "//pkg:__pkg__",
+ ],
+ deps = [
+ "//:protobuf",
+ ":protoc_lib_nowkt",
+ ],
+)
+
# Note: this is an alias for now. In the future, this rule will become the
# cc_binary for protoc, and //:protoc will become an alias.
alias(
diff --git a/src/google/protobuf/compiler/code_generator.cc b/src/google/protobuf/compiler/code_generator.cc
index 6c1a967a11..3f48e37770 100644
--- a/src/google/protobuf/compiler/code_generator.cc
+++ b/src/google/protobuf/compiler/code_generator.cc
@@ -38,8 +38,8 @@
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/compiler/plugin.pb.h"
#include "google/protobuf/descriptor.h"
-#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/str_split.h"
+#include "absl/strings/strip.h"
namespace google {
namespace protobuf {
@@ -126,10 +126,10 @@ void ParseGeneratorParameter(
// Strips ".proto" or ".protodevel" from the end of a filename.
std::string StripProto(const std::string& filename) {
- if (HasSuffixString(filename, ".protodevel")) {
- return StripSuffixString(filename, ".protodevel");
+ if (absl::EndsWith(filename, ".protodevel")) {
+ return std::string(absl::StripSuffix(filename, ".protodevel"));
} else {
- return StripSuffixString(filename, ".proto");
+ return std::string(absl::StripSuffix(filename, ".proto"));
}
}
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
index 09d82f039b..dba9729834 100644
--- a/src/google/protobuf/compiler/command_line_interface.cc
+++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -75,6 +75,7 @@
#include "google/protobuf/compiler/subprocess.h"
#include "google/protobuf/compiler/plugin.pb.h"
#include "google/protobuf/stubs/strutil.h"
+#include "absl/strings/match.h"
#include "google/protobuf/stubs/stringprintf.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h"
@@ -1065,9 +1066,9 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
if (mode_ == MODE_COMPILE) {
for (int i = 0; i < output_directives_.size(); i++) {
std::string output_location = output_directives_[i].output_location;
- if (!HasSuffixString(output_location, ".zip") &&
- !HasSuffixString(output_location, ".jar") &&
- !HasSuffixString(output_location, ".srcjar")) {
+ if (!absl::EndsWith(output_location, ".zip") &&
+ !absl::EndsWith(output_location, ".jar") &&
+ !absl::EndsWith(output_location, ".srcjar")) {
AddTrailingSlash(&output_location);
}
@@ -1088,12 +1089,12 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
for (const auto& pair : output_directories) {
const std::string& location = pair.first;
GeneratorContextImpl* directory = pair.second.get();
- if (HasSuffixString(location, "/")) {
+ if (absl::EndsWith(location, "/")) {
if (!directory->WriteAllToDisk(location)) {
return 1;
}
} else {
- if (HasSuffixString(location, ".jar")) {
+ if (absl::EndsWith(location, ".jar")) {
directory->AddJarManifest();
}
@@ -1971,7 +1972,7 @@ CommandLineInterface::InterpretArgument(const std::string& name,
// Some other flag. Look it up in the generators list.
const GeneratorInfo* generator_info = FindGeneratorByFlag(name);
if (generator_info == nullptr &&
- (plugin_prefix_.empty() || !HasSuffixString(name, "_out"))) {
+ (plugin_prefix_.empty() || !absl::EndsWith(name, "_out"))) {
// Check if it's a generator option flag.
generator_info = FindGeneratorByOption(name);
if (generator_info != nullptr) {
@@ -1981,7 +1982,7 @@ CommandLineInterface::InterpretArgument(const std::string& name,
parameters->append(",");
}
parameters->append(value);
- } else if (HasPrefixString(name, "--") && HasSuffixString(name, "_opt")) {
+ } else if (absl::StartsWith(name, "--") && absl::EndsWith(name, "_opt")) {
std::string* parameters =
&plugin_parameters_[PluginName(plugin_prefix_, name)];
if (!parameters->empty()) {
@@ -2165,8 +2166,8 @@ bool CommandLineInterface::GenerateOutput(
std::string error;
if (output_directive.generator == nullptr) {
// This is a plugin.
- GOOGLE_CHECK(HasPrefixString(output_directive.name, "--") &&
- HasSuffixString(output_directive.name, "_out"))
+ GOOGLE_CHECK(absl::StartsWith(output_directive.name, "--") &&
+ absl::EndsWith(output_directive.name, "_out"))
<< "Bad name for plugin generator: " << output_directive.name;
std::string plugin_name = PluginName(plugin_prefix_, output_directive.name);
diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc
index 6b330b8ff1..1ac81e6a77 100644
--- a/src/google/protobuf/compiler/command_line_interface_unittest.cc
+++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc
@@ -794,6 +794,7 @@ TEST_F(CommandLineInterfaceTest, MultipleInputsWithImport) {
"bar.proto", "Bar");
}
+
TEST_F(CommandLineInterfaceTest, MultipleInputsWithImport_DescriptorSetIn) {
// Test parsing multiple input files with an import of a separate file.
FileDescriptorSet file_descriptor_set;
diff --git a/src/google/protobuf/compiler/cpp/BUILD.bazel b/src/google/protobuf/compiler/cpp/BUILD.bazel
index 1798fce624..bf95ffef03 100644
--- a/src/google/protobuf/compiler/cpp/BUILD.bazel
+++ b/src/google/protobuf/compiler/cpp/BUILD.bazel
@@ -53,9 +53,10 @@ cc_library(
"//src/google/protobuf/compiler:__pkg__",
],
deps = [
- "//:protobuf",
+ "//src/google/protobuf:protobuf_nowkt",
"//src/google/protobuf/compiler:code_generator",
"@com_google_absl//absl/base:core_headers",
+ "@com_google_absl//absl/container:btree",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/container:layout",
diff --git a/src/google/protobuf/compiler/cpp/file.cc b/src/google/protobuf/compiler/cpp/file.cc
index dff09a8690..729e66e240 100644
--- a/src/google/protobuf/compiler/cpp/file.cc
+++ b/src/google/protobuf/compiler/cpp/file.cc
@@ -38,21 +38,32 @@
#include