Hi Bazel experts,
We want to use Bazel to build one ECU that consists of different controllers. For each controller an own elf file is built and needs partly separate compiler and linker flags.
In addition, we want to build the complete ECU by calling one ECU target and build the dependencies via transitions. For the development use case it should be possible to call individual targets with the right configuration from the command line. It should be avoided to define compiler and linker flags twice.
I am aware of the following mechanisms to specify compiler and linker flags:
1. Bazel provides the option to specify compiler and linker flags via --cxxopt, --copt, --conlyopt, --linkopt e.g. from the command line or .bazelrc file. For c and cpp different compiler flags can be specified.
2. CC rules provide the option to specify compiler and linker flags via copts and linkopts to the attributes. This is valid for the rule target. If you have c/cpp mixed; it is just possible to specify it to c/cpp executions and not individual to c or cpp executions.
Do you have some ideas or best practices how to work with compiler and linker flags in our scenario?
If I read it correctly https://docs.bazel.build/versions/main/skylark/config.html it is also no option to specify the flags in .bazelrc in different configs and reuse it inside the transition. “Bazel doesn’t support transitioning on --config. This is because --config is an “expansion” flag that expands to other flags.”
Best regards,
Michael F.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/773fa058-3e17-4d3b-9fd2-ebf38b82e3a2n%40googlegroups.com.
Thx
for your comment.
I think your solution works well in a scenario where you use an individual
toolchain configuration and modify the toolchain itself. With the
“feature” approach it is possible to use it from the command line / .bazelrc or
in the context of transitions.
In a scenarion where the auto detected c/c++ toolchain or any generic toolchain are used I don't see a proper solution yet. It would be great if the individual flags could be organized on a central location and grouped together for managing different sets of flags.