Commit graph

3363 commits

Author SHA1 Message Date
Eric Huss b64d0f3645 Don't use debug display for error object. 2020-04-15 17:29:19 -07:00
Eric Huss 75e7b41823 Fix nightly test matching rustc "warning" output. 2020-04-12 21:09:39 -07:00
bors 53b1c48a51 Auto merge of #8087 - ehuss:freshness-interrupted2, r=alexcrichton
Fix freshness when linking is interrupted.

Fixes a scenario where hitting Ctrl-C while linking would leave a corrupted executable, but Cargo would think it is "fresh" and fail to rebuild it.

This also includes a separate commit which adds more documentation on fingerprinting.

Fixes #7767
2020-04-10 16:33:24 +00:00
bors 7d720ef051 Auto merge of #8062 - ehuss:tree, r=alexcrichton
Add `cargo tree` command.

This migrates [cargo-tree](https://github.com/sfackler/cargo-tree/) into Cargo as a built-in command. This is based on a recent master (4108d216ec), and should be mostly similar in functionality. There are a variety changes:

* `--all-targets` renamed to `--no-filter-targets` to avoid confusion with the `--all-targets` flag used in other Cargo commands with a different meaning.
* `--all`/`-a` renamed to `--no-dedupe` to avoid confusion with the `-all` flag which means "all workspace crates" in other Cargo commands.
* `--duplicate` renamed to `--duplicates` (with alias), just a personal preference.
* Added support for multiple roots (workspace support).
* Added the `--graph-features` flag for including features in the graph (to "explain" why a feature is enabled).
* Added `{f}` to format string to show features.
* Handles new feature resolver.
* Handles cyclical dev dependencies.
* Added a test suite.
* Dropped the dependency on petgraph, in favor of a simpler custom graph.

Closes #7286.
2020-04-09 19:53:41 +00:00
bors 239f2bfd0c Auto merge of #8069 - ehuss:build-finished, r=alexcrichton
Add "build-finished" JSON message.

This adds a JSON message when a build is finished.  This is useful for tools to know when to stop parsing JSON, which is particularly useful for commands like `cargo test` or `cargo run` where additional output may follow.

Closes #7978
2020-04-09 19:34:39 +00:00
Eric Huss cd396f340a Fix freshness when linking is interrupted. 2020-04-09 08:46:14 -07:00
bors 3a976c1767 Auto merge of #8074 - ehuss:package-features2, r=alexcrichton
Extend -Zpackage-features with more capabilities.

This is a proposal to extend `-Zpackage-features` with new abilities to change how features are selected on the command-line.  See `unstable.md` for documentation on what it does.

I've contemplated a variety of ways we could transition this to stable. I tried a few experiments trying to make a "transition with warnings" mode, but I'm just too concerned about breaking backwards compatibility.  The current way is just fundamentally different from the new way, and I think it would be a bumpy ride to try to push it.

The stabilization story is that the parts of this that add new functionality (feature flags in virtual worskpaces, and `member/feat` syntax) can be stabilized at any time.  The change for `cargo build -p member --features feat` in a different member's directory can maybe be part of `-Zfeatures` stabilization, which will need to be opt-in.  I've been trying to come up with some transition plan, and I can't think of a way without making it opt-in, and making it part of `-Zfeatures` is an opportunity to simplify things.  One concern is that this might be confusing (`--features` flag could behave differently in different workspaces, and documenting the differences), but that seems hard to avoid.

Closes #6195
Closes #4753
Closes #5015
Closes #4106
Closes #5362
2020-04-09 15:43:07 +00:00
bors 1e6ed94ad7 Auto merge of #8090 - mbStavola:invalid-dep-naming, r=alexcrichton
Disallow invalid dependency names through crate renaming

resolves #6656

As suggested in the issue, I simply checked the dep names by calling `validate_package_name` on the dependencies during the TOML deserialization process.

It might be a bit too strict (and sudden) to error out in this case, so it might be best to convert this into a warning instead. However, this _is_ pretty invalid behavior so I'm not too sure really.
2020-04-09 15:26:04 +00:00
bors da54d6b219 Auto merge of #8073 - ehuss:hash-channel, r=alexcrichton
Use the same filename hash for pre-release channels.

This changes it so that filenames do not hash the entire verbose version from rustc if they are a pre-release version. The intent is to avoid leaving stale artifacts in the target directory whenever someone updates a nightly or beta release. This should help reduce disk space usage for someone who updates these toolchains frequently.

I tested with the rustc repo, and it seems to be OK. It keeps everything in separate target directories, so I think it should be generally safe. This should only affect someone switching between different nightlies and wanting to avoid recompiling when switching back. I suspect that is a rare use case, though if there are complaints this can be easily reverted (or made a config option). cargo-bisect-rustc should also be safe since it uses a different target directory for each toolchain.

One concern here for me was incremental support. It looks like ([src](6387b09153/src/librustc_incremental/persist/file_format.rs (L88-L100))) the incremental cache includes the detailed rustc version, so I think that is safe. It also looks like it is [smart enough](6387b09153/src/librustc_incremental/persist/load.rs (L40-L49)) to delete stale files.

We will need to be more careful in the future when changing the target directory structure or the format of files. We previously relied on the fact that each new nightly will use different filenames. If we change the structure in a backwards-incompatible way, we will need to be careful to update the version (`1.hash` in `compute_metadata`).
2020-04-09 14:25:08 +00:00
Matt Stavola fcff51b3e0
Add test for bad renaming 2020-04-08 23:46:30 -07:00
Eric Huss 54ace8af65 Merge -Zpackage-features2 and -Zpackage-features. 2020-04-08 14:06:09 -07:00
Rocco 79c8ae8299
Compatibility for rust-lang/rust#69926 2020-04-07 15:23:43 +02:00
Eric Huss 6e3f35b20a Use the same filename hash for pre-release channels. 2020-04-05 13:46:37 -07:00
Eric Huss c889bbfba8 Add "build-finished" JSON message. 2020-04-04 18:56:50 -07:00
Eric Huss c17bfcbdb2 Implement -Zpackage-features2 2020-04-04 18:04:03 -07:00
Eric Huss 7c403447bd Switch --invert to take the package name as an argument. 2020-04-03 19:52:21 -07:00
Eric Huss 96ff434cb9 Rename --dep-kinds to --edges and fold in --graph-features. 2020-04-03 19:16:39 -07:00
Eric Huss 3b1df3a46f Change --no-dev-dependencies to --dep-kinds. 2020-04-02 15:12:17 -07:00
Eric Huss ec5e297b70 Change --no-filter-targets to --target=all. 2020-04-02 12:20:55 -07:00
Eric Huss a9ff02ed5a Change --no-indent and --prefix-depth to a single --prefix option. 2020-04-02 11:48:52 -07:00
Eric Huss e1c95e2f42 Fix tree format parsing for bare } 2020-04-02 11:31:39 -07:00
Eric Huss 6868215982 Don't show (*) deduplicate if a node doesn't have any dependencies to show. 2020-04-02 11:25:20 -07:00
Eric Huss 9dc56c6280 Deduplicate nodes across roots. 2020-04-02 11:09:06 -07:00
Alex Crichton bac300bda0 Add support for -Cembed-bitcode=no
This commit is the Cargo half of support necessary for
rust-lang/rust#70458. Today the compiler emits embedded bytecode in
rlibs by default, but compresses it. This is both extraneous disk space
and wasted build time for almost all builds, so the PR in question there
is changing rustc to have a `-Cembed-bitcode` flag which, when enabled,
places the bitcode in the object file rather than an auxiliary file (no
extra compression), but also enables `-Cembed-bitcode=no` to disable
bitcode emission entirely.

This Cargo support changes Cargo to pass `-Cembed-bitcode=no` for almost
all compilations. Cargo will keep `lto = true` and such working by not
passing this flag (and thus allowing bitcode to get embedded), but by
default `cargo build` and `cargo build --release` will no longer have
any bitcode in rlibs which should result in speedier builds!

Most of the changes here were around the test suite and various
assertions about the `rustc` command lines we spit out. One test was
hard-disabled until we can get `-Cembed-bitcode=no` into nightly, and
then we can make it a nightly-only test. The test will then be stable
again once `-Cembed-bitcode=no` hits stable.

Note that this is intended to land before the upstream `-Cembed-bitcode`
change. The thinking is that we'll land everything in rust-lang/rust all
at once so there's no build time regressions for anyone. If we were to
land the `-Cembed-bitcode` PR first then there would be a build time
regression until we land Cargo changes because rustc would be emitting
uncompressed bitcode by default and Cargo wouldn't be turning it off.
2020-04-01 14:31:06 -07:00
Eric Huss 96a393719b Add cargo tree command. 2020-03-31 15:14:47 -07:00
Eric Huss 6dcc25c9a6 Remove clippy tests. 2020-03-29 14:46:27 -07:00
Eric Huss 86ee8cecd3 Fix -Zfeatures=itarget with certain host dependencies 2020-03-27 14:58:03 -07:00
bors 1e2f8dbf7b Auto merge of #8020 - xiongmao86:issue7853, r=ehuss
Checking for binary that is built as an implicit dependency of an integration test.

When a project containing binary with required-features, the binary will only be built with the given dependency's feature is enabled. But this feature syntax is not checked when the binary is built as an implicit dependency of an integration test. This pr addresses this issue.

More info is in the issue page: this pr fixes #7853.
2020-03-27 18:35:48 +00:00
xiongmao86 f1d46e3bca Testing for binary built as an implicit dependency. 2020-03-27 18:15:38 +08:00
Alex Tokarev d3b9d89a38 Use stabilized version of rustdoc's --crate-version
Since --crate-version flag of rustdoc was stabilized, there is no need to enable its unstable features when using it.
2020-03-26 01:17:45 +03:00
bors 8a0d4d9c9a Auto merge of #8028 - ehuss:new-proc-macro-decouple, r=alexcrichton
Re-implement proc-macro feature decoupling.

This is essentially a rewrite of #8003. Instead of adding proc-macro to the index, it uses a strategy of downloading all packages before doing feature resolution. Then the package can be inspected for the proc-macro field.

This is a fairly major change. A brief overview:
- `PackageSet` now has a `download_accessible` method which tries to download a minimal set of every accessible package. This isn't very smart right now, and errs on downloading too much. In most cases it should be the same (or nearly the same) as before. It downloads extra in the following cases:
    - The check for `[target]` dependencies checks both host and target for every dependency. I could tighten that up a little so build dependencies only check for the host, but it would add some complexity and I wanted to get feedback first.
    - Optional dependencies disabled by the new feature resolver will get downloaded.
- Removed the loop in computing unit dependencies where downloading used to reside.
- When downloading starts, it should now show a more accurate count of how many crates are to be downloaded. Previously the count would fluctuate while the graph is being built.
2020-03-24 17:57:04 +00:00
Eric Huss 944f5049f1 Re-implement proc-macro feature decoupling. 2020-03-22 15:08:02 -07:00
Eric Huss b112255f37 Fix bug with -Zfeatures=dev_dep and check --profile=test. 2020-03-22 10:58:10 -07:00
bors 03d7154e77 Auto merge of #8017 - aleksator:3672_color_build_script_warnings_on_panic, r=ehuss
Print colored warnings when build script panics

Fixes #3672
2020-03-18 19:35:24 +00:00
Alex Tokarev 590c803ff1 Print colored warnings when build script panics
Fixes #3672
2020-03-18 22:08:17 +03:00
Alex Tokarev c9e3141b0f Do not supply --crate-version flag to rustdoc if present in RUSTDOCFLAGS or extra compiler arguments 2020-03-18 21:26:49 +03:00
bors 92d0ce8069 Auto merge of #8003 - ehuss:proc-macro-index, r=alexcrichton
Add proc-macro to index, and new feature resolver.

This adds the "pm" field to the index so that Cargo can detect which packages contain a proc-macro without downloading the package.

The second commit builds on that to support proc-macros in the new "de-unification" of the new feature resolver. This prevents dependencies shared between proc-macros and other dependency kinds from having features unified.

cc #7915
2020-03-18 14:00:07 +00:00
Eric Huss 51f3253238 Fix config profiles using "dev" in cargo test. 2020-03-17 10:29:27 -07:00
Eric Huss 0b115f57aa -Zfeatures=host_dep: Support decoupling proc-macro features. 2020-03-15 15:59:42 -07:00
Eric Huss aa80a984c0 Add unit-graph JSON output. 2020-03-15 15:16:36 -07:00
Eric Huss 5a1862cd36 Add proc-macro to the index. 2020-03-15 10:10:25 -07:00
bors 7302186d7b Auto merge of #7533 - yaahc:clippy-banishment, r=ehuss
Close the front door for clippy but open the back
2020-03-14 20:50:15 +00:00
Eric Huss ac79b537e1 Bump to 0.45.0. 2020-03-13 19:31:06 -07:00
Jane Lusby d9a77ce0d0 fix unix cfg on include 2020-03-13 15:31:33 -07:00
Jane Lusby 76797b5c2a switch from bash script to rust program 2020-03-13 14:59:41 -07:00
Jane Lusby b0351e4d87 Close the front door for clippy but open the back 2020-03-12 19:27:48 -07:00
bors 2bdc87972c Auto merge of #7838 - ehuss:fix-memory-rustc-output, r=alexcrichton
Avoid buffering large amounts of rustc output.

If `rustc` prints out a lot of information (such as with `RUSTC_LOG`, or a huge number of diagnostics), cargo would buffer up large amounts of that in memory.  For normal builds, this would happen if the terminal does not print fast enough. For "fresh" replay, *everything* was being buffered.

There are two issues:
1. There is no back-pressure on the mpsc queue.  If messages come in faster than they can be processed, it grows without bounds.
2. The cache-replay code runs in the "fresh" code path which does not spawn a thread. Thus the main thread was blocked and unable to process `Message`s while the replay is happening.

The solution here is to use a bounded queue, and to always spawn a thread for the "fresh" case.

The main concern here is performance.  Previously the "fresh" jobs avoided spawning a thread to improve performance.  I did a fair bit of profiling to understand the impact, using projects with anywhere from 100 to 500 units.  On my macOS machine, I found spawning a thread to be slightly faster (1-5%).  On Linux and Windows, it was generally about 0 to 5% slower.  It might be helpful for others to profile it on their own system.

I'm on the fence for the cost/benefit here.  It seems generally good to reduce memory usage, but the slight performance hit is disappointing.  I tried several other approaches to fix this, all with worse trade offs (I can discuss them if interested).

Fixes #6197
2020-03-12 16:55:12 +00:00
Eric Huss 2fa95e3ec4 Add "Updating" status for git submodules. 2020-03-11 18:37:31 -07:00
Eric Huss c67cd7a1a2 Add test for caching large output. 2020-03-10 11:23:18 -07:00
Jiajie Chen 9f07c83417 Don't create hardlink for library test, integrations tests and benches, fixing #7960 2020-03-05 13:03:49 +08:00