rust-lang / rust-lang/rust

parallel compiler: static mut refs in lib not reproducible

Open
#162,203 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-parallel-compiler A-reproducibility C-bug T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

followup https://github.com/rust-lang/rust/issues/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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported rustc command with c.rs, including --crate-type lib, -Zthreads=30, and the other listed flags, then compare repeated md5sum results for out. Done means the compiler produces identical output artifacts across repeated builds for this example.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.