Reputation: 146
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 = [...]
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.
Thanks!
Upvotes: 7
Views: 3773
Reputation: 28751
I think you have to copy the default generated toolchain into your project and make modifications in it.
You'd run bazel info
to locate your output_base
directory, and find the toolchain files there.
Source: https://groups.google.com/g/bazel-discuss/c/N1qvsGMJoAE
Upvotes: 2