Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Occasional non-reproducibility when building rustc #69352

Open
jgalenson opened this issue Feb 21, 2020 · 10 comments
Open

Occasional non-reproducibility when building rustc #69352

jgalenson opened this issue Feb 21, 2020 · 10 comments
Labels
A-reproducibility Area: Reproducible / deterministic builds C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jgalenson
Copy link

Over the past few days I have occasionally seen my builds of rustc be non-reproducible. The differences most often seem to be in stage 1's libparking_log, librustc_parse, or librustc_driver.

A git bisect suggests that this was caused by 138c50f, although due to the fact that this issue is itself difficult to reproduce this could potentially be incorrect. But after many builds with and without that patch, I have only seen the error with it. Assuming that is correct, I believe this issue might well be due to non-determinism in LLVM's -O3, but I'm not sure how to run just the LLVM portion on the compile so I'm not sure.

Note that this is a part of #34902.

@jgalenson jgalenson added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 21, 2020
@Aaron1011

This comment has been minimized.

@Centril Centril removed the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 21, 2020
@Mark-Simulacrum Mark-Simulacrum added A-reproducibility Area: Reproducible / deterministic builds I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Feb 21, 2020
@Mark-Simulacrum
Copy link
Member

It seems plausible that bumping the optimization level would cause instability in llvm, cc @eddyb

@eddyb
Copy link
Member

eddyb commented Feb 21, 2020

cc @nagisa @nikic @hanna-kruppe Is there any easy way to diagnose this sort of thing, short of getting -C llvm-args=-print-after-all dumps for one of the affected crates and diffing them?

@Mark-Simulacrum If we do have to do this the hard way, maybe exposing cargo rustc via ./x.py rustc would be a good idea? It also would've come in handy when debugging bugs while compiling stage1 libcore (being able to add flags easily just to one crate's rustc's invocation).

@eddyb
Copy link
Member

eddyb commented Feb 21, 2020

@jgalenson I forget if/how we expose this, but if you can change codegen-units to 1, can you still reproduce? I think you'd need that for -print-after-all (otherwise you'd get threads stomping on eachother), but also it might tell us what role ThinLTO plays in this.

@jgalenson
Copy link
Author

@eddyb Doesn't codegen-units default to 1? I did not change anything for it in config.toml.

@nikic
Copy link
Contributor

nikic commented Feb 21, 2020

@eddyb You can use -Z no-parallel-llvm to avoid interleaving without touching optimization settings, it's not necessary to disable codegen units.

I don't have a great suggestion on how to debug this beyond diffing the transform log.

There is some open non-determinism in LVI (will usually manifest in jump threading), though no idea if that is hit or something else.

@Mark-Simulacrum
Copy link
Member

If we do have to do this the hard way, maybe exposing cargo rustc via ./x.py rustc would be a good idea? It also would've come in handy when debugging bugs while compiling stage1 libcore (being able to add flags easily just to one crate's rustc's invocation).

This wold be pretty painful to do today I suspect do to how rustbuild works internally, and I haven't had the energy to try and investigate changes there for the past couple months.

@eddyb
Copy link
Member

eddyb commented Feb 24, 2020

@Mark-Simulacrum How so, can't we "just" turn one of the cargo build commands into a cargo rustc command?

@Mark-Simulacrum
Copy link
Member

Hm, perhaps. Though I'm not sure :) Certainly one would likely expect some way to get the arguments passed in a stage-specific way... I would need to look into it, and I don't have the bandwidth or energy right now unfortunately.

@eddyb
Copy link
Member

eddyb commented Feb 24, 2020

Certainly one would likely expect some way to get the arguments passed in a stage-specific way...

I mean, everything would still be go through the src/bootstrap/bin/rustc.rs wrapper (i.e. we wouldn't change anything below invoking Cargo), we'd just have a way to pass extra arguments and building one specific crate.

For now it's probably easier to locally change src/bootstrap/bin/rustc.rs to check for a specific --crate-name argument and add the right LLVM args.

jgalenson added a commit to jgalenson/reproducible-rustc that referenced this issue Apr 24, 2020
We unfortunately have to add a patch to fix
rust-lang/rust#69352.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-reproducibility Area: Reproducible / deterministic builds C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants