-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Include version number of libs being built in cargo lib metadata (esp. librustc_driver*.so
)
#137036
base: master
Are you sure you want to change the base?
Conversation
Previously, on a non-stable channel, it's possible for two builds from different versioned sources (e.g. 1.84.0 vs 1.84.1) to produce `librustc_driver*.so` with the same filename hashes. This causes problems with side-by-side installs wrt. linker search paths because 1.84.1 rustc bin and 1.84.0 may try to link to the "same" `librustc_driver*.so` (same filename hash) but fail because the contents of the so is actually different. We try to mitigate this by including the version number of artifacts being built via `__CARGO_DEFAULT_LIB_METADATA`.
this looks reasonable to me. The worst that could happen, other than just not working, is that cargo would rebuild more often than necessary, or link in multiple versions of the same crate with different hashes. i would only expect that to happen though if someone modifies src/version while bootstrap is running, which, why? so i don't think this is very risky. |
ideally we would pass the version number to cargo somehow. it's weird to try and manage cargo's metadata for it. but if that's hard this is fine as a workaround. (there's been an ongoing pattern where there's an impedance mismatch between what bootstrap is doing and what cargo is doing...sometimes I wish we had our own build system instead of just wrapping cargo.) |
Yes, that'll rebuild, but also, don't do that |
Yeah unfortunately I don't know of a way to somehow override the crate version number. |
librustc_driver*.so
)librustc_driver*.so
)
Applied the patch through portage, installed 1.84.0 again and rebuilt 1.84.1, all good on my end: demize@yveltal ~ $ /usr/bin/rustc-1.84.0 -vV
rustc 1.84.0-nightly (9fc6b4312 2025-01-07) (gentoo)
binary: rustc
commit-hash: 9fc6b43126469e3858e2fe86cafb4f0fd5068869
commit-date: 2025-01-07
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.7
demize@yveltal ~ $ /usr/bin/rustc-1.84.1 -vV
rustc 1.84.1-nightly (e71f9a9a9 2025-01-27) (gentoo)
binary: rustc
commit-hash: e71f9a9a98b0faf423844bf0ba7438f29dc27d58
commit-date: 2025-01-27
host: x86_64-unknown-linux-gnu
release: 1.84.1-nightly
LLVM version: 19.1.7
demize@yveltal ~ $ lddtree /usr/bin/rustc-1.84.{0,1}
rustc-1.84.0 => /usr/bin/rustc-1.84.0 (interpreter => /lib64/ld-linux-x86-64.so.2)
librustc_driver-ea0e1b0c5d10469b.so => not found
libc.so.6 => /usr/lib64/libc.so.6
ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
rustc-1.84.1 => /usr/bin/rustc-1.84.1 (interpreter => /lib64/ld-linux-x86-64.so.2)
librustc_driver-6f5156ee640647f4.so => not found
libc.so.6 => /usr/lib64/libc.so.6
ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 |
librustc_driver*.so
)librustc_driver*.so
)
// `rustc_driver`'s version number is always `0.0.0`, which can cause problems on | ||
// side-by-side installs because we don't include the version number of the `rustc_driver` | ||
// being built. This can cause non-stable channel builds producing artifacts that end up | ||
// with identical `librustc_driver*.so` filename hashes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW I'm not super happy with this comment, lmw if there's a better wording/explanation for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a problem regardless of the channel. it just happens to not trigger on stable because cargo uses different heuristics per-channel for what to include in the metadata hash.
Previously, on a non-stable channel, it's possible for two builds from different versioned sources (e.g. 1.84.0 vs 1.84.1) to produce a
librustc_driver*.so
with the same filename hashes. This causes problems with side-by-side installs wrt. linker search paths because 1.84.1 rustc bin and 1.84.0 rustc bin may try to link to the "same"librustc_driver*.so
(same filename hash) but fail because the contents of the so is actually different.We try to mitigate this by including the version number of artifacts being built via
__CARGO_DEFAULT_LIB_METADATA
(kind of an ugly hack, but I don't think cargo has a way for us to tell cargo to use a package version override).Fixes #136701 (mitigates, really).
Testing
Tested manually1 by:
and observing that changing
src/version
to bump a point release causeslibrustc_driver*.so
to have a different hash while sources are unmodified otherwise.cc @clan @demize could you check that if you backport this change against 1.84.{0,1} as reported in #136701, that the produced
rustc
binary works, under the context of the Gentoo build system setup?Footnotes
on a
x86_64-unknown-linux-gnu
host, no cross ↩