Skip to content

Wasteful duplication between incremental build dirs and normal artifacts. #70823

Open
@eddyb

Description

@eddyb

Incremental compilation reuses object files by storing a copy of them in the incremental cache directory, which is then copied into the rlib.

This results to build dirs which are twice as big as they need to be (which then gets multiplied by the number of stale artifacts that aren't removed by any tool AFAICT).

There are several ways we could resolve this, but they can be split into two categories:

  • incremental cache holds the object files
    • Cargo could have a mode in which it instructs rustc to emit object files but only in the incremental cache and then downstream rustc to use that incremental cache
      • this would allow non-Cargo tooling to keep working, but we'd have to support rlibs as the same time as the new system and we might unknowingly break them if Cargo doesn't use them
    • the rlib doesn't have to be a real archive, we could have a different format that references the files in the incremental cache, or even make the rlib a directory full of hardlinks, or a hardlink itself etc.
  • rlib artifact holds the object files
    • not clear what's possible at all for other crate types, for now they'd keep the duplication
    • we probably want to hardlink/symlink it from the incremental cache and hash each object file so we can check it's still the same and only reuse it then
      • we might already be doing that hashing anyway, in case the incremental dir is corrupted
    • requires no change in tooling AFAICT, including custom non-Cargo setups

cc @rust-lang/compiler

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-incr-compArea: Incremental compilationC-enhancementCategory: An issue proposing an enhancement or a PR with one.I-heavyIssue: Problems and improvements with respect to binary size of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions