build: fix bazel build for c++17 (#5097)

This commit changes the way bazel chooses which version to build.
Before, we had a COPT set to -std=c++17, which is analogous to the cmake
way.
However, googletest decided to follow abseil, meaning this is *not*
recommended at all, and causes a mixed-standard build.

From https://github.com/abseil/abseil-cpp/blob/master/FAQ.md#how-to-i-set-the-c-dialect-used-to-build-abseil
we have 3 options to define the standard. Using a bazelrc is what I
believe to be the simplest, as it "fixes" the repo standard.

Signed-off-by: Nathan Gauër <brioche@google.com>
This commit is contained in:
Nathan Gauër 2023-02-02 15:05:02 +01:00 committed by GitHub
parent 1a49b52188
commit d8759a140b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 4 additions and 8 deletions

1
.bazelrc Normal file
View File

@ -0,0 +1 @@
build --cxxopt=-std=c++17

View File

@ -1 +1 @@
5.0.0 5.0.0

4
DEPS
View File

@ -5,9 +5,7 @@ vars = {
'effcee_revision': 'c7b4db79f340f7a9981e8a484f6d5785e24242d1', 'effcee_revision': 'c7b4db79f340f7a9981e8a484f6d5785e24242d1',
# Pin to the last version of googletest that supports C++11. 'googletest_revision': 'ebedaa18c7cafa15f06ab3d814440e510fad9559',
# Anything later requires C++14
'googletest_revision': 'v1.12.0',
# Use protobufs before they gained the dependency on abseil # Use protobufs before they gained the dependency on abseil
'protobuf_revision': 'v3.13.0.1', 'protobuf_revision': 'v3.13.0.1',

View File

@ -4,13 +4,10 @@ COMMON_COPTS = [
"-DSPIRV_CHECK_CONTEXT", "-DSPIRV_CHECK_CONTEXT",
"-DSPIRV_COLOR_TERMINAL", "-DSPIRV_COLOR_TERMINAL",
] + select({ ] + select({
# On Windows, assume MSVC.
# C++14 is the default in VisualStudio 2017.
"@platforms//os:windows": [], "@platforms//os:windows": [],
"//conditions:default": [ "//conditions:default": [
"-DSPIRV_LINUX", "-DSPIRV_LINUX",
"-DSPIRV_TIMER_ENABLED", "-DSPIRV_TIMER_ENABLED",
"-std=c++11",
"-fvisibility=hidden", "-fvisibility=hidden",
"-fno-exceptions", "-fno-exceptions",
"-fno-rtti", "-fno-rtti",

View File

@ -31,7 +31,7 @@ function ExitIfIsInterestingError() {
# We are not rolling google test for now. The latest version requires C++14. # We are not rolling google test for now. The latest version requires C++14.
dependencies=("external/effcee/" dependencies=("external/effcee/"
# "external/googletest/") "external/googletest/"
"external/re2/" "external/re2/"
"external/spirv-headers/") "external/spirv-headers/")