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

Possibly add a way to disable sysroot on rustc #31

Open
ehuss opened this issue Sep 6, 2019 · 5 comments · Fixed by rust-lang/cargo#7421
Open

Possibly add a way to disable sysroot on rustc #31

ehuss opened this issue Sep 6, 2019 · 5 comments · Fixed by rust-lang/cargo#7421
Labels
implementation Implementation exploration and tracking issues S-needs-design Status: needs design work stabilization blocker This needs a resolution before stabilization

Comments

@ehuss
Copy link
Contributor

ehuss commented Sep 6, 2019

The current implementation uses --extern flags to tell rustc where the standard library dependencies are located. This runs into a few problems when a user attempts to use extern crate for a crate that was not included. For example, a no_std crate that has extern std, or an extern 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 to rustc 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.

@ehuss ehuss added the implementation Implementation exploration and tracking issues label Sep 6, 2019
@Ericson2314
Copy link

Yes this is definitely the right approach long term. Banish the sysroot!

@alexcrichton
Copy link
Member

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".

@alexcrichton
Copy link
Member

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?

@alexcrichton
Copy link
Member

Fixed in rust-lang/cargo#7421

bors added a commit to rust-lang/cargo that referenced this issue Dec 12, 2019
Switch build-std to use --extern

Switch `build-std` to use `--extern` flags instead of `--sysroot`.

This is mostly a revert of #7421. It uses the new extern flag options introduced in rust-lang/rust#67074. It avoids modifying the extern prelude which was the source of the problem of rust-lang/wg-cargo-std-aware#40.

Closes rust-lang/wg-cargo-std-aware#49
Reopens rust-lang/wg-cargo-std-aware#31
@ehuss
Copy link
Contributor Author

ehuss commented Dec 12, 2019

Reopen due to rust-lang/cargo#7699.

@ehuss ehuss reopened this Dec 12, 2019
@ehuss ehuss reopened this Feb 11, 2020
@ehuss ehuss added stabilization blocker This needs a resolution before stabilization S-needs-design Status: needs design work labels May 3, 2023
bors added a commit to rust-lang/cargo that referenced this issue May 18, 2024
Temporarily fix standard_lib tests on linux.

This fixes the standard_lib tests which are broken in the latest nightly. The latest nightly now requires rust-lld to be in the sysroot for x86_64-unknown-linux-gnu. This broke these tests which were trying to verify that the standard library is not required. This temporarily removes this validation, but we should have some way of enforcing it (rust-lang/wg-cargo-std-aware#31).

cc rust-lang/rust#125246
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
implementation Implementation exploration and tracking issues S-needs-design Status: needs design work stabilization blocker This needs a resolution before stabilization
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants