Building of protoc doesn't reflect cxxopts (and consequently can't build with recent absl)
What version of protobuf and what language are you using? Cloned version ad42a9761a50dc9555339349b7da428d1c2de621 Language: N/A (though I'd like to target c++)
What operating system (Linux, Windows, ...) and version? Mac OS/X
What runtime / compiler are you using (e.g., python version or gcc version) clang (default via blaze)
What did you do? Steps to reproduce the behavior:
- Create an empty workspace with the following
workspace(name="com_monkeynova_bug_test")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository",
"new_git_repository")
git_repository(
name = "com_google_absl",
remote = "https://github.com/abseil/abseil-cpp.git",
commit = "92fdbfb301f8b301b28ab5c99e7361e775c2fb8a",
)
git_repository(
name = "com_google_protobuf",
remote = "https://github.com/protocolbuffers/protobuf.git",
# branch = "main",
commit = "ad42a9761a50dc9555339349b7da428d1c2de621",
)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()
- bazelisk build @com_google_protobuf//src/google/protobuf:wrappers_proto -- Error about C++v14 from absl
- bazelisk build --cxxopt=-std=c++1z @com_google_protobuf//src/google/protobuf:wrappers_proto -- Same error
What did you expect to see I expect for the cxxopt to be passed through to the construction of the protoc tooling used to compile the proto.
What did you see instead? Compiler errors
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).
Running the following succeeds:
bazelisk build --cxxopt=-std=c++1z @com_google_protobuf//:protoc
However running without the --cxxopt fails
bazelisk build @com_google_protobuf//:protoc
This indicates that if I could get the cxxopt to the protoc compilation building the wrapper_proto it should work.
Anything else we should know about your project / environment This is a recent failure, though I suspect that's in part because absl only recently started requiring c++ 14 support
Ah, this is a "feature" of host configuration being distinct from target configuration with regards to tool options. I see the logic in keeping them separate (to avoid unnecessary rebuilding of tools simply because -c dbg or -c opt was switched), though this took quite a while for me to find the right incantation of flags to get right. Namely:
bazelisk build --host_cxxopt=-std=c++14 @com_google_protobuf//src/google/protobuf:wrappers_proto
I don't know exactly what the right course of action here is. I'm able to workaround in my own use now, but this feels like something that's going to crop up as an interesting usability problem for others.
Maybe each C++ target that requires C++14 features should explicitly set copts to include -std=c++14 (or the MSVC equivalent). Otherwise every user has to set the option in .bazelrc or on the command line.
All our C++ targets do set -std=c++14 already (except in MSVC) since https://github.com/protocolbuffers/protobuf/pull/10482. It looks like this PR went in a few days after this issue was filed, so I suspect it is now fixed. I'll add this copt to MSVC as well for completeness