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

Optional toolchains #3601

Closed
ianthehat opened this issue Aug 23, 2017 · 8 comments
Closed

Optional toolchains #3601

ianthehat opened this issue Aug 23, 2017 · 8 comments
Assignees
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Configurability platforms, toolchains, cquery, select(), config transitions type: feature request

Comments

@ianthehat
Copy link
Contributor

There are reasons to write rules where the exact toolchains used might vary depending on information available at analysis time.
The specific example here is that linking a go_binary needs a cc toolchain only if there was cgo in any of it's transitive dependencies.
At the moment to get the cc toolchain you have to say you need it in the rule, and then it is an error if one is not available, even if the go_binary rule was not really going to use it.
If we defer the error to the point of first access, then pure go builds will ask for a cc toolchain, but not get it, and go ahead to compile without error, whereas builds with cgo would complain if there was no cc toolchain but compile if there was.
There may be use cases where it would be nice to test whether the toolchain was available, but that's not strictly needed for this case.

@hlopko
Copy link
Member

hlopko commented Jun 6, 2019

Another use case for this would be tools for various languages. E.g. rules_java use a tool called singlejar that is written in C++. This causes confusion in rules_java users: "Why do I need to have gcc installed when I'm only building Java??". We could rewrite the tool in Java, but then powerusers come and complain that the tool is too slow for them.

If we had support for optional toolchains, we could in theory use the knowledge that C++ toolchain is available to use the C++ tool, and in case it's not available, fallback to the Java tool.

</fairy_tale>

Cc @lberki, @iirina because they are interested :)

@lberki
Copy link
Contributor

lberki commented Jun 6, 2019

I think that automatically choosing a Java singlejar implementation would be actively harmful, because it would open the way towards accidental slowdowns that are hard to track down. Better be explicit than implicit.

@jin jin added team-Configurability platforms, toolchains, cquery, select(), config transitions untriaged and removed category: extensibility > toolchains labels May 6, 2020
@katre katre added ice-box and removed untriaged labels May 18, 2020
@katre
Copy link
Member

katre commented May 18, 2020

Placing this in the icebox since we have no plans to take on this work.

@sventiffe sventiffe added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) and removed ice-box labels Nov 10, 2020
@katre
Copy link
Member

katre commented Feb 24, 2021

Recent discussions (see #12897) have brought back the idea of optional toolchains. One possibility is to make all toolchains optional, and then rule implementations can provide a more-appropriate error message if they cannot continue without a toolchain of a specific type.

The main issue with this is migration: all existing uses of toolchains would need to add checks and error messages. I may take some time to consider alternatives or ways to ease this migration and bring this back to the forefront.

@philsc
Copy link
Contributor

philsc commented Mar 7, 2021

I also liked @aiuto's idea of marking all targets that don't have a toolchain as incompatible: #12419

If you then try to explicitly build an incompatible target, bazel would tell you it's incompatible because it couldn't find any toolchains.

@katre
Copy link
Member

katre commented Jan 22, 2022

See https://github.com/bazelbuild/proposals/blob/main/designs/2022-01-21-optional-toolchains.md :)

@uhthomas
Copy link
Contributor

uhthomas commented Mar 1, 2022

Implementation tracked in #14726.

@katre
Copy link
Member

katre commented May 4, 2022

This is now implemented and will be in the next LTS release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Configurability platforms, toolchains, cquery, select(), config transitions type: feature request
Projects
None yet
Development

No branches or pull requests

8 participants