-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Toolchains should be defined as build rules #7869
Comments
@shs96c Have you read the documentation on toolchains: https://docs.bazel.build/versions/master/toolchains.html? If so, what is missing from the current work that would be helpful? |
After 7 days with no response, I am closing this issue. Feel free to re-open it with a detailed description of the functionality that is not currently provided. |
@katre, my apologies for not answering sooner. I should be a little more careful about reading my emails. The major problem with toolchains as outlined in the doc is that they need to be registered in the WORKSPACE. This precludes one building a toolchain as part of the build process, and then using that in rules that depend on that build chain. This would make writing self-hosting compilers tricky, but (less esoterically) means that all toolchains must be compiled and present on the system before build time (either downloaded via an |
@shs96c: There is nothing stopping you from compiling a toolchain as part of the build. Consider this example:
Then by registering the The only thing that cannot be expressed easily in this system is a bootstrapping compiler: using a pre-built (possibly minimal) |
So this can already be done without needing to register the toolchains in my In a large monorepo, the top-level |
I think we are speaking past each other with the term "toolchains should be defined build rules". The problem from my side is this: toolchains are defined using rules in BUILD files: there's the The only requirement that is placed on toolchains by being registered in the WORKSPACE file is that they must be statically defined: like every other build target, Bazel needs to have a name for them after the BUILD file is loaded. (This does not preclude using macros to generate toolchains, of course). As nearly as I can tell, your objection is simply that you don't wish the WORKSPACE to grow larger or be edited? In that case, use the There is a technical reason why toolchains (and execution platforms) have to be registered in the WORKSPACE: there isn't anyplace else to do it. Using the example of cc rules: when a new |
Thank you for the thoughtful reply. I see your point about why default toolchains need to be registered in the In the case where a toolchain is passed in as a rule parameter, the target for the toolchain seems like the appropriate thing to use. Sadly, calling |
Closing for now since this isn't work we intend to pick up. Feel free to open a discussion on the mailing list if you have a proposal to make this easier for you. |
There are times when it is desirable to build a new toolchain using Bazel, and then use that build subsequent rules. Consequently, defining all toolchains as part of a Bazel's configs, rather than in build rules, is impractical. It follows that it should be possible to define new toolchains using regular build files and targets.
Examples where this might be helpful are compiler development, or when iterating on new Android development releases.
The text was updated successfully, but these errors were encountered: