Skip to content

Commit

Permalink
Upgrade third_party/googletest submodule to current main branch (#10393)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
acozzette authored and MaHeyndrickx committed Aug 12, 2022
1 parent 4c3ab6c commit 7df94e2
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 24 deletions.
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build --cxxopt=-std=c++14
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 <atomic>
int main() {
Expand Down
7 changes: 3 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)

Expand Down
4 changes: 2 additions & 2 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion kokoro/linux/aarch64/protoc_crosscompile_aarch64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion kokoro/linux/aarch64/python_crosscompile_aarch64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
10 changes: 0 additions & 10 deletions src/google/protobuf/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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
################################################################################
Expand Down
2 changes: 1 addition & 1 deletion third_party/googletest
Submodule googletest updated 361 files

0 comments on commit 7df94e2

Please sign in to comment.