Skip to content

Strict version hash is sensitive to presence of standard library source code on host #153898

@dtolnay

Description

@dtolnay

I am reporting a likely unintended side effect of #142594 that should get compiler team scrutiny.

Since Rust 1.89.0 or nightly-2025-06-23 (#142594), compiling the same source code will produce a different output artifact depending on whether or not standard library sources are present during compilation.

For example, with this src/lib.rs file:

pub fn repro() {
    unimplemented!("...")
}
$ rustup component remove rust-src --toolchain=nightly-2025-06-22
$ rustc +nightly-2025-06-22 src/lib.rs --crate-name=repro --crate-type=lib --edition=2024 --emit=metadata && rustc +nightly-2025-06-22 -Zls=root librepro.rmeta | rg '^hash'
hash f498d9b8b442661b3b48683256f3913a stable_crate_id StableCrateId(6398988076306807592)

$ rustup component add rust-src --toolchain=nightly-2025-06-22
$ rustc +nightly-2025-06-22 src/lib.rs --crate-name=repro --crate-type=lib --edition=2024 --emit=metadata && rustc +nightly-2025-06-22 -Zls=root librepro.rmeta | rg '^hash'
hash f498d9b8b442661b3b48683256f3913a stable_crate_id StableCrateId(6398988076306807592)
$ rustup component remove rust-src --toolchain=nightly-2025-06-23
$ rustc +nightly-2025-06-23 src/lib.rs --crate-name=repro --crate-type=lib --edition=2024 --emit=metadata && rustc +nightly-2025-06-23 -Zls=root librepro.rmeta | rg '^hash'
hash 1e9121fe4158816afef1f8c53f33dabd stable_crate_id StableCrateId(18041666587592679647)

$ rustup component add rust-src --toolchain=nightly-2025-06-23
$ rustc +nightly-2025-06-23 src/lib.rs --crate-name=repro --crate-type=lib --edition=2024 --emit=metadata && rustc +nightly-2025-06-23 -Zls=root librepro.rmeta | rg '^hash'
hash 3bfa9667f7c341fe78b80185c86717eb stable_crate_id StableCrateId(18041666587592679647)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-reproducibilityArea: Reproducible / deterministic buildsC-bugCategory: This is a bug.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions