Commit graph

10441 commits

Author SHA1 Message Date
Chris Field 8b80e52ca8 Add multitarget test
Using the multitarget feature to print the configuration of multiple
compiler target configurations, a test is created.
2021-02-21 19:50:21 -05:00
Chris Field de340a2ef6 Add first test
Not sure how to handle running the test on different hosts, so the first
test is explicit about the compile target to print the configuration.
2021-02-21 19:35:33 -05:00
Chris Field 8ce7633a65 Fix warning with unused import 2021-02-20 10:40:08 -05:00
Chris Field fa8e9ae931 Change to forwarding rustc stdio to cargo
The `exec_with_output` function and subsequent writing to stdout and
stderr is replaced with the `exec` function that inherits the stdio
streams from Cargo is used.

Weirdly, I originally tried to use the `exec` function but I go no
output. The `cargo run -- rustc --print cfg` appear to just hang. So, I
switched to using the `exec_with_output` function. Now, the `exec`
function appears to work and it is much simplier. There must have been
something else going on with my system at the time.
2021-02-20 10:35:27 -05:00
Chris Field 39fb01c2a2 Change to use TargetInfo type
The `TargetInfo` type, but more specifically the `TargetInfo::new`
method is used instead of the making the `env_args` function public and
using it.

This means the `env_args` function can go back to being private, too.
2021-02-10 19:30:21 -05:00
Chris Field 2aa4fba820 Change scope of function
The `output_err_info` function can be private now that the
implementation for the `cargo rustc --print <FOO>` command has changed
to not capture the output.
2021-02-10 19:10:14 -05:00
Chris Field f32f72f456 Fix missing import 2021-02-09 20:31:41 -05:00
Chris Field 37065f08fc Merge branch 'master' of https://github.com/rust-lang/cargo into feature-rustc-cfg-argument 2021-02-09 19:41:54 -05:00
Chris Field a8fffa827b Merge branch 'feature-rustc-cfg-argument' of https://github.com/volks73/cargo into feature-rustc-cfg-argument 2021-02-09 19:41:27 -05:00
bors 46bac2dc44 Auto merge of #9133 - alexcrichton:git-default-branch, r=ehuss
Change git dependencies to use `HEAD` by default

This commit follows through with work started in #8522 to change the
default behavior of `git` dependencies where if not branch/tag/etc is
listed then `HEAD` is used instead of the `master` branch. This involves
also changing the default lock file format, now including a `version`
marker at the top of the file notably as well as changing the encoding
of `branch=master` directives in `Cargo.toml`.

If we did all our work correctly then this will be a seamless change.
First released on stable in 1.47.0 (2020-10-08) Cargo has been emitting
warnings about situations which may break in the future. This means that
if you don't specify `branch = 'master'` but your HEAD branch isn't
`master`, you've been getting a warning. Similarly if your dependency
graph used both `branch = 'master'` as well as specifying nothing, you
were receiving warnings as well. These two situations are broken by this
commit, but it's hoped that by giving enough times with warnings we
don't actually break anyone in practice.
2021-02-09 23:42:27 +00:00
Chris Field c86864ba2f Fix missing import after merge 2021-02-09 13:26:46 -05:00
Chris Field a740608352 Merge branch 'master' of https://github.com/rust-lang/cargo into feature-rustc-cfg-argument
# Conflicts:
#	src/cargo/ops/cargo_compile.rs
2021-02-09 13:20:32 -05:00
Christopher Field d0b15d432f
Merge branch 'master' into feature-rustc-cfg-argument 2021-02-09 13:09:31 -05:00
Chris Field d7034c6021 Fix formatting 2021-02-09 13:07:37 -05:00
Chris Field 5a24ad1732 Change println macro to drop_println
I figured out the error was me improperly using the macro. CI build
failed because `println` macro is not allowed in Cargo codebase.
2021-02-09 13:06:02 -05:00
Alex Crichton 9f2ce1ffef Squash warnings on the nightly channel 2021-02-09 07:30:08 -08:00
Alex Crichton 1fefa5de26 Add back in deleted tests 2021-02-09 07:29:01 -08:00
Chris Field a05dac35cb Remove duplicate check for empty kinds 2021-02-08 21:42:21 -05:00
Chris Field 2cd5d9dfe1 Change to enumerate implementation
Only printing an empty line after the first target output is changed to
use the `enumerate` method on an Iterator with a non-zero index.

I could not get the `drop_println` macro to compile. Something about the
`shell` missing. The standard library `println` macro seems work fine.
2021-02-08 21:35:13 -05:00
Chris Field 2f985aec30 Remove unnecessary arguments and env removal 2021-02-08 21:20:32 -05:00
Chris Field db77c3165a Fix warnings 2021-02-08 21:18:07 -05:00
Chris Field bf3ed17fca Remove cache output and error handling
Error handling is done by rustc and the stderr is simply printed. The
`rustc --print <FOO>` command is always executed instead of using the
cache.
2021-02-08 21:14:57 -05:00
bors 9140c546fe Auto merge of #9152 - dzmitry-lahoda:patch-1, r=Eh2406
appendix auth gcm link to new repo (which is xplat)
2021-02-08 16:20:08 +00:00
Dzmitry Lahoda 5a0226d9bd
gcm link to new repo (which is xplat) 2021-02-08 19:13:07 +03:00
bors 56e0df699d Auto merge of #9148 - bjorn3:fix_ci, r=ehuss
Fix warnings of the new non_fmt_panic lint

This fixes the CI failure since the latest nightly. See https://github.com/rust-lang/rust/pull/81645
2021-02-06 19:12:01 +00:00
bjorn3 f5a3d55983 Fix warnings of the new non_fmt_panic lint 2021-02-06 19:10:42 +01:00
bors 90b6fa8634 Auto merge of #9142 - ehuss:fix-doc-orphan, r=Eh2406
Fix panic with doc collision orphan.

As I feared, the collision removal added in #9077 caused problems due to orphans left in the unit graph. Ironically, it was the collision warning detection code which failed, as it iterates over all the keys of the graph.

The solution is to remove all orphans from the graph after collisions have been removed.

Fixes #9136
2021-02-05 18:11:29 +00:00
Eric Huss 5ebb605c9a Fix panic with doc collision orphan. 2021-02-05 10:02:34 -08:00
Alex Crichton c4b53c956f Fix a bug loading v2 lockfiles
This commit fixes a bug in Cargo where after `DefaultBranch` and
`Branch("master")` are considered distinct no v2 lockfile would by
default match a dependency specification with the `branch = 'master'`
annotation. A feature of the v2 lockfile, however, is that no mention of
a branch is equivalent to the `master` branch.

The bug here is fixed by updating the code which registers a previous
lock file with our `PackageRegistry`. This code registers nodes, only
with v2 lock files, for both default and `master` branch git
dependencies. This way requests for either one will get matched now that
they're considered distinct.
2021-02-04 10:44:01 -08:00
Alex Crichton 7dd9872c13 Change git dependencies to use HEAD by default
This commit follows through with work started in #8522 to change the
default behavior of `git` dependencies where if not branch/tag/etc is
listed then `HEAD` is used instead of the `master` branch. This involves
also changing the default lock file format, now including a `version`
marker at the top of the file notably as well as changing the encoding
of `branch=master` directives in `Cargo.toml`.

If we did all our work correctly then this will be a seamless change.
First released on stable in 1.47.0 (2020-10-08) Cargo has been emitting
warnings about situations which may break in the future. This means that
if you don't specify `branch = 'master'` but your HEAD branch isn't
`master`, you've been getting a warning. Similarly if your dependency
graph used both `branch = 'master'` as well as specifying nothing, you
were receiving warnings as well. These two situations are broken by this
commit, but it's hoped that by giving enough times with warnings we
don't actually break anyone in practice.
2021-02-04 08:54:40 -08:00
bors 34170fcd6e Auto merge of #9131 - ehuss:fix-vendor-permissions, r=alexcrichton
Fix permission issue with `cargo vendor`.

I think there was an unintended regression in #8937 where the vendored output does not retain the original permissions.

Fixes #9127.
2021-02-04 15:52:52 +00:00
Eric Huss 33f648ab3b Fix permission issue with cargo vendor. 2021-02-03 17:37:00 -08:00
bors aaaf296ab7 Auto merge of #9112 - alexcrichton:split-debuginfo, r=ehuss
Add split-debuginfo profile option

This commit adds a new `split-debuginfo` option to Cargo compilation
profiles which gets forwarded to the `-Csplit-debuginfo` codegen option
in rustc. This commit also sets the default, only on macOS, to be
`-Csplit-debuginfo=unpacked`. The purpose of this change is to leverage
rust-lang/rust#79570 to avoid running `dsymutil` on incremental builds
while also preserving a pleasant debugging experience by default. This
should lead to much faster incremental build times on macOS since
`dsymutil` isn't exactly the speediest tool in the world.

This is technically a breaking change in Cargo because we're no longer
by-default producing the `*.dSYM` folders on macOS. If those are still
desired, however, authors can always run `dsymutil` themselves or
otherwise configure `split-debuginfo = 'packed'` in their
manifest/profile configuration.
2021-02-03 22:50:15 +00:00
Alex Crichton ffa9dbd348 Don't change the macOS default just yet 2021-02-03 14:06:41 -08:00
bors 537dc099d3 Auto merge of #9126 - ehuss:registry-builder, r=alexcrichton
Add RegistryBuilder for tests, and update crates-io error handling.

This adds `RegistryBuilder` to the test suite to make it more flexible to create different registry setups, and to reuse code a little more easily.

This also makes a small adjustment to the registry API to add a `ResponseError` type to make it easier to work with API errors.  As part of this, some tests were added to validate the API behavior for response errors.  There are only a few very small changes here:
* Extra newlines are removed from the headers printed in the error message.
* The UTF-8 error now also includes the text "invalid response from server".
* The "file too large" crates.io publish error now displays the tarball size.  (There is no test for this because it is only issued for talking to `crates.io`.)

Split from #9111.
2021-02-03 15:56:05 +00:00
bors 398514abd6 Auto merge of #9125 - ehuss:index-docs, r=alexcrichton
Add some documentation for index and registry stuff.

This adds some internal docs for index and registry things.

Split out of #9111.
2021-02-03 15:21:05 +00:00
bors 3875bbbba4 Auto merge of #9122 - ehuss:fix-multiple-run-custom-build, r=alexcrichton
Fix env/cfg set for `cargo test` and `cargo run`.

There are some situations where a build script may need to run multiple times for the same package during the same `cargo` session.  There was a bug in that some of the values in the `Compilation` struct didn't handle this case.  The solution here is to be more careful about how this extra data is associated with `Unit`s, instead of assuming a package's build script only runs once.

The things that were not being handled properly:

* `Compilation::extra_env`, which is the output of `cargo:rustc-env` in build scripts.  The solution here is to use the `Metadata` hash which is used elsewhere for distinguishing build script outputs.
* `Compilation::cfgs`, which is the output of `cargo:rustc-cfg` in build scripts and the features to be set, and this is only used for doctests.  The solution here is to just add those `--cfg` flags directly in the `Doctest` struct.

The situations that cause a build script to be run multiple times:

* A package needed for both the host and target.  In the test here, this was accomplished with a proc-macro (which has to be `host`) and a cyclical dev dependency, but there are many other ways to trigger this.
* Something built with different features (with the new feature resolver), usually due to host/target differences.
* Something built with different profile settings, usually due to host/target differences.

Fixes #9100
2021-02-03 02:09:41 +00:00
Eric Huss 1607a68e92 Add note about cargo:rustc-env variables set at runtime. 2021-02-02 18:07:12 -08:00
Eric Huss 06b8d1cac1 Add a ResponseError for registry API interaction.
The intent here is to make it easier to work with API errors.

This also includes some new tests for checking network errors.
2021-02-02 17:44:57 -08:00
Eric Huss 340656e29d Add RegistryBuilder to help initializing test registries.
The intent here is to make it more flexible to create different registry
setups, and to reuse code a little more easily.
2021-02-02 15:48:48 -08:00
Eric Huss 838e538420 Add some documentation for index and registry stuff. 2021-02-02 15:48:09 -08:00
Eric Huss d8673d93d2 Fix env/cfg set for cargo test and cargo run. 2021-02-01 19:20:54 -08:00
Alex Crichton cc5e9df64a Cache failures in the rustc info cache
This commit updates the rustc info cache to cache failures to execute
rustc as well as successes. This fixes a weird issue where if you're
probing for flags the `rustc_info_cache` test fails on channels which
don't have the flag since previously a failure to execute rustc resulted
in never caching the result.
2021-02-01 11:29:25 -08:00
Alex Crichton ed4568e108 Add split-debuginfo profile option
This commit adds a new `split-debuginfo` option to Cargo compilation
profiles which gets forwarded to the `-Csplit-debuginfo` codegen option
in rustc. This commit also sets the default, only on macOS, to be
`-Csplit-debuginfo=unpacked`. The purpose of this change is to leverage
rust-lang/rust#79570 to avoid running `dsymutil` on incremental builds
while also preserving a pleasant debugging experience by default. This
should lead to much faster incremental build times on macOS since
`dsymutil` isn't exactly the speediest tool in the world.

This is technically a breaking change in Cargo because we're no longer
by-default producing the `*.dSYM` folders on macOS. If those are still
desired, however, authors can always run `dsymutil` themselves or
otherwise configure `split-debuginfo = 'packed'` in their
manifest/profile configuration.
2021-02-01 09:21:36 -08:00
bors e099df243b Auto merge of #9108 - CPerezz:locked_warn, r=alexcrichton
Impl warn for locked install without Cargo.lock

If we're installing in --locked mode and there's no `Cargo.lock` published
ie. the bin was published before https://github.com/rust-lang/cargo/pull/7026
the cargo install errors were not stating that it was due to the lack of
the `Cargo.lock` file. Instead, the error seemed completely unrelated.

Therefore, this tries to address this by adding a warn in the stderr
output.

Closes #9106

I will need some help on the testing side (assuming the code I added for the warning is correct).
It looks to me that the publish function implemented for testing purposes does not publish `Cargo.lock` which is the actual convention. Should this be updated too? See  #7026
2021-02-01 16:24:34 +00:00
bors c6f2815698 Auto merge of #9121 - vext01:extra-link-arg-doc, r=alexcrichton
Document -Z extra-link-arg.

Whilst reading the cargo source code, I encountered `-Z extra-link-arg`. I'd missed this flag before because it is not documented in `-Z help`.

This commit adds the one-liner documentation.

([This argument **is** mentioned in the unstable cargo book](https://doc.rust-lang.org/beta/cargo/reference/unstable.html#extra-link-arg))
2021-02-01 15:39:10 +00:00
bors 4e4490f337 Auto merge of #9120 - dimo414:patch-1, r=alexcrichton
Flip 'foo' and 'bar' to be consistent

The "Renaming dependencies" section initially uses 'foo' as the crate name and 'bar' as a rename, but then swaps them and uses 'bar' as the example crate name in the context of optional dependencies. Now both examples in this section treat 'foo' as the original crate name.
2021-02-01 15:06:07 +00:00
Edd Barrett 0b515f38b0 Document -Z extra-link-arg. 2021-02-01 14:51:50 +00:00
Michael Diamond 2663d7d3af
Flip 'foo' and 'bar' to be consistent
The "Renaming dependencies" section initially uses 'foo' as the crate name and 'bar' as a rename, but then swaps them and uses 'bar' as the example crate name in the context of optional dependencies. Now both examples in this section treat 'foo' as the original crate name.
2021-01-31 23:27:56 -08:00
bors c5f7fa1bdb Auto merge of #9115 - djc:fix-msrv-handling, r=ehuss
Don't try to parse MSRV if feature is not enabled

`@ehuss` is something like this what you had in mind? Should we add tests to make sure this works correctly?
2021-01-30 22:50:11 +00:00