Skip to content

Re-organize build-dir by package + hash, rather than artifact type #15010

@epage

Description

@epage

Implementation:

Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-dir-new-layout

Known issues

Unresolved issues

Open questions

  • Transition plan: while build-dir isn't stable, enough tools rely on the layout that we'd want to setup a transition plan so they can have time to test against the new layout and work to support both
  • What do we call the directory? I said build/ as its all encompassing
  • Can the old build/ and deps/ content live in the same place?
  • How should we handle incremental/?
  • Can we share across <profile> at least?
    • <hash> is the -C extra-filename hash and doesn't encompass all of fingerprinting, so we'd need to audit if there are cases that don't change the hash that we'd stil need per-profile
    • Changing of local source is one example, so at least local packages still need to be scoped by profile
    • Blocked on More granular locking in cargo_rustc #4282
  • Remove redundant -Cextra-filename in files where possible.
  • Re-evaluate if we want platform to be unconditionally included in the build-dir layout, or if we can completely drop it (blocked on More granular locking in cargo_rustc #4282)
  • Is <pkgname>/<hash> good enough or do we need to go with prefixes to reduce the number of items within a directory, see feat(build-dir): Reorganize build-dir layout #15947 (comment)
  • Can we simplify how fingerprints are stored, reducing pressure on path lengths
  • Under the new layout, should cargo clean -p also cleans old layout paths? See feat(build-dir): Reorganize build-dir layout #15947 (comment)
  • Is the current handling of build scripts sufficient or should we explicitly split them into separate entries

Future extensions

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.


Original

note: I specify build-dir to clarify which half of #14125 I'm referring to. The files and layout of build-dir does not have compatibility guarantees (source).

Currently, build-dir is laid out like

  • target/
    • <target-platform>/?
      • <profile>/
        • incremental/
        • build/
          • <package>-<hash>/
            • build*script-*
        • deps/
          • <package>-<hash>*

Currently,

  • cargo clean -p <package> will operate on everything for <package>

In the future, we could have

These could be aided by re-arranging the build-dir to be organized around <package>-<hash>, like

  • target/
    • <target-platform>/?
      • <profile>/
        • incremental/
        • build/
          • <package>-<hash>/
            • build*script-*
            • *.d

Side effects

  • We'll have to change how we invoke rustc which will increase the length of the command-line
    • Currently, we blindly point rustc at deps/ and rustc finds the files it needs. We'll instead need to point to each individual artifact rustc may need.

Metadata

Metadata

Assignees

Labels

A-layoutArea: target output directory layout, naming, and organizationC-cleanupCategory: cleanup within the codebaseS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions