Skip to content

parallel compiler: static mut refs in lib not reproducible #162203

Description

@matthiaskrgr

followup #140413 :3
we still have problems with --crate-type lib

I tried this code:

#![crate_type="lib"]
static mut TEST: &'static mut [isize] = &mut [1];
static mut TEST_RAW: *mut [isize] = &mut [1isize] as *mut _;
pub fn main() {}

rustc --edition=2024 -Zremap-cwd-prefix=reproducible_dir --cap-lints=warn -Ccodegen-units=1 -Clink-dead-code=true -Zthreads=30 -o out c.rs >& /dev/null ; md5sum out

I expected to see this happen: equal md5sums

Instead, this happened:flipflopping md5s

479f094c3654ecbd0f7fb298a98c12e6  out
0e8d752e35f181aae67e3c4b925028bd  out
0e8d752e35f181aae67e3c4b925028bd  out
479f094c3654ecbd0f7fb298a98c12e6  out
479f094c3654ecbd0f7fb298a98c12e6  out
479f094c3654ecbd0f7fb298a98c12e6  out
479f094c3654ecbd0f7fb298a98c12e6  out
0e8d752e35f181aae67e3c4b925028bd  out
479f094c3654ecbd0f7fb298a98c12e6  out
0e8d752e35f181aae67e3c4b925028bd  out
479f094c3654ecbd0f7fb298a98c12e6  out
0e8d752e35f181aae67e3c4b925028bd  out
0e8d752e35f181aae67e3c4b925028bd  out
0e8d752e35f181aae67e3c4b925028bd  out
479f094c3654ecbd0f7fb298a98c12e6  out
479f094c3654ecbd0f7fb298a98c12e6  out
0e8d752e35f181aae67e3c4b925028bd  out
479f094c3654ecbd0f7fb298a98c12e6  out

Meta

rustc --version --verbose:

rustc 1.100.0-nightly (5db7f4be8 2026-09-01)
binary: rustc
commit-hash: 5db7f4be8a36c1b8ae19299469e2be2b0f052c21
commit-date: 2026-09-01
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.0

Activity

  1. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    A-reproducibilityArea: Reproducible / deterministic builds
    on Sep 2, 2026
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 2, 2026
  3. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 3, 2026
  4. susitsm commented on Sep 9, 2026

    @susitsm
    Contributor

    The cause is as described in #162202 (comment) . Static mut refs generate DefId-s during const evel, in intern_as_new_static. When const eval is done in parallel, these DefId's order won't be deterministic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parallel-compilerArea: parallel compilerA-reproducibilityArea: Reproducible / deterministic buildsC-bugCategory: This is a bug.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