Open ehuss opened 4 years ago
Yes this is definitely the right approach long term. Banish the sysroot!
I would personally consider this a blocker for stabilization in one form or another. It should be easy enough and is basically a form of hygiene, but I just ran into some really weird errors locally which ended up being caused because rustc was still using its original sysroot to load the proc_macro
, which transitively loaded two versions of std
. The bug was in Cargo/on my end for not building proc_macro
, but if we either cleared out the sysroot or passed it an empty one then I would've gotten a proper error for "the proc_macro
crate can't be found".
One thing I just thought of thinking about this again, if we turn off --sysroot
then rustc would lose implicit access to the bundled rust-lld
linker which I believe a number of custom targets rely on (and wasm surely does too). We may not actually be able to remove the --sysroot
in that case?
Reopen due to https://github.com/rust-lang/cargo/pull/7699.
The current implementation uses
--extern
flags to tellrustc
where the standard library dependencies are located. This runs into a few problems when a user attempts to useextern crate
for a crate that was not included. For example, ano_std
crate that hasextern std
, or anextern crate test
when libtest is not built. These will attempt to load from the default sysroot which causes a huge number of inscrutable errors.It may be nice to tell
rustc
to not look in the pre-built sysroot to avoid this problem (and will result in a nicer "crate not found" error). This can be done with--sysroot=nonexistent
or an empty directory. Alternatively, we can add a new flag torustc
to disable the sysroot search.This may have complications, since the sysroot is used for more than rlib dependencies. For example, it is also used for bundled things (like linkers? bundled crt objects?).
Beware this may affect things like clippy-driver, rustdoc, etc.