Skip to content

bootstrap: Remove the distinction between compiler and compiler_for #96176

Open
@jyn514

Description

@jyn514

I am not sure whether compiler/compiler_for is a meaningful + worthwhile distinction; I think the best way to find out is probably to try to unify and see what goes wrong. I suspect the intent behind the addition was largely the typical "it seems like this one place wants something slightly different" that perhaps was more of a patchwork fix than done with long-term correctness, so it's unlikely to be super principled I expect in terms of where it's used and such.

I tried changing this and it went ... not well. Removing compiler altogether gives 71 build errors, and changing it to alias compiler_for(stage, host, host) fails a bunch of the tests, including some that look like real issues:

---- builder::tests::dist::dist_with_targets_and_hosts stdout ----
thread 'builder::tests::dist::dist_with_targets_and_hosts' panicked at 'assertion failed: `(left == right)`

Diff < left / right > :
 [
     Rustc {
         compiler: Compiler {
<            stage: 1,
>            stage: 2,
             host: A,
>        },
>    },
>    Rustc {
>        compiler: Compiler {
>            stage: 2,
>            host: B,
         },
     },
 ]

', src/bootstrap/builder/tests.rs:314:9

Looking at the call sites, they usually look like this:

            fn make_run(run: RunConfig<'_>) {
                run.builder.ensure($name {
                    compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
                    target: run.target,
                    extra_features: Vec::new(),
                });
            }

so I think the "proper" fix is to pass run.target into compiler_for in most of these cases; at very least, we can't assume it's always host.

In some cases it may not be clear what target is appropriate - feel free to ask on Zulip.

@rustbot label +A-rustbuild +E-mentor +E-medium

Originally posted by @jyn514 in #96000 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions