Skip to content

Object file in /tmp produces non-deterministic builds on Windows for crate-type=bin #112587

Open
@danakj

Description

@danakj

When building a --crate-type=bin target with rustc, an object file is produced in /tmp/<randomname> and that absolute path is then passed to the linker.

Windows puts paths to all object files in the PDB file, so this results in non-deterministic Windows builds (see #88982 (comment)). To be deterministic all paths must be relative paths, or fixed paths.

To resolve this, we could:

  1. Grow a command line to specify the path to the object file that rustc should write, and then pass to the linker.
  2. Grow a command line to specify the temp root (replacing /tmp or similar when specified), allowing it to be specified relative to the CWD. Then ensure -Zremap-cwd-prefix gets applied to it in order to produce a relative path.
  3. Other??

(FWIW I am cross-compiling Linux to Windows here which is why you see /tmp in the path :) But same things occur building on Windows.)

Metadata

Metadata

Labels

A-reproducibilityArea: Reproducible / deterministic buildsC-bugCategory: This is a bug.O-windows-msvcToolchain: MSVC, Operating system: Windows

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions