### What does this PR try to resolve?
RFC 3841 has merged, and x86_64-apple-darwin will be demoted to tier-2
in 1.90.0. In Cargo we usually run test against tier-1 platforms, so
x86_64-apple-darwin should be removed.
Also, that target platform is often the slowest one in CI, we are happy
to remove it to save us a couple of minutes.
https://rust-lang.github.io/rfcs/3841-demote-x86_64-apple-darwin.html
### How to test and review this PR?
Run `cargo test` locally with cross-compile tests enabled, and no
regression.
RFC 3841 has merged, and x86_64-apple-darwin will be demoted to tier-2
in 1.90.0. In Cargo we usually run test against tier-1 platforms, so
x86_64-apple-darwin should be removed.
Also, that target platform is often the slowest one in CI,
we are happy to remove it to save us a couple of minutes.
https://rust-lang.github.io/rfcs/3841-demote-x86_64-apple-darwin.html
### What does this PR try to resolve?
While preparing to stabilize `build-dir`, [it was
discovered](https://github.com/rust-lang/cargo/issues/14125#issuecomment-3127467689)
that `cargo package` will sometimes use the build cache for dependency
crates if `CARGO_TARGET_DIR` is explicitly set.
If target-dir is not set, the build will be preformed in an "inner
target dir" at `target/package/{name}-{version}/target` and rebuild
everything.
This PR changes the default behavior to always use the build cache,
matching the behavior of having `target-dir` set.
### How to test and review this PR?
Added a dedicated test to verify the previous behavior (cargo recompiled
non-workspace crates) in the first commit.
Then updated it to verify the new behavior.
### Related links/notes
* I did some Git archaeology and I _think_ this behavior was introduced
in #2912
* While searching through the commit/pr history was never able to find
any explicit reason why the behavior is the way it is.
* Even if it was intentional, it has been 9 years since and Cargo's
fingerprinting/rebuild detection is much more mature now so I believe
its worth revisiting if this is still the desired behavior.
* Would help mitigate https://github.com/rust-lang/cargo/issues/14941
The error message for unknown values of `cargo-features` was unhelpful:
```text
Caused by:
unknown cargo feature `build-dir`
```
I've made it more explanatory, and matching the style of the other
errors:
```text
Caused by:
feature `build-dir` is not a valid unstable feature for Cargo.toml
This feature can be enabled via -Zbuild-dir or the `[unstable]` section in config.toml.
See https://doc.rust-lang.org/cargo/reference/unstable.html for more information.
```
### What does this PR try to resolve?
This PR adds initial support into Cargo for JSON timing sections,
implemented in rustc in https://github.com/rust-lang/rust/pull/142123.
This allows Cargo to read frontend/codegen/linking time from rustc, and
thus reporting slightly more detailed data in the `cargo build
--timings` output.
The PR modifies Cargo to tell rustc to emit the section messages
(`--json=...,timings`), and it adds the section timings data to the HTML
table output and the JSON output. It does not yet integration different
sections in the HTML unit chart (I want to do that as a follow-up).
Note that the JSON timings are currently only supported on the nightly
compiler (they are not stabilized). The new behavior is thus gated
behing an unstable Cargo flag (`-Zsection-timings`). When the flag is
unused, the HTML table should look more or less the same as before, just
that the code now supports both options.
### How to test and review this PR?
You can run e.g. this to generate the timing report with a nightly
compiler:
```bash
export RUSTC=`rustup +nightly which rustc`
target/debug/cargo build -Zsection-timings --timings
```
on some crate, e.g. [ripgrep](https://github.com/BurntSushi/ripgrep).
Tracking issue: https://github.com/rust-lang/cargo/issues/15817
When running `cargo package` the verify the build cache
(target-dir/build-dir) will not be used and all dependencies will be
recompiled.
This is inconsistent as setting target dir (via `CARGO_TARGET_DIR` for
example) will cause `cargo package` to reuse the build cache.
This commit changes the default behavior to always use the build cache,
matching the behavior of having target-dir set.
This should also help fixing these spurious "cannot package because some
excluded file is untracked" issues.
### Tasks
* [x] step-by-step conversion of `vcs.rs`
* [x] use proper feature toggle
* [x] ~~cleanup~~ final check by myself
* [ ] ~~move split & rename into its own commit. Probably squash all
changes except for the gix upgrade.~~
- I like to have the major stages of this PR conserved.
* [x] upgrade to a gix release including
https://github.com/GitoxideLabs/gitoxide/pull/2016
- This was done in `master` already.
* [x] fix tests by fixing `gix` - `submodules()` call isn't bare-repo
safe.
* [x] fix failure on Windows
- `gix status` seems to go through a symlink, arriving at the wrong
conclusion, on Windows.
* [x] fix performance regression on `aws-sdk-rust`.
### Notes for the Reviewer
* This implementation is both faster and more correct, thus affects
#15416 and #14955.
Related to https://github.com/GitoxideLabs/gitoxide/issues/106.
This should also help fixing these spurious "cannot package because
some excluded file is untracked" issues.
Remove the respective `git2` implementation at the same time
as there seems to be no need for it.
This is not necessary, as 32 is the default, and actually of the wrong
type now since it's a number now.
When planning to make these type mismatches error, cargo would fail
here, so I just removed it.
This custom target test very much shows how Cargo should be a subtree,
in this case it was fine because there's a compatible fix that I can
push now, otherwise it would have been very annoying.
The `[hints]` table in a `Cargo.toml` manifest provides optional
information that Cargo can use for building the package, and will use
even when using the package as a dependency. All hints can be safely
ignored, and Cargo only warns about unknown hints, but does not error.
This allows packages to use hints without depending on new Cargo.
Add a `mostly-unused` hint, which allows a package to hint that most
users of the package will not use most of its items. This is useful for
improving the build performance of crates with large dependencies.
Crates can override this hint using `hint-mostly-unused = false` in
their profile for a dependency.
These tests show what prior versions of Cargo will do with hints.
The subsequent addition of support for hints will modify these tests to
reflect the corresponding changes to Cargo.
Hi Everyone!
This is PR for the implementation of the first milestone of [GSoC
Project : Build Script
Delegation](https://summerofcode.withgoogle.com/programs/2025/projects/nUt4PdAA)
This will provide actual implementation for #15630
### What does this PR try to resolve?
Now, multiple build scripts are parsed, this PR aims to implement the
functioning the feature. This PR will allow users to use multiple build
scripts, and is backward compatible with single script as well as
boolean values.
**Motivation :** This will help users to maintain separate smaller and
cleaner build scripts instead of one large build script. This is also
necessary for build script delegation.
Deferred
- Accessing each build script's `OUT_DIR`: This will be handled in a
follow up PR. For now, each build script writes to its own `OUT_DIR` and
`OUT_DIR` for the regular build targets is set to the build script with
the **lexicographically largest** name..
- User control over which build script wins in a conflict. This will be
handled in a follow up PR. If two build scripts write to the same env
variable, which gets applied to the binary? Currently, its the build
script with the **lexicographically largest** name. This makes it
deterministic. With some futzing, users can control this for now.
However, with build script delegation, users won't be able to control
this. We likely want it based off of the order the user assigns into the
build script array.
- Something about linking a C library is actually preferring
**lexicographically smallest** name. We should handle conflicts
consistently. We need to dig into what parts are doing it based on
smallest and make sure that whatever priority scheme we use for env
variables applies here as well.
### How to test and review this PR?
There is a feature gate `multiple-build-scripts` that can be passed via
`cargo-features` in `Cargo.toml`. So, you have to add
```toml
cargo-features = ["multiple-build-scripts"]
```
Preferably on the top of the `Cargo.toml` and use nightly toolchain to
use the feature
A user will now be able to use flags like `--workspace` with `cargo
publish`.
`cargo package` will now also work with those flags without having to
pass `--no-verify --exclude-lockfile`.
Many release tools have come out that solve this problem.
They will still need a lot of the logic that went into that for other
parts of the release process.
However, a cargo-native solution allows for:
- Verification during dry-run
- Better strategies for waiting for the publish timeout
`cargo publish` is non-atomic at this time.
If there is a server side error, network error, or rate limit during the publish,
the workspace will be left in a partially published state.
Verification is done before any publishing so that won't affect things.
There are multiple strategies we can employ for improving this over time,
including
- atomic publish
- `--idempotent` (#13397)
- leave this to release tools to manage
This includes support for `--dry-run` verification.
As release tools didn't have a way to do this before,
users may be surprised at how slow this is because a `cargo build` is
done instead of a `cargo check`. This is being tracked in #14941.
This adds to `cargo package` the `--registry` and `--index` flags to
help with resolving dependencies when depending on a package being
packaged at that moment.
These flags are only needed when a `cargo package --workspace` operation
would have failed before due to inability to find a locally created
dependency.
Regarding the publish timeout, `cargo publish --workspace` publishes
packages in batches and we only timeout if nothing in the batch has
finished being published within the timeout, deferring the rest to the
next wait-for-publish. So for example, if you have packages `a`, `b`, `c` then
we'll wait up to 60 seconds and if only `a` and `b` were ready in that time,
we'll then wait another 60 seconds for `c`.
During testing, users ran into issues with `.crate` checksums that we've
not been able to reproduce since:
- https://github.com/rust-lang/cargo/issues/1169#issuecomment-2567995987
- #14396
By stabilizing this, Cargo's behavior becomes dependent on an overlay
registry.
When generating a lockfile or verifying a package, we overlay the
locally generated `.crate` files on top of the registry so the registry
appears as it would and everything works.
If there is a conflict with a version, the local version wins which is
important for the dry-run mode of release tools as they won't have
bumped the version yet.
Our concern for the overlay registry is dependency confusion attacks.
Considering this is not accessible for general user operations, this
should be fine.
Fixes#1169Fixes#10948
### What does this PR try to resolve?
This is prep for updating `toml` which will change some of these error
messages
### How to test and review this PR?