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

Rustc_metadata cann't correctly find std crate if the linked binary launched not from /usr/bin #57196

Closed
o01eg opened this issue Dec 29, 2018 · 1 comment
Labels
A-metadata Area: Crate metadata

Comments

@o01eg
Copy link
Contributor

o01eg commented Dec 29, 2018

Same as #57014 issue happened with crate search:
If I launch /usr/bin/clippy-driver without setting sysroot it get correct default /usr

DEBUG 2018-12-29T08:16:26Z: rustc_metadata::creader: resolving extern crate stmt. ident: std orig_name: None
 INFO 2018-12-29T08:16:26Z: rustc_metadata::creader: resolving crate `extern crate std as std`
 INFO 2018-12-29T08:16:26Z: rustc_metadata::creader: falling back to a load
DEBUG 2018-12-29T08:16:26Z: rustc::session::filesearch: using sysroot = /usr, triple = x86_64-unknown-linux-gnu
DEBUG 2018-12-29T08:16:26Z: rustc::session::filesearch: searching /usr/lib64/rust-9999/rustlib/x86_64-unknown-linux-gnu/lib

If I launch /tmp/rust-clippy/target/release/clippy-driver built from sources I get incorrect sysroot:

DEBUG 2018-12-29T08:18:41Z: rustc_metadata::creader: resolving extern crate stmt. ident: std orig_name: None
 INFO 2018-12-29T08:18:41Z: rustc_metadata::creader: resolving crate `extern crate std as std`
 INFO 2018-12-29T08:18:41Z: rustc_metadata::creader: falling back to a load
DEBUG 2018-12-29T08:18:41Z: rustc::session::filesearch: using sysroot = /tmp/rust-clippy/target, triple = x86_64-unknown-linux-gnu
DEBUG 2018-12-29T08:18:41Z: rustc::session::filesearch: searching /tmp/rust-clippy/target/lib64/rust-9999/rustlib/x86_64-unknown-linux-gnu/lib
DEBUG 2018-12-29T08:18:41Z: rustc::session::filesearch: using sysroot = /tmp/rust-clippy/target, triple = x86_64-unknown-linux-gnu
DEBUG 2018-12-29T08:18:41Z: rustc::session::filesearch: searching /tmp/rust-clippy/target/lib64/rust-9999/rustlib/x86_64-unknown-linux-gnu/lib

Currently clippy solves it with launching rustc from PATH: https://github.com/rust-lang/rust-clippy/blob/980bcd8c537aaa7b157aae4f05f8edca9905e331/src/driver.rs#L52

                    Command::new("rustc")
                        .arg("--print")
                        .arg("sysroot")
                        .output()
                        .ok()
                        .and_then(|out| String::from_utf8(out.stdout).ok())
                        .map(|s| s.trim().to_owned())

As crates are placed within libdir shouldn't introduce filesearch::get_or_default_libdir based on rustc_driver*.so location instead of using filesearch::get_or_default_sysroot based on binary location?

@o01eg o01eg changed the title Rustc_driver cann't correctly find std crate if the linked binary launched not from /usr/bin Rustc_metadata cann't correctly find std crate if the linked binary launched not from /usr/bin Dec 29, 2018
@Centril Centril added the A-metadata Area: Crate metadata label Dec 29, 2018
@bjorn3
Copy link
Member

bjorn3 commented May 16, 2023

Should be fixed by #103660.

@bjorn3 bjorn3 closed this as completed May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-metadata Area: Crate metadata
Projects
None yet
Development

No branches or pull requests

3 participants