Skip to content

Clean up dependency tracking in Rustbuild #50509

Closed
@Mark-Simulacrum

Description

@Mark-Simulacrum

The primary idea here is that throughout compile, check, tool, and test.rs we call builder.cargo, with a series of clear_if_dirty calls before it depending on the implicit dependencies of the given crate.

I'd like for us to instead utilize the Mode argument passed. That should ensure that we appropriately do this without having to think about it when adding new tools and tests.

I believe the appropriate first step here is to refactor the existing Mode enum into something like the below; then we'd have to change the uses of it throughout the codebase to apply this strategy:

  • Only compilations of std, test, rustc, and the codegen libraries should use Mode::{Std, Test, Rustc, Codegen} respectively. Primarily the changes here are in tool.rs.
  • Tool compilations that today use Mode::Librustc would become Mode::RustcTool, and same for the other combinations. There isn't a Mode::CodegenTool as those don't currently exist to my knowledge, but we can add it if necessary.

Once this initial refactor is done, I think that's a good point to file a PR as it's an incremental change that can be reviewed on its own. The second change (which will close this issue) is to change Builder::cargo to have a match on the passed mode which will call clear_if_dirty with the stamp dependencies of the given Mode. Note that this means for Mode::Rustc we need to call clear_if_dirty on std, test stamps, whereas Mode::RustcTool needs to call clear_if_dirty for std, test, and rustc stamps. This is mostly just inlining code.

enum Mode {
    Std,
    Test,
    Rustc,
    Codegen,
    ToolStd,
    ToolTest,
    ToolRustc,
}

cc @collin5 -- if you're interested please let me know

Metadata

Metadata

Assignees

No one assigned

    Labels

    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