-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
macos: linking errors with split-debuginfo and switching toolchains #9353
Comments
This looks like an odd interaction with incremental, if you set I agree though that the fix here is to probably ensure that |
This has me worried that there might be a bigger underlying problem, but I don't see how it is possible. My understanding of the incremental cache is that it validates the rust version and if it doesn't match, it deletes the incremental cache. Any ideas how stale cache data could infect the new build? |
Oh I was just assuming that was the case since I think object files are stored separately than other metadata in the cache and so it may bypass other forms of version-checking logic? (I'm not sure if a version check mismatch invalidates just one piece of data or the entire incremental directory that was specified) |
Oh, I think I see what is happening! The
all end up being the same inode. Running the second command ends up overwriting the contents of another incremental directory, and then running the third command doesn't know its cache got modified. |
Oh interesting! I suppose this is a case where rustc is not removing a file before opening it for writing? |
I'm confused why those files would be hardlinked. I don't think we should be sharing object files between different versions of Rust; a build with |
To clarify, the sequence is:
I haven't finished my investigation on reworking the hash behavior. I think using the correct |
I am getting linking errors when switching between different toolchains on macos using split-debuginfo.
Reproduction
Create a new binary cargo project
foo
and add the following toCargo.toml
:Run in this order:
cargo +stable build
cargo +nightly build
cargo +stable build
Where
stable
is 1.51 andnightly
is 1.53. This will also happen with the inverse order (nighty/stable/nightly) or using beta 1.52. The last steps results in the error:I expected the 3rd build to rebuild from scratch and replace the output binary with success.
One curious thing I noticed is that the different toolchains produce mostly different
.o
filenames, but two of the filenames are the same.foo.4pil1rvk4hlgrvxn.o
is one of those files. I am a bit confused, as I would assumerustc
would have completely replaced any overlapping files, so I'm uncertain how conflicting filenames could be a problem here. I could imagine other scenarios involving rlibs where this would be a problem, but not with just a single binary.Out of curiosity, I collected the unmangled names and here is the comparison:
foo.core.alx3lauo-in-foo.7k7dwitq-fmt.rcgu.o
foo.core.3y4jtb65-in-foo.7k7dwitq-fmt.rcgu.o
foo.core.alx3lauo-in-foo.7k7dwitq-hint.volatile.rcgu.o
foo.core.3y4jtb65-in-foo.7k7dwitq-hint.volatile.rcgu.o
foo.foo.7k7dwitq.rcgu.o
foo.foo.7k7dwitq.rcgu.o
foo.foo.7k7dwitq-fallback.cgu.rcgu.o
foo.foo.7k7dwitq-fallback.cgu.rcgu.o
foo.std.83sbzbw6-in-foo.7k7dwitq-process.rcgu.o
foo.std.76rm7o7m-in-foo.7k7dwitq-process.rcgu.o
foo.std.83sbzbw6-in-foo.7k7dwitq-rt.volatile.rcgu.o
foo.std.76rm7o7m-in-foo.7k7dwitq-rt.volatile.rcgu.o
foo.std.83sbzbw6-in-foo.7k7dwitq-sys-unix-process-process_common.rcgu.o
foo.std.76rm7o7m-in-foo.7k7dwitq-sys-unix-process-process_common.rcgu.o
foo.std.83sbzbw6-in-foo.7k7dwitq-sys_common-backtrace.volatile.rcgu.o
foo.std.76rm7o7m-in-foo.7k7dwitq-sys_common-backtrace.volatile.rcgu.o
foo.foo.7k7dwitq-crate.allocator.rcgu.o
foo.foo.7k7dwitq-crate.allocator.rcgu.o
I think the underlying problem is that the
-C metadata
flag is the same across toolchains for binaries on macos. This causes the crate disambiguator to be the same, causing the cgu hash to be the same. This is exposed here. I think the solution will be to include the rustc version in thetarget_short_hash
, though I don't remember if that needs to be stable across versions.There are a few other scenarios where Cargo reuses metadata hashes (described here) that will need to be investigated if they also suffer from this issue.
I'm still a bit confused why rustc doesn't just overwrite the files.
The text was updated successfully, but these errors were encountered: