Commit graph

3341 commits

Author SHA1 Message Date
Matt Stavola fcff51b3e0
Add test for bad renaming 2020-04-08 23:46:30 -07:00
Rocco 79c8ae8299
Compatibility for rust-lang/rust#69926 2020-04-07 15:23:43 +02: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 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
bors 5fe8ab57e2 Auto merge of #7959 - ehuss:restricted-crate-names, r=alexcrichton
Try to better handle restricted crate names.

This attempts to improve handling of restricted crate names, particularly for `cargo new` and `cargo init`. Hopefully the code is straightforward to follow, but in summary the changes are:

**General changes**

* Add more details to the error messages about why a name is not allowed, and what is allowed.
* Change the valid package name check to be restricted to Unicode XID. This brings it in line with non_ascii_idents support in rustc. For the most part, this is pretty much the same as before. Note: this is used for the package name, and registry names. The differences are:
    * Package names cannot start with numbers. Previously this was only rejected in `cargo new`. crates.io also rejects numbers. Numbers are also not valid crate names.
    * Package names cannot start with dash `-`. This is a somewhat arbitrary change, but seems like it would stem problems. crates.io also rejects this.
    * Package names cannot start with these characters that were previously allowed: https://gist.github.com/ehuss/804a797950001b5226e1264b6f65211f#file-not_start_but_alphanumeric-txt
        * Most of these are wacky numbers or other strange things.
    * Package names cannot contain these characters that were previously allowed: https://gist.github.com/ehuss/804a797950001b5226e1264b6f65211f#file-not_continue_but_alphanumeric-txt
        * These are mostly odd things that for whatever reason the Unicode people decided not to include. It seems unlikely to me that someone would want to use one of these.
* Display a warning on Windows if a Cargo target is a special Windows filename. The build error tends to be hard to understand, so the hope is the warning will make it evident.
* `cargo package/publish`: Warn if a special Windows name is in the package.

**cargo new/init specific changes**

* Update keyword list to 2018 edition.
* Add warning if creating a library that has one of the conflicting names (deps/examples/build/incremental).
* Warn about conflicting std names (core/std/alloc/proc-macro).
* Windows reserved names: Rejected on windows, warned on other platforms.
* Warn about non-ASCII package names.
* Only print the `--name` suggestion for `cargo init`. I found the suggestion confusing, and I feel like it doesn't really make sense for `cargo new` (since it would only affect the directory name).
2020-03-04 15:37:33 +00:00
Eric Huss 887ee6cc70 Fix bug with new feature resolver and required-features. 2020-03-03 11:46:37 -08:00
Eric Huss 2a874aa522 Warn when packaging files with Windows special names. 2020-03-02 16:14:36 -08:00
Eric Huss 15ac82b677 Warn on Windows about reserved target names. 2020-03-02 16:04:25 -08:00
Eric Huss 95008f91e5 Try to better handle restricted crate names. 2020-03-02 16:04:24 -08:00
bors bda50510d1 Auto merge of #7956 - ehuss:fix-collision-test, r=alexcrichton
Fix rare failure in collision_export test.

Seen once on CI in #7952 (https://dev.azure.com/rust-lang/cargo/_build/results?buildId=22112&view=logs&j=a5e52b91-c83f-5429-4a68-c246fc63a4f7&t=d4864165-4be3-5e34-b483-a6b05303aa68). I was able to reproduce it locally, though it is rare. There seems to be some kind of race issue on macOS with two processes trying to symlink the same directory at the same time. The solution is to serialize the build so they don't run at the same time.
2020-03-02 18:05:34 +00:00
Eric Huss f2c8070df5 Fix rare failure in collision_export test. 2020-03-02 09:46:39 -08:00
bors ac2eb69346 Auto merge of #7947 - quark-zju:ignore-broken-git, r=ehuss
Ignore broken Cargo.toml in git sources

Commit 3d6de41774 (#3998) made cargo
ignore Cargo.toml files that are invalid TOML in a git source.
This change further ignores Cargo.toml files that are valid TOML but
cannot really be loaded in a git source.

This is potentially an alternative fix for #6822.
2020-03-02 17:38:11 +00:00
Eric Huss b786f85fa4 Fix plugin tests for latest nightly. 2020-03-02 08:52:30 -08:00
Jun Wu a2cddeeb9f Ignore broken Cargo.toml in git sources
Commit 3d6de41774 (#3998) made cargo
ignore Cargo.toml files that are invalid TOML in a git source.
This change further ignores Cargo.toml files that are valid TOML but
cannot really be loaded.

This is potentially an alternative fix for #6822.
2020-02-29 09:31:52 -08:00
bors e618d47a17 Auto merge of #7943 - aleksator:7933_cargo_cfgs, r=ehuss
Filter out cfgs which should not be used during build

Fixes #7933: Filter invalid CARGO_CFG_ in build scripts
2020-02-27 17:12:21 +00:00
bors 7ba6e497be Auto merge of #7934 - ehuss:query-error-context, r=Eh2406
Provide extra context on a query failure.

This adds error context when a query fails, primarily to tell you which parent package included the dependency that failed. For example, imagine deep within your dependency graph you have a `git` dependency, and it fails to download. The current error doesn't tell you where in the graph that `git` dependency was included.

I also slightly tweaked the `failed to load source` error message. I felt like the existing wording could be misinterpreted that it was an error loading the dependency *for* the given package. I felt like there were multiple ways to interpret it, so I tried to simplify it to avoid that possibility.
2020-02-27 16:37:10 +00:00
Eric Huss 1eca786d7f Add path to the failure to load a dependency. 2020-02-27 08:17:18 -08:00
Alex Tokarev a6239da8b2 Filter out cfgs which should not be used during build
Fixes #7933: Filter invalid CARGO_CFG_ in build scripts
2020-02-27 11:53:53 +03:00
Eric Huss a07fec1b7b Provide extra context on a query failure. 2020-02-25 10:17:11 -08:00
Eric Huss 517b59dbb4 Enable cargo doc --open tests on macos. 2020-02-25 08:13:30 -08:00
Matthias Krüger 1d912002e9 fix most remaining clippy findings (mostly redundant imports) 2020-02-21 12:15:16 +01:00
bors f0a7bf7dcd Auto merge of #7903 - aleksator:1681_doc_crate_version, r=ehuss
Add an option to include crate versions to the generated docs

Fixes https://github.com/rust-lang/cargo/issues/1681
2020-02-21 02:57:41 +00:00
Alex Tokarev 1ea41babdc Add an option to include crate versions to the generated docs
Fixes https://github.com/rust-lang/cargo/issues/1681
2020-02-21 00:34:33 +03:00
Eric Huss 90887707ed Copy license-file into package if outside of root. 2020-02-20 13:27:25 -08:00
Eric Huss ab33bc0c36 Add a warning if license-file points to a file that does not exist. 2020-02-20 13:27:00 -08:00
Eric Huss 4d0fda7cd9 Fix bug where an optional dependency is disabled in one fork, and enabled in another. 2020-02-20 12:15:40 -08:00