Arlo Siemsen [Wed, 15 Jul 2020 17:43:34 +0000 (10:43 -0700)]
Make `cargo metadata` output deterministic
Uses BTreeMap instead of HashMap for the `cargo metadata` command.
The change did not cause a measurable performance impact for
running `cargo metadata` on `cargo` itself.
bors [Thu, 25 Jun 2020 18:47:08 +0000 (18:47 +0000)]
Auto merge of #8409 - alexcrichton:git-instead-of, r=Eh2406
Improve git error messages a bit
This commit is targeted at further improving the error messages
generated from git errors. For authentication errors the actual URL
fetched is now printed out as well if it's different from the original
URL. This should help handle `insteadOf` logic where SSH urls are used
instead of HTTPS urls and users can know to track that down.
Otherwise the logic about recommending `net.git-fetch-with-cli` was
tweaked a bit and moved to the same location as the rest of our error
reporting.
Note that a change piggy-backed here as well is that `Caused by:` errors
are now automatically all tabbed over a bit instead of only having the
first line tabbed over. This required a good number of tests to be
updated, but it's just an updated in renderings.
Alex Crichton [Thu, 25 Jun 2020 15:25:52 +0000 (08:25 -0700)]
Improve git error messages a bit
This commit is targeted at further improving the error messages
generated from git errors. For authentication errors the actual URL
fetched is now printed out as well if it's different from the original
URL. This should help handle `insteadOf` logic where SSH urls are used
instead of HTTPS urls and users can know to track that down.
Otherwise the logic about recommending `net.git-fetch-with-cli` was
tweaked a bit and moved to the same location as the rest of our error
reporting.
Note that a change piggy-backed here as well is that `Caused by:` errors
are now automatically all tabbed over a bit instead of only having the
first line tabbed over. This required a good number of tests to be
updated, but it's just an updated in renderings.
bors [Wed, 24 Jun 2020 20:09:07 +0000 (20:09 +0000)]
Auto merge of #8364 - alexcrichton:default-no-master, r=ehuss
Improve support for non-`master` main branches
This commit improves Cargo's support for git repositories whose "main
branch" is not called `master`. Cargo currently pretty liberally assumes
that if nothing else about a git repository is specified then `master`
is the branch name to use. Instead now Cargo has a fourth option as the
desired reference of a repository named `DefaultBranch`. Cargo doesn't
know anything about the actual name of the default branch, it just
updates how git references are fetched internally.
This commit is motivated by news that GitHub is likely to switch away
from the default branch being named `master` in the near future. It
would be a bit of a bummer if from now on everyone had to type
`branch = '...'`, so this tries to improve that!
When #8325 was added, only CARGO_PKG_LICENSE was added. However, the field license [may be empty](https://doc.rust-lang.org/cargo/reference/manifest.html#the-license-and-license-file-fields) if the license_field is filled in.
bors [Tue, 23 Jun 2020 15:18:10 +0000 (15:18 +0000)]
Auto merge of #8323 - naerbnic:add_workspace_metadata_table, r=alexcrichton
Add support for `workspace.metadata` table
Implements feature request #8309
Additionally includes the information in the output of "cargo metadata" through a new top-level field `metadata`, similar to the per-package `metadata` field
bors [Mon, 22 Jun 2020 21:07:37 +0000 (21:07 +0000)]
Auto merge of #8398 - ehuss:clean-reserved-name, r=Eh2406
Fix overzealous `clean -p` for reserved names.
#8210 changed the way `clean -p` worked, but in some ways it is a little too sloppy. If a package has a test named `build`, then it would delete the `build` directory thinking an executable named "build" exists. This changes it so that it does not attempt to delete tests/benches from the uplift directory.
bors [Mon, 22 Jun 2020 00:35:00 +0000 (00:35 +0000)]
Auto merge of #8395 - ehuss:fix-opt-dep-order, r=Eh2406
Fix order-dependent feature resolution.
There is a situation where if you have `pkg/feature` syntax, and `pkg` is an optional dependency, but also a dev-dependency, and the dev-dependency appears before the (optional) normal dependency in the summary, then the optional dependency would not get activated. This is because the feature code used `find` to get the first entry.
Alex Crichton [Mon, 15 Jun 2020 21:06:03 +0000 (14:06 -0700)]
Improve support for non-`master` main branches
This commit improves Cargo's support for git repositories whose "main
branch" is not called `master`. Cargo currently pretty liberally assumes
that if nothing else about a git repository is specified then `master`
is the branch name to use. Instead now Cargo has a fourth option as the
desired reference of a repository named `DefaultBranch`. Cargo doesn't
know anything about the actual name of the default branch, it just
updates how git references are fetched internally.
This commit is motivated by news that GitHub is likely to switch away
from the default branch being named `master` in the near future. It
would be a bit of a bummer if from now on everyone had to type
`branch = '...'`, so this tries to improve that!
bors [Thu, 18 Jun 2020 17:14:16 +0000 (17:14 +0000)]
Auto merge of #8363 - alexcrichton:less-git-data, r=ehuss
Cut down on data fetch from git dependencies
Currently Cargo pretty heavily over-approximates data fetch for git
dependencies. For the index it fetches precisely one branch, but for all
other git dependencies Cargo will fetch all branches and all tags all
the time. In each of these situations, however, Cargo knows if one
branch is desired or if only one tag is desired.
This commit updates Cargo's fetching logic to plumb the desired
`GitReference` all the way down to `fetch`. In that one location we then
determine what to fetch. Namely if a branch or tag is explicitly
selected then we only fetch that one reference from the remote, cutting
down on the amount of traffic to the git remote.
Additionally a bugfix included here is that the GitHub fast path for
checking if a repository is up-to-date now works for non-`master`-based
branch dependencies.
Alex Crichton [Tue, 16 Jun 2020 16:02:01 +0000 (09:02 -0700)]
Update how locked git commits are fetched
This commit refactors various logic of the git source internals to
ensure that if we have a locked revision that we plumb the desired
branch/tag all the way through to the `fetch`. Previously we'd switch to
`Rev` very early on, but the fetching logic for `Rev` is very eager and
fetches too much, so instead we only resolve the locked revision later
on.
Internally this does some various refactoring to try to make various
bits and pieces of logic a bit easyer to grok, although it's still
perhaps not the cleanest implementation.
Alex Crichton [Mon, 15 Jun 2020 20:36:23 +0000 (13:36 -0700)]
Cut down on data fetch from git dependencies
Currently Cargo pretty heavily over-approximates data fetch for git
dependencies. For the index it fetches precisely one branch, but for all
other git dependencies Cargo will fetch all branches and all tags all
the time. In each of these situations, however, Cargo knows if one
branch is desired or if only one tag is desired.
This commit updates Cargo's fetching logic to plumb the desired
`GitReference` all the way down to `fetch`. In that one location we then
determine what to fetch. Namely if a branch or tag is explicitly
selected then we only fetch that one reference from the remote, cutting
down on the amount of traffic to the git remote.
Additionally a bugfix included here is that the GitHub fast path for
checking if a repository is up-to-date now works for non-`master`-based
branch dependencies.
bors [Mon, 15 Jun 2020 14:38:34 +0000 (14:38 +0000)]
Auto merge of #8359 - ehuss:doctest-xcompile-linker, r=alexcrichton
Support linker with -Zdoctest-xcompile.
This adds support for `-Clinker` with `-Zdoctest-xcompile`.
I'm not entirely sure how `-Zdoctest-xcompile` was supposed to work without setting the linker. I tested this with std on arm-unknown-linux-gnueabihf with qemu. It seems to work (although it was quite slow).
bors [Mon, 15 Jun 2020 14:05:10 +0000 (14:05 +0000)]
Auto merge of #8358 - ehuss:fix-target-host-doctest, r=alexcrichton
Fix doctests not running with --target=HOST.
There was a regression in #8167 where `cargo test --target=$HOST` stopped running doctests. This caused doctests to silently stop running in rust-lang/rust (https://github.com/rust-lang/rust/issues/73286). This PR restores the original behavior where `--target=$HOST` behaves as-if it is a normal host test.
There was a discussion about this at https://github.com/rust-lang/cargo/pull/8167#pullrequestreview-402196323, but I think I let it slip through the cracks.
bors [Thu, 11 Jun 2020 22:13:37 +0000 (22:13 +0000)]
Auto merge of #8353 - ehuss:fix-missing-readme, r=alexcrichton
Fix failure with missing readme.
#8277 added implicit README support, but it also rejected parsing any manifest where the README was missing. This causes a problem because the README is often missing in many registry packages (for various reasons).
This removes the validation at parsing time. Cargo has historically not had hard enforcement at the parsing stage. Whether or not the readme exists has always been enforced during publishing. I have added some extra context to the error message, and added a test to that effect.
bors [Thu, 11 Jun 2020 15:34:15 +0000 (15:34 +0000)]
Auto merge of #8349 - ehuss:fix-lto, r=alexcrichton
Some LTO fixes.
This reworks the LTO computation a little to address a few issues:
- `cargo build` in a project with both a lib and bin would not engage the optimization introduced in #8192 where the lib *should* be compiled with `-C linker-plugin-lto` (bitcode only). This happened because the old code was starting root units as `Lto::None`. The solution here is to conditionally choose the starting Lto for roots.
- A project with a dylib dependency would fail to build. It was building the dylib with `-C linker-plugin-lto` which is not valid.
- A project with a bin/lib would build the lib differently based on whether or not it was selected. This changes it so that the lib is built the same. See `lto::between_builds`, where the second build the lib is now fresh.
- Tests/benchmarks of a `lib` target will now support LTO.
- Treats example libs a little more consistently as regular libs.
I scattered some comments throughout, hopefully it's not too difficult to follow.
bors [Tue, 9 Jun 2020 20:03:14 +0000 (20:03 +0000)]
Auto merge of #8277 - tverghis:default-readme, r=alexcrichton
Default values for `readme` if not specified
If the a value for `readme` is not specified in Cargo.toml, we will now check for the existence of files named `README.md`, `README.txt` or `README`. If one does exist, the name of that file will be defaulted in to the manifest for the project.
This behavior can be suppressed if `readme` is set to `false`.
bors [Mon, 8 Jun 2020 14:19:43 +0000 (14:19 +0000)]
Auto merge of #8267 - drmikehenry:prefix, r=alexcrichton
Support `{prefix}` and `{lowerprefix}` markers in `config.json` `dl` key
Hello,
The crates.io-index Git repository uses a nice directory structure to keep individual directory sizes under control.
When mirroring crates.io, it's useful to store crate files in a similar directory structure for the same reasons.
Cargo provides "markers" for use in the `dl` key of the `config.json` file in crates.io-index to allow flexibility in mapping a crate's name and version into a URL for the crate. The marker `{crate}` is replaced by the crate's name, and the marker `{version}` is replaced with the crate's version. The default URL template is `https://crates.io/api/v1/crates/{crate}/{version}/download`.
Currently, if a mirror of crates.io stores crates in a directory structure similar to that of crates.io-index, it's up to the server to construct the directory name from the crate name. This eliminates trivial web servers and `file:` URLs from hosting such a tree of crates.
This pull requests adds two new markers for the `dl` key in `config.json`, allowing Cargo to supply the directory name as part of the URL. The marker `{lowerprefix}` is the same directory name used within crates.io-index; it is calculated from the crate name converted to lowercase. The marker `{prefix}` is similar, but it uses the crate name as-is (without case conversion), which is useful for supporting older versions of Cargo that lack these markers; for example, nginx rewrite rules can easily construct `{prefix}` but can't perform case-conversion to construct `{lowerprefix}`. These new markers will provide implementation flexibility and simplicity for crate mirror servers.
bors [Fri, 5 Jun 2020 16:39:10 +0000 (16:39 +0000)]
Auto merge of #8331 - ehuss:1.45-beta-backport, r=Eh2406
1.45 beta backports
Beta backports for:
* #8290 — Fix fingerprinting for lld on Windows with dylib.
* #8329 — Don't hash executable filenames on apple platforms. (fix macos backtraces)
bors [Fri, 5 Jun 2020 14:31:21 +0000 (14:31 +0000)]
Auto merge of #8329 - ehuss:apple-no-hash, r=alexcrichton
Don't hash executable filenames on apple platforms.
Due to some recent changes to the backtrace crate, backtraces on apple platforms haven't been working (they are missing line/filename information). The reason is that previously libbacktrace would hunt through the directory for any matching file in the `.dSYM` directory. The new implementation expects a file matching the executable name exactly (which no longer includes the hash because Cargo renames it).
The solution here is to not include a hash in the executable filename. This matches the behavior on Windows which does it for a similar reason (paths are embedded in pdb files).
The downside is that switching between different settings (like different features) causes Cargo to rebuild the binary each time. I don't think this is a particularly common use case, at least I've not heard any complaints about this behavior on Windows.
bors [Wed, 27 May 2020 19:33:35 +0000 (19:33 +0000)]
Auto merge of #8290 - ehuss:fix-lld-freshness, r=alexcrichton
Fix fingerprinting for lld on Windows with dylib.
This fixes an issue where if `lld` is used on Windows, dynamic libraries will never be treated as "fresh". This is a regression from #8210 where Cargo is expecting export files to be created, but lld does not create these.
The solution is to ignore "Auxiliary" files in fingerprinting, which AFAIK aren't really needed (only the primary output files really matter).
bors [Fri, 5 Jun 2020 14:31:21 +0000 (14:31 +0000)]
Auto merge of #8329 - ehuss:apple-no-hash, r=alexcrichton
Don't hash executable filenames on apple platforms.
Due to some recent changes to the backtrace crate, backtraces on apple platforms haven't been working (they are missing line/filename information). The reason is that previously libbacktrace would hunt through the directory for any matching file in the `.dSYM` directory. The new implementation expects a file matching the executable name exactly (which no longer includes the hash because Cargo renames it).
The solution here is to not include a hash in the executable filename. This matches the behavior on Windows which does it for a similar reason (paths are embedded in pdb files).
The downside is that switching between different settings (like different features) causes Cargo to rebuild the binary each time. I don't think this is a particularly common use case, at least I've not heard any complaints about this behavior on Windows.
Passing a relative path to Workspace now bails with proper message.
Previously, this failure will return an unhelpful warning.
This commit adds an error message saying that the argument for
`manifest_path` must be an absolute path.
bors [Wed, 3 Jun 2020 15:03:10 +0000 (15:03 +0000)]
Auto merge of #8319 - alexcrichton:fix-access, r=Eh2406
Fix an accidental raw access of field
The manifest has a few different ways of specifying whether a crate is a
procedural macro, and there's a `TomlTarget::proc_macro()` method to
unify these various lines. Unfortunately though we had a bug where one
location forgot to call the method and read the raw field! This led to
surprising behavior where the different ways to specify a proc macro
would have subtly different changes in behavior. The fix here in this PR
is to ensure that we access the property always via the method.
Alex Crichton [Wed, 3 Jun 2020 14:38:21 +0000 (07:38 -0700)]
Fix an accidental raw access of field
The manifest has a few different ways of specifying whether a crate is a
procedural macro, and there's a `TomlTarget::proc_macro()` method to
unify these various lines. Unfortunately though we had a bug where one
location forgot to call the method and read the raw field! This led to
surprising behavior where the different ways to specify a proc macro
would have subtly different changes in behavior. The fix here in this PR
is to ensure that we access the property always via the method.
bors [Tue, 2 Jun 2020 16:35:38 +0000 (16:35 +0000)]
Auto merge of #8307 - pickfire:alias-help, r=alexcrichton
Show alias in help message
Improve feature discovery of help message
Inspired by x.py help https://github.com/rust-lang/rust/issues/71357
Improves https://github.com/rust-lang/cargo/issues/6104
Ivan Tham [Tue, 2 Jun 2020 12:52:00 +0000 (20:52 +0800)]
Show alias in help message
Improve feature discovery of help message
Inspired by x.py help https://github.com/rust-lang/rust/issues/71357
Improves https://github.com/rust-lang/cargo/issues/6104
bors [Mon, 1 Jun 2020 22:35:00 +0000 (22:35 +0000)]
Auto merge of #8297 - mjarkk:warn-when-using-hash-in-git-url, r=ehuss
Warn if using hash in git URL, Fixes #8241
This fixes an issue where if the user wants to set the git rev but doesn't know how and as results tries to set the ref in the url hash as also shown when downloading the dependency.
Now cargo returns a warning notifying the user about the correct way to set the ref.
bors [Mon, 1 Jun 2020 16:01:10 +0000 (16:01 +0000)]
Auto merge of #8274 - Eh2406:8249-repro, r=alexcrichton
reset lockfile information between resolutions
#8249 pointed out that some kind of lockfile data was leaking between calls to the resolver. @ehuss made a reproducing test case. This PR resets the `LockedMap` data structure when calling `register_previous_locks`.