Bazel:将编译标志添加到默认C ++工具链 [英] Bazel: add compile flags to default C++ toolchain
问题描述
我想在默认的C ++工具链中添加一些编译器和链接器标志,以便我构建的所有目标(本地或导入)都共享它们.
I would like to add some compiler and linker flags to the default C++ toolchain, so that all the targets I build (local or imported) share them.
我知道可以定义自己的工具链,但是我不想这样做,因为它非常复杂且容易出错.
I know that can define my own toolchain, but I don't want to do that as it's very complicated and easy to get wrong.
理想情况下,我想要这样的东西:
Ideally I would like something like this:
cc_toolchain = cc_default_toolchain()
cc_toolchain.copts = [...]
cc_toolchain.linkopts = [...]
此外,我不想在 .bashrc
文件中设置全局标志,因为每个平台都难以配置,并且在不同存储库之间共享也不容易.
Also, I don't want to set global flags in the .bashrc
file, as it's hard to configure per platform and it's not easy to share among different repositories.
谢谢!
推荐答案
我认为您必须将默认生成的工具链复制到您的项目中并在其中进行修改.
I think you have to copy the default generated toolchain into your project and make modifications in it.
您将运行 bazel info
来找到您的 output_base
目录,并在此处找到工具链文件.
You'd run bazel info
to locate your output_base
directory, and find the toolchain files there.
来源: https://groups.google.com/g/bazel-discuss/c/N1qvsGMJoAE
这篇关于Bazel:将编译标志添加到默认C ++工具链的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!