TLDR: what's the best way to override or nullify certain bazel commandline flags for a target?
We are using bazel to build C++ code and CUDA code. Due to certain platform limitation, we use C++ 17 for C++ code, but C++ 14 for CUDA (since the cuda compiler nvcc doesn't support C++ 17, but we still need C++ 17 features in regular C++ code). We use
rules_cuda to build CUDA targets.
To do this, currently we pass -std=c++17 to all the cc targets (by copts), and no special flag for CUDA targets. Without any flag the compilers (gcc and nvcc) default to use c++ 14. We don't use --cxxopt=-std=c++17 flag, since this flag will be passed to nvcc and cause failures. This has been working fine.
Now we are introducing
abseil to the codebase. Abseil recommends
--cxxopt=-std=c++17 to set what C++ dialect to use. As mentioned above, this will break CUDA build.
Ideally I'd like to modify cuda targets (cuda_library rule) such that they can override the -std=c++17 flag or nullify it. I have been looking into this discussion on
transition and general discussions Google gives me, but have not got a clear solution yet.