21421 Commits

Author SHA1 Message Date
Weihang Lo
cf622c4be3
fix(vendor): recursively filter git files in subdirectories (#16439)
### What does this PR try to resolve?

Fixes #16148
Fixes #13607

Right now cargo vendor only filters .gitattributes, .gitignore, and .git
at the top level of each package. If these files exist in
subdirectories, they don't get filtered. This causes problems when the
vendored code gets checked into a git repo - git processes those files
and modifies them, which breaks checksums.

I ran into this when trying to vendor libssh2-sys. The .gitattributes
file in libgit2/src/util/ was getting its line endings changed by git,
causing checksum failures.

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

This follows the atomic commit pattern:
- First commit adds a test showing the current buggy behavior (test
passes)
- Second commit implements the fix and updates test assertions (test
still passes)

The fix uses components() to recursively check for .git directories
(since they can appear at any path level like deep/nested/.git/config),
while using file_name() for .gitattributes and .gitignore files.

### Additional context

This should also help with #13607 since it filters .gitignore and .git
recursively too.

If people actually need git functionality in their vendored deps, they
can add rules to their own .gitattributes at the root level.
2025-12-27 14:28:13 +00:00
Vishal Pokala
4c6f5a61ab fix(vendor): recursively filter git files in subdirectories
Fixes #14712
2025-12-27 13:04:27 +00:00
Ed Page
94c368ad2b
fix(vendor): unpack from local-registry cache path (#16435)
### What does this PR try to resolve?

In https://github.com/rust-lang/cargo/pull/15514, Cargo starts
direct-extraction from `.crate`
tarball in `$CARGO_HOME/registry/cache` when vendoring. This is fine
with
remote registrires but not for local registries, as local registries'
tarball are stored along with index.

This fix abstracts `cache_path` to `RegistryData` trait, so every
registry source type can define its own locationa of tarball cache.

Note that for local-registry when accessing either index or cache, the
assumption is that file lock of the index and cache directory need to
be externally synchronized. Cargo doesn't take care of it.

Fixes https://github.com/rust-lang/cargo/issues/16412

### How to test and review this PR?
2025-12-26 19:39:15 +00:00
Vishal Pokala
5400ea7000 test(vendor): add test showing git files aren't filtered recursively 2025-12-26 16:15:21 +00:00
Weihang Lo
c7f10b7358
fix(vendor): unpack from local-registry cache path
In rust-lang/cargo#15514, Cargo starts direct-extraction from `.crate`
tarball in `$CARGO_HOME/registry/cache` when vendoring. This is fine with
remote registrires but not for local registries, as local registries'
tarball are stored along with index.

This fix abstracts `cache_path` to `RegistryData` trait, so every
registry source type can define its own locationa of tarball cache.

Note that for local-registry when accessing either index or cache, the
assumption is that file lock of the index and cache directory need to
be externally synchronized. Cargo doesn't take care of it.
2025-12-26 10:59:58 -05:00
Weihang Lo
a2b970f9a1
test(vendor): show local-registry vendor regression
This is a minimal reproducible example of rust-lang/cargo#16412
2025-12-26 10:59:14 -05:00
Weihang Lo
0f5388d9c7
feat(index): Stabilize pubtime (#16372)
### What does this PR try to resolve?

Unblocks #15973, #5221

Closes #15491
Closes #16270

### How to test and review this PR?
2025-12-26 15:24:43 +00:00
Weihang Lo
c15cd9bdee
Experiment: Render timing pipeline in SVG (#15091)
### What does this PR try to resolve?

This PR adds an SVG renderer and allows users to choose between Canvas
and SVG for rendering charts, which should hopefully resolve #8850.
<img width="1405" height="937" alt="image"
src="https://github.com/user-attachments/assets/760a1a61-72b3-45bc-b36a-bb581e50c0a6"
/>

### Additional information

This does not guarantee a pixel-perfect match from the previous
canvas-based solution, but I maintain it stays as close as possible.
2025-12-25 16:46:56 +00:00
eth3lbert
d4e9a7abf5
perf(timings): fix Firefox scrolling jank with the SVG renderer
When rendering SVGs with a large number of units, Firefox becomes quite
janky during scrolling. This appears to be caused by dependency lines
that use merged paths and dashed styles. Therefore, this approach splits
them into multiple paths instead.
2025-12-25 06:25:33 +08:00
eth3lbert
75b26bf59a
feat(timings): allow rendering charts with selected renderer
This allows users to choose between canvas and SVG rendering, and it defaults to canvas.
2025-12-25 06:25:30 +08:00
eth3lbert
ec3913ebe4
feat(timings): add a SvgRenderer class 2025-12-25 06:25:27 +08:00
eth3lbert
1e6663eb15
refactor(timings): extract get_legend_entries() fn 2025-12-25 06:25:24 +08:00
eth3lbert
54d33afbc7
refactor(timings): extract CanvasRenderer class 2025-12-25 06:25:21 +08:00
eth3lbert
c31ddf412d
refactor(timings): extract compute_unit_coords and graph_dimension fns 2025-12-25 06:25:16 +08:00
Ed Page
aaa648864c
chore(triagebot): auto-label Command-report (#16429) 2025-12-23 15:50:38 +00:00
Weihang Lo
54bf4dbb00
chore(triagebot): auto-label Command-report 2025-12-23 09:56:23 -05:00
Weihang Lo
3861f60f6b
fix(sbom): Don't set CARGO_SBOM_PATH when empty (like stable) (#16419)
### What does this PR try to resolve?

Noticed `CARGO_SBOM_PATH` was being set when playing around with
artifact-deps.

I could have gated the env by whether the nightly feature was enabled
but figured it would be better to not set if it there aren't SBOMs.

### How to test and review this PR?
2025-12-19 21:53:33 +00:00
Ed Page
9755978749 fix(sbom): Don't set CARGO_SBOM_PATH when empty (like stable)
Noticed `CARGO_SBOM_PATH` was being set when playing around with
artifact-deps.

I could have gated the env by whether the nightly feature was enabled
but figured it would be better to not set if it there aren't SBOMs.
2025-12-19 15:23:04 -06:00
Ed Page
2b7dac9dcb test(sbom): Show CARGO_SBOM_PATH behavior 2025-12-19 11:37:18 -06:00
Ed Page
2dd8d64f6d test(sbom): Switch to snapshots 2025-12-19 11:37:12 -06:00
Ed Page
1f5feecdf3
chore(ci): report-timings to upload HTML report (#16416)
### What does this PR try to resolve?

This could help review the HTML report by download the artifacts.

### How to test and review this PR?

To review the HTML report changed in this PR

1. Go the the summary page of the associated GitHub Action run (e.g.,
<https://github.com/rust-lang/cargo/actions/runs/20354778718>)
2. Scroll to "Artifacts" section and download the `timing-report`
artifact
4. Unzip the `timing-report.zip` file, and open the
`cargo-timing-*.html` in your browser
2025-12-19 00:12:18 +00:00
Weihang Lo
22fcb74074
chore(ci): report-timings to upload HTML report
This could help review the HTML report by download the artifacts.
2025-12-18 18:25:13 -05:00
Ed Page
f4266b7981
fix(report): get the same feature parity of --timings (#16414)
### What does this PR try to resolve?

After this `cargo report timings` has 99.9% of the feature parity of
what `--timings` renders.

This adds some new fields to some events:

* unit-registered
  * `features`: a list of enabled features for the unit
* unit-graph-finished
* `requested_units`: a list of user-requested units. Not calliing this
root units because we may have synthetic "super-root" units in the
future (like doc-merge, post-processing, or user-defined units), which
people may care less and want to focus on what they are actually
building.
* build-started
  * `requested_platforms`: alist of target platforms the build is for

The only thing left is CPU usage, but I don't consider it is a
necessary.

Part of <https://github.com/rust-lang/cargo/issues/15844>

### How to test and review this PR?

[Rendered HTML
snapshot](4702fc0211/tests/testsuite/cargo_report_timings/html_snapshot/out/cargo-timing-20060724T012128000Z-b0fd440798ab3cfb.html)
2025-12-18 22:36:45 +00:00
Weihang Lo
40613e1e58
fix(report): track requested units
Done by having `requested: true` field in user-requested units

Instead of calling it "root units", here we use "requested units",
which represent the actual build targets that users requested.

This is for reserving future extension that requested units may not
always be the "root units" of the unit graph. We might have some
synthetic units like rustdoc-merge, lipo universal binary for macOS,
post-processing, or any user-defined super root units.
The requested units sounds more future-proof than root_units,
2025-12-18 16:32:45 -05:00
Weihang Lo
725980d756
fix(report): track enabled features in unit-registered events 2025-12-18 16:32:45 -05:00
Weihang Lo
2f39f17f85
fix(report): show fingerprint dirty fresh count
This is done by tracking unit-fingerprint events.
2025-12-18 16:32:44 -05:00
Weihang Lo
2ebf882c68
fix(report): show the requested target platforms
we additionally log this info in each `unit-registered` event
2025-12-18 16:32:44 -05:00
Weihang Lo
25d703fed4
fix(report): show the first line of rustc -vV
This shows what `--timings` showing.
2025-12-18 16:32:44 -05:00
Weihang Lo
09bf02339b
refactor(report): prepare metadata in unit-registered event 2025-12-18 16:32:19 -05:00
Weihang Lo
9b344b0c09
test: remove HTML snapshot test for cargo report timings
This caused a headache that

* You need to remember to generate timings report, otherwise the HTML
  get stale.
* The source diff of both the log file and the HTML report are basically
  unreviewable, and the timestamp and elapsed time change every time.

We'd like to find a better way to help review timing HTML instead of this.
2025-12-18 16:30:25 -05:00
Ed Page
6f706c26bb
fix(docs): Document the only possible values for DEBUG in build scripts (#16413)
### What does this PR try to resolve?

fixes #16363 by splitting the documentation of `DEBUG` and `OPT_LEVEL`
and listing the only possible values for `DEBUG` as commented by ehuss.
(I hope it's okay to just take your comment as documentation 😄 )

### How to test and review this PR?

With `mdbook build --open` for example.
2025-12-18 00:27:10 +00:00
dawe
6ede1799d8
fix(docs): Document the only possible values for DEBUG and add links 2025-12-18 00:55:01 +01:00
Ed Page
d8fc14a058
fix(log): emit fingeprint log also for no-rebuild unit (#16408)
### What does this PR try to resolve?

This makes the log message more complete.
Also consumers can check whether a crate is really "no rebuild needed"

It also open a door if we want to log the current fingerprint value.

Part of <https://github.com/rust-lang/cargo/issues/15844>.

### How to test and review this PR?

The test diff should show the behavior change
2025-12-17 21:22:34 +00:00
Weihang Lo
32de338894
fix(log): emit fingeprint log also for no-rebuild unit
This makes the log message more complete.
Also consumers can check whether a crate is really "no rebuild needed"

It also open a door if we want to log the current fingerprint value.
2025-12-17 09:52:20 -05:00
Weihang Lo
371a9beeb7
test(log): also enable build-analysis for first builds 2025-12-16 23:48:03 -05:00
Weihang Lo
5cdc66dbd1
refactor(log): fingerprint comparison result in enum 2025-12-16 23:44:54 -05:00
Weihang Lo
0bb662ba66
fix(log): migrate rebuild message to unit index
Consumer can reference to unit-registered event for details
2025-12-16 20:44:02 -05:00
Weihang Lo
a6228ba34c
Fix link to doc_cfg docs in cargo book (#16404)
Needed for CI of https://github.com/rust-lang/rust/pull/150055 to pass.
Also: I used a full URL instead of a relative path to avoid this can
kind of issues in the future since `cargo` is a submodule and not a
subtree.
2025-12-16 21:26:36 +00:00
Ed Page
c0be385549
Add best pratice for how to check in generated files (#16405)
Best practice here is to have a test that checks if the generated file
matches, but that wasn't documented anywhere.
2025-12-16 17:19:34 +00:00
Josh Triplett
f488dd5f1c Add best pratice for how to check in generated files
Best practice here is to have a test that checks if the generated file
matches, but that wasn't documented anywhere.
2025-12-16 08:45:09 -08:00
Guillaume Gomez
899771db49 Remove link to doc_cfg docs in cargo book 2025-12-16 16:40:16 +01:00
Ed Page
e364307574
test: Use a larger default term width (#16403)
@ehuss [made a
comment](https://github.com/rust-lang/cargo/pull/16391#issuecomment-3649925243)
saying that `cargo` should set `__CARGO_TEST_TTY_WIDTH_DO_NOT_USE_THIS
to a very large value to avoid problems with long paths in tests. This
PR does that by setting it to `200` (the previous default was `140`).

Note: `200` is a start, and we can always go up if needed
2025-12-16 00:36:10 +00:00
Scott Schafer
3ed083194c
test: Use a larger default term width 2025-12-15 16:59:09 -07:00
Scott Schafer
60a26668ce
test: Add default term width to tests 2025-12-15 16:59:05 -07:00
Ed Page
93ce46e9e7
Document more services and permissions of the cargo team (#16402)
This updates the contributor guide with more information about what
services and permissions are available to the Cargo team. This is
primarily to capture that we have a new `rust-lang/cargo-team`
repository. I took the opportunity to update some related information.
2025-12-15 21:41:27 +00:00
Eric Huss
3ccdc467e1 Document more services and permissions of the cargo team
This updates the contributor guide with more information about what
services and permissions are available to the Cargo team. This is
primarily to capture that we have a new `rust-lang/cargo-team`
repository. I took the opportunity to update some related information.
2025-12-15 12:47:03 -08:00
Weihang Lo
e10429934c
fix(new): Improve quality of package name error messages (#16398)
### What does this PR try to resolve?

While triaging #16396, I noticed that the error messages don't match the
rustc style which we are aiming for, so I tweaked the messages and went
ahead and fixed #16396.

Fixes #16396

### How to test and review this PR?

Since `different-binary-name` doesn't have a `-Z` variant, I held off on
suggesting it so we didn't suggest using an unstable feature.
2025-12-15 17:43:54 +00:00
Ed Page
a7cdba1d8f
feat(log): add more log events (#16390)
### What does this PR try to resolve?

* `resolution-started`
* `resolution-finished`
* `unit-graph-started`
* `unit-graph-finished`
* `unit-registered`

The first four events are simple log events with elapsed time.

The `unit-registered` event contains unit metadata and the index, so
that `unit-started` doesn't need to have those. As a result, the timing
replay now requires `unit-registered` events to derive those data.

The log and HTML snapshot also changed to `rustfix`, which is a bit
smaller in size.

Part of <https://github.com/rust-lang/cargo/issues/15844>

### How to test and review this PR?
2025-12-15 15:39:58 +00:00
Ed Page
214f69e806 fix(new): Only suggest bin.name for valid crate names
Validate crate names are a superset of valid package names which also
try to work for `--extern`.

Fixes #16396
2025-12-15 09:02:00 -06:00
Ed Page
88e3641818 fix(new): Be more direct in errors/warnings 2025-12-15 08:31:49 -06:00