-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Do not resolve symlinks when finding crates. #29433
Conversation
The resolved path may not end in '.rlib', causing us to try to read the archive as an object file.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
P.S. If there's a way to cherry-pick this into stable, that would be really nice. |
If we're not going to use the result of |
I went with a minimal change, but I can certainly switch to "file exists" if that's what's preferred. Canonicalize saves lookups later, but can result in a completely different filename. In our case, the cloud builder creates symlinks of the form libcore-xyzzy.rlib -> /network/cas/$FILEHASH. Canonicalizing causes a "cannot find crate 'core'" error. The alternative is to not rely on the filename past this point, making sure to pass down rlib-ness (and possibly more) as a parameter. |
For reference, the behavior of resolving symlinks was added in #12474. I'm not sure if the original reason for adding that behavior is still relevant. @alexcrichton might have something to say about it? |
Apparently it does still matter. Okay, so I'll close this and rework it to not rely on the filename after canonicalization. |
Do not rely on file extensions after path canonicalization. Rustc does not recognize libraries which are symlinked to files having extension other than .rlib. The problem is that find_library_crate calls fs::canonicalize on found library paths, but then the resulting path is passed to get_metadata_section, which assumes it will end in ".rlib" if it's an rlib (from https://internals.rust-lang.org/t/is-library-path-canonicalization-worth-it/3206). cc #29433
The resolved path may not end in '.rlib', causing us to try to read the
archive as an object file.