Fix LLVM rebuild with download-ci-llvm. #98513
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes an issue where updating a local checkout that includes a change in
src/version
causes a linking failure.The cause is that the
rustc_llvm
build script usesrerun-if-changed
ofllvm-config
to know if it needs to rerun. Cargo only compares the timestamp of the last time the build script to the file. However, extracting the tar files retains the timestamps in the tarball which may be some time in the past. Sincesrc/version
is included in the LLVM.so
filename,rustc
attempts to load the wrong shared library since therustc_llvm
build script doesn't rerun.rust-lang/cargo#10791 contains a more detailed explanation.
The solution here is a hack which updates the timestamp of
llvm-config
to the current time when it is extracted.This is a bit of a hack, but seems to be the best solution I can think of until rust-lang/cargo#10791 is fixed. There are likely several other situations where this is a problem (such as using system LLVM), and this isn't really a complete fix.
Note that apple platforms are not directly affected by this problem because they don't have a version in the dylib filename.
How to test this:
./x.py build library/std
./x.py build library/std
Fixes #98495