9728 Commits

Author SHA1 Message Date
Eric Huss
d750198a66 Bump to 0.48.0 2020-07-18 09:33:35 -07:00
Eric Huss
c3e422c6b8 Remove embed-bitcode check now that it is on stable. 2020-07-18 09:32:39 -07:00
bors
c004bf938b Auto merge of #8494 - lu-zero:unbreak-cargo-c, r=ehuss
Add back Manifest::targets_mut

It is needed by cargo-c, it was removed in df5cb70e7bc8872216af736f108f5a959a6d2302
2020-07-18 03:14:53 +00:00
bors
2a64ae86b9 Auto merge of #8500 - alexcrichton:build-override-opt-level-0, r=Eh2406
Build host dependencies with opt-level 0 by default

This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.

Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.

The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:

* In some cases build scripts and procedural macros can take quite a
  long time to run!
* Cargo may not build dependencies more than once if they're shared with
  the main build. This only applies to builds without `--target` where
  the same crate is used in the final binary as in a build script.

In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:

    [profile.release.build-override]
    opt-level = 3

or you can configure this via the environment:

    export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3

There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.

At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 20:21:25 +00:00
Alex Crichton
dc4b695f41 Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.

Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.

The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:

* In some cases build scripts and procedural macros can take quite a
  long time to run!
* Cargo may not build dependencies more than once if they're shared with
  the main build. This only applies to builds without `--target` where
  the same crate is used in the final binary as in a build script.

In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:

    [profile.release.build-override]
    opt-level = 3

or you can configure this via the environment:

    export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3

There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.

At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 12:39:41 -07:00
bors
03f084c068 Auto merge of #8497 - alexcrichton:fix-rebuild-on-rename, r=ehuss
Fix freshness checks for build scripts on renamed dirs

This commit fixes an issue in Cargo where when an entire project
directory is renamed (preserving the target directory) then path
dependencies with build scripts would have their build scripts rereun
when building again. The problem with this was that when a build script
doesn't print `rerun-if-changed` Cargo's conservative fingerprint listed
an absolute path in it, which was intended to be a relative path.

The fix here is to use a relative path in the fingerprint to ensure that
it's not the reason a rebuild happens when directories are renamed.
2020-07-17 19:30:46 +00:00
Alex Crichton
64a468261a Fix freshness checks for build scripts on renamed dirs
This commit fixes an issue in Cargo where when an entire project
directory is renamed (preserving the target directory) then path
dependencies with build scripts would have their build scripts rereun
when building again. The problem with this was that when a build script
doesn't print `rerun-if-changed` Cargo's conservative fingerprint listed
an absolute path in it, which was intended to be a relative path.

The fix here is to use a relative path in the fingerprint to ensure that
it's not the reason a rebuild happens when directories are renamed.
2020-07-17 10:07:06 -07:00
Luca Barbato
9c8544a3dc Add back Manifest::targets_mut
It is needed by cargo-c, it was removed in df5cb70e7bc8872216af736f108f5a959a6d2302
2020-07-17 18:16:05 +02:00
bors
0a9f2efd7f Auto merge of #8490 - alexcrichton:std-customize-features, r=ehuss
Add a `-Zbuild-std-features` flag

This flag is intended to pair with `-Zbuild-std` as necessary to
configure the features that libstd is built with. This is highly
unlikely to ever be stabilized in any form (unlike `-Zbuild-std` which
we'd like to stabilize at some point), but can be useful for
experimenting with the standard library. For example today it can be
used to test changes to binary size by disabling backtraces.

My intention is that we won't need a `--no-default-features` equivalent
for libstd, where after rust-lang/rust#74377 is merged we can
unconditionally specify default features are disabled but the default
set of features lists `default`. That way if users want to override the
list *and* include the default feature, they can just be sure to include
`default`.
2020-07-17 15:22:03 +00:00
Alex Crichton
1faf5b9f00 Add a -Zbuild-std-features flag
This flag is intended to pair with `-Zbuild-std` as necessary to
configure the features that libstd is built with. This is highly
unlikely to ever be stabilized in any form (unlike `-Zbuild-std` which
we'd like to stabilize at some point), but can be useful for
experimenting with the standard library. For example today it can be
used to test changes to binary size by disabling backtraces.

My intention is that we won't need a `--no-default-features` equivalent
for libstd, where after rust-lang/rust#74377 is merged we can
unconditionally specify default features are disabled but the default
set of features lists `default`. That way if users want to override the
list *and* include the default feature, they can just be sure to include
`default`.
2020-07-17 07:02:19 -07:00
bors
8aa332deaa Auto merge of #8495 - matthiaskrgr:clippy_v15, r=Eh2406
clippy cleanups

Fixes a couple of clippy warnings.
Ignores clippy::collapsible_if warnings in the future (iirc there were not desired)
clippy::redundant_clone is enabled by default by clippy already.
2020-07-17 13:55:20 +00:00
Matthias Krüger
833ad21d49 fix clippy warnings 2020-07-17 12:31:45 +02:00
Matthias Krüger
d491688d17 clippy lints: redundant_clone is on by default, allow clippy::collapsible_if 2020-07-17 11:56:44 +02:00
bors
b92636f24f Auto merge of #8492 - ehuss:fix-publish-py, r=alexcrichton
Fix self-publish script.

Removes the dry run, since it won't work (verification fails since dependencies aren't actually published).

Also adds a sleep in-between publishing to give the index a moment to update.
2020-07-16 22:26:51 +00:00
Eric Huss
9f79450e0b Fix self-publish script. 2020-07-16 15:21:51 -07:00
bors
136348497d Auto merge of #8491 - alexcrichton:fix-unstable-build-std-config, r=Eh2406
Ensure `unstable.build-std` works like `-Zbuild-std`

This fixes an issue where the deserializer for `-Zbuild-std` was a bit
fancier than the `unstable.build-std` directive.

cc #8393
2020-07-16 17:12:38 +00:00
Alex Crichton
78314caf38 Ensure unstable.build-std works like -Zbuild-std
This fixes an issue where the deserializer for `-Zbuild-std` was a bit
fancier than the `unstable.build-std` directive.

cc #8393
2020-07-16 08:49:04 -07:00
bors
e37b35cc53 Auto merge of #8489 - arlosi:deterministic_metadata, r=alexcrichton
Make `cargo metadata` output deterministic

Uses BTreeMap instead of HashMap for the `cargo metadata` command, ensuring the output is sorted.

The change did not cause a measurable performance impact for running `cargo metadata` on `cargo` itself.

Fixes #8477
2020-07-16 15:35:49 +00:00
Arlo Siemsen
58869e5ce6 Stop ignoring Array ordering Json comparison tests. Update tests to have sorted order. 2020-07-15 16:32:19 -07:00
Arlo Siemsen
18ff915c8a 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.

Fixes #8477
2020-07-15 10:59:44 -07:00
bors
1bc6e45a05 Auto merge of #8467 - alexcrichton:gha, r=ehuss
Switch to github actions

This commit switches our CI from Azure Pipelines to GitHub Actions. The intention here is to follow the "idiomatic" provider of CI for rust-lang, and otherwise GitHub Actions is better integrated with GitHub's UI right now too.

I'll need to tweak bors to actually `@bors: r+` this to have it successfully get merged, but I think it'd be good to get some review first.
2020-07-15 14:45:12 +00:00
Alex Crichton
1ceefa5c47 Switch to github actions 2020-07-15 07:44:50 -07:00
bors
43cf77395c Auto merge of #8476 - Rustin-Liu:rustin-patch, r=ehuss
fix: add space to comments
2020-07-13 17:35:42 +00:00
Rustin-Liu
9ede5267ce fix: refine test 2020-07-11 10:36:49 +08:00
Rustin-Liu
773ab74b87 fix: add space to comments 2020-07-11 00:16:21 +08:00
bors
f35ebafc74 Auto merge of #8393 - ludumipsum:unstable_flags_in_config, r=alexcrichton
Allow configuring unstable flags via config file

# Summary

This fixes #8127 by mapping the `unstable` key in `.cargo/config` to Z flags.

It should have no impact on stable/beta cargo, and on nightlies it gives folks the ability to configure Z flags for an entire project or workspace. This is meant to make it easier to try things like the [new features resolver](https://github.com/rust-lang/cargo/issues/8088) behavior, mtime-on-use, build-std, or timing reports across a whole project.

I've also included a small (but entirely independent) ergonomics change -- treating dashes and underscores identically in Z flags. That's along for the ride in this PR as the last commit, and is included here because it makes for more idiomatic toml file keys (`print_im_a_teapot = yes` vs `print-im-a-teapot = yes`). Please let me know if y'all would prefer that be in a separate PR, or not happen at all.

# Test Plan

Apologies if I've missed anything -- this is my first cargo contrib and I've tried to hew to the contributing guide. If I've slipped up, please let me know how and I'll fix it.

NB. My linux machine doesn't have multilib set up, so I disabled cross tests.

 * `cargo test` passes for each commit in the stack
 * I formatted each commit in the stack with `rustfmt`
 * New tests are included alongside the relevant change for each change
 * I've validated each test by locally undoing the code change they support and confirming failure.
 * The CLI wins, for both enable and disabling Z flags, as you'd expect.

Keys in `unstable` which do not correspond with a Z flag will trigger an error indicating the invalid flag came from a config file read:

```
Invalid [unstable] entry in Cargo config

Caused by:
  unknown `-Z` flag specified: an-invalid-flag
```

If you'd like to see a test case which isn't represented here, I'm happy to add it. Just let me know.

# Documentation

I've included commits in this stack updating the only docs page that seemed relevant to me, skimming the book -- `unstable.md`.
2020-07-09 23:47:33 +00:00
Alex Berghage
d035daae4e Fix tests for handling env key overlaps / errors 2020-07-09 13:12:34 -06:00
Alex Berghage
e49b3aed79 Add tests verifying overlapping prefixes and defaults
These tests demonstrate the current failure mode around
overlapping env keys and inner structs. To some extent this
is a limitation of mapping on to environment variables with
an underscore as both the namespace separator and the
substitute for dashes in flag names in that the mapping is
not strictly one-to-one.
2020-07-09 12:53:42 -06:00
bors
0506d8d5c9 Auto merge of #8427 - davidtwco:terminal-width, r=ehuss
Add support for rustc's `-Z terminal-width`.

This PR continues the work started in #7315, adding support for rustc's `-Z terminal-width` flag, which is used to trim diagnostic output to fit within the current terminal and was added in rust-lang/rust#63402 (with JSON emitter support in rust-lang/rust#73763).

At the time of writing, rust-lang/rust#73763 isn't in nightly, so the test added in this PR will fail, but it should pass tomorrow (I've confirmed that it works with a local rustc build).

cc @estebank
2020-07-09 16:16:56 +00:00
bors
62123e4cff Auto merge of #8473 - alexcrichton:fix-fingerprint-loc, r=ehuss
Avoid colliding with older Cargo fingerprint changes

The fingerprint format Cargo stores changed recently in a way that
older Cargos cannot understand. Unfortunately though older Cargos are
colliding on some compilation units trying to read the new format and
they're bailing out. This commit fixes this issue by ensuring that the
location for fingerprint metadata is different in older Cargos and newer
Cargos.

Fingerprint metadata is always stored in a location with a hash in the
file name. This hash typically includes the hash of rustc's version
information itself, but for units which don't have a `Metadata` it's a
much simpler hash which is much more likely to collide with other
versions of Cargo. The fix in this commit is to extract the metadata
version that we're hashing to a constant, and then also hash it for
generating a filesystem location to house fingerprint data for a unit
that has no `Metadata`.

Closes #8472
Closes #8298
2020-07-09 15:50:43 +00:00
Alex Crichton
15d4960ed1 Avoid colliding with older Cargo fingerprint changes
The fingerprint format Cargo stores changed recently in a way that
older Cargos cannot understand. Unfortunately though older Cargos are
colliding on some compilation units trying to read the new format and
they're bailing out. This commit fixes this issue by ensuring that the
location for fingerprint metadata is different in older Cargos and newer
Cargos.

Fingerprint metadata is always stored in a location with a hash in the
file name. This hash typically includes the hash of rustc's version
information itself, but for units which don't have a `Metadata` it's a
much simpler hash which is much more likely to collide with other
versions of Cargo. The fix in this commit is to extract the metadata
version that we're hashing to a constant, and then also hash it for
generating a filesystem location to house fingerprint data for a unit
that has no `Metadata`.

Closes #8472
2020-07-09 07:51:00 -07:00
David Wood
af924d4ecf
Introduce TtyWidth
This commit introduces a `TtyWidth` enum which enables better handling
of the tty-width on Windows.

Signed-off-by: David Wood <david@davidtw.co>
2020-07-09 10:19:10 +01:00
Alex Berghage
b82281ad94 fix docs to drop reverted change 2020-07-08 22:11:05 -06:00
Alex Berghage
90b9c6a763 fix nightly rustdoc-extern tests 2020-07-08 22:05:52 -06:00
Alex Berghage
782b32bdfa clearer comment on doubleparse of cli flags 2020-07-08 21:33:35 -06:00
Alex Berghage
724273ed25 Minor test fix (error text comparison)
Serde's errors for missing fields are a lil' different than
the ones from our Deserializer.
2020-07-08 21:22:44 -06:00
Alex Berghage
62d62333c0 Revert workaround and patch Deserializer
This patch changes how ConfigMapAccess iterates k/v pairs when
deserializing structs.

Previously we produced keys for exactly the set of fields needed
for a struct, and errored out in the deserializer if we can't find
anything for that field.

This patch makes us produces keys from the union of two sets:

1. All fields that are both needed for the struct and can be found
   in the environment.
2. All fields in the config table.

This change allows serde's codegen to handle both missing and
unknown fields via the usual derive annotations (default or
deny_unknown_fields respectively)
2020-07-08 21:14:47 -06:00
bors
4f74d9b2a7 Auto merge of #8469 - ehuss:long-filename-windows, r=alexcrichton
Disable long_file_names test if not supported on Windows.

This test will fail on Windows if Cargo's target directory is over 80 characters long (as it is in rust's CI).
2020-07-08 17:13:00 +00:00
Eric Huss
35758d2c92 Disable long_file_names test if not supported on Windows. 2020-07-08 16:57:40 -07:00
David Wood
4177f66fd2
Add documentation for -Z terminal-width
This commit adds relevant documentation for the `-Z terminal-width`
flag.

Signed-off-by: David Wood <david@davidtw.co>
2020-07-08 10:56:49 +01:00
David Wood
6d740aa2e6
Make -Z terminal-width opt-in.
This commit modifies the parsing of `-Z terminal-width` so that it can
optionally take a value and only uses `accurate_err_width` when the user
does not provide a value - therefore making the emission of `-Z
terminal-width` opt-in.

Signed-off-by: David Wood <david@davidtw.co>
2020-07-08 10:56:47 +01:00
Esteban Küber
c46b9a70bd
Add support for rustc's -Z terminal-width.
This commit adds support for rustc's `-Z terminal-width` flag, which is
used to trim diagnostic output to fit within the current terminal.

Co-authored-by: David Wood <david@davidtw.co>
Signed-off-by: David Wood <david@davidtw.co>
2020-07-08 10:56:45 +01:00
Alex Berghage
08f1020f48 Drop broken test asserting invalid configs error on nightly
The current behavior, with the default-false workaround in place,
is not able to identify extra members of the `unstable` table, so
it can't error on unexpected members.

I'll add this test back in with a Deserializer refactor to clean up
the extra logic added to CliUnstable.
2020-07-07 23:38:26 -06:00
Alex Berghage
c532c4964e Treat all CliUnstable values as default-false
This is a workaround in case y'all would like to land this change
before I'm able to finish up a Deserializer refactor.
2020-07-07 23:38:26 -06:00
Alexander Berghage
14c32d4911 [fixup] use single-line serde annotations 2020-07-07 23:38:26 -06:00
Alexander Berghage
bd938f077d Switch unstable config parsing to serde
Tests are currently failing, looks like there's something in the
Deserializer impl that's forcing field-missing errors even when
the serde `default` annotation is applied.
2020-07-07 23:38:26 -06:00
Alexander Berghage
48a6f59ec3 Revert misfeatures
Per comments on the PR, a couple changes need to be backed out.
2020-07-07 23:38:26 -06:00
Alex Berghage
6d7421cacb Clarify CliUnstable::parse/update_with_table
These masquerade like construction functions, but they're
in-place mutators since they're meant to be used one after
another in a precedence chain.
2020-07-07 23:38:26 -06:00
Alex Berghage
c60da96b51 Update src/doc/src/reference/unstable.md
Co-authored-by: Eric Huss <eric@huss.org>
2020-07-07 23:38:26 -06:00
Alex Berghage
9cb1ef88b6 Allow both dashes and underscores for Z flags
This makes it a little easier to match whatever
the natural formatting is for where you're setting
unstable options -- CLI or config file.
2020-07-07 23:38:26 -06:00