Repository navigation
Nondeterminism encountered in metadata for doc_link_resolutions #124357
Description
Activity
- addedneeds-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triagingThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
on Apr 25, 2024 - addedA-metadataArea: Crate metadataArea: Crate metadataT-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.A-reproducibilityArea: Reproducible / deterministic buildsArea: Reproducible / deterministic builds
on Apr 25, 2024 cc @petrochenkov, who authored #94857. Can you think of any obvious places to check for sources of nondeterminism?
Our determinism checker suddenly went stably green after #122053 was merged.
https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/rust_toolchain.core.x64-determinism-build_only/b8749794715383439057/overviewOur determinism checker suddenly went stably green after #122053 was merged. https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/rust_toolchain.core.x64-determinism-build_only/b8749794715383439057/overview
It turns out there was another change in the Fuchsia source that landed in the same window between failing and passing runs that seems to have fixed the determinism issue (placing each rlib into its own exclusive directory in our build system). #122053 is not the critical change (false alarm).
Just to check are you making sure that different crates with the same crate name have different
-Cmetadataarguments passed in? And are you making sure that for all direct dependencies the rlib or rmeta path is explicitly passed in using--extern? If so there should be no non-determinism in resolving dependencies unlike what the comment onrust_one_rlib_per_dirsuggests.@bjorn3 We do all of those things, or at least attempt to. I can't tell what's going on, but I'd much rather be able to point to specific rlibs of transitive dependencies than rely on a selection algorithm that can change based on the state of my build directory (whether the build is buggy or not).
Reacted by David FangSince it looks like the nondeterminism was related to changes in inputs, I'm going to close this issue.
but I'd much rather be able to point to specific rlibs of transitive dependencies than rely on a selection algorithm that can change based on the state of my build directory
It shouldn't change no matter what the state of the build directory is. We record a crate hash for each dependency and only load transitive dependencies matching this crate hash. Each unique rlib should get a unique crate hash no matter how small the change is. If that is not the case, there is a bug somewhere in rustc. If you were building two crates with the same crate name and
-Cmetadatait is possible that temporary artifacts get mixed up between them, but as you are passing unique-Cmetadataarguments, that shouldn't happen.- removedneeds-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triagingThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
on Apr 27, 2024 It's possible the metadata keys aren't as unique as we thought. In any case it will be difficult to reproduce the issue outside of our build, and it's unlikely we will continue to investigate if we aren't seeing more determinism failures.
IMO the compiler forcing the use of search directories hinders debugging and reproducibility. I'd much rather point it to individual files and rely on such hashing mechanisms as a backup / error detection only.
Fuchsia has a test that checks whether rustc output is deterministic, and we find that it fairly reliably reorders bits of the metadata output for
doc_link_resolutionsfor one particular crate in our build.I determined this by picking out some changes of d5bd169 to add
RUSTC_FILE_ENCODER_PANIC_AT_OFFSETand examining the backtrace at an offset that differs in one failure in the hexdump below. I also grepped for the strings that appear in all of the differences.[`std::ops::Deref`].Lines are from compiler commit 7f2fc33. Source code of the crate is available here.
Full backtrace
In the following diff, the first version (red) is more common.