From b136ee35e5e0dab3cfe0d0c1318223d97dec13e3 Mon Sep 17 00:00:00 2001 From: Marjolein Heyndrickx Date: Wed, 10 Aug 2022 10:04:06 +0200 Subject: [PATCH 1/8] Fix Wpedantic warning 'extra ;' for c++ --- src/google/protobuf/descriptor.h | 16 ++++++++-------- src/google/protobuf/parse_context.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h index beb3e641c655..2b5cc100f4df 100644 --- a/src/google/protobuf/descriptor.h +++ b/src/google/protobuf/descriptor.h @@ -615,7 +615,7 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Descriptor); }; -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(Descriptor, 136); +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(Descriptor, 136) // Describes a single field of a message. To get the descriptor for a given // field, first get the Descriptor for the message in which it is defined, @@ -992,7 +992,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldDescriptor); }; -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FieldDescriptor, 72); +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FieldDescriptor, 72) // Describes a oneof defined in a message type. class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase { @@ -1073,7 +1073,7 @@ class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(OneofDescriptor); }; -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(OneofDescriptor, 40); +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(OneofDescriptor, 40) // Describes an enum type defined in a .proto file. To get the EnumDescriptor // for a generated enum type, call TypeName_descriptor(). Use DescriptorPool @@ -1244,7 +1244,7 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumDescriptor); }; -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumDescriptor, 72); +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumDescriptor, 72) // Describes an individual enum constant of a particular type. To get the // EnumValueDescriptor for a given enum value, first get the EnumDescriptor @@ -1329,7 +1329,7 @@ class PROTOBUF_EXPORT EnumValueDescriptor : private internal::SymbolBaseN<0>, GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumValueDescriptor); }; -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumValueDescriptor, 32); +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumValueDescriptor, 32) // Describes an RPC service. Use DescriptorPool to construct your own // descriptors. @@ -1412,7 +1412,7 @@ class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceDescriptor); }; -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(ServiceDescriptor, 48); +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(ServiceDescriptor, 48) // Describes an individual service method. To obtain a MethodDescriptor given // a service, first get its ServiceDescriptor, then call @@ -1501,7 +1501,7 @@ class PROTOBUF_EXPORT MethodDescriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MethodDescriptor); }; -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(MethodDescriptor, 64); +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(MethodDescriptor, 64) // Describes a whole .proto file. To get the FileDescriptor for a compiled-in // file, get the descriptor for something defined in that file and call @@ -1709,7 +1709,7 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileDescriptor); }; -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FileDescriptor, 152); +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FileDescriptor, 152) // =================================================================== diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h index c72e19fe0d0e..51f2e326c7e5 100644 --- a/src/google/protobuf/parse_context.h +++ b/src/google/protobuf/parse_context.h @@ -636,7 +636,7 @@ RotRight7AndReplaceLowByte(uint64_t res, const char& byte) { res |= 0xFF & byte; #endif return res; -}; +} inline PROTOBUF_ALWAYS_INLINE const char* ReadTagInlined(const char* ptr, uint32_t* out) { From 71af7209d92838ebd9bf0e5095ef4077e27b1b4c Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Wed, 10 Aug 2022 20:37:27 +0000 Subject: [PATCH 2/8] Use protoc version for --version --- .../protobuf/compiler/command_line_interface.cc | 2 +- src/google/protobuf/stubs/common.cc | 12 ++++++++++-- src/google/protobuf/stubs/common.h | 7 ++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index f5cc9a91737f..652ce0449585 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -1844,7 +1844,7 @@ CommandLineInterface::InterpretArgument(const std::string& name, if (!version_info_.empty()) { std::cout << version_info_ << std::endl; } - std::cout << "libprotoc " << internal::VersionString(PROTOBUF_VERSION) + std::cout << "libprotoc " << internal::ProtocVersionString(PROTOBUF_VERSION) << PROTOBUF_VERSION_SUFFIX << std::endl; return PARSE_ARGUMENT_DONE_AND_EXIT; // Exit without running compiler. diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc index f1a815022d4d..5e6ce708288c 100644 --- a/src/google/protobuf/stubs/common.cc +++ b/src/google/protobuf/stubs/common.cc @@ -92,7 +92,7 @@ void VerifyVersion(int headerVersion, } } -std::string VersionString(int version) { +std::string VersionString(int version, bool cppMajor) { int major = version / 1000000; int minor = (version / 1000) % 1000; int micro = version % 1000; @@ -100,7 +100,11 @@ std::string VersionString(int version) { // 128 bytes should always be enough, but we use snprintf() anyway to be // safe. char buffer[128]; - snprintf(buffer, sizeof(buffer), "%d.%d.%d", major, minor, micro); + if (cppMajor) { + snprintf(buffer, sizeof(buffer), "%d.%d.%d", major, minor, micro); + } else { + snprintf(buffer, sizeof(buffer), "%d.%d", minor, micro); + } // Guard against broken MSVC snprintf(). buffer[sizeof(buffer)-1] = '\0'; @@ -108,6 +112,10 @@ std::string VersionString(int version) { return buffer; } +std::string ProtocVersionString(int version) { + return VersionString(version, false); +} + } // namespace internal // =================================================================== diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 427df67d4f1a..2d6bcf86158c 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -106,7 +106,12 @@ void PROTOBUF_EXPORT VerifyVersion(int headerVersion, int minLibraryVersion, const char* filename); // Converts a numeric version number to a string. -std::string PROTOBUF_EXPORT VersionString(int version); +// If cppMajor is true the string will have the C++ major version, otherwise +// the string will be the protoc version. +std::string PROTOBUF_EXPORT VersionString(int version, bool cppMajor = true); + +// Prints the protoc compiler version (no major version) +std::string PROTOBUF_EXPORT ProtocVersionString(int version); } // namespace internal From 8fee1dea9d9c05881a9b22f010d4b4e84c177407 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Wed, 10 Aug 2022 23:41:45 +0000 Subject: [PATCH 3/8] Update to have two distinct methods --- src/google/protobuf/stubs/common.cc | 22 +++++++++++++++------- src/google/protobuf/stubs/common.h | 4 +--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc index 5e6ce708288c..3fa3d04c759a 100644 --- a/src/google/protobuf/stubs/common.cc +++ b/src/google/protobuf/stubs/common.cc @@ -92,7 +92,7 @@ void VerifyVersion(int headerVersion, } } -std::string VersionString(int version, bool cppMajor) { +std::string VersionString(int version) { int major = version / 1000000; int minor = (version / 1000) % 1000; int micro = version % 1000; @@ -100,11 +100,7 @@ std::string VersionString(int version, bool cppMajor) { // 128 bytes should always be enough, but we use snprintf() anyway to be // safe. char buffer[128]; - if (cppMajor) { - snprintf(buffer, sizeof(buffer), "%d.%d.%d", major, minor, micro); - } else { - snprintf(buffer, sizeof(buffer), "%d.%d", minor, micro); - } + snprintf(buffer, sizeof(buffer), "%d.%d.%d", major, minor, micro); // Guard against broken MSVC snprintf(). buffer[sizeof(buffer)-1] = '\0'; @@ -113,7 +109,19 @@ std::string VersionString(int version, bool cppMajor) { } std::string ProtocVersionString(int version) { - return VersionString(version, false); + int minor = (version / 1000) % 1000; + int micro = version % 1000; + + // 128 bytes should always be enough, but we use snprintf() anyway to be + // safe. + char buffer[128]; + snprintf(buffer, sizeof(buffer), "%d.%d", minor, micro); + + // Guard against broken MSVC snprintf(). + buffer[sizeof(buffer)-1] = '\0'; + + return buffer; + } } // namespace internal diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 2d6bcf86158c..64787684bbf8 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -106,9 +106,7 @@ void PROTOBUF_EXPORT VerifyVersion(int headerVersion, int minLibraryVersion, const char* filename); // Converts a numeric version number to a string. -// If cppMajor is true the string will have the C++ major version, otherwise -// the string will be the protoc version. -std::string PROTOBUF_EXPORT VersionString(int version, bool cppMajor = true); +std::string PROTOBUF_EXPORT VersionString(int version); // Prints the protoc compiler version (no major version) std::string PROTOBUF_EXPORT ProtocVersionString(int version); From f36b3c286b84ed7524503eb0a5e3d663b62a39bf Mon Sep 17 00:00:00 2001 From: Mike Kruskal <62662355+mkruskal-google@users.noreply.github.com> Date: Thu, 11 Aug 2022 10:41:07 -0700 Subject: [PATCH 4/8] Disabling upb tests in python_cpp builds (#10392) * Disabling upb tests in python_cpp builds * Adding comment about upb --- kokoro/linux/python310_cpp/continuous.cfg | 4 +++- kokoro/linux/python310_cpp/presubmit.cfg | 1 + kokoro/linux/python37_cpp/continuous.cfg | 3 ++- kokoro/linux/python37_cpp/presubmit.cfg | 1 + kokoro/linux/python38_cpp/continuous.cfg | 3 ++- kokoro/linux/python38_cpp/presubmit.cfg | 1 + kokoro/linux/python39_cpp/continuous.cfg | 3 ++- kokoro/linux/python39_cpp/presubmit.cfg | 1 + 8 files changed, 13 insertions(+), 4 deletions(-) diff --git a/kokoro/linux/python310_cpp/continuous.cfg b/kokoro/linux/python310_cpp/continuous.cfg index 1f91c26713d8..e76abe18a033 100644 --- a/kokoro/linux/python310_cpp/continuous.cfg +++ b/kokoro/linux/python310_cpp/continuous.cfg @@ -11,7 +11,9 @@ env_vars { env_vars { key: "BAZEL_TARGETS" - value: "//python/... @upb//python/..." + # Note: upb tests don't work since the C++ extension takes precedence here. + # Note: upb tests don't work since the C++ extension takes precedence here. + value: "//python/..." } env_vars { diff --git a/kokoro/linux/python310_cpp/presubmit.cfg b/kokoro/linux/python310_cpp/presubmit.cfg index 1c4cfeebc8f4..5b87fd6c51b5 100644 --- a/kokoro/linux/python310_cpp/presubmit.cfg +++ b/kokoro/linux/python310_cpp/presubmit.cfg @@ -11,6 +11,7 @@ env_vars { env_vars { key: "BAZEL_TARGETS" + # Note: upb tests don't work since the C++ extension takes precedence here. value: "//python/..." } diff --git a/kokoro/linux/python37_cpp/continuous.cfg b/kokoro/linux/python37_cpp/continuous.cfg index 44f6606a9fc7..ebef92806f09 100644 --- a/kokoro/linux/python37_cpp/continuous.cfg +++ b/kokoro/linux/python37_cpp/continuous.cfg @@ -11,7 +11,8 @@ env_vars { env_vars { key: "BAZEL_TARGETS" - value: "//python/... @upb//python/..." + # Note: upb tests don't work since the C++ extension takes precedence here. + value: "//python/..." } env_vars { diff --git a/kokoro/linux/python37_cpp/presubmit.cfg b/kokoro/linux/python37_cpp/presubmit.cfg index 54b2de47e156..ebef92806f09 100644 --- a/kokoro/linux/python37_cpp/presubmit.cfg +++ b/kokoro/linux/python37_cpp/presubmit.cfg @@ -11,6 +11,7 @@ env_vars { env_vars { key: "BAZEL_TARGETS" + # Note: upb tests don't work since the C++ extension takes precedence here. value: "//python/..." } diff --git a/kokoro/linux/python38_cpp/continuous.cfg b/kokoro/linux/python38_cpp/continuous.cfg index dc24fd2a3d8b..decd46649486 100644 --- a/kokoro/linux/python38_cpp/continuous.cfg +++ b/kokoro/linux/python38_cpp/continuous.cfg @@ -11,7 +11,8 @@ env_vars { env_vars { key: "BAZEL_TARGETS" - value: "//python/... @upb//python/..." + # Note: upb tests don't work since the C++ extension takes precedence here. + value: "//python/..." } env_vars { diff --git a/kokoro/linux/python38_cpp/presubmit.cfg b/kokoro/linux/python38_cpp/presubmit.cfg index f9d025a3af72..decd46649486 100644 --- a/kokoro/linux/python38_cpp/presubmit.cfg +++ b/kokoro/linux/python38_cpp/presubmit.cfg @@ -11,6 +11,7 @@ env_vars { env_vars { key: "BAZEL_TARGETS" + # Note: upb tests don't work since the C++ extension takes precedence here. value: "//python/..." } diff --git a/kokoro/linux/python39_cpp/continuous.cfg b/kokoro/linux/python39_cpp/continuous.cfg index f11d73ed8918..97970087b040 100644 --- a/kokoro/linux/python39_cpp/continuous.cfg +++ b/kokoro/linux/python39_cpp/continuous.cfg @@ -11,7 +11,8 @@ env_vars { env_vars { key: "BAZEL_TARGETS" - value: "//python/... @upb//python/..." + # Note: upb tests don't work since the C++ extension takes precedence here. + value: "//python/..." } env_vars { diff --git a/kokoro/linux/python39_cpp/presubmit.cfg b/kokoro/linux/python39_cpp/presubmit.cfg index d7deef5b6982..97970087b040 100644 --- a/kokoro/linux/python39_cpp/presubmit.cfg +++ b/kokoro/linux/python39_cpp/presubmit.cfg @@ -11,6 +11,7 @@ env_vars { env_vars { key: "BAZEL_TARGETS" + # Note: upb tests don't work since the C++ extension takes precedence here. value: "//python/..." } From 4c3ab6ca00286b832a01808f7e166d0982d8d5c2 Mon Sep 17 00:00:00 2001 From: Mike Kruskal <62662355+mkruskal-google@users.noreply.github.com> Date: Thu, 11 Aug 2022 16:52:36 -0700 Subject: [PATCH 5/8] Reverting changes to ruby aarch64 build. (#10394) * Reverting changes to ruby aarch64 build. * Adding IN_DOCKER environment variable to prevent codegen * Pass the cmake-built protoc to the ruby runner --- kokoro/linux/aarch64/test_ruby_aarch64.sh | 2 +- kokoro/linux/ruby_aarch64/build.sh | 16 ++++++++++++++++ kokoro/linux/ruby_aarch64/continuous.cfg | 19 ++----------------- kokoro/linux/ruby_aarch64/presubmit.cfg | 19 ++----------------- 4 files changed, 21 insertions(+), 35 deletions(-) create mode 100755 kokoro/linux/ruby_aarch64/build.sh diff --git a/kokoro/linux/aarch64/test_ruby_aarch64.sh b/kokoro/linux/aarch64/test_ruby_aarch64.sh index 91ee5f288a48..e256e4edccea 100755 --- a/kokoro/linux/aarch64/test_ruby_aarch64.sh +++ b/kokoro/linux/aarch64/test_ruby_aarch64.sh @@ -24,4 +24,4 @@ kokoro/linux/aarch64/dockcross_helpers/run_dockcross_manylinux2014_aarch64.sh ko # otherwise the UID would be homeless under the docker container and pip install wouldn't work. For simplicity, # we just run map the user's home to a throwaway temporary directory -docker run $DOCKER_TTY_ARGS --rm --user "$(id -u):$(id -g)" -e "HOME=/home/fake-user" -v "$(mktemp -d):/home/fake-user" -v "$(pwd)":/work -w /work arm64v8/ruby:2.7.3-buster kokoro/linux/aarch64/ruby_build_and_run_tests_with_qemu_aarch64.sh \ No newline at end of file +docker run $DOCKER_TTY_ARGS --rm --user "$(id -u):$(id -g)" -e "HOME=/home/fake-user" -e "PROTOC=/work/protoc" -v "$(mktemp -d):/home/fake-user" -v "$(pwd)":/work -w /work arm64v8/ruby:2.7.3-buster kokoro/linux/aarch64/ruby_build_and_run_tests_with_qemu_aarch64.sh diff --git a/kokoro/linux/ruby_aarch64/build.sh b/kokoro/linux/ruby_aarch64/build.sh new file mode 100755 index 000000000000..6473e0d222ef --- /dev/null +++ b/kokoro/linux/ruby_aarch64/build.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# +# This is the top-level script we give to Kokoro as the entry point for +# running the "continuous" and "presubmit" jobs. + +set -ex + +# Change to repo root +cd $(dirname $0)/../../.. + +# Initialize any submodules. +git submodule update --init --recursive + +kokoro/linux/aarch64/qemu_helpers/prepare_qemu.sh + +kokoro/linux/aarch64/test_ruby_aarch64.sh diff --git a/kokoro/linux/ruby_aarch64/continuous.cfg b/kokoro/linux/ruby_aarch64/continuous.cfg index 044e8267afed..ae8269640495 100644 --- a/kokoro/linux/ruby_aarch64/continuous.cfg +++ b/kokoro/linux/ruby_aarch64/continuous.cfg @@ -1,26 +1,11 @@ # Config file for running tests in Kokoro # Location of the build script in repository -build_file: "protobuf/kokoro/linux/bazel.sh" +build_file: "protobuf/kokoro/linux/ruby_aarch64/build.sh" timeout_mins: 120 -env_vars { - key: "CONTAINER_IMAGE" - value: "gcr.io/protobuf-build/emulation/linux:aarch64-4e847d7a01c1792471b6dd985ab0bf2677332e6f" -} - -env_vars { - key: "BAZEL_TARGETS" - value: "//ruby/..." -} - -env_vars { - key: "BAZEL_EXTRA_FLAGS" - value: "--define=ruby_platform=c" -} - action { define_artifacts { - regex: "**/sponge_log.*" + regex: "**/sponge_log.xml" } } diff --git a/kokoro/linux/ruby_aarch64/presubmit.cfg b/kokoro/linux/ruby_aarch64/presubmit.cfg index 044e8267afed..ae8269640495 100644 --- a/kokoro/linux/ruby_aarch64/presubmit.cfg +++ b/kokoro/linux/ruby_aarch64/presubmit.cfg @@ -1,26 +1,11 @@ # Config file for running tests in Kokoro # Location of the build script in repository -build_file: "protobuf/kokoro/linux/bazel.sh" +build_file: "protobuf/kokoro/linux/ruby_aarch64/build.sh" timeout_mins: 120 -env_vars { - key: "CONTAINER_IMAGE" - value: "gcr.io/protobuf-build/emulation/linux:aarch64-4e847d7a01c1792471b6dd985ab0bf2677332e6f" -} - -env_vars { - key: "BAZEL_TARGETS" - value: "//ruby/..." -} - -env_vars { - key: "BAZEL_EXTRA_FLAGS" - value: "--define=ruby_platform=c" -} - action { define_artifacts { - regex: "**/sponge_log.*" + regex: "**/sponge_log.xml" } } From 7df94e24733307a9c3c334eaf85386741c1bf091 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Thu, 11 Aug 2022 18:22:15 -0700 Subject: [PATCH 6/8] Upgrade third_party/googletest submodule to current main branch (#10393) * Upgrade third_party/googletest submodule to current main branch We can finally do this upgrade now that we have dropped our autotools build. Googletest recommends living at head, so let's go straight to the most recent commit on main. For some reason the googletest archive is not present in the Bazel build mirror, so I removed that entry and just left the GitHub download link in our WORKSPACE file. Googletest now requires C++14, so I updated all the C++11 flags I could find to C++14 instead. I added a .bazelrc file to add -std=c++14 for all our Bazel builds. * Delete the empty //src/google/protobuf:protobuf_test target * Avoid building C++ unit tests in aarch64 jobs for Python and Ruby --- .bazelrc | 1 + CMakeLists.txt | 8 ++++---- WORKSPACE | 7 +++---- examples/Makefile | 4 ++-- kokoro/linux/aarch64/protoc_crosscompile_aarch64.sh | 2 +- kokoro/linux/aarch64/python_crosscompile_aarch64.sh | 2 +- python/setup.py | 2 +- src/google/protobuf/BUILD.bazel | 10 ---------- third_party/googletest | 2 +- 9 files changed, 14 insertions(+), 24 deletions(-) create mode 100644 .bazelrc diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 000000000000..f93facf00a8c --- /dev/null +++ b/.bazelrc @@ -0,0 +1 @@ +build --cxxopt=-std=c++14 diff --git a/CMakeLists.txt b/CMakeLists.txt index 345d7d05a491..b343c64e48ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,11 +32,11 @@ if(protobuf_DEPRECATED_CMAKE_SUBDIRECTORY_USAGE) get_filename_component(protobuf_SOURCE_DIR ${protobuf_SOURCE_DIR} DIRECTORY) endif() -# Add c++11 flags +# Add c++14 flags if (CYGWIN) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14") else() - set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) endif() @@ -187,7 +187,7 @@ set(protobuf_LINK_LIBATOMIC false) if (NOT MSVC) include(CheckCXXSourceCompiles) set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) - set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -std=c++11) + set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -std=c++14) check_cxx_source_compiles(" #include int main() { diff --git a/WORKSPACE b/WORKSPACE index ebe53315f03c..20e7415a6296 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -9,11 +9,10 @@ local_repository( http_archive( name = "com_google_googletest", - sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb", - strip_prefix = "googletest-release-1.10.0", + sha256 = "ea54c9845568cb31c03f2eddc7a40f7f83912d04ab977ff50ec33278119548dd", + strip_prefix = "googletest-4c9a3bb62bf3ba1f1010bf96f9c8ed767b363774", urls = [ - "https://mirror.bazel.build/github.com/google/googletest/archive/release-1.10.0.tar.gz", - "https://github.com/google/googletest/archive/release-1.10.0.tar.gz", + "https://github.com/google/googletest/archive/4c9a3bb62bf3ba1f1010bf96f9c8ed767b363774.tar.gz", ], ) diff --git a/examples/Makefile b/examples/Makefile index 2a64b64fe372..ef7a4ef58e94 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -41,11 +41,11 @@ protoc_middleman_dart: addressbook.proto add_person_cpp: add_person.cc protoc_middleman pkg-config --cflags protobuf # fails if protobuf is not installed - c++ -std=c++11 add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf` + c++ -std=c++14 add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf` list_people_cpp: list_people.cc protoc_middleman pkg-config --cflags protobuf # fails if protobuf is not installed - c++ -std=c++11 list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf` + c++ -std=c++14 list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf` add_person_dart: add_person.dart protoc_middleman_dart diff --git a/kokoro/linux/aarch64/protoc_crosscompile_aarch64.sh b/kokoro/linux/aarch64/protoc_crosscompile_aarch64.sh index 2880507539aa..7f07968d9a0c 100755 --- a/kokoro/linux/aarch64/protoc_crosscompile_aarch64.sh +++ b/kokoro/linux/aarch64/protoc_crosscompile_aarch64.sh @@ -4,5 +4,5 @@ set -ex -cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_WITH_ZLIB=0 . +cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_WITH_ZLIB=0 -Dprotobuf_BUILD_TESTS=OFF . make -j8 diff --git a/kokoro/linux/aarch64/python_crosscompile_aarch64.sh b/kokoro/linux/aarch64/python_crosscompile_aarch64.sh index 97d0a2403acc..a04c7e408c36 100755 --- a/kokoro/linux/aarch64/python_crosscompile_aarch64.sh +++ b/kokoro/linux/aarch64/python_crosscompile_aarch64.sh @@ -12,7 +12,7 @@ PYTHON="/opt/python/cp38-cp38/bin/python" git submodule update --init --recursive # Build protoc and libprotobuf -cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_WITH_ZLIB=0 . +cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_WITH_ZLIB=0 -Dprotobuf_BUILD_TESTS=OFF . make -j8 # create a simple shell wrapper that runs crosscompiled protoc under qemu diff --git a/python/setup.py b/python/setup.py index 283c99af607a..3364ba9f7ad2 100755 --- a/python/setup.py +++ b/python/setup.py @@ -331,7 +331,7 @@ def HasLibraryDirsOpt(): extra_compile_args.append('-Wno-invalid-offsetof') extra_compile_args.append('-Wno-sign-compare') extra_compile_args.append('-Wno-unused-variable') - extra_compile_args.append('-std=c++11') + extra_compile_args.append('-std=c++14') if sys.platform == 'darwin': extra_compile_args.append('-Wno-shorten-64-to-32') diff --git a/src/google/protobuf/BUILD.bazel b/src/google/protobuf/BUILD.bazel index ac9b420d5182..b5e1a5e44cd8 100644 --- a/src/google/protobuf/BUILD.bazel +++ b/src/google/protobuf/BUILD.bazel @@ -1073,16 +1073,6 @@ cc_test( ], ) -# Legacy target: all test sources used to be part of this rule. It is -# still kept around for now. -cc_test( - name = "protobuf_test", - srcs = [], - deps = [ - "@com_google_googletest//:gtest_main", - ], -) - ################################################################################ # Helper targets for Kotlin tests ################################################################################ diff --git a/third_party/googletest b/third_party/googletest index 5ec7f0c4a113..4c9a3bb62bf3 160000 --- a/third_party/googletest +++ b/third_party/googletest @@ -1 +1 @@ -Subproject commit 5ec7f0c4a113e2f18ac2c6cc7df51ad6afc24081 +Subproject commit 4c9a3bb62bf3ba1f1010bf96f9c8ed767b363774 From 94502599df70d1467ff9649ea72dca572fed2ff1 Mon Sep 17 00:00:00 2001 From: Mike Kruskal <62662355+mkruskal-google@users.noreply.github.com> Date: Thu, 11 Aug 2022 20:53:29 -0700 Subject: [PATCH 7/8] Fixing php proto generation script to work properly during sync (#10395) --- php/generate_descriptor_protos.sh | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/php/generate_descriptor_protos.sh b/php/generate_descriptor_protos.sh index 2239312ab5d5..1a600abc6392 100755 --- a/php/generate_descriptor_protos.sh +++ b/php/generate_descriptor_protos.sh @@ -5,10 +5,10 @@ set -e -PROTOC=protoc +PROTOC=$(realpath protoc) if [ ! -f $PROTOC ]; then bazel build -c opt //:protoc - PROTOC=bazel-bin/protoc + PROTOC=$(realpath bazel-bin/protoc) fi if test ! -e src/google/protobuf/stubs/common.h; then @@ -19,16 +19,17 @@ __EOF__ exit 1 fi -$PROTOC --php_out=internal:php/src google/protobuf/descriptor.proto -$PROTOC --php_out=internal_generate_c_wkt:php/src \ - src/google/protobuf/any.proto \ - src/google/protobuf/api.proto \ - src/google/protobuf/duration.proto \ - src/google/protobuf/empty.proto \ - src/google/protobuf/field_mask.proto \ - src/google/protobuf/source_context.proto \ - src/google/protobuf/struct.proto \ - src/google/protobuf/type.proto \ - src/google/protobuf/timestamp.proto \ - src/google/protobuf/wrappers.proto +pushd src +$PROTOC --php_out=internal:../php/src google/protobuf/descriptor.proto +$PROTOC --php_out=internal_generate_c_wkt:../php/src \ + google/protobuf/any.proto \ + google/protobuf/api.proto \ + google/protobuf/duration.proto \ + google/protobuf/empty.proto \ + google/protobuf/field_mask.proto \ + google/protobuf/source_context.proto \ + google/protobuf/struct.proto \ + google/protobuf/type.proto \ + google/protobuf/timestamp.proto \ + google/protobuf/wrappers.proto popd From def602dd07b7eae1cac6823705975317b5607fc3 Mon Sep 17 00:00:00 2001 From: Marjolein Heyndrickx Date: Fri, 12 Aug 2022 11:22:09 +0200 Subject: [PATCH 8/8] change macro to avoid pedantic warning --- src/google/protobuf/descriptor.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h index 699afd968094..653f734438bf 100644 --- a/src/google/protobuf/descriptor.h +++ b/src/google/protobuf/descriptor.h @@ -199,7 +199,7 @@ namespace internal { // #if !defined(PROTOBUF_INTERNAL_CHECK_CLASS_SIZE) -#define PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(t, expected) +#define PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(t, expected) static_assert(true, "") #endif class FlatAllocator; @@ -616,7 +616,7 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Descriptor); }; -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(Descriptor, 136) +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(Descriptor, 136); // Describes a single field of a message. To get the descriptor for a given // field, first get the Descriptor for the message in which it is defined, @@ -993,7 +993,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldDescriptor); }; -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FieldDescriptor, 72) +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FieldDescriptor, 72); // Describes a oneof defined in a message type. class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase { @@ -1074,7 +1074,7 @@ class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(OneofDescriptor); }; -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(OneofDescriptor, 40) +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(OneofDescriptor, 40); // Describes an enum type defined in a .proto file. To get the EnumDescriptor // for a generated enum type, call TypeName_descriptor(). Use DescriptorPool @@ -1245,7 +1245,7 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumDescriptor); }; -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumDescriptor, 72) +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumDescriptor, 72); // Describes an individual enum constant of a particular type. To get the // EnumValueDescriptor for a given enum value, first get the EnumDescriptor @@ -1330,7 +1330,7 @@ class PROTOBUF_EXPORT EnumValueDescriptor : private internal::SymbolBaseN<0>, GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumValueDescriptor); }; -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumValueDescriptor, 32) +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(EnumValueDescriptor, 32); // Describes an RPC service. Use DescriptorPool to construct your own // descriptors. @@ -1413,7 +1413,7 @@ class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceDescriptor); }; -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(ServiceDescriptor, 48) +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(ServiceDescriptor, 48); // Describes an individual service method. To obtain a MethodDescriptor given // a service, first get its ServiceDescriptor, then call @@ -1502,7 +1502,7 @@ class PROTOBUF_EXPORT MethodDescriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MethodDescriptor); }; -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(MethodDescriptor, 64) +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(MethodDescriptor, 64); // Describes a whole .proto file. To get the FileDescriptor for a compiled-in // file, get the descriptor for something defined in that file and call @@ -1710,7 +1710,7 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileDescriptor); }; -PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FileDescriptor, 152) +PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(FileDescriptor, 152); // ===================================================================