Skip to content
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

Fix LLVM rebuild with download-ci-llvm. #98513

Merged
merged 1 commit into from
Jun 26, 2022

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Jun 25, 2022

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 uses rerun-if-changed of llvm-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. Since src/version is included in the LLVM .so filename, rustc attempts to load the wrong shared library since the rustc_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:

  1. On a linux host, enable download-ci-llvm
  2. Check out 7036449 (the commit just before the last version bump)
  3. ./x.py build library/std
  4. Check out 5f015a2 (the commit that bumped the version)
  5. ./x.py build library/std

Fixes #98495

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 25, 2022
@Mark-Simulacrum
Copy link
Member

@bors r+ rollup

Thanks for the investigation -- I agree this is a partial, but OK fix for now.

@bors
Copy link
Contributor

bors commented Jun 26, 2022

📌 Commit 418b1fa has been approved by Mark-Simulacrum

@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 Jun 26, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 26, 2022
Rollup of 8 pull requests

Successful merges:

 - rust-lang#98371 (Fix printing `impl trait` under binders)
 - rust-lang#98385 (Work around llvm 12's memory ordering restrictions.)
 - rust-lang#98474 (x.py: Support systems with only `python3` not `python`)
 - rust-lang#98488 (Bump RLS to latest master on rust-lang/rls)
 - rust-lang#98491 (Fix backtrace UI test when panic=abort is used)
 - rust-lang#98502 (Fix source sidebar hover in ayu theme)
 - rust-lang#98509 (diagnostics: consider parameter count when suggesting smart pointers)
 - rust-lang#98513 (Fix LLVM rebuild with download-ci-llvm.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit fba8dfd into rust-lang:master Jun 26, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jun 26, 2022
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Linker error when building rustc after LLVM version change
5 participants