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

Make Cargo aware of standard library dependencies #1133

Closed
wants to merge 66 commits into from
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 May 25, 2015
4c0ea2a
First version
Ericson2314 May 26, 2015
eee7dba
Fix were/where Typo
Ericson2314 May 26, 2015
9da1b02
Use true defaults to avoid double negatives as suggested by @Valloric
Ericson2314 May 26, 2015
630ac97
Typo
Ericson2314 May 28, 2015
a7425e6
Rewrite after talking to @alexcrichton on IRC.
Ericson2314 May 29, 2015
37e9246
Messed up target triple in anecdote
Ericson2314 May 30, 2015
d549d15
Clarify that stable Rust won't allow linking any library in the sysroot
Ericson2314 Jun 15, 2015
b3476e1
Motivate incrementally
Ericson2314 Aug 16, 2015
c22463f
Nit: Fix Some wrongly-capitalized "Cargo"s
Ericson2314 Aug 31, 2015
c257f34
Detailed design for overrides
Ericson2314 Sep 3, 2015
4a8bf9b
Overhaul and expand on detailed design: core is stable and [reaplace]…
Ericson2314 Apr 25, 2016
4b4d8a3
Two more drawbacks
Ericson2314 Apr 25, 2016
1ee980f
Fix typo
Ericson2314 May 11, 2016
f0a0b3b
Rewrite to use upcoming Cargo registries.
Ericson2314 Jul 12, 2016
3422763
Fix broken hyperlink
Ericson2314 Jul 12, 2016
8392c4a
Typos caught by @eternaleye, thanks!
Ericson2314 Jul 12, 2016
ffc442b
Clarify what implicit deps are, including unresolved issues
Ericson2314 Jul 12, 2016
1c53ae1
Motivate the use of registries, and move the speculative `[ideally..]…
Ericson2314 Jul 12, 2016
cc8a1f2
Unresolved question on `cargo new`
Ericson2314 Jul 13, 2016
71ba640
Prevent snooping binaries from the sysroot; sysroot binaries not copied
Ericson2314 Jul 13, 2016
9a61baa
`test` is an implicit dev-dependency.
Ericson2314 Jul 13, 2016
89a461a
Whether implicit test and dev dependencies are mandatory is unresolved
Ericson2314 Jul 13, 2016
4656eb9
Typos
Ericson2314 Jul 13, 2016
984bcb5
Add `language-version` key, and alternative for compiler-rt handling
Ericson2314 Jul 13, 2016
af9442b
Add unresolved questions for fine-grained configuration (e.g. exact CPU)
Ericson2314 Jul 13, 2016
d16f8c3
Either both the sysroot source and binaries can resolved, or neither
Ericson2314 Jul 13, 2016
77be419
Add parenthetical.
Ericson2314 Jul 13, 2016
afae118
Use `stdlib = true|false` rather than crates.io fallback to begin with.
Ericson2314 Jul 27, 2016
a1f8ab1
Clarify the forward compatibility section
Ericson2314 Jul 27, 2016
2334770
Copy-edit 0000-cargo-libstd-awareness.md
jethrogb Aug 1, 2016
61cd8ca
Revise a view corrections / add more of my own.
Ericson2314 Aug 1, 2016
fac0c9b
By the time this lands, Compiler-rt will be tamed.
Ericson2314 Aug 4, 2016
a062095
Extra 'a' typo
Ericson2314 Aug 5, 2016
bbf1ec6
"bounds" -> "semver requirements"
Ericson2314 Aug 6, 2016
81a923a
Clarify "at the time": "in Rust 1.0"
Ericson2314 Aug 6, 2016
51cfdb6
Remove stale alternative
Ericson2314 Aug 6, 2016
a36a46b
Clarify drawback on unconstrained interfaces
Ericson2314 Aug 6, 2016
e6aae38
Clarify drawback and fix typo
Ericson2314 Aug 6, 2016
7e73557
More eloquence and details about how sysroot binaries will be used.
Ericson2314 Aug 6, 2016
f7fd3df
Fix sysroot paths
Ericson2314 Aug 6, 2016
b327075
Add missing closing paren
Ericson2314 Aug 6, 2016
d38daad
Clarify how implicit dependencies are disabled
Ericson2314 Aug 6, 2016
f8859d5
Grammar for implicit dep disabling
Ericson2314 Aug 6, 2016
d208a5f
`core` is the only crate needing to use the `implicit-dependencies` key
Ericson2314 Aug 6, 2016
cb67deb
Clarify stdlib deps vs rust language dep
Ericson2314 Aug 6, 2016
e8b1aa2
For now, "stdlib = true" is a source
Ericson2314 Aug 6, 2016
477d8bc
Finally figure out how deps are passed to rustc
Ericson2314 Aug 8, 2016
b9aa2da
Add alternatives for "sysroot = true" and language version
Ericson2314 Aug 12, 2016
26e1b6e
Purge language about registries, misc clarifications of surrounding text
Ericson2314 Aug 13, 2016
d35237f
Split huge paragraph
Ericson2314 Aug 13, 2016
28353b2
Clamp down on dependencies; mention unstability
Ericson2314 Aug 13, 2016
44f1e84
Talk about `version = "*"`
Ericson2314 Aug 13, 2016
2ea3e83
the -> a
Ericson2314 Aug 13, 2016
324e225
Add @brson's text on sysroot binary filenames
Ericson2314 Aug 13, 2016
02889b8
Remove obsolete unresolved question
Ericson2314 Aug 13, 2016
bbc503b
Talk about lockfiles.
Ericson2314 Aug 13, 2016
b1e1b4b
Remove rustbuild ideas, and talk about implementation roadmap instead
Ericson2314 Aug 13, 2016
50a0862
Slightly update the roadmap
Ericson2314 Aug 19, 2016
e8f14b7
Typo
Ericson2314 Aug 23, 2016
c501fd9
Prevent stdlib deps as replacements
Ericson2314 Aug 30, 2016
2719c44
No `stdlib = false`
Ericson2314 Aug 30, 2016
54aa001
Include the name of the temporary stdlib deps pruning option
Ericson2314 Aug 30, 2016
2774668
Talk about `custom-implicit-stdlib-dependencies` and hack flags in ge…
Ericson2314 Aug 31, 2016
d85091a
Fix typo
Ericson2314 Oct 10, 2016
ee4104f
Fix typos found by @est31 and @JinShil. Thanks!
Ericson2314 Jan 7, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions text/0000-cargo-libstd-awareness.md
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

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 to false by default, make it use-implicit-deps and make it true by default.

Whatever name is bikeshedded should be boolean-positive.

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`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar here; instead of --no-sysroot, make it --use-sysroot=false (with the default being true).

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?