Commit graph

7784 commits

Author SHA1 Message Date
bors 7b13469ee9 Auto merge of #6772 - Aaron1011:feature/final-pub-priv, r=ehuss
Implement the 'frontend' of public-private dependencies

This is part of https://github.com/rust-lang/rust/issues/44663

This implements the 'frontend' portion of [RFC 1977](https://github.com/rust-lang/rfcs/blob/master/text/1977-public-private-dependencies.md). Once PRs https://github.com/rust-lang/rust/pull/59335 and https://github.com/rust-lang/crates.io/pull/1685 are merged,
it will be possible to test the full public-private dependency feature:
marking a dependency a public, seeing exported_private_dependencies
warnings from rustc, and seeing pub-dep-reachability errors from Cargo.

Everything in this commit should be fully backwards-compatible - users
who don't enable the 'public-dependency' cargo feature won't notice any
changes.

Note that this commit does *not* implement the remaining two features of
the RFC:

* Choosing smallest versions when 'cargo publish' is run
* Turning exported_private_dependencies warnings into hard errors when 'cargo publish' is run

The former is a major change to Cargo's behavior, and should be done in a separate PR with some kind of rollout plan.

The latter is described by the RFC as being enabled at 'some point in the future'. This can be done via a follow-up PR.
2019-04-26 22:47:59 +00:00
bors 0c891a0091 Auto merge of #6853 - Eh2406:caching-the-dependency, r=alexcrichton
Caching the dependencies

There are 2 sources of facts for the resolver:
1. The `Registry` tells us for a Dependency what versions are available to fulfil it.
2. The `Summary` tells us for a version (and features) what dependencies need to be fulfilled for it to be activated.

The `Registry` was cached with a `RegistryQueryer` back in #5112. This adds a `DepsCache` to cache the calculation of which dependencies are activated by features.

In the happy path `flag_activated` means that we don't get to reuse `build_deps`, but the more we backtrack the more time we save. In pathological cases like https://github.com/rust-lang/cargo/issues/6258#issuecomment-479204465, I have measured this as a 10% improvement with release.

This also means that `build_deps` can be run in a context free way, which may be useful in a follow up PR to solve https://github.com/rust-lang/cargo/issues/6258#issuecomment-482620770.
2019-04-26 14:28:07 +00:00
Aaron Hill f4aac94f12
Properly fix assertion and tests 2019-04-26 00:07:04 -04:00
Aaron Hill 2de44c47ce
Relax assertion 2019-04-25 23:24:32 -04:00
Aaron Hill df4d2095ac
Prevent 'public' specifier from being used on non-Normal dependencies 2019-04-25 22:42:19 -04:00
Aaron Hill 8c8824fad8
Remove 'private' flag 2019-04-25 22:42:19 -04:00
Aaron Hill a22a7dbc38
Pass --extern-private or --extern, but not both 2019-04-25 22:42:19 -04:00
Aaron Hill e578fc1835
Fix serializing fingerprint 2019-04-25 22:42:19 -04:00
Aaron Hill 8a45e5c0b0
Format pub_priv test 2019-04-25 22:42:19 -04:00
Aaron Hill 8185564a53
Track 'public/private' depenendecy status in fingerprint 2019-04-25 22:42:19 -04:00
Aaron Hill 715d6ace02
Update unstable reference 2019-04-25 22:42:18 -04:00
Aaron Hill be9ae5e547
Fix error message on stable 2019-04-25 22:42:18 -04:00
Aaron Hill 87f1a4b217
Implement the 'frontend' of public-private dependencies
This is part of https://github.com/rust-lang/rust/issues/44663

This implements the 'frontend' portion of RFC 1977. Once PRs
https://github.com/rust-lang/rust/pull/59335 and
https://github.com/rust-lang/crates.io/pull/1685 are merged,
it will be possible to test the full public-private dependency feature:
marking a dependency a public, seeing exported_private_dependencies
warnings from rustc, and seeing pub-dep-reachability errors from Cargo.

Everything in this commit should be fully backwards-compatible - users
who don't enable the 'public-dependency' cargo feature won't notice any
changes.

Note that this commit does *not* implement the remaining two features of
the RFC:

* Choosing smallest versions when 'cargo publish' is run
* Turning exported_private_dependencies warnings into hard errors when
'cargo publish' is run

The former is a major change to Cargo's behavior, and should be done
in a separate PR with some kind of rollout plan.

The latter is described by the RFC as being enabled at 'some point in
the future'. This can be done via a follow-up PR.
2019-04-25 22:42:18 -04:00
bors c9330feb48 Auto merge of #6879 - froydnj:patch-1, r=ehuss
fix typo in rustc.rs comment
2019-04-25 21:43:38 +00:00
Nathan Froyd 5d98ed4b8b
fix typo in rustc.rs comment 2019-04-25 17:09:35 -04:00
Eh2406 79714ba974 combine the caching structs 2019-04-25 16:09:26 -04:00
Eh2406 623863e52f add lots of comments 2019-04-25 15:39:14 -04:00
bors 49c6465a32 Auto merge of #6878 - matthiaskrgr:typo, r=Eh2406
fix typo (superfluous "o" after period).

found while reading through the code docs
2019-04-25 18:31:32 +00:00
Matthias Krüger 2b41dd4a4f fix typo (superfluous "o" after period). 2019-04-25 20:22:46 +02:00
Eh2406 5ae13e3200 cache the output of build_deps 2019-04-25 12:31:51 -04:00
Eh2406 c36301c614 make build_deps a stand alone function 2019-04-25 12:31:50 -04:00
Eh2406 a372cae105 use a BTreeSet to store features 2019-04-25 12:31:50 -04:00
Eh2406 949f49a5fb make resolve_features a stand alone function 2019-04-25 12:31:48 -04:00
Eh2406 4aacb80550 use PackageId were we can 2019-04-25 12:31:47 -04:00
Eh2406 95de3a1d11 move RegistryQueryer to a dedicated mod 2019-04-25 12:31:47 -04:00
Eh2406 77a7e3fe94 InternedString because we can 2019-04-25 12:31:47 -04:00
Eh2406 ea40fc4f54 some clippy things 2019-04-25 12:31:46 -04:00
bors 65629426c5 Auto merge of #6867 - alexcrichton:improvements, r=ehuss
Backend refactorings and perf improvements

This PR is extracted from https://github.com/rust-lang/cargo/pull/6864 and then also additionally adds some commits related to performance optimizations that I noticed while profiling https://github.com/rust-lang/cargo/pull/6864. Each commit is in theory standalone and should pass all the tests, as well as being descriptive about what it's doing.
2019-04-25 15:52:08 +00:00
bors a507ae4fc8 Auto merge of #6860 - Eh2406:no-RcList, r=alexcrichton
Make required dependency as future an error, remove RcList

This makes it an error to set a feature on a dependency if it is the name of a required dependency not a feature. This has been a warning for a long time. The resolver will backtrack to find a version that works, if one is available. So I think it is safe to make the change.

If you need to make a optional dependency into a required dependency without a semver breaking change this can be done with rename dependencies.

The result is that we can remove 3 data structures that get cloned once per tick of the resolver.
2019-04-25 15:26:21 +00:00
Alex Crichton 32269f4a34 Document unsafety in UnitInterner 2019-04-23 14:58:01 -07:00
Alex Crichton d274fba070 Hoist a workspace membership check out of a loop
This commit moves a linear scan which happens once-per-each-dependency
to an O(1) lookup which happens only once for each package. This removes
another 30ms or so from a null build in Servo.
2019-04-22 16:08:19 -07:00
Alex Crichton f660b3e464 Turn Workspace::is_member into an O(1) query
This commit moves it from a linear query which does a lot of hashing of
`PathBuf` to an `O(1)` query that only hashes `PackageId`. This improves
Servo's null build performance by 50ms or so, causing a number of
functions to disappear from profiles.
2019-04-22 16:01:58 -07:00
Alex Crichton e45444665c Intern units for fast hashing
This commit starts to intern `Unit` structures for a few reasons:

* This primarily makes equality and hashing much faster. We have tons of
  hash lookups with units, and they were showing up quite high
  in profiles. It turns out `Unit` hashes a *ton* of data, and most of
  it is always redundant. To handle this they're all only hashed once
  now and hashing/equality are just pointer checks.

* The size of `Unit` is now drastically reduced to just one pointer, so
  movement of units throughout the backend should be much more
  efficient.
2019-04-22 15:06:37 -07:00
Eh2406 35ff555b70 just give up and make it an error 2019-04-22 17:31:55 -04:00
Alex Crichton bd8253fdeb Avoid reparsing env_args continuously
We only need to parse this information once, so calculate it when a
`TargetInfo` is created and then just reuse that from then on out.
2019-04-22 14:11:16 -07:00
Alex Crichton 724602857c Sort units once, not each call to dep_targets
The code lying around in `dep_targets` is pretty old at this point, but
given the current iteraiton there's no need to re-sort on each call to
`dep_targets`, only initially during construction!
2019-04-22 14:11:16 -07:00
Alex Crichton 12e0ffa6a7 Remove the Key type from JobQueue
This isn't actually necessary with a bit of refactoring, and in general
it makes management of `JobQueue` simpler since there's one less type to
worry about. The one main usage of `Key` vs `Unit` was that `Key` was
`Send` to be placed in `Message`, but this was replaced by just
assigning each `Unit` an ever-increasing integer, and then `Finished`
contains the integer rather than the `Key` itself which we can map once
we get back to the main thread.
2019-04-22 13:47:31 -07:00
Alex Crichton 21cae017cd Refactor JobQueue::run slightly
Take a `&Context` argument instead of a few component arguments, avoids
passing around some extraneous information.
2019-04-22 13:47:26 -07:00
Alex Crichton b36594db39 Correct a condition to request jobserver tokens
This looks like it was a bug ever present from the original
implementation of a GNU jobserver in #4110, but we currently
unconditionally request a token is allocated for any job we pull off our
job queue. Rather we only need to request tokens for everything but the
first job because we already have an implicit token for that job.
2019-04-22 13:47:18 -07:00
Alex Crichton 21ea254b86 Remove the Vec<Job> from DependencyQueue
I... don't think this needed any more! Doing some digging looks like
this was originally added in 79768eb0d. That was so early it didn't even
use a PR and was almost 5 years ago. Since then we've had a huge number
of changes to the backend and `Unit` nowadays does all the deduplication
we need, so no need to store a `Vec` here and we can just have a mapping
of `Key` to `Job` and that's it.
2019-04-22 13:47:11 -07:00
Eh2406 a4737160bf fix replacements 2019-04-22 15:48:57 -04:00
Eh2406 d0c80ecb4b address nits 2019-04-19 13:58:16 -04:00
bors 6be12653dc Auto merge of #6863 - daxpedda:patch-1, r=alexcrichton
Improved docs for `maintenance` options

I thought the lack of clear meanings for the available options could use some improvement.
Basically an upgrade of #4431.

Got the relevant text from rust-lang/crates.io#704 and the corresponding [rfc](https://github.com/rust-lang/rfcs/blob/master/text/1824-crates.io-default-ranking.md)

*Questions*
1. Should I put the descriptions outside of the code block?
2. I copied the wording including "maintainer" and "author", should I replace it with "you" or something more appropriate?
2019-04-19 15:05:03 +00:00
daxpedda dee137b6ee
Improved docs for maintenance options
I thought the lack of clear meanings for the available options could use some improvement.
Basically an upgrade of #4431.

Got the relevant text from rust-lang/crates.io#704 and the corresponding [rfc](https://github.com/rust-lang/rfcs/blob/master/text/1824-crates.io-default-ranking.md)

*Questions*
1. Should I put the descriptions outside of the code block?
2. I copied the wording including "maintainer" and "author", should I replace it with "you" or something more appropriate?
2019-04-19 16:04:14 +02:00
Eh2406 8cd9b0c7fa remove dead code 2019-04-18 15:05:35 -04:00
Eh2406 097dbdf85d invert parents to get graph 2019-04-18 15:05:35 -04:00
Eh2406 df62a578ba list used used_replacements after we figure out what is used 2019-04-18 15:05:35 -04:00
Eh2406 0131d09dd4 move to a function 2019-04-18 15:05:34 -04:00
Eh2406 4590e74f11 calculate features the hard way 2019-04-18 15:05:34 -04:00
Eh2406 f0f856502e remove the resolver warnings 2019-04-18 15:05:33 -04:00