Uh oh!
There was an error while loading. Please reload this page.
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.
rust-highfive
commented
Oct 28, 2015
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. |
taralx
commented
Oct 28, 2015
P.S. If there's a way to cherry-pick this into stable, that would be really nice. |
retep998
commented
Oct 28, 2015
If we're not going to use the result of |
taralx
commented
Oct 28, 2015
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. |
eefriedman
commented
Oct 28, 2015
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? |
taralx
commented
Oct 28, 2015
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.