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

[Bug]: bazel passes '-std=c++0x' which is too old #4254

Closed
pogo59 opened this issue May 24, 2023 · 4 comments
Closed

[Bug]: bazel passes '-std=c++0x' which is too old #4254

pogo59 opened this issue May 24, 2023 · 4 comments
Assignees

Comments

@pogo59
Copy link

pogo59 commented May 24, 2023

Describe the issue

Trying to build googletest with bazel, I see it passing '-std=c++0x' on the gcc command line, which of course fails the version check for C++14 or later in gtest-port.h. I am a bazel noob but I don't see anything in the BUILD files related to this.

Steps to reproduce the problem

$ bazel build //:gtest
INFO: Analyzed target //:gtest (1 packages loaded, 59 targets configured).
INFO: Found 1 target...
ERROR: /home/probinson/ssd/projects/google/googletest/BUILD.bazel:80:11: Compiling googletest/src/gtest-typed-test.cc failed: (Exit 1): gcc failed: error executing command (from target //:gtest) /usr/lib/icecc/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF ... (remaining 34 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from googletest/include/gtest/internal/gtest-internal.h:42:0,
                 from googletest/include/gtest/gtest-typed-test.h:174,
                 from googletest/src/gtest-typed-test.cc:30:
googletest/include/gtest/internal/gtest-port.h:280:2: error: #error C++ versions less than C++14 are not supported.
 #error C++ versions less than C++14 are not supported.
  ^~~~~
Target //:gtest failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.481s, Critical Path: 0.30s
INFO: 15 processes: 15 internal.
FAILED: Build did NOT complete successfully

What version of GoogleTest are you using?

$ git rev-parse HEAD
e49c6b9

What operating system and version are you using?

Ubuntu 18.04

What compiler and version are you using?

$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) 

What build system are you using?

$ bazel --version
bazel 6.2.0

Additional context

CONTRIBUTING.md doesn't say a word about using bazel so I'm just guessing how to build with it.

@pgawro
Copy link
Contributor

pgawro commented May 25, 2023

@pogo59 I created PR with fix for your issue. But also you can achieve same results by running bazel build //:gtest --cxxopt=-std=c++14

Let me know if that helped you

@pogo59
Copy link
Author

pogo59 commented May 25, 2023

@pgawro yes that allowed the build to complete, thanks!

@dinord dinord self-assigned this May 31, 2023
@dinord
Copy link
Collaborator

dinord commented May 31, 2023

We strongly recommend setting the standard via command line: https://github.com/abseil/abseil-cpp/blob/master/FAQ.md#how-to-i-set-the-c-dialect-used-to-build-abseil

I'll review bazel quickstart docs and make sure we have an example for setting the language standard.

@pogo59
Copy link
Author

pogo59 commented May 31, 2023

Having a googletest doc that describes how to build (and test!) googletest using bazel would be even more helpful!

kunitoki pushed a commit to kunitoki/googletest that referenced this issue Nov 4, 2023
…el quickstart and readme.

An equivalent for CMake was merged in google@aa99ce5

Fixes google#4254

PiperOrigin-RevId: 536759641
Change-Id: I8400064a24e0d78f17a0720046f505efa1167b4f
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

No branches or pull requests

3 participants