Fix Rust build caching by using absolute paths #45
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.
We've had Lighthouse users on Discord reporting linking errors related to
blst
for a while, which would always be solved bycargo clean
and a rebuild (suggesting a build caching issue). Today it happened to me and I decided to investigate.I found that the build script's use of
../..
was causing the C compiler to reach out of the sandbox (OUT_DIR
) given to it by Cargo, and into a path shared by all Cargo packages that shouldn't be modified from a build script. One of the compiler invocations it was making was:Note the
../..
in the-o
argument that causes files to be written totarget/release/build/src/server.o
. If there are multiple versions ofblst
in the build cache (due to updates, etc), then they share these files, and I think that must confuse Cargo (unfortunately I can't describe an exact mechanism of action here). The Cargo docs have this to say:In an attempt to fix it, I've switched to using absolute paths, and can confirm that the compiler invocations look more sensible now:
And
server.o
ends up inOUT_DIR
instead of its previous location. I hope this is the only build caching issue, and alleviates the problems our users have been facing 🤞