-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
hash collision on /usr/lib/rust/lib-1.84.1/librustc_driver-???.so #136701
Comments
that hash is a -C metadata value calculated by cargo (based on a bunch of things, one of which is the version number). i would be extremely surprised to see a collision here. how did you install 1.84.0 and .1? are you sure they are actually different compilers? |
1.84.0:
1.84.1:
@clan I believe the gentoo build system has a bug. |
Yeah I was about to say, they're both searching under 1.84.0 dir which is sus, but then it's the same driver... |
yes, it turns out the reason is 'channel = "nightly"' in config.toml
updated: i mean non-unique but write unique, :( |
it seems version is cut if channel="nightly"? |
it's probably the first time to have 1.X.0 and 1.X.1 in gentoo, so have this bug. |
This comment has been minimized.
This comment has been minimized.
Gentoo is a source based distribution, user can control the feature themselves by the so called USE flag, that's why it took some time to find out the reason. |
@clan The last time I counseled someone about a bug they were having with Gentoo's build system, it became apparent Gentoo is doing some pretty... opinionated... things with how y'all are building our software. In other words, it seems to me the default way you are building our things is not what I would do if I was configuring rustc for a source-based distribution. I would not make it an option to build rustc with a different channel, I would simply make nightly rustc a separate package. |
It's possible that this might be a different issue. But without a repro that rules out the gentoo build system it's hard to say. |
From our view, only the date XOR the semver is truly relevant.
So the idea of "1.84.1 nightly" is not something we're going to plan around, and using our build system to produce such a beast will provide you with such "entertaining" results as you have seen. From the perspective of "someone who would like to be able to triage bug reports from Gentoo users", it is most preferable for us if all nightly versions are actual nightly versions, and all stable versions are actual stable versions. Stable versions can wind up with patches that a nightly version will never have, so their commit hashes would not be equal, and the dates would be mismatched. Of course, if there are additional patches on top, I would not object, but it would be best if they at least used the source tarball that matched that stable or nightly version. |
Oh, the gentoo build system based on https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-lang/rust/rust-1.84.0.ebuild#n373 seems to be setting a |
what the tux |
My current understanding is "nightly" have more features than stable (I don't know is it still true for released tarballs)? So we provide options to let user can try by their own choice. From the distribution's side, we'd like to find a solution to make this hash not unique in any case (try best). We've found "-C metadata" might be a option, but since I don't how this hash is calculated now, it may or may not be the best solution? |
...why do you want to make the hash not unique? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I'll take a look. @clan is there a smaller repro (maybe with the exact |
let me prepare a config.toml for 1.84.1
|
I'll see, but not very soon, build take long time, ... |
Try a minimal config against 1.84.1 sources like: profile = "dist"
change-id = 999999
[build]
build-stage = 1
test-stage = 1
extended = false
tools = []
[llvm]
download-ci-llvm = true
[rust]
channel = "nightly"
description = "meow"
codegen-backends = ["llvm"]
download-rustc = false
debug = false
debuginfo-level = 1 and just |
ok, i'll try this when free, thanks for the help |
I did a bit of investigation on where this hash comes from in the first place.
|
The two most recent nightlies having the same filename seems like a bug too (not that I think that it will cause issues in practice, but I think fixing that would also fix this). |
nightly-2025-02-06 has a different librustc_driver.so filename too. |
I expected this collision to be because I wish we had added a command to bootstrap for debugging the resolved value of each config, not just the ones that have been explicitly overridden. @onur-ozkan i think that would be useful in general, not just for this issue - maybe you are interested in adding it? The rustc_driver itself is being built with a different version number (this can be seen when you overrode the .so file with LD_LIBRARY_PATH). And you said you are building from a tarball, so you end up with a
I think that second bit of code is to blame, and I think it will be fixed by appending the version number to that |
yes ok, this happens because cargo hashes the version of rustc used during the build (see |
For the nightly channel it is intentional that |
I am slandering cargo. The real problem is the version number is always set to 0.0.0: https://github.com/rust-lang/rust/blob/1.84.1/compiler/rustc_driver/Cargo.toml#L3 We should be overriding that with the resolved version from
Yes, you're right. That happens here: https://github.com/rust-lang/cargo/blob/66221abdeca2002d318fde6efff516aab091df0e/src/cargo/core/compiler/build_runner/compilation_files.rs#L692-L711 That seems a little suspicious, but I think we are getting "lucky" that cargo is considering the version number of the build compiler; that only works because gentoo is using 1.84.0 to build 1.84.1; it wouldn't help us if they were building with 1.83.0 (which is explicitly supported). The right fix is not to use 0.0.0 for rustc_driver unconditionally. |
I thought this is overriden? rust/src/bootstrap/src/core/build_steps/compile.rs Lines 1149 to 1161 in d2f335d
|
No. Those env variables are only read by code in compiler/, not by cargo. |
Oh oops sorry yeah, I misread that 😅 |
Tracked separately in #136738. |
build success:
|
so can I confirm there is a bug for the hash calculation of librustc_driver-???.so which will cause same hash for build on different source? what are the workarounds to avoid this hash collision? thanks a lot. |
@clan a workaround would be to patch compiler/rustc_driver/Cargo.toml to use version = 1.84.1 (and .0, respectively) instead of 0.0.0. You will have to update that patch for each new release until this gets fixed upstream. (I have not tested that patch, if it doesn't work please let me know on this issue.) |
Like jyn said, probably (at least) two things need to be done to address your issue:
|
@jieyouxu omit-git-hash is unrelated. This happens any time you use a channel other than stable. |
Even if we "fix" the "bug", the reality is that we will never test anything like Gentoo's configuration, which allows you to put two incredibly patched nightly rustcs into the same PATH and just hope that works out, adequately. You simply cannot just jam two rustcs into /usr/bin and pray for success. That will bite you in the ass. |
Provisional update: gentoo's RPATH was not being set in the Lines 640 to 644 in 73bf794
This advisory seems... unfortunate, because in the absence of an ELF-configured RPATH, Gentoo has developed... alternate solutions for the problem that RPATH solves. These solutions seem like they could have been adequately replaced by simply using an Even if it does not work out in larger-scale testing, I suspect we should stop telling people their business: the default way we build uses a relative RPATH: |
Tested this on my machine, I can confirm this works. I'll follow up with @clan on bgo. |
https://bugs.gentoo.org/949374
We have users' report on unable to run rustc after build rust 1.84.0 and 1.84.1 (no report for earlier version), and it is high suspected the problem is on the collision on librustc_driver-???.so, two version (1.84.0 & 1.84.1) use the same filename (in different path), so rustc-1.84.1 will use librustc_driver in rust 1.84.0, then failed with error:
/usr/lib/rust/1.84.1/bin/rustc: symbol lookup error: /usr/lib/rust/1.84.1/bin/rustc: undefined symbol: _ZN3std2rt19lang_start_internal17h12de313c8fa04a78E
ldd confirm:
both rustc 1.84.0 & 1.84.1 use librustc_driver.so with the same name 'librustc_driver-6f6761e2f1b0d7ca.so'
My question is:
thanks.
The text was updated successfully, but these errors were encountered: