Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameters for copts/cxxopts/conlyopts/linkops to toolchains #191

Open
sin-ack opened this issue Aug 9, 2024 · 0 comments
Open

Add parameters for copts/cxxopts/conlyopts/linkops to toolchains #191

sin-ack opened this issue Aug 9, 2024 · 0 comments

Comments

@sin-ack
Copy link

sin-ack commented Aug 9, 2024

Problem Definition

I am currently working on an SDK which uses Bazel. The SDK exposes itself as a Bazel package to downstream users, and as part of that, provides its own toolchain. This toolchain was up until recently just using the system C++ compiler (with all the associated badness that entails), and I'm currently on a quest to make it use hermetic_cc_toolchain. However, the old toolchain was passing a bunch of compile flags in its cc_toolchain_configure, and I couldn't find any alternative in hermetic_cc_toolchain that would allow me to encapsulate them in the same way. Currently hermetic_cc_toolchain will have a bunch of pre-determined flags that work for itself (and some special-casing for Go, apparently), but it doesn't allow extending that with custom flags.

My current workaround is adding --copt flags in .bazelrc, but asking every downstream user to maintain this file manually and handle updating it is cumbersome.

Solution

It would be great if I could do this:

load("@hermetic_cc_toolchain//toolchain:defs.bzl", zig_toolchains = "toolchains")

zig_toolchains(
    copts = [
       "-Wall",
       "-Wextra",
       # yadda yadda yadda
    ],
)

This would pass the flags down to every generated toolchain repository through declare_cc_toolchains. Then I would be able to put this in a macro and just tell downstream to call it (via WORKSPACE or module extensions). Maybe in the future it would be worthwhile to be able to specify target-specific flags as well, but this would still solve the majority of the problem for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant