Skip to content

Address libunwind.a inconsistency issues in the bootstrap program #144473

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zeroomega
Copy link

@zeroomega zeroomega commented Jul 25, 2025

We noticed when building rustc multiple time in a roll, some files will not be consistent across the build despite the fact that they are built from same source under the same environment. This patch addresses the inconsistency issue we found on libunwind.a, by sorting the order of the files passed to the linker.

@rustbot
Copy link
Collaborator

rustbot commented Jul 25, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jul 25, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 25, 2025

This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp.

@rust-log-analyzer

This comment has been minimized.

let source_date_epoch_env = "SOURCE_DATE_EPOCH";
if let Ok(var) = std::env::var(&source_date_epoch_env) {
cargo.env(&source_date_epoch_env, &var);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we clearing the environment somewhere? I'd expect that passing through an env variable unchanged is the default?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure. But with out this passthrough, the SOURCE_DATE_EPOCH didn't appear in env arg list when building cargo when running SOURCE_DATE_EPOCH=timestamp python3 x.py install

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a rebuild and removed the "SOURCE_DATE_EPOCH" pass through code I have. The build command is SOURCE_DATE_EPOCH=1735689600 python3 x.py install --config config4.toml --verbose 2>&1 |tee build4.log I. So the bootstrap program didn't copy its env args to the cargo. See the verbose log:

Building tool cargo (stage1 -> stage2, x86_64-unknown-linux-gnu)
running: cd "/mnt/nvme_crypt/SRC/rust" && env -u MAKEFLAGS -u MFLAGS AR_x86_64_unknown_linux_gnu="/mnt/nvme_crypt/SRC/TQ/prebuilt/third_party/clang/linux-x64/bin/llvm-ar" CARGO_INCREMENTAL="0" CARGO_LOG="cargo::core::compiler::fingerprint=info" CARGO_PROFILE_RELEASE_CODEGEN_UNITS="1" CARGO_PROFILE_RELEASE_DEBUG="0" CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS="false" CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS="false" CARGO_PROFILE_RELEASE_STRIP="false" CARGO_TARGET_DIR="/mnt/nvme_crypt/SRC/rust/build4/x86_64-unknown-linux-gnu/stage1-tools" CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER="/mnt/nvme_crypt/SRC/TQ/prebuilt/third_party/clang/linux-x64/bin/clang++" CC_x86_64_unknown_linux_gnu="/mnt/nvme_crypt/SRC/TQ/prebuilt/third_party/clang/linux-x64/bin/clang" CFG_COMMIT_DATE="2025-07-09" CFG_COMMIT_HASH="eabb4cd923deb73e714f7ad3f5234d68ca284dbe" CFG_COMPILER_BUILD_TRIPLE="x86_64-unknown-linux-gnu" CFG_COMPILER_HOST_TRIPLE="x86_64-unknown-linux-gnu" CFG_RELEASE="1.90.0-nightly" CFG_RELEASE_CHANNEL="nightly" CFG_RELEASE_NUM="1.90.0" CFG_SHORT_COMMIT_HASH="eabb4cd92" CFG_VERSION="1.90.0-nightly (1c6de2150 2025-07-16)" CFG_VER_DATE="2025-07-16" CFG_VER_HASH="1c6de215099bbe33668de762f9591187f6c25eef" CFLAGS_x86_64_unknown_linux_gnu="" CXXFLAGS_x86_64_unknown_linux_gnu="" CXX_x86_64_unknown_linux_gnu="/mnt/nvme_crypt/SRC/TQ/prebuilt/third_party/clang/linux-x64/bin/clang++" DOC_RUST_LANG_ORG_CHANNEL="https://doc.rust-lang.org/nightly" LIBC_CHECK_CFG="1" LIBZ_SYS_STATIC="1" LZMA_API_STATIC="1" RANLIB_x86_64_unknown_linux_gnu="/mnt/nvme_crypt/SRC/TQ/prebuilt/third_party/clang/linux-x64/bin/llvm-ar s" REAL_LIBRARY_PATH_VAR="LD_LIBRARY_PATH" RUSTBUILD_NATIVE_DIR="/mnt/nvme_crypt/SRC/rust/build4/x86_64-unknown-linux-gnu/native" RUSTC="/mnt/nvme_crypt/SRC/rust/build4/bootstrap/debug/rustc" RUSTC_BOOTSTRAP="1" RUSTC_BREAK_ON_ICE="1" RUSTC_ERROR_METADATA_DST="/mnt/nvme_crypt/SRC/rust/build4/tmp/extended-error-metadata" RUSTC_HOST_FLAGS="--check-cfg=cfg(bootstrap) -Clinker=/mnt/nvme_crypt/SRC/TQ/prebuilt/third_party/clang/linux-x64/bin/clang++" RUSTC_INSTALL_BINDIR="bin" RUSTC_LIBDIR="/mnt/nvme_crypt/SRC/rust/build4/x86_64-unknown-linux-gnu/stage1/lib" RUSTC_LINK_STD_INTO_RUSTC_DRIVER="1" RUSTC_LINT_FLAGS="" RUSTC_REAL="/mnt/nvme_crypt/SRC/rust/build4/x86_64-unknown-linux-gnu/stage1/bin/rustc" RUSTC_SNAPSHOT="/mnt/nvme_crypt/SRC/rust/build4/x86_64-unknown-linux-gnu/stage1/bin/rustc" RUSTC_SNAPSHOT_LIBDIR="/mnt/nvme_crypt/SRC/rust/build4/x86_64-unknown-linux-gnu/stage1/lib" RUSTC_STAGE="1" RUSTC_SYSROOT="/mnt/nvme_crypt/SRC/rust/build4/x86_64-unknown-linux-gnu/stage1" RUSTC_TLS_MODEL_INITIAL_EXEC="1" RUSTC_VERBOSE="1" RUSTC_WRAPPER="/mnt/nvme_crypt/SRC/rust/build4/bootstrap/debug/rustc" RUSTDOC="/mnt/nvme_crypt/SRC/rust/build4/bootstrap/debug/rustdoc" RUSTDOCFLAGS="--cfg=windows_raw_dylib -Csymbol-mangling-version=v0 -Zunstable-options --check-cfg=cfg(bootstrap) --check-cfg=cfg(llvm_enzyme) --check-cfg=cfg(rust_analyzer) --crate-version 1.90.0-nightly\t(1c6de2150\t2025-07-16) -Clinker=/mnt/nvme_crypt/SRC/TQ/prebuilt/third_party/clang/linux-x64/bin/clang++" RUSTDOC_REAL="/path/to/nowhere/rustdoc/not/required" RUSTFLAGS="--cfg=windows_raw_dylib -Csymbol-mangling-version=v0 -Zunstable-options --check-cfg=cfg(bootstrap) --check-cfg=cfg(llvm_enzyme) --check-cfg=cfg(rust_analyzer) -Zmacro-backtrace -Csplit-debuginfo=off -Clink-arg=-L/mnt/nvme_crypt/SRC/rust/build4/x86_64-unknown-linux-gnu/llvm/lib\n -Clink-args=-Wl,-z,origin -Clink-args=-Wl,-rpath,$ORIGIN/../lib -Alinker-messages -Zunstable-options" RUST_TEST_THREADS="128" SYSROOT="/mnt/nvme_crypt/SRC/rust/build4/x86_64-unknown-linux-gnu/stage1" __CARGO_DEFAULT_LIB_METADATA="nightlytool-rustc1.90.0" "/mnt/nvme_crypt/SRC/rust/build4/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "128" "-Zroot-dir=/mnt/nvme_crypt/SRC/rust" "-v" "--release" "--manifest-path" "/mnt/nvme_crypt/SRC/rust/src/tools/cargo/Cargo.toml" "--features" "all-static" "--message-format" "json-render-diagnostics" (failure_mode=Exit)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a closer look. The cargo process to build cargo did inherited the SOURCE_DATE_EPOCH variable. It is the debug output didn't print it because it is not explicitly passed to the child process. Maybe worth improve the debug output to include the env args the child process inherited implicitly. It would make the debugging easier.
Anyway, I removed the environment variable handling in the latest patch set. Please take a look.

@zeroomega zeroomega force-pushed the rustc_inconsistency branch from 2285c8c to 7515619 Compare July 29, 2025 21:55
@rustbot
Copy link
Collaborator

rustbot commented Jul 29, 2025

Some changes occurred in src/tools/cargo

cc @ehuss

@rustbot

This comment has been minimized.

@zeroomega zeroomega force-pushed the rustc_inconsistency branch from 7515619 to 52bbc67 Compare July 29, 2025 22:01
@rust-log-analyzer

This comment has been minimized.

@zeroomega zeroomega force-pushed the rustc_inconsistency branch from 52bbc67 to 0792f7d Compare July 29, 2025 22:40
We noticed when building rustc multiple time in a roll, some files
will not be consistent across the build despite the fact that they
are built from same source under the same environment. This patch
addresses the inconsistency issue we found on libunwind.a by sorting
the order of the files passed to the linker.
@zeroomega zeroomega force-pushed the rustc_inconsistency branch from 0792f7d to b3f369d Compare July 30, 2025 21:28
@zeroomega
Copy link
Author

@rustbot ready

@Mark-Simulacrum
Copy link
Member

Can you fix the PR description + title to reflect the current state of the PR? Those both get persisted into the commit history so good for them to be accurate.

r=me with that done.

@zeroomega zeroomega changed the title Address some rustc inconsistency issues Address libunwind.a inconsistency issues in the bootstrap program Aug 4, 2025
@zeroomega
Copy link
Author

Done.
r=Mark-Simulacrum

@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 4, 2025

📌 Commit b3f369d has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 4, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 5, 2025
…ark-Simulacrum

Address libunwind.a inconsistency issues in the bootstrap program

We noticed when building rustc multiple time in a roll, some files will not be consistent across the build despite the fact that they are built from same source under the same environment. This patch addresses the inconsistency issue we found on libunwind.a, by sorting the order of the files passed to the linker.
bors added a commit that referenced this pull request Aug 5, 2025
Rollup of 16 pull requests

Successful merges:

 - #143857 (Port #[macro_export] to the new attribute parsing infrastructure)
 - #144133 (Stabilize const TypeId::of)
 - #144369 (Upgrade semicolon_in_expressions_from_macros from warn to deny)
 - #144443 (Make target pointer width in target json an integer)
 - #144473 (Address libunwind.a inconsistency issues in the bootstrap program)
 - #144659 (bootstrap: refactor mingw dist and fix gnullvm)
 - #144682 (Stabilize `strict_overflow_ops`)
 - #144794 (Port `#[coroutine]` to the new attribute system)
 - #144835 (Anonymize binders in tail call sig)
 - #144836 (Change visibility of Args new function)
 - #144900 (Stabilize `unsigned_signed_diff` feature)
 - #144903 (Rename `begin_panic_handler` to `panic_handler`)
 - #144910 (Add regression tests for seemingly fixed issues)
 - #144926 (Correct the use of `must_use` on btree::IterMut)
 - #144928 (Drop `rust-version` from `rustc_thread_pool`)
 - #144931 ([win][arm64ec] Fix msvc-wholearchive for Arm64EC)

Failed merges:

 - #144914 (Add support for `ty::Instance` path shortening in diagnostics)

r? `@ghost`
`@rustbot` modify labels: rollup
Kobzol added a commit to Kobzol/rust that referenced this pull request Aug 5, 2025
…ark-Simulacrum

Address libunwind.a inconsistency issues in the bootstrap program

We noticed when building rustc multiple time in a roll, some files will not be consistent across the build despite the fact that they are built from same source under the same environment. This patch addresses the inconsistency issue we found on libunwind.a, by sorting the order of the files passed to the linker.
bors added a commit that referenced this pull request Aug 5, 2025
Rollup of 15 pull requests

Successful merges:

 - #143857 (Port #[macro_export] to the new attribute parsing infrastructure)
 - #144133 (Stabilize const TypeId::of)
 - #144369 (Upgrade semicolon_in_expressions_from_macros from warn to deny)
 - #144473 (Address libunwind.a inconsistency issues in the bootstrap program)
 - #144659 (bootstrap: refactor mingw dist and fix gnullvm)
 - #144682 (Stabilize `strict_overflow_ops`)
 - #144794 (Port `#[coroutine]` to the new attribute system)
 - #144835 (Anonymize binders in tail call sig)
 - #144836 (Change visibility of Args new function)
 - #144900 (Stabilize `unsigned_signed_diff` feature)
 - #144903 (Rename `begin_panic_handler` to `panic_handler`)
 - #144910 (Add regression tests for seemingly fixed issues)
 - #144926 (Correct the use of `must_use` on btree::IterMut)
 - #144928 (Drop `rust-version` from `rustc_thread_pool`)
 - #144931 ([win][arm64ec] Fix msvc-wholearchive for Arm64EC)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants