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

Add a --sysroot option to build and rustc commands #2312

Closed
Zoxc opened this issue Jan 25, 2016 · 3 comments
Closed

Add a --sysroot option to build and rustc commands #2312

Zoxc opened this issue Jan 25, 2016 · 3 comments

Comments

@Zoxc
Copy link
Contributor

Zoxc commented Jan 25, 2016

When cross compiling you need to provide both a target and a sysroot (a place where all the target libraries can be found). Both cargo and rustc should provide a way to set these. rustc's --sysroot might be buggy or rust specific, see rust-lang/rust#31180 and it does not pass it on to the linker.

@alexcrichton
Copy link
Member

This sounds like it's a use case for RUSTFLAGS rather than its own dedicated flag. All of the cross-compiling linkers I've seen in the past auto-find their own sysroot so making this a first-class option may be too front-and-center for this?

@Zoxc
Copy link
Contributor Author

Zoxc commented Jan 31, 2016

This won't be very useful if you have to pass the C sysroot in RUSTFLAGS anyway.

japaric pushed a commit to japaric/cargo that referenced this issue Mar 4, 2016
This patch lets you use the 'profile.$profile.sysroot' key in Cargo.toml to pass `--sysroot $path`
to `rustc` during the compilation of the current crate and its dependencies.

Main use cases are kernel development and bare metal programming (e.g. microcontrollers) where the
application depends on a minimal set of "core" crates like `core`, `alloc`, `collections`, etc.
These dependencies need to be cross compiled for the target platform/architecture and a "sysroot"
(*) provides, IMO ,the cleanest way to make these core dependencies available to the many crates
that conform the application.

(*) A sysroot is basically a directory that holds the already (cross) compiled "standard" crates
(i.e. `core`, `std`, etc) that are linked to your Rust programs when you call `rustc`. The important
bit is that you don't explicitly spell out these dependencies in e.g. a Cargo.toml; they are
implicitly available. The fastest way to familiarize with sysroots is to explore the default sysroot
with something like `tree $(rustc --print sysroot)`.

cc rust-lang#2312
@carols10cents
Copy link
Member

This sounds like it can be closed. Please reopen if I'm wrong! 🌵

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants