Commit graph

10779 commits

Author SHA1 Message Date
Jade fc5840d175 Fix dep-info files emitting paths relative to deps' roots
Sample `shoo.d` file prior to this change is below, note the `build.rs`
at the end, which was not from my package.

From booping the debugger, I found this was coming from
`compiler_builtins`.  This is not really their bug though: if a build.rs
asks for rerun-if-changed on some crate relative path, this will happen
in general. So I've fixed it in Cargo and added a test to prevent it
regressing.

```
target/riscv64imac-mu-shoo-elf/release/shoo: /home/jade/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/core_arch_docs.md /home/jade/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/macros.rs /home/jade/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/mod.rs /home/jade/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/simd.rs /home/jade/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/simd_llvm.rs crates/build_bits/src/lib.rs shoo/src/main.rs shoo/src/task.rs shoo/src/vectors.s build.rs
```

This change fixes it so it's like:

```
target/riscv64imac-mu-shoo-elf/release/shoo: /home/jade/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.39/build.rs /home/jade/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.14/build.rs /home/jade/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/core_arch_docs.md /home/jade/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/macros.rs /home/jade/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/mod.rs /home/jade/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/simd.rs /home/jade/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/simd_llvm.rs crates/build_bits/src/lib.rs shoo/src/main.rs shoo/src/task.rs shoo/src/vectors.s
```
2021-04-27 05:08:33 -07:00
bors d1baf0d81d Auto merge of #9405 - Hawk777:cargo-pkg-for-build-scripts, r=ehuss
Document that CARGO_PKG_ are availble to build.rs

Fixes GH-9403.
2021-04-24 23:21:19 +00:00
Christopher Head 1624d465ef
Document that CARGO_PKG_ are availble to build.rs 2021-04-24 10:35:39 -07:00
bors 0ed318d182 Auto merge of #9397 - alexcrichton:fix-hash, r=ehuss
Restore crates.io's `SourceId` hash value to before

This commit restores the hash value of the crates.io `SourceId` to what
it was before #9384. In #9384 the enum variants of `SourceKind` were
reordered which accidentally changed the hash value of the `SourceId`
for crates.io. A change here means that users with a new version of
Cargo will have to redownload the index and all crates, which is
something that we strive to avoid forcing.

In changing this, though, it required a manual implementation of `Ord`
to still contain the actual fix from #9384 which is to sort `SourceKind`
differently from how it's defined. I was curious as to why this was
necessary since it wasn't ever necessary in the past and this led to an
odd spelunking which turned up some interesting information. Turns out
Rust 1.47 and after had a breaking change where Cargo would sort
dependencies differently. This means that #9334 *could* have been opened
up much earlier, but it never was. We ironically only saw an issue when
we fixed this regression (although we didn't realize we were fixing a
regression). This means that we are now permanently codifying the
regression in Cargo.
2021-04-23 20:54:54 +00:00
Alex Crichton d99c35c2e3 Clarify some versions 2021-04-23 12:27:19 -07:00
Alex Crichton 4567826e9a Restore crates.io's SourceId hash value to before
This commit restores the hash value of the crates.io `SourceId` to what
it was before #9384. In #9384 the enum variants of `SourceKind` were
reordered which accidentally changed the hash value of the `SourceId`
for crates.io. A change here means that users with a new version of
Cargo will have to redownload the index and all crates, which is
something that we strive to avoid forcing.

In changing this, though, it required a manual implementation of `Ord`
to still contain the actual fix from #9384 which is to sort `SourceKind`
differently from how it's defined. I was curious as to why this was
necessary since it wasn't ever necessary in the past and this led to an
odd spelunking which turned up some interesting information. Turns out
Rust 1.47 and after had a breaking change where Cargo would sort
dependencies differently. This means that #9334 *could* have been opened
up much earlier, but it never was. We ironically only saw an issue when
we fixed this regression (although we didn't realize we were fixing a
regression). This means that we are now permanently codifying the
regression in Cargo.
2021-04-23 12:04:26 -07:00
bors c321437b53 Auto merge of #9392 - alexcrichton:fix-patch-git-head-issue, r=ehuss
Fix loading `branch=master` patches in the v3 lock transition

This commit fixes an issue pointed out during #9352 where in the v2->v3
lock file transition (currently happening on nightly) Cargo will not
correctly use the previous lock file entry for `[patch]` directives that
point to git dependencies using `branch = 'master'` explicitly. The
reason for this is that Cargo previously, with the v2 format, considered
`branch=master` and `DefaultBranch` to be equivalent dependencies. Now
that Cargo treats those as distinct resolve nodes we need to load lock
files that use `DefaultBranch` and transparently use those for
`branch=master` dependencies.

These lock file nodes do not naturally unify so we have to go out of our
way to get the two to line up in modern Cargo. This was previously done
for the lock file at large, but the previous logic didn't take `[patch]`
into account. Unfortunately almost everything to do with `[patch]` and
lock files is pretty complicated, and this is no exception. The fix here
is wordy, verbose, and quite subtle in how it works. I'm pretty sure it
does work though and I think that this should be good enough to at least
transition most users off the v2 lock file format. Once this has baked
in Cargo for some time (on the scale of a year) I would hope that we
could just remove this logic since it's only really here for a
transitionary period.

Closes #9352
2021-04-23 18:45:03 +00:00
bors 4bcbf87e4e Auto merge of #9396 - ehuss:changelog-1.52-beta, r=alexcrichton
Update changelog for 1.52 beta changes.

A few things were reverted on the beta branch.
2021-04-23 16:15:36 +00:00
Eric Huss 06ccdfafec Update changelog for 1.52 beta changes. 2021-04-23 09:10:32 -07:00
bors 02103f9baf Auto merge of #9393 - ehuss:build-std-updating, r=alexcrichton
Fix build-std updating the index on every build.

https://github.com/rust-lang/rust/pull/83776 has caused a problem where build-std will update the index on every build. That PR added `std_detect` from the `stdarch` submodule as a path dependency of `std`. However, since `stdarch` has a workspace of its own, an exclusion had to be added to `Cargo.toml` so that it does not treat `std_detect` as a workspace member (because nested workspaces are not supported).

The problem is that the std `Cargo.lock` file is built thinking that `std_detect` is *not* a workspace member. This means that its dev-dependencies are not included. However, when cargo resolves the std workspace, it doesn't know that `std_detect` should be excluded, so it considers it a workspace member (because it is a path dependency). This means that it expects the dev-dependencies to be in Cargo.lock. Because they are missing, it ends up poisoning the registry and triggering an update:

> poisoning registry `https://github.com/rust-lang/crates.io-index` because std_detect v0.1.5 (/Users/eric/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/stdarch/crates/std_detect) looks like it changed auxv

The solution here is to skip dev-dependencies if they are not actively being resolved, even if the package is a workspace member.

This has happened before (#8962), so I have updated the test to check for it.

There are some alternative solutions I considered:

* Add support for nested workspaces. 😄
* Use a symlink to `std_detect` in the `rust-lang/rust` repository so that it appears to cargo as-if it is "outside" of the stdarch workspace, and thus can be treated like a normal workspace member (and remove the "exclude"). That seems a little hacky.

Fixes #9390
2021-04-23 14:23:21 +00:00
Eric Huss 3b7cb69eed Fix build-std updating the index on every build. 2021-04-22 17:18:26 -07:00
Alex Crichton fe484973f0 Fix loading branch=master patches in the v3 lock transition
This commit fixes an issue pointed out during #9352 where in the v2->v3
lock file transition (currently happening on nightly) Cargo will not
correctly use the previous lock file entry for `[patch]` directives that
point to git dependencies using `branch = 'master'` explicitly. The
reason for this is that Cargo previously, with the v2 format, considered
`branch=master` and `DefaultBranch` to be equivalent dependencies. Now
that Cargo treats those as distinct resolve nodes we need to load lock
files that use `DefaultBranch` and transparently use those for
`branch=master` dependencies.

These lock file nodes do not naturally unify so we have to go out of our
way to get the two to line up in modern Cargo. This was previously done
for the lock file at large, but the previous logic didn't take `[patch]`
into account. Unfortunately almost everything to do with `[patch]` and
lock files is pretty complicated, and this is no exception. The fix here
is wordy, verbose, and quite subtle in how it works. I'm pretty sure it
does work though and I think that this should be good enough to at least
transition most users off the v2 lock file format. Once this has baked
in Cargo for some time (on the scale of a year) I would hope that we
could just remove this logic since it's only really here for a
transitionary period.

Closes #9352
2021-04-22 08:33:03 -07:00
bors a85ae1a276 Auto merge of #9386 - ehuss:ehuss-profile-typo, r=alexcrichton
Fix typo in profile docs
2021-04-21 13:59:34 +00:00
Eric Huss bf6985ba93
Fix typo in profile docs 2021-04-20 17:36:28 -07:00
bors 8dd5336620 Auto merge of #9384 - alexcrichton:fix-order, r=ehuss
Fix disagreement about lockfile ordering on stable/nightly

This commit fixes an issue where the order of packages serialized into a
lock file differs on stable vs nightly. This is due to a bug introduced
in #9133 where a manual `Ord` implementation was replaced with a
`#[derive]`'d one. This was an unintended consequence of #9133 and means
that the same lock file produced by two different versions of Cargo only
differs in what order items are serialized.

With #9133 being reverted soon on the current beta channel this is
intended to be the nightly fix for #9334. This will hopefully mean that
those projects which don't build with beta/nightly will remain
unaffected, and those affected on beta/nightly will need to switch to
the new nightly ordering when it's published (which matches the current
stable). The reverted beta will match this ordering as well.

Closes #9334
2021-04-21 00:13:47 +00:00
bors fb0130cdb3 Auto merge of #9365 - jyn514:rustc-bootstrap-crate-name, r=ehuss
Don't give a hard error when the end-user specifies RUSTC_BOOTSTRAP=crate_name

Fixes https://github.com/rust-lang/cargo/issues/9362.
The whole point of https://github.com/rust-lang/rust/pull/77802/ was to allow specifying this granularly, giving a hard error defeats the point.

I didn't know how to check what targets were reverse-dependencies of build.rs, so I just unconditionally use the library name (and give a hard error for anything else, even if it's the name of one of the binaries). End-users can still opt-in with RUSTC_BOOTSTRAP=1, and no public binaries use RUSTC_BOOTSTRAP=1, so I don't think this a big deal in practice.

<details><summary>Script to verify all crates using RUSTC_BOOTSTRAP=1 have a library</summary>

```sh
curl https://pastebin.com/raw/fGQ97xP6 | cut -d / -f1 | grep -v shnatsel | grep -v cargo- | sed 's#-\([0-9]\)#/\1#' | xargs -i curl -s -I -L "https://docs.rs/{}/" -w "%{http_code}\n" -o/dev/null
```

It should output 20 200s in a row.

</details>

r? `@ehuss` cc `@mark-simulacrum`

I don't know what cargo's policy is for backports, but this should be backported to 1.52.
2021-04-20 23:43:12 +00:00
bors a18936b14c Auto merge of #9369 - PicoJr:fix-9350, r=ehuss
Fix #9350 (cargo build -Z help is missing options)

> Do not merge yet, some options are still undocumented.

Fix #9350 (cargo build -Z help is missing options)

Add a procedural macro to declare `CliUnstable` struct and provide help messages instead of hard-coding help in `src/bin/cargo/cli.rs`

> Flags documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html

Feedback welcome
2021-04-20 21:58:22 +00:00
bors 05d37ae2c0 Fix #9350 (cargo build -Z help is missing options)
> Do not merge yet, some options are still undocumented.

Fix #9350 (cargo build -Z help is missing options)

Add a procedural macro to declare `CliUnstable` struct and provide help messages instead of hard-coding help in `src/bin/cargo/cli.rs`

> Flags documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html

Feedback welcome
2021-04-20 21:58:22 +00:00
Alex Crichton eb6e1b34a4 Fix disagreement about lockfile ordering on stable/nightly
This commit fixes an issue where the order of packages serialized into a
lock file differs on stable vs nightly. This is due to a bug introduced
in #9133 where a manual `Ord` implementation was replaced with a
`#[derive]`'d one. This was an unintended consequence of #9133 and means
that the same lock file produced by two different versions of Cargo only
differs in what order items are serialized.

With #9133 being reverted soon on the current beta channel this is
intended to be the nightly fix for #9334. This will hopefully mean that
those projects which don't build with beta/nightly will remain
unaffected, and those affected on beta/nightly will need to switch to
the new nightly ordering when it's published (which matches the current
stable). The reverted beta will match this ordering as well.

Closes #9334
2021-04-20 13:27:12 -07:00
bors eb5476bd13 Auto merge of #9379 - stanislav-tkach:patch-1, r=Eh2406
an struct -> a struct
2021-04-20 13:01:37 +00:00
Stanislav Tkach ee2a0deece
SemVer Compatibility: an struct -> a struct 2021-04-20 13:07:39 +03:00
bors 905af54996 Auto merge of #9378 - ehuss:help-windows, r=alexcrichton
Handle man pages better on Windows.

If a user has `man` installed on Windows via msys/mingw/etc, then `cargo help <subcommand>` would fail with `No manual entry for C:\Users\User\AppData\Local\Temp\cargo-manlSKwTQ`.  This is because the cygwin universe does not handle windows-style paths and does not auto-translate in this scenario.

The solution here is to run the command from within the temp directory and use a relative path which *should* work on all platforms and environments. I tested on windows (powershell, cmd, and mingw), macos, and linux.

Fixes #9197
2021-04-19 20:48:01 +00:00
Eric Huss 1a3bb390d3 Handle man pages better on Windows. 2021-04-19 12:44:08 -07:00
bors 9ae6d41e33 Auto merge of #9368 - weihanglo:issue-9319, r=ehuss
fix: better error message when dependency/workspace member missing

May fix #9319
2021-04-19 19:15:18 +00:00
bors 2c6e748aeb Auto merge of #9376 - nicolaiunrein:patch-1, r=alexcrichton
Fix typo in book

While reading I found a little typo in the docs and corrected it.
2021-04-19 14:06:38 +00:00
nicolaiunrein 68a1f03e54
Fix typo in book
While reading I found a little typo in the docs and corrected it.
2021-04-19 09:34:03 +02:00
bors 1243c378b9 Auto merge of #9348 - matklad:wrapper-fingerprint, r=ehuss
Don't re-use rustc cache when RUSTC_WRAPPER changes

We cache initial `rustc --version` invocations, to speed up noop builds.

We check the mtime of `rustc` to bust the cache if the complier changed.
However, before this PR, we didn't look at mtimes of `RUSTC_WRAPPER` /
`RUSTC_WORKSPACE_WRAPPER`, so we could've re-use old cache with new
wrapper.
2021-04-18 17:24:23 +00:00
bors 97edf92087 Auto merge of #9372 - weihanglo:missing-split-debuginfo-in-config, r=ehuss
doc: add split-debuginfo doc in config chapter

Follow up for https://github.com/rust-lang/cargo/pull/9224.
2021-04-18 16:56:59 +00:00
Weihang Lo 8b3c9adfc4
doc: add split-debuginfo doc in config chapter 2021-04-18 09:41:22 +08:00
Joshua Nelson 5a7149683f Fix tests 2021-04-17 12:13:30 -04:00
Joshua Nelson 1b36ddc1a4 minor cleanup 2021-04-17 11:36:58 -04:00
Joshua Nelson 236fe8767d Use the library name to decide whether the override should be allowed from the top-level.
If there's no library, give a hard error unless features are
unconditionally allowed with RUSTC_BOOTSTRAP=1.
2021-04-17 11:36:55 -04:00
Joshua Nelson 6d6f466351 Use the crate name instead of the package name
This doesn't work because it uses the name of the build script, which is
always build_script_build. I'm not sure what to change it to - the name
of the library crate could be different than the name of the package,
and there could be multiple different crates being compiled in the same
package.
2021-04-17 10:58:40 -04:00
Joshua Nelson 04fa2f2a3b Don't give a hard error on RUSTC_BOOTSTRAP=crate_name 2021-04-17 10:50:38 -04:00
Weihang Lo 9c0d865389 fix: more error context for missing dep of workspace member 2021-04-17 14:24:29 +08:00
Weihang Lo 832fff8dd1
fix: more context when failed to load workspace member 2021-04-17 13:56:39 +08:00
bors 163097cdd9 Auto merge of #9367 - weihanglo:refactor/remove-CargoResultExt, r=alexcrichton
refactor: remove `CargoResultExt`

All `chain_err` -> `with_context` are done by IDE refactoring.

- Remove `CargoResultExt`.
- Call `format!` instead of `anyhow::format_err!` to reduce unnecessary macro expansions.
e870eac996/src/cargo/util/errors.rs (L12-L18)
2021-04-16 22:05:43 +00:00
bors 57b75970e0 Auto merge of #9363 - ehuss:cargo-env-fingerprint, r=alexcrichton
Track "CARGO" in environment fingerprint.

There is an issue where if a package includes an `env!("CARGO")`, that value is not tracked in the fingerprint. If different cargos are used, it will not rebuild. This changes it so that the path to cargo will be tracked in the fingerprint if the CARGO env var is in the dep-info file.

This came up with rust's build system where it [tracks the env](60158f4a7c/src/bootstrap/config.rs (L574)). If you build rust once, and then change the `cargo` value in `config.toml` and try building again, it would not pick up the change which caused me some confusion.

In theory, cargo could fingerprint this every time, but I figure that could be disruptive and trigger needlessly in some situations.

This diff is a little bigger than I would like for such an obscure case.  As an alternative, I think rustbuild could just print `cargo:rerun-if-env-changed=CARGO`, but I figure this could potentially be useful for other projects.
2021-04-16 21:42:36 +00:00
Weihang Lo 9099b49191
refactor: remove unnecessary anyhow macro calls 2021-04-17 02:57:41 +08:00
Weihang Lo ebca519069
refactor: remove CargoResultExt 2021-04-17 02:13:55 +08:00
Aleksey Kladov f6070b3e3f Don't re-use rustc cache when RUSTC_WRAPPER changes
We cache initial `rustc --version` invocations, to speed up noop builds.

We check the mtime of `rustc` to bust the cache if the complier changed.
However, before this PR, we didn't look at mtimes of `RUSTC_WRAPPER` /
`RUSTC_WORKSPACE_WRAPPER`, so we could've re-use old cache with new
wrapper.
2021-04-16 20:08:11 +03:00
Eric Huss 2551535ea9 Track "CARGO" in environment fingerprint. 2021-04-15 13:54:46 -07:00
bors e870eac996 Auto merge of #9356 - ehuss:clippy-allow, r=Eh2406
Update clippy lint allow set.

This updates the clippy lints to default allow. We would prefer not to take clippy lint PRs at this time as there are a number of false positives and subjective style changes that we would rather not review.

I left a couple lints as `warn` that I have found useful when refactoring.
2021-04-14 20:23:16 +00:00
Eric Huss 376619d176 Update testsuite/main.rs lint comment. 2021-04-13 12:25:13 -07:00
Eric Huss 00f3fc90d1 Update 2018 idioms comment. 2021-04-13 10:02:21 -07:00
Eric Huss 10eb56f2c4 Update clippy lint allow set. 2021-04-13 09:02:07 -07:00
bors 57c512b3df Auto merge of #9338 - tniessen:typo-doc-suport, r=ehuss
Fix 'suport' typo in documentation
2021-04-09 19:19:37 +00:00
Tobias Nießen 4575cbfb36
Fix 'suport' typo in documentation 2021-04-09 20:03:28 +02:00
bors 65d57e6f38 Auto merge of #9328 - ehuss:contrib-typo, r=Eh2406
Fix typo in contrib docs.

😳
2021-04-04 15:07:52 +00:00
Eric Huss 45e5e418f3
Fix typo in contrib docs. 2021-04-03 19:49:16 -07:00