abseil-cpp
abseil-cpp copied to clipboard
Compiling the quickstart with C++20
I am following the Quickstart and can't seem to get it to compile with a standard version newer than C++0x. My workspace file is copy/pasted from the tutorial:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "com_google_absl",
urls = ["https://github.com/abseil/abseil-cpp/archive/98eb410c93ad059f9bba1bf43f5bb916fc92a5ea.zip"],
strip_prefix = "abseil-cpp-98eb410c93ad059f9bba1bf43f5bb916fc92a5ea",
)
http_archive(
name = "bazel_skylib",
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz"],
sha256 = "f7be3474d42aae265405a592bb7da8e171919d74c16f082a5457840f06054728",
)
http_archive(
name = "com_google_googletest",
urls = ["https://github.com/google/googletest/archive/011959aafddcd30611003de96cfd8d7a7685c700.zip"],
strip_prefix = "googletest-011959aafddcd30611003de96cfd8d7a7685c700",
)
http_archive(
name = "com_github_google_benchmark",
urls = ["https://github.com/google/benchmark/archive/bf585a2789e30585b4e3ce6baf11ef2750b54677.zip"],
strip_prefix = "benchmark-bf585a2789e30585b4e3ce6baf11ef2750b54677",
sha256 = "2a778d821997df7d8646c9c59b8edb9a573a6e04c534c01892a40aa524a7b68c",
)
I further have a .bazelrc like the following (also tried the command-line flags):
build:c++20 --cxxopt=-std=c++20
build:c++20 --copt=-std=c++20
build --config=c++20
Then running:
bazelisk test --sandbox_writable_path=$HOME/.cache/ --test_tag_filters=-benchmark @com_google_absl//...
fails with:
ERROR: /home/tom/.cache/bazel/_bazel_tom/cdf5ab22dd3c27db056e899d731234c7/external/com_google_absl/absl/synchronization/BUILD.bazel:30:11: Compiling absl/synchronization/internal/graphcycles.cc failed: (Exit 1): gcc failed: error executing command /usr/lib64/ccache/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 33 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/com_google_absl/absl/synchronization/internal/graphcycles.cc:42:
external/com_google_absl/absl/base/internal/spinlock.h:156:21: warning: bitwise operation between different enumeration types 'absl::base_internal::SpinLock::<unnamed enum>' and 'absl::base_internal::SpinLock::<unnamed enum>' is deprecated [-Wdeprecated-enum-enum-conversion]
156 | ~(kSpinLockHeld | kSpinLockCooperative | kSpinLockDisabledScheduling) };
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
external/com_google_absl/absl/synchronization/internal/graphcycles.cc: In member function 'void absl::synchronization_internal::GraphCycles::RemoveNode(void*)':
external/com_google_absl/absl/synchronization/internal/graphcycles.cc:451:52: error: incomplete type 'std::numeric_limits<unsigned int>' used in nested name specifier
451 | if (x->version == std::numeric_limits<uint32_t>::max()) {
|
As you can see in the error message, it's passing '-std=c++0x' to the invocation. I don't think this is the g++ default anyway.
I have g++ 12.2.1 which should support the newer standard. What am I missing?