-
Notifications
You must be signed in to change notification settings - Fork 69
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
Allow overriding default codegen backend on a per-target basis #670
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed. cc @rust-lang/compiler @rust-lang/compiler-contributors |
@rustbot second |
@rustbot label -final-comment-period +major-change-accepted |
…end, r=cjgillot Allow targets to override default codegen backend Implements rust-lang/compiler-team#670.
…end, r=cjgillot Allow targets to override default codegen backend Implements rust-lang/compiler-team#670.
Rollup merge of rust-lang#116793 - WaffleLapkin:target_rules_the_backend, r=cjgillot Allow targets to override default codegen backend Implements rust-lang/compiler-team#670.
…gillot Allow targets to override default codegen backend Implements rust-lang/compiler-team#670.
Proposal
Add a field to
TargetOptions
, which allows overriding default codegen backend (CFG_DEFAULT_CODEGEN_BACKEND
). Such that the priority for choosing codegen backend will be:CFG_DEFAULT_CODEGEN_BACKEND
env variable"llvm"
This can be really helpful, given an exotic target that can only be compiled by a specific codegen backend. Full disclosure: at my
{dayjob}
we are working on a custom backend forrustc
that supports an exotic target. This is something we'll add to our fork either way, but also would like to upstream.This may not sound like a major thing, however, this creates a cyclic dependency because of
target_override
:https://github.com/rust-lang/rust/blob/bf1e3f31f95c0f75b9bf51a58e8684f750f919f2/compiler/rustc_codegen_ssa/src/traits/backend.rs#L73-L76
So my current idea is to "iterate till fixpoint". Get a backend for the target, ask it for override, ask the target for backend override, ... and so on, untill the target stops changing. Note that in practice, it's unlikely that this will take more that 1 (0?) iterations, backends should return targets that either don't have an override or that have an override for the same backend.Based on discussions in the zulip thread I've changed my opinion on this. It seems like forbidding target and backend to overwrite each other at the same time is a better idea, as it both simplifies the implementation/required changes and prevents surprising behavior.
Mentors or Reviewers
I'm planning to implement this; I don't have anyone in mind for reviews.
Process
The main points of the Major Change Process are as follows:
@rustbot second
.-C flag
, then full team check-off is required.@rfcbot fcp merge
on either the MCP or the PR.You can read more about Major Change Proposals on forge.
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.
The text was updated successfully, but these errors were encountered: