-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
OSX compilation with debuginfo isn't deterministic #47086
Copy link
Copy link
Closed
Labels
A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)Area: Debugging information in compiled programs (DWARF, PDB, etc.)A-reproducibilityArea: Reproducible / deterministic buildsArea: Reproducible / deterministic buildsC-bugCategory: This is a bug.Category: This is a bug.O-macosOperating system: macOSOperating system: macOST-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)Area: Debugging information in compiled programs (DWARF, PDB, etc.)A-reproducibilityArea: Reproducible / deterministic buildsArea: Reproducible / deterministic buildsC-bugCategory: This is a bug.Category: This is a bug.O-macosOperating system: macOSOperating system: macOST-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
This is an issue extracted from #47066 (comment) which is caused by an issue that any OSX compilation with debuginfo ends up being nondeterministic. Specifically (currently known at least) the source of nondeterminism is that an mtime for an object file winds up in the final binary.
It turns out this isn't really our fault (unfortunately that makes it harder to fix!). This can be reproduced with just C and a linker:
Here we're using the exact same object file (with two timestamps) and we're seeing different linked artifacts.
This is a source of bugs in programs that expect rustc to be deterministic (aka #47066 as was originally stated) and is something that we as rustc should probably fix.
Unfortunately I don't really know of a fix for this myself. I'd be tempted to take a big hammer to the problem and deterministically set all mtime fields for objects going into the linker to a known fixed value, but that unfortunately doesn't fix the determinism for C code (whose objects we don't control) and also is probably too big of a hammer (if a build system uses the mtime of the object to control rebuilds it'd get mixed up).
We could also use something like
goblinand reach in to the specific field and remove the actual data. I found it in a symbol section with theN_OSOtype (described in various documents online too apparently). We may be able to postprocess all output artifacts on OSX to maybe just zero out these fields unconditionally (or set them to something like May 15, 2015), although I'm not actually sure if this would be easy to do.