-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-reproducibilityArea: Reproducible / deterministic buildsArea: Reproducible / deterministic buildsC-bugCategory: This is a bug.Category: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Description
Summary
When building a particular crate normally, the generated bitcode is nondeterministic, but when using a bootstrapped rustc it is not.
Command used
##############################
# Demonstrate nondeterminism #
##############################
git clone https://github.com/apache/datafusion.git --depth 1 -b 36.0.0
cd datafusion
cargo update -p chrono --precise 0.4.39
cargo build --release -p datafusion-expr
cp target/release/libdatafusion_expr.rlib 1.rlib
cp 1.rlib 2.rlib
# Will terminate when it detects nondeterminism, usually within 10 iterations
i=0
while diff -q 1.rlib 2.rlib; do
((i++))
rm -rf target/release/deps/libdatafusion_* target/release/libdatafusion_expr.*
cargo build --release -p datafusion-expr
cp target/release/libdatafusion_expr.rlib 2.rlib
done
echo after $i iterations
#########################################################################
# Building from source solves the nondeterminism, even with no patches! #
#########################################################################
git clone https://github.com/rust-lang/rust --depth 1 -b 1.88.0 ../rust
cd ../rust
./x build library # using --set llvm.download-ci-llvm=false gives the same result
cd ../datafusion
export RUSTC=../rust/build/host/stage1/bin/rustc
cargo build --release -p datafusion-expr
cp target/release/libdatafusion_expr.rlib 1.rlib
cp 1.rlib 2.rlib
# Will run forever since the outputs are now deterministic
i=0
while diff -q 1.rlib 2.rlib; do
((i++))
rm -rf target/release/deps/libdatafusion_* target/release/libdatafusion_expr.*
cargo build --release -p datafusion-expr
cp target/release/libdatafusion_expr.rlib 2.rlib
done
echo after $i iterations
Expected behaviour
There may be two separate bugs here.
- The generated bitcode should be deterministic
- The bootstrapped rustc should behave the same as the released version
Actual behaviour
The released compiler generates nondeterministic bitcode, but switching to the bootstrapped compiler makes it deterministic.
Bootstrap configuration (bootstrap.toml)
Default
Operating system
Ubuntu 20.04
HEAD
Additional context
I originally thought the nondeterminism was due to a bug in LLVM. The details of what exactly is nondeterministic can be found at llvm/llvm-project#151006.
Metadata
Metadata
Assignees
Labels
A-reproducibilityArea: Reproducible / deterministic buildsArea: Reproducible / deterministic buildsC-bugCategory: This is a bug.Category: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.