Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up[Request for Experiment] Sysroot building functionality #4959
Comments
This comment has been minimized.
This comment has been minimized.
|
I do plan to someday get back to that. This seems like a great step until then! Especially if rustboot can utilize it. |
This comment has been minimized.
This comment has been minimized.
|
Also, fwiw, my plan was to draft a sub-RFC based on what I implemented in #2768, which I considered not just a convenient but also meaningful subset. The idea was more (opt-in) ditching sysroots altogether, so only rustc itself need think about bootstrapping. |
This comment has been minimized.
This comment has been minimized.
|
The tweak to assume the presence and location of the * no idea how we'd get data for this, besides a survey |
This comment has been minimized.
This comment has been minimized.
|
I think it would be good to restrict the crates which can be placed in the sysroot to the usual ones we would expect there, unless there is good reason not to? Are there other parts of the program other than build scripts that should be built with the host profile? Proc macros/custom derives seem like one thing. Are there more? I wonder if there is a more user-friendly surface syntax we could layer on top of the custom sysroot facility? It seems like for any given platform and version, the sysroot setup will be the same, so it would be good to be able to set that all up once and then point to it from user crates, rather than having to spell it out each time. |
nrc
referenced this issue
Feb 1, 2018
Closed
Make Cargo aware of standard library dependencies #1133
This comment has been minimized.
This comment has been minimized.
Could this path be discovered by running |
This comment has been minimized.
This comment has been minimized.
FenrirWolf
commented
Feb 1, 2018
|
That's what's proposed in the potential additions/tweaks section |
This comment has been minimized.
This comment has been minimized.
For my usecase (wasm) I want to be able to get a copy of the rust std, hack around with it to create my own integrations with JS directly in libstd, and then build it. I'd say that experimenting with libstd (either to experiment with targets, or with the intent of making PRs against the main Rust repo) should not be an advanced use case and any solution should take care to have it as a first-class feature. That's not to say that we can't make the |
This comment has been minimized.
This comment has been minimized.
|
Another thing to think about, if we integrate rustup functionality into Cargo, does this sysroot stuff interact with any of the cross-compilation-oriented toolchain features from rustup? |
This comment has been minimized.
This comment has been minimized.
|
I didn’t mean that Cargo would necessarily have rustup-specific functionality. Rustup could for example set an environment variable that Cargo (and |
This comment has been minimized.
This comment has been minimized.
|
It's kind of the plan that we'll merge rustup and Cargo this year |
japaric
referenced this issue
Mar 7, 2018
Closed
Bundled LLD is not found when sysroot is changed #48772
This comment has been minimized.
This comment has been minimized.
|
I brought it up in rust-lang/rfcs#1133 (comment) and @matklad posted a response rust-lang/rfcs#1133 (comment), but for posterity I think it's better I mirror and elaborate my concerns on this proposal here.
|
This comment has been minimized.
This comment has been minimized.
|
@Ericson2314, here's one more argument for, eventually, getting rid of sysroot altogether: currently, we have to use one set of compiler flags for stdlib, for all use cases. Building your own std should allow one to use the precise flags one wants. The particular problems today are:
|
This comment has been minimized.
This comment has been minimized.
|
How are the stability guarantees around this? xargo breaks every now and then because something in rustc changes. (Though I assume if rustc CI tests that this works, that would happen less often.) Also, compiling libstd requires nightly features -- so i we want to permit custom sysroots on stable, and people start patching libstd, they could easily end up in a situation where upgrading the compiler breaks their code. |
japaric
referenced this issue
Mar 21, 2018
Closed
Allowing stable channel rustc in Rust's style #204
bradjc
referenced this issue
Apr 15, 2018
Closed
Tracking: Minimize dependencies to build kernel #866
This comment has been minimized.
This comment has been minimized.
elichai
commented
Jun 3, 2018
|
Sounds like a great idea. |
elichai
referenced this issue
Jul 24, 2018
Open
compiler_builtins & compiler_builtins_shim leading multiple matching crates #218
ketsuban
referenced this issue
Dec 8, 2018
Open
Add support for custom targets in the style of xargo/cargo-xbuild #1538
This comment has been minimized.
This comment has been minimized.
|
“Implementation details” section should be updated to discuss |
japaric commentedJan 20, 2018
•
edited
Summary
This RFE proposes adding Xargo's functionality of building a sysroot on the fly to Cargo as a nightly-only feature.
Motivation
Many (all?) no-std / embedded developers have to Install One More Tool because the ability to build core / std from source is missing in Cargo. Apart from the inconvenience, the Xargo wrapper is from for perfect: it can trigger unnecessary sysroot rebuilds because it doesn't replicate Cargo fingerprinting mechanism; it can sometimes fail to trigger a necessary sysroot rebuild (japaric/xargo#189); it doesn't track changes in the sysroot source code (japaric/xargo#139); and it doesn't understand the
+nightlycommand line argument because it's not a rustup shim (japaric/xargo#123) among other deviations from the behavior users expect from a built-in Cargo subcommand.Apart from all the issues Xargo also ties no-std / embedded development to the nightly channel. This experiment will hopefully be a first step towards enabling no-std / embedded development on the stable channel.
Implementation details
User interface:
[sysroot]A
[sysroot]section will be added to Cargo configuration file:There the user can specify the crates that will be included in the sysroot. Only path and git dependencies are allowed. The
[sysroot.rust-src]setting is a convenience that lets the user use relative paths.Behavior
If a
[sysroot]setting is found in Cargo configuration file:Cargo will (re)build the sysroot crates for the target and place the build artifacts in
$TARGET_DIR/sysroot/lib/rustlib/$TARGETbefore executing subcommands that involve invokingrustcorrustdoc. Then when invoking the actual subcommand Cargo will append the argument--sysroot=$TARGET_DIR/sysrootto all itsrustcandrustdocinvocations except the ones used to build build scripts (build.rs).The usual fingerprinting mechanism applies to the sysroot build: for example changes to
[profile]in Cargo.toml and changes in the sysroot source code will trigger a sysroot rebuild.The sysroot crates will always be built using the release profile to not regress the performance and binary size of dev builds when switching to builds that use
[sysroot].Multi-stage builds
There are crates in the
stdfacade, like thetestcrate, that have implicit dependencies on other members of the facade. Building sysroots that include these crates require multi-stage builds.In multi-stage builds the sysroot will be build as follows: all the crates in the first stage are build against the default sysroot; then all the crates in the second stage are build using the stage 1 artifacts as a custom sysroot (i.e.
--sysrootis passed torustc); then all the crates in the third stage are build using the stage 1 and 2 artifacts as a custom sysroot; the process continues until all stages are built; finally the artifacts of all the stages are placed in$TARGET_DIR/sysroot/lib/rustlib/$TARGET.Potential additions / tweaks
Xargo doesn't require the user to specify a
rust-srcsetting because it assumes that bothrustupand therust-srccomponent are installed and it usesrustc --print sysrootto get the path to the Rust source. We could do the same here by either: (a) probing for the existence ofrust-srcand printing a helpful error message when it's not installed, or (b) committing to always shiprust-srcwith the toolchain.Xargo always rebuilds the sysroot in release mode but we could have the Cargo implementation use the dev profile when
--releaseis not passed to the subcommand.Future steps
Revisit rust-lang/rfcs#1133 to see if there's a desire for the changes proposed there that aren't included in this RFE: eliminating the concept of the sysroot, versioning the crates in the std facade, etc.
UPDATE(2018-01-20): Don't pass
--sysroottorustcwhen building build scripts (build.rs). Those should be build against the default sysroot because they always run on the host. If the build scripts were to be build against the custom sysroot the sysroot would need to contain therust-stdartifacts of the host and that would require copying (or linking) those into$TARGET_DIR/sysroot/lib/rustlib/$HOST, which is a waste of space.cc @alexcrichton @nrc @Ericson2314