20307 Commits

Author SHA1 Message Date
0xPoe
a7fcef21fe refactor: move IndexPackage and RegistryDependency to cargo-util-schemas for better modularity
Signed-off-by: 0xPoe <techregister@pm.me>
2025-07-27 15:02:27 +02:00
Weihang Lo
dfcf4c2cbd
fix: no-proc-macro is overridden by subsequent edges (#15764)
### What does this PR try to resolve?
To close #15763.

### How to test and review this PR?
See steps in #15763.
2025-07-23 16:56:18 +00:00
ChenRuiwei
2654f29ddb fix: no-proc-macro is overridden by subsequent edges 2025-07-24 00:06:54 +08:00
ChenRuiwei
4fdd6ecbab test: add test for no-proc-macro order issue 2025-07-24 00:06:54 +08:00
Weihang Lo
9b5231f892
Use gix for cargo package (#15534)
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.
2025-07-23 03:13:49 +00:00
Sebastian Thiel
dfe3737634
Optimize performance of cargo package.
This is achieved by allowing `gix status` to only run in the
package root, while running it another time just on the few files
that are interesting outside of the package root.

This saves a lot of time compared to the previous implementation,
which ran the status on the entire repository.
2025-07-23 04:36:45 +02:00
Sebastian Thiel
d3b85cd96a
Provide a package implementation with gix-status.
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.
2025-07-23 04:36:07 +02:00
Sebastian Thiel
ac04a82c7f
Upgrade gix to the latest version.
This will fix an issue with submodules that couldn't be queried
in an unborn repository.
2025-07-23 04:32:28 +02:00
Weihang Lo
d2ee2df594
cargo-credential-libsecret: give FFI correctly-sized object (#15767)
### What does this PR try to resolve?

The type is
```c
typedef struct {
	const gchar *name;
	SecretSchemaFlags flags;
	SecretSchemaAttribute attributes[32];

	/* <private> */
	gint reserved;
	gpointer reserved1;
	gpointer reserved2;
	gpointer reserved3;
	gpointer reserved4;
	gpointer reserved5;
	gpointer reserved6;
	gpointer reserved7;
} SecretSchema;
```
so the current object we give it is 8 pointers too short

It's incredibly lucky that libsecret, at this time, only uses
`reserved`, and not in any of the functions we call

Also, some obvious cleanups while I was there and comparing with [my
implementation](https://github.com/nabijaczleweli/cargo-update/blob/v17.0.0/src/ops/mod.rs#L1443)
from [cargo-update
17.0.0](https://github.com/nabijaczleweli/cargo-update/releases/v17.0.0).

### How to test and review this PR?

Observe
https://sources.debian.org/src/libsecret/0.20.5-3/libsecret/secret-schema.h/#L43
I suppose?
2025-07-22 23:40:40 +00:00
наб
ed85b79f8b
cargo-credential-libsecret: c""-style literals 2025-07-23 01:05:56 +02:00
наб
688d59002e
rustfmt mess 2025-07-22 23:03:05 +02:00
наб
67749b1a30
cargo-credential-libsecret: don't allocate "url" C string
We already don't do this and use this precise idiom elsewhere
2025-07-22 23:03:04 +02:00
наб
1abdb1d2aa
cargo-credential-libsecret: give FFI correctly-sized object
The type is
	typedef struct {
		const gchar *name;
		SecretSchemaFlags flags;
		SecretSchemaAttribute attributes[32];

		/* <private> */
		gint reserved;
		gpointer reserved1;
		gpointer reserved2;
		gpointer reserved3;
		gpointer reserved4;
		gpointer reserved5;
		gpointer reserved6;
		gpointer reserved7;
	} SecretSchema;
so the current object we give it is 8 pointers too short

It's incredibly lucky that libsecret, at this time,
only uses reserved, and not in any of the functions we call
2025-07-22 23:02:56 +02:00
наб
219a4da303
cargo-credential-libsecret: pull out error, attr_url, schema too 2025-07-22 22:44:08 +02:00
Weihang Lo
5b295b77ee
Remove unnecessary target-c-int-width from target specs (#15759)
### What does this PR try to resolve?

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 in
https://github.com/rust-lang/rust/pull/144218, 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.

### How to test and review this PR?

If the test suite passes, it works
2025-07-20 13:44:51 +00:00
Noratrieb
a6e1f11d4e Remove unnecessary target-c-int-width from target specs
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.
2025-07-20 15:04:25 +02:00
Ed Page
f5b3a6ba89
Expose artifact dependency getters in cargo-as-a-library (#15753)
### What does this PR try to resolve?

Information about artifact dependencies is already available through
`cargo metadata`, and therefore also through serializing and re-parsing
`dependency.serialized()` using `serde_json::to_value` +
`serde_json::from_value`. This PR makes the same information available
directly through the library API of `cargo::core::Dependency`.

I ran into these private methods while working on
https://github.com/rust-lang/cargo/issues/15751.

### How to test and review this PR?

`cargo check`
2025-07-18 18:23:10 +00:00
David Tolnay
04bafa3624
Expose artifact dependency getters in cargo-as-a-library 2025-07-18 10:06:57 -07:00
Ed Page
6833aa715d
Add [hints] table in Cargo.toml, and a hints.mostly-unused hint (#15673)
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.

---

In the future, this same mechanism could be used for other hints, such
as
`min-opt-level`.

### How to test and review this PR?

This PR is built atop https://github.com/rust-lang/cargo/pull/15643 .
I'd
suggest reviewing that PR separately, then just reviewing the new
commits in
this PR.

The new "hints" testsuite module demonstrates the expected behavior of
hints.

Like https://github.com/rust-lang/cargo/pull/15643 , the nightly-only
tests
will only pass once https://github.com/rust-lang/rust/pull/135656 has
been
merged into Rust.
2025-07-13 02:25:52 +00:00
Josh Triplett
94c27dfaea cargo-util-schemas: Bump breaking version for schema change 2025-07-12 14:55:10 -07:00
Josh Triplett
e44bde554d Respect capped lints for dependencies 2025-07-12 14:55:10 -07:00
Josh Triplett
78b4afb4f3 Expand test to produce warnings for deps, which will subsequently get capped 2025-07-12 14:54:56 -07:00
Josh Triplett
9949fa8a66 Include package ID in warnings to identify affected crate 2025-07-12 14:47:27 -07:00
Josh Triplett
28b9762466 Add stable documentation for the [hints] table 2025-07-12 14:47:22 -07:00
Josh Triplett
fe86023863 Parse hints permissively to allow for future expansion
Make it only a warning, not an error, to have a hint value of the wrong
type.
2025-07-11 16:54:36 -07:00
Josh Triplett
0c5ea24f13 Add documentation for hints.mostly-unused 2025-07-11 16:54:36 -07:00
Josh Triplett
1921d097ca Add [hints] table in Cargo.toml, and a hints.mostly-unused hint
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.
2025-07-11 16:54:36 -07:00
Josh Triplett
f415c112f9 Add additional tests for hints.mostly-unused (showing existing behavior)
These tests demonstrate the behavior of current Cargo, and will be
changed when adding `hints.mostly-unused` to reflect the new behavior.
2025-07-11 16:54:36 -07:00
Josh Triplett
a206766e43 Add initial version of hints tests, to show pre-[hints] Cargo behavior
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.
2025-07-11 16:54:30 -07:00
Josh Triplett
8fd9309102 Remove unnecessary parentheses around closure body, to fix unused-parens warning 2025-07-11 16:54:19 -07:00
Ed Page
eabb4cd923
feat: Implementation and tests for multiple-build-scripts (#15704)
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
2025-07-09 22:07:55 +00:00
Naman Garg
bfb869748c
Use Vector for build script Units and UnitHash 2025-07-10 03:02:58 +05:30
Naman Garg
a24abd6fc2
Add multiple build scripts to unit deps 2025-07-10 03:02:34 +05:30
Weihang Lo
f9ee73d6b7
perf: Speed up TOML parsing by upgrading toml (#15736)
### What does this PR try to resolve?

For numbers, see https://epage.github.io/blog/2025/07/toml-09/

Further areas for improvement:
- Enable `fast_hash` (see #15649)
- Only track spans for local manifests, allowing us to skip the
`make_owned` call for most packages

### How to test and review this PR?
2025-07-09 16:18:12 +00:00
Naman Garg
72290ad03a
Replace build with check in test rerun_untracks_other_files 2025-07-09 02:38:52 +05:30
Naman Garg
e9df793c47
Add tests for multiple build scripts execution 2025-07-09 02:38:50 +05:30
Ed Page
194fe22da6 perf: Speed up TOML parsing by switching BTreeMap to IndexMap 2025-07-08 13:08:58 -05:00
Ed Page
ad8fb2f0c9 refactor(manifest): Switch from toml_edit to toml
Technically this will cause a small regression in performance from
`toml_edit@0.23` but not `toml_edit@0.22`
2025-07-08 13:01:29 -05:00
Ed Page
6e04449c27 refactor: Resolve deprecations 2025-07-08 12:02:29 -05:00
Ed Page
539a48452a perf: Update toml 2025-07-08 11:55:41 -05:00
Weihang Lo
8f80388a78
Mark cachelock tests that rely on interprocess blocking behaviour as unsupported on AIX. (#15734)
This PR marks several tests within cache_lock.rs as unsupported on the
AIX platform. The tests relies on flock() behaviour that is not
supported on AIX.
2025-07-08 15:47:06 +00:00
Uyiosa Iyekekpolor
bc43610058 mark cachelock tests that rely on interprocess blocking behaviour as unsuported on AIX 2025-07-08 10:09:25 -04:00
Weihang Lo
0322bdd37a
feat(publish): Stabilize multi-package publishing (#15636)
### What does this PR try to resolve?

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:
- ~~#15647~~ Fixed for `cargo publish --dry-run` in #15711
  - But `cargo package` still has the problem
- #14396 (not been able to reproduce)
- #15622 (reproducible with consecutive `cargo publish` calls)

Fixes #1169
Fixes #10948

### How to test and review this PR?

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.
2025-07-07 21:54:46 +00:00
Weihang Lo
463e483346
Update to Rust 2024 (#15732)
This updates all crates to Rust 2024.
2025-07-06 11:39:11 +00:00
Eric Huss
e24a9865ac Apply deprecated_safe_2024 2025-07-05 20:17:36 -07:00
Eric Huss
639143579a Bump crate versions 2025-07-05 19:57:28 -07:00
Eric Huss
2d02d5a203 Ignore rustfmt 2024 commit 2025-07-05 19:51:10 -07:00
Eric Huss
1ce8023626 Rustfmt 2024 2025-07-05 19:50:36 -07:00
Eric Huss
fb0c7c99cf Update all crates to 2024 edition 2025-07-05 19:39:17 -07:00
Eric Huss
9d710a98a1 Apply unsafe_op_in_unsafe_fn 2025-07-05 19:29:43 -07:00