-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Make Cargo aware of standard library dependencies #1133
Closed
Closed
Changes from 3 commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
7f3d678
Copy in template
Ericson2314 4c0ea2a
First version
Ericson2314 eee7dba
Fix were/where Typo
Ericson2314 9da1b02
Use true defaults to avoid double negatives as suggested by @Valloric
Ericson2314 630ac97
Typo
Ericson2314 a7425e6
Rewrite after talking to @alexcrichton on IRC.
Ericson2314 37e9246
Messed up target triple in anecdote
Ericson2314 d549d15
Clarify that stable Rust won't allow linking any library in the sysroot
Ericson2314 b3476e1
Motivate incrementally
Ericson2314 c22463f
Nit: Fix Some wrongly-capitalized "Cargo"s
Ericson2314 c257f34
Detailed design for overrides
Ericson2314 4a8bf9b
Overhaul and expand on detailed design: core is stable and [reaplace]…
Ericson2314 4b4d8a3
Two more drawbacks
Ericson2314 1ee980f
Fix typo
Ericson2314 f0a0b3b
Rewrite to use upcoming Cargo registries.
Ericson2314 3422763
Fix broken hyperlink
Ericson2314 8392c4a
Typos caught by @eternaleye, thanks!
Ericson2314 ffc442b
Clarify what implicit deps are, including unresolved issues
Ericson2314 1c53ae1
Motivate the use of registries, and move the speculative `[ideally..]…
Ericson2314 cc8a1f2
Unresolved question on `cargo new`
Ericson2314 71ba640
Prevent snooping binaries from the sysroot; sysroot binaries not copied
Ericson2314 9a61baa
`test` is an implicit dev-dependency.
Ericson2314 89a461a
Whether implicit test and dev dependencies are mandatory is unresolved
Ericson2314 4656eb9
Typos
Ericson2314 984bcb5
Add `language-version` key, and alternative for compiler-rt handling
Ericson2314 af9442b
Add unresolved questions for fine-grained configuration (e.g. exact CPU)
Ericson2314 d16f8c3
Either both the sysroot source and binaries can resolved, or neither
Ericson2314 77be419
Add parenthetical.
Ericson2314 afae118
Use `stdlib = true|false` rather than crates.io fallback to begin with.
Ericson2314 a1f8ab1
Clarify the forward compatibility section
Ericson2314 2334770
Copy-edit 0000-cargo-libstd-awareness.md
jethrogb 61cd8ca
Revise a view corrections / add more of my own.
Ericson2314 fac0c9b
By the time this lands, Compiler-rt will be tamed.
Ericson2314 a062095
Extra 'a' typo
Ericson2314 bbf1ec6
"bounds" -> "semver requirements"
Ericson2314 81a923a
Clarify "at the time": "in Rust 1.0"
Ericson2314 51cfdb6
Remove stale alternative
Ericson2314 a36a46b
Clarify drawback on unconstrained interfaces
Ericson2314 e6aae38
Clarify drawback and fix typo
Ericson2314 7e73557
More eloquence and details about how sysroot binaries will be used.
Ericson2314 f7fd3df
Fix sysroot paths
Ericson2314 b327075
Add missing closing paren
Ericson2314 d38daad
Clarify how implicit dependencies are disabled
Ericson2314 f8859d5
Grammar for implicit dep disabling
Ericson2314 d208a5f
`core` is the only crate needing to use the `implicit-dependencies` key
Ericson2314 cb67deb
Clarify stdlib deps vs rust language dep
Ericson2314 e8b1aa2
For now, "stdlib = true" is a source
Ericson2314 477d8bc
Finally figure out how deps are passed to rustc
Ericson2314 b9aa2da
Add alternatives for "sysroot = true" and language version
Ericson2314 26e1b6e
Purge language about registries, misc clarifications of surrounding text
Ericson2314 d35237f
Split huge paragraph
Ericson2314 28353b2
Clamp down on dependencies; mention unstability
Ericson2314 44f1e84
Talk about `version = "*"`
Ericson2314 2ea3e83
the -> a
Ericson2314 324e225
Add @brson's text on sysroot binary filenames
Ericson2314 02889b8
Remove obsolete unresolved question
Ericson2314 bbc503b
Talk about lockfiles.
Ericson2314 b1e1b4b
Remove rustbuild ideas, and talk about implementation roadmap instead
Ericson2314 50a0862
Slightly update the roadmap
Ericson2314 e8f14b7
Typo
Ericson2314 c501fd9
Prevent stdlib deps as replacements
Ericson2314 2719c44
No `stdlib = false`
Ericson2314 54aa001
Include the name of the temporary stdlib deps pruning option
Ericson2314 2774668
Talk about `custom-implicit-stdlib-dependencies` and hack flags in ge…
Ericson2314 d85091a
Fix typo
Ericson2314 ee4104f
Fix typos found by @est31 and @JinShil. Thanks!
Ericson2314 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
- Feature Name: cargo_libstd_awareness | ||
- Start Date: 2015-05-26 | ||
- RFC PR: (leave this empty) | ||
- Rust Issue: (leave this empty) | ||
|
||
# Summary | ||
|
||
Currently, all packages implicitly depend on libstd. This makes Cargo unsuitable for packages that | ||
need a custom-built libstd, or otherwise depend on crates with the same names as libstd and the | ||
crates behind the facade. The proposed fixes also open the door to a future where libstd can be | ||
Cargoized. | ||
|
||
# Motivation | ||
|
||
Bare-metal work cannot use a standard build of libstd. But since any crate built with Cargo can link | ||
with a system-installed libstd if the target matches, using Cargo for such projects can be irksome | ||
or impossible. | ||
|
||
Cargoizing libstd also generally simplifies the infrastructure, and makes cross compiling much | ||
slicker, but that is a separate discussion. | ||
|
||
Finally, I first raised this issue here: https://github.com/rust-lang/Cargo/issues/1096 Also, there | ||
are some (heavily bit-rotted) projects at https://github.com/RustOS-Fork-Holding-Ground that depend | ||
on each other in the way this RFC would make much more feasible. | ||
|
||
# Detailed design | ||
|
||
The current situation seems to be more of an accident of `rustc`'s pre-Cargo history than an | ||
explicit design decision. Cargo passes the location and name of all depended on crates to `rustc`. | ||
This is good because it means that that no undeclared dependencies on other Cargo packages can leak | ||
through. However, it also passes in `--sysroot /path/to/some/libdir`, the directory being were | ||
libstd is. This means packages are free to use libstd, the crates behind the facade, or none of the | ||
above, with Cargo being none the wiser. | ||
|
||
The only new interface proposed is a boolean field to the package meta telling Cargo that the | ||
package does not depend on libstd by default. This need not imply Rust's `no_std`, as one might want | ||
to `use` their own build of libstd by default. To disambiguate, this field is called | ||
q`no-implicit-deps`; please, go ahead and bikeshead the name. `no-implicit-deps` is false by | ||
default to maintain compatibility with existing packages. | ||
|
||
The meaning of this flag is defined in 3 phases, where each phase extends the last. The idea being | ||
is that while earlier phases are easier to implement, later phases yield a more elegant system. | ||
|
||
## Phase 1 | ||
|
||
Add a `--no-sysroot` flag to `rustc`, and pass that to `rustc` is the case that `no-implicit-deps` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar here; instead of |
||
is true. | ||
|
||
This hotfix is enough to allow us bare-metal devs to use Cargo for our own projects, but doesn't | ||
suffice for creating an ecosystem of packages that depend on crates behind the facade but not libstd | ||
itself. This is because the choices are all or nothing: Either one implicitly depends on libstd or | ||
the crates behind the facade, or they don't depend on them at all. | ||
|
||
## Phase 2 | ||
|
||
Since, passing in a directory of crates is inherently more fragile than passing in a crate | ||
itself, make Cargo use `--no-sysroot` in all cases. | ||
|
||
Cargo would special case package names corresponding to the crates behind the facade, such that if | ||
the package don't exist, it would simply pass the corresponding system crate to `rustc`. I assume | ||
the names are blacklisted on crates.io already, so by default the packages won't exist. But users | ||
can use config files to extend the namespace so their own modded libstds can be used instead. Even | ||
if they don't want to change libstd but just cross-compile it, this is frankly the easiest way as | ||
Cargo will seemliest cross compile both their project and it's transitive dependencies. | ||
|
||
In this way we can put packages on crates.io that depend on the crates behind the facade. Some | ||
packages that already exist, like liblog and libbitflags, should be given features that optionally | ||
allow them to avoid libstd and just depend directly on the crates behind the facade they really | ||
need. | ||
|
||
## Phase 3 | ||
|
||
If/when the standard library is built with Cargo and put on crates.io, all the specially-cased | ||
package names can be treated normally, | ||
|
||
The standard library is be downloaded and built from crates.io. Or equivalently, Cargo comes with a | ||
cache of that build, as Cargo should be able cache builds between projects at this point. Just as in | ||
phase 2, `no-implicit-deps` just prevents libstd from implicitly being appended to the list of | ||
dependencies. | ||
|
||
Again, to make this as least controversial as possible, this RFC does not propose outright that the | ||
standard library should be Cargoized. This 3rd phases just describes how this feature would work | ||
were that to happen. | ||
|
||
# Drawbacks | ||
|
||
I really don't know of any. Development for hosted environments would hardly be very affected. | ||
|
||
# Alternatives | ||
|
||
Make it so all dependencies, even libstd, must be explicit. C.f. Cabal and base. | ||
|
||
# Unresolved questions | ||
|
||
There are multiple lists of dependencies for different things (e.g. tests), Should libstd be append | ||
to all of them in phases 2 and 3? |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The specific name doesn't concern me too much, but do make it boolean-positive instead of negative. So instead of having
no-implicit-deps
and setting it tofalse
by default, make ituse-implicit-deps
and make ittrue
by default.Whatever name is bikeshedded should be boolean-positive.