C++ compile flags end up being used for linking too #467
-
There seems to be an unfortunate interaction between Bazel flags and CMake when using rules_foreign_cc. Namely:
rules_nixpkgs/toolchains/cc/cc.nix Lines 190 to 193 in 244ae50 Then I can't seem to find a way to pass any flags to CMake that would be used for compilation only, but not for linking — having that would allow for a better toolchain file to be crafted. This is probably a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
After some trial and error, I worked around this by modifying add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-xc++>) This works as long as I also remove the |
Beta Was this translation helpful? Give feedback.
After some trial and error, I worked around this by modifying
@rules_foreign_cc
to include the following in the crosstool file:add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-xc++>)
This works as long as I also remove the
-x c++
from the compiler flags. That can be done either by patching@rules_nixpkgs_cc
(but then any non-Cmake C++ targets would break), or by further patching@rules_foreign_cc
to not set the flags that are also used for linking. That is probably the correct approach, so I'll be filing an issue with@rules_foreign_cc
, just wanted to quickly note the workaround in this discussion.