Closed
Description
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?