rust-lang / rust-lang/rust

`--crate-type=rlib` + `-Cdebuginfo=2` + `-Zremap-cwd-prefix=.` is not reproducible on Windows

Open
#129,117 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-reproducibility A-testsuite C-bug O-windows S-needs-repro T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

In https://github.com/rust-lang/rust/pull/128456#issuecomment-2289562440 we noticed that:

--crate-type=rlib + -C debuginfo=2 + -Z remap-cwd-prefix=. on Windows caused the rlib to be unreproducible.

https://github.com/rust-lang/rust/blob/0f442e265c165c0a78633bef98de18517815150c/tests/run-make/reproducible-build/Makefile#L4-L5

Two source files:

  1. https://github.com/rust-lang/rust/blob/0ba9db87e61adcfd9a978188f61c20d9b423a099/tests/run-make/reproducible-build/reproducible-build-aux.rs
  2. https://github.com/rust-lang/rust/blob/0ba9db87e61adcfd9a978188f61c20d9b423a099/tests/run-make/reproducible-build/reproducible-build.rs

Steps:

  • Let "root" test directory be called $base_dir.
  • rustc reproducible-build-aux.rs
  • mkdir test
  • cp reproducible-build.rs test/reproducible-build.rs
  • compiler 1: rustc --crate-type=rlib -C debuginfo=2 -Zremap-cwd-prefix=. -L $cwd reproducible-build.rs
  • mv libreproducible_build.rlib libfoo.rlib
  • cd test
  • compiler 2: rustc --crate-type=rlib -C debuginfo=2 -Zremap-cwd-prefix=. -L $base_dir --out-dir=$base_dir reproducible-build.rs
  • cd $base_dir
  • check if libreproducible_build.rlib and libfoo.rlib are different

Marking as S-needs-repro as I'm not sure of the root cause or exact reproduction environment; the test case failed on x86_64-msvc ci job. I'm also not exactly sure of the intended semantics of -Z remap-cwd-prefix=..

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 with tests/run-make/reproducible-build/Makefile and the two mentioned sources, reproducible-build-aux.rs and reproducible-build.rs. Reproduce the differing rlibs on the x86_64-msvc CI environment using the listed rustc commands, then investigate the intended semantics of -Z remap-cwd-prefix=.. Done means the Windows case has a confirmed root cause and an agreed reproducibility result.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, compilers, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.