16135 Commits

Author SHA1 Message Date
Eric Huss
8161ba50cd Ignore changing_spec_relearns_crate_types on windows-gnu 2023-11-13 19:17:51 -08:00
bors
4e02f11faf Auto merge of #12965 - weihanglo:hash, r=epage
fix: do not panic when failed to parse rustc commit-hash
2023-11-13 21:10:30 +00:00
Weihang Lo
7ca122c009
fix: do not panic when failed to parse rustc commit-hash
In some situation the commit-hash in `rustc -vV` output is "unknown".
The debug assertion must not block any progress on others like miri.
2023-11-13 15:47:38 -05:00
Ed Page
46d9894014 refactor(toml): Split out InheritablePackage from InheritableFields
This allows us to move bookkeeping / logic out of the schema
2023-11-13 14:22:49 -06:00
bors
43abf90619 Auto merge of #12970 - Eh2406:MaybeSummary, r=epage
query{_vec} use IndexSummary

This builds on the work from https://github.com/rust-lang/cargo/pull/12749 and the discussion of the overall approach is at https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/better.20error.20messages.20for.20filtered.20versions.2E

### What does this PR try to resolve?

Changing the two traits `Registry` and `Source` to use the new `IndexSummary' involves a lot of changes all throughout the code base. This would be hard to review if it also included any logic changes. So this PR is just adding the type to the trait and immediately unwrapping every place it is used.

The hope is that reviewing changes to logic/ergonomics will be easier to review once the mechanical changes have been merged.

### How should we test and review this PR?

This is an internal re-factoring and all the tests still pass.
2023-11-13 19:47:24 +00:00
Jacob Finkelman
6835fa3867 query{_vec} should use IndexSummary 2023-11-13 19:39:25 +00:00
Ed Page
0eda16f823 refactor(toml): Be specific with inheriting action 2023-11-13 11:44:56 -06:00
Ed Page
f8a63f67cd refactor(toml): Hard-code InheritableField for package table 2023-11-13 11:11:17 -06:00
bors
946fbf9b2b Auto merge of #12966 - weihanglo:version-bump, r=epage
Bump to 0.77.0; update changelog

[rendered](https://github.com/weihanglo/cargo/blob/version-bump/CHANGELOG.md)
2023-11-13 15:30:06 +00:00
Weihang Lo
b811a5dc3c
Update changelog for 1.76.0 2023-11-13 10:04:28 -05:00
Weihang Lo
0babf351a9
Update changelog for 1.75.0 2023-11-13 10:04:28 -05:00
bors
a4764b0dd8 Auto merge of #12962 - hi-rustin:rustin-patch-cargo-search, r=weihanglo
Improve about information of `cargo search`
2023-11-13 12:40:10 +00:00
hi-rustin
3076190954 Update cargo-search.md and its man page
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-11-13 19:50:30 +08:00
hi-rustin
918d32b34d Improve about information of cargo search
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-11-13 19:50:21 +08:00
Pietro Albini
ab76a0bf3b
respect rust-lang/rust's omit-git-hash
The config.toml file in rust-lang/rust has the omit-git-hash option,
which prevents git information from being embedded into binaries. This
works for most tools, as they rely on the git information provided by
bootstrap through environment variables.

Cargo does its own git detection in its build script though, which
didn't adhere to to that option. This changes that by skipping git
detection whenever bootstrap signals the option is enabled.
2023-11-13 11:58:44 +01:00
Weihang Lo
94687c3d28
Update changelog for 1.74.0 2023-11-13 01:05:03 -05:00
Weihang Lo
12d9d753ab
Bump to 0.77.0 2023-11-13 01:05:03 -05:00
bors
2cbbf6e073 Auto merge of #12959 - ehuss:quiet-global, r=epage
Fix --quiet being used with nested subcommands.

This fixes an issue where `--quiet` doesn't work with commands that have subcommands. This is because `config_configure` only looks at the global and top-level subcommand, and not deeper subcommands. The issue was that `--quiet` was not defined as a global flag. This was changed in https://github.com/rust-lang/cargo/pull/6358 in order to give a better help message for `cargo test --quiet`. I don't remember if clap just didn't support overriding at the time, or if we just didn't know how it worked. Anyways, it seems to work to override it now, so I think it should be fine to mark it as global.

This should bring in `--quiet` more in-line with how `--verbose` works. This means that `--quiet` is now accepted with `cargo report`, `cargo help`, and `cargo config`.

This also fixes `--quiet` with `cargo clean gc`.

This should also help with supporting `--quiet` with the new `cargo owner` subcommands being added in
https://github.com/rust-lang/cargo/pull/11879.

As for this diff, the help text changes because the `--quiet` flag is changing position (except for the 3 commands mentioned above where it is now added).

Fixes #12957
2023-11-12 21:10:03 +00:00
Eric Huss
80ffb1de1c Fix --quiet being used with nested subcommands.
This fixes an issue where `--quiet` doesn't work with commands that have
subcommands. This is because `config_configure` only looks at the global
and top-level subcommand, and not deeper subcommands. The issue was that
`--quiet` was not defined as a global flag. This was changed in
https://github.com/rust-lang/cargo/pull/6358 in order to give a better
help message for `cargo test --quiet`. I don't remember if clap just
didn't support overriding at the time, or if we just didn't know how it
worked. Anyways, it seems to work to override it now, so I think it
should be fine to mark it as global.

This should bring in `--quiet` more in-line with how `--verbose` works.
This means that `--quiet` is now accepted with `cargo report`,
`cargo help`, and `cargo config`.

This also fixes `--quiet` with `cargo clean gc`.

This should also help with supporting `--quiet` with the new `cargo
owner` subcommands being added in
https://github.com/rust-lang/cargo/pull/11879.

Fixes #12957
2023-11-12 11:17:43 -08:00
bors
fa62a0e505 Auto merge of #12963 - RalfJung:commit-hash, r=weihanglo
make some debug assertion failures more informative

In https://github.com/rust-lang/miri/issues/3160, we got a report of a user running into an assertion failure in cargo. Unfortunately the failure message is not very informative. This PR hopefully makes that failure easier to debug.
2023-11-12 18:25:47 +00:00
Ralf Jung
1b3a53ca38 make some debug assertion failures more informative 2023-11-12 18:39:06 +01:00
bors
3eb246cd87 Auto merge of #12960 - epage:refactor, r=weihanglo
refactor(toml): Consistently lead with 'Toml' prefix

### What does this PR try to resolve?

Like with #12954, I noticed this inconsistency while working towards #12801 and wanted to fix it.

### How should we test and review this PR?

### Additional information
2023-11-12 06:07:38 +00:00
bors
984bd910f3 Auto merge of #12961 - epage:dead, r=weihanglo
refactor(toml): Remove unused method

### What does this PR try to resolve?

While finding better homes for logic for #12801, I found this part of the workspace-inheritance trait was unused.

### How should we test and review this PR?

### Additional information
2023-11-12 05:38:00 +00:00
Ed Page
b3afe463ff refactor(toml): Remove unused method 2023-11-11 20:44:52 -06:00
Ed Page
58b0b18783 refactor(toml): Decouple dependency and package field inheritance 2023-11-11 20:44:31 -06:00
Ed Page
0d9bcd7781 refactor(toml): Switch from Workspace to Inherit terms
`Workspace` and `MaybeWorkspace` doesn't make the intent as clear.
Generally when talking about this, we say that it "inherits".
This also better matches the terms in `cargo_toml` and `cargo-manifest`
packages.
2023-11-11 20:40:59 -06:00
Ed Page
2c61a70bb2 refactor(toml): Consistently lead with 'Toml' prefix 2023-11-11 20:38:52 -06:00
bors
309473fcc3 Auto merge of #12958 - ehuss:fix-last-use-now-race, r=epage
Fix non-deterministic behavior in last-use repopulation

This fixes an issue where some last-use tests would fail sporadically because the code that populates missing database entries was using the current time as it was iterating over the files. If the clock happened to roll over while it was iterating, then different files would get different timestamps non-deterministically.

The fix is to snapshot the current time when it starts, and reuse that time while repopulating. I didn't do this originally just because I was reluctant to pass yet another argument around. However, it seems like this is necessary. In #12634, we discussed other options such as having some kind of process-global "now" snapshot (like in `Config`), but I'm reluctant to do that because I am uneasy dealing with long-lived programs, or handling before/after relationships (like different parts of the code not considering that all timestamps might be equal). It might be something that we could consider in the future, but I'm not sure I want to try right now.
2023-11-12 00:35:29 +00:00
Eric Huss
76370163ba Fix non-deterministic behavior in last-use repopulation
This fixes an issue where some last-use tests would fail sporadically
because the code that populates missing database entries was using the
current time as it was iterating over the files. If the clock happened
to roll over while it was iterating, then different files would get
different timestamps non-deterministically.

The fix is to snapshot the current time when it starts, and reuse that
time while repopulating. I didn't do this originally just because I was
reluctant to pass yet another argument around. However, it seems like
this is necessary. In #12634, we discussed other options such as having
some kind of process-global "now" snapshot (like in `Config`), but I'm
reluctant to do that because I am uneasy dealing with long-lived
programs, or handling before/after relationships (like different parts
of the code not considering that all timestamps might be equal). It
might be something that we could consider in the future, but I'm not
sure I want to try right now.
2023-11-11 16:08:01 -08:00
bors
9a1b0924c6 Auto merge of #12634 - ehuss:last-use, r=epage
Add cache garbage collection

### What does this PR try to resolve?

This introduces a new garbage collection system which can track the last time files were used in cargo's global cache, and delete old, unused files either automatically or manually.

### How should we test and review this PR?

This is broken up into a large number of commits, and each commit should have a short overview of what it does. I am breaking some of these out into separate PRs as well (unfortunately GitHub doesn't really support stacked pull requests). I expect to reduce the size of this PR if those other PRs are accepted.

I would first review `unstable.md` to give you an idea of what the user side of this looks like. I would then skim over each commit message to give an overview of all the changes. The core change is the introduction of the `GlobalCacheTracker` which is an interface to a sqlite database which is used for tracking the timestamps.

### Additional information

I think the interface for this will almost certainly change over time. This is just a stab to create a starting point where we can start testing and discussing what actual user flags should be exposed. This is also intended to start the process of getting experience using sqlite, and getting some testing in real-world environments to see how things might fail.

I'd like to ask for the review to not focus too much on bikeshedding flag names and options. I expect them to change, so this is by no means a concrete proposal for where it will end up. For example, the options are very granular, and I would like to have fewer options. However, it isn't clear how that might best work. The size-tracking options almost certainly need to change, but I do not know exactly what the use cases for size-tracking are, so that will need some discussion with people who are interested in that.

I decided to place the gc commands in cargo's `cargo clean` command because I would like to have a single place for users to go for deleting cache artifacts. It may be possible that they get moved to another command, however introducing new subcommands is quite difficult (due to shadowing existing third-party commands). Other options might be `cargo gc`, `cargo maintenance`, `cargo cache`, etc. But there are existing extensions that would interfere with.

There are also more directions to go in the future. For example, we could add a `cargo clean info` subcommand which could be used for querying cache information (like the sizes and such). There is also the rest of the steps in the original proposal at https://hackmd.io/U_k79wk7SkCQ8_dJgIXwJg for rolling out sqlite support.

See #12633 for the tracking issue
2023-11-11 20:45:02 +00:00
Eric Huss
0cd970b1c0 Move gc options under a cargo clean gc subcommand.
This was requested to separate the interaction of `cargo clean` and the
cleaning of global cache data, and to minimize the impact of this
initial implementation.
2023-11-11 12:36:25 -08:00
Eric Huss
1e1a42ca71 Use unreachable instead of panic. 2023-11-11 10:56:59 -08:00
Eric Huss
7dd15fe19f Move gc.auto.frequency default to a constant. 2023-11-11 10:56:59 -08:00
Eric Huss
56c8d90d13 Use walkdir's built-in sorting option. 2023-11-11 10:56:59 -08:00
Eric Huss
9a41a6110c Remove shared-target gc kind.
This kind is unlikely to be implemented in the foreseeable future, and
we don't really know what it is going to look like.
2023-11-11 10:56:58 -08:00
Eric Huss
ead7904ad4 Add gc tracing target. 2023-11-11 10:56:58 -08:00
Eric Huss
89b870e6ee Use newtype wrapper for parent table IDs. 2023-11-11 10:56:58 -08:00
Eric Huss
73bf9fc2a7 Consolidate the git checkout du logic. 2023-11-11 10:56:58 -08:00
Eric Huss
73b87a2cc8 Use constants for auto gc config defaults. 2023-11-11 10:56:58 -08:00
Eric Huss
4d9b165d8c Move types to be near their impls. 2023-11-11 10:56:58 -08:00
Eric Huss
a86c4aa8b3 Some doc clarifications and fixes. 2023-11-11 10:56:58 -08:00
Eric Huss
e7cebdce21 Tweak unstable docs wording to avoid some confusion. 2023-11-11 10:56:58 -08:00
Eric Huss
4ad8adcf55 Fix unstable gc.auto config not showing the table name. 2023-11-11 10:56:58 -08:00
Eric Huss
7c55a4e334 Add headers to unstable gc docs. 2023-11-11 10:56:58 -08:00
Eric Huss
79da1756b5 Always assert the package cache lock is held.
This should help ensure that it is properly acquired even on the stable
code path.
2023-11-11 10:56:58 -08:00
Eric Huss
803cb81941 Add tracking issue 2023-11-11 10:56:58 -08:00
Eric Huss
5d358674e7 Add a trace message when running offline. 2023-11-11 10:56:58 -08:00
Eric Huss
5e27630be0 Use average days in a month instead of fixed 30. 2023-11-11 10:56:58 -08:00
Eric Huss
14d78e48b2 Fix to correctly use config.extra_verbose() 2023-11-11 10:56:58 -08:00
Eric Huss
6110d9d3f5 Simplify with split_at 2023-11-11 10:56:58 -08:00