Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update googletest to 1.11 to fix build with gcc 11 #1916

Merged
merged 1 commit into from
Jan 13, 2022

Conversation

PiRK
Copy link
Contributor

@PiRK PiRK commented Jan 12, 2022

Description

Recent versions of gcc (11.x) changed some rule about uninitialized variables, causing a warning which is for some reason considered as an error when I try to run bootstrap.sh. See google/googletest#3219 and google/googletest#3024

This fixes it by updating googletest to 1.11.00

Testing instructions

On Ubuntu 21.10, follow the build instructions, then try to run bootstrap.sh.

Without the patch, it causes the following error:

$ ./bootstrap.sh
#### Initializing... ####
PREFIX: /home/pierre/dev/wallet-core/build/local
patching cmake minimum version
patching file CMakeLists.txt
patching file googletest/CMakeLists.txt
patching file googlemock/CMakeLists.txt
-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is GNU 11.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python (found version "3.9.7")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pierre/dev/wallet-core/build/local/src/gtest/googletest-release-1.10.0
Scanning dependencies of target gtest
[ 12%] Building CXX object googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
In file included from /home/pierre/dev/wallet-core/build/local/src/gtest/googletest-release-1.10.0/googletest/src/gtest-all.cc:42:
/home/pierre/dev/wallet-core/build/local/src/gtest/googletest-release-1.10.0/googletest/src/gtest-death-test.cc: In function ‘bool testing::internal::StackGrowsDown()’:
/home/pierre/dev/wallet-core/build/local/src/gtest/googletest-release-1.10.0/googletest/src/gtest-death-test.cc:1301:24: error: ‘dummy’ may be used uninitialized [-Werror=maybe-uninitialized]
 1301 |   StackLowerThanAddress(&dummy, &result);
      |   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/home/pierre/dev/wallet-core/build/local/src/gtest/googletest-release-1.10.0/googletest/src/gtest-death-test.cc:1290:13: note: by argument 1 of type ‘const void*’ to ‘void testing::internal::StackLowerThanAddress(const void*, bool*)’ declared here
 1290 | static void StackLowerThanAddress(const void* ptr, bool* result) {
      |             ^~~~~~~~~~~~~~~~~~~~~
/home/pierre/dev/wallet-core/build/local/src/gtest/googletest-release-1.10.0/googletest/src/gtest-death-test.cc:1299:7: note: ‘dummy’ declared here
 1299 |   int dummy;
      |       ^~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [googletest/CMakeFiles/gtest.dir/build.make:82: googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:219: googletest/CMakeFiles/gtest.dir/all] Error 2
make: *** [Makefile:160: all] Error 2

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

None of the checklist items are applicable.

@hewigovens
Copy link
Contributor

@PiRK could you please check if gtest 1.11.0 has fixed this or not? also sed on macOS by default is bsd version, that's why iOS CI failed

@PiRK
Copy link
Contributor Author

PiRK commented Jan 12, 2022

@PiRK could you please check if gtest 1.11.0 has fixed this or not? also sed on macOS by default is bsd version, that's why iOS CI failed

I believe gtest 1.11 has fixed this. I can compile it without an error. I initially assumed that it wasn't fixed in 1.11 because when I searched for the error message I saw reports of the same error happening with that version, but those users must have been mistaken, or maybe they were building the master branch.

I will update the PR to simply use 1.11 instead of 1.10, rather than patching an old version, if that is OK with you.

@hewigovens
Copy link
Contributor

Yes, let's try 1.11.0

This fixes a build issue caused by gcc 11 changing the rules about what constitutes a `-Werror=maybe-uninitialized` error (see google/googletest#3024)

As a side benefit, this simplifies the build  script by removing the need for a few patches.
@PiRK PiRK force-pushed the fix_googletest_uninitialized branch from 51f8040 to 526f846 Compare January 12, 2022 14:46
@PiRK PiRK changed the title Fix warning maybe-uninitialized in install-dependencies Update googletest to 1.11 to fix build with gcc 11 Jan 12, 2022
@PiRK
Copy link
Contributor Author

PiRK commented Jan 12, 2022

Copy link
Contributor

@hewigovens hewigovens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update

@hewigovens hewigovens requested a review from vikmeup January 12, 2022 23:33
@hewigovens hewigovens merged commit e3af4fd into trustwallet:master Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants