21121 Commits

Author SHA1 Message Date
Eric Huss
6cf360061e Update to mdbook 0.5
Changelog: https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-051
2025-11-22 13:13:29 -08:00
Ed Page
19678fce85
test: re-enable test since not flaky anymore (#16287)
Fixes in rust-lang/cargo#16052
Resolves rust-lang/cargo#16047
2025-11-22 12:09:26 +00:00
Weihang Lo
60d59c9c94
test: re-enable test since not flaky anymore
Fixes in rust-lang/cargo#16052
Resolves rust-lang/cargo#16047
2025-11-21 21:58:53 -05:00
Ed Page
9fa462fe3a
Enable CARGO_CFG_DEBUG_ASSERTIONS in build scripts based on profile (#16160)
Build scripts need to know whether debug assertions are enabled to
properly configure dependencies with matching assertion behavior.
Previously, `CARGO_CFG_DEBUG_ASSERTIONS` was filtered out because the
cfg query to rustc doesn't include profile settings.

This PR manually sets `CARGO_CFG_DEBUG_ASSERTIONS` based on the
profile's `debug-assertions` setting, allowing build scripts to
configure dependencies appropriately.

FCP:
https://github.com/rust-lang/cargo/pull/16160#issuecomment-3458280652

Closes #15760
2025-11-21 20:49:51 +00:00
Ed Page
2b7dbd9f3d
fix(config-include): disallow glob and template syntax (#16285)
### What does this PR try to resolve?

This reserves future possibility for us to support globa syntax and
templated paths.

Addressing
https://github.com/rust-lang/cargo/pull/16284#discussion_r2550499932
2025-11-21 20:47:19 +00:00
Ed Page
1a7d588470
test(config-include): include always relative to including config (#16286)
### What does this PR try to resolve?

Address feedback:
https://github.com/rust-lang/cargo/pull/16284#discussion_r2550527353
2025-11-21 20:27:24 +00:00
Weihang Lo
637da934f9
test(config-include): include always relative to including config 2025-11-21 14:54:54 -05:00
Weihang Lo
80c849ee46
fix(config-include): disallow glob and template syntax
This reserves future possibility for us to support globa syntax and
templated paths.

Addressing https://github.com/rust-lang/cargo/pull/16284#discussion_r2550499932
2025-11-21 13:53:54 -05:00
Weihang Lo
61fe8750c7
test(config-include): show glob/template syntax isnt disallowed
Which we want to disallow to reserve for future.
2025-11-21 13:46:45 -05:00
Weihang Lo
f3b7ff70e9
docs(guide): When suggesting alt dev profile, link to related issue (#16275)
### What does this PR try to resolve?

Having sections in the build performance chapter link out to their
issues is helpful for:
- giving hope that things will improve
- providing a place for people to subscribe to for updates
- raise visibility for ensuring we get appropriaet feedback (e.g. on
degrading the debugger experience)

Noticed this was missing while writing up about this new chapter on the
blog post.

### How to test and review this PR?
2025-11-21 17:13:38 +00:00
Ed Page
6ed260f255
refactor(timings): separate data collection and presentation (#16282)
### What does this PR try to resolve?

The goal of this refactor is to separate data collection and
presentation,
so that we can replay an HTML report from log generated by
`-Zbuild-analysis`.

### How to test and review this PR?

Should have no user-facing change,
though I would encourage review to run `cargo build --timings`
and check if there is anything broken.
2025-11-21 02:22:54 +00:00
Weihang Lo
ae9beb94c7
refactor(timings): make error into render context 2025-11-20 19:30:03 -05:00
Weihang Lo
874b19bfcc
refactor(timings): use itertools string join 2025-11-20 19:30:03 -05:00
Weihang Lo
62ccd03f26
refactor(timings): render context stop referencing to buildrunner 2025-11-20 19:30:03 -05:00
Weihang Lo
ff8bca4b75
refactor(timings): use inline arg capture 2025-11-20 19:30:02 -05:00
Weihang Lo
cef8626ae8
refactor(timings): add a render context 2025-11-20 19:25:35 -05:00
Weihang Lo
bfb07a3da0
refactor(timings): make report render pure
Don't access an shell or file system in render reporting module.
2025-11-20 19:22:24 -05:00
Weihang Lo
5fbb9c3495
refactor(timings): extract presentation layer to a module 2025-11-20 19:11:19 -05:00
Weihang Lo
d89b09fb91
refactor(timings): make report_html free function 2025-11-20 18:51:14 -05:00
Weihang Lo
4ce06ef03a
refactor(timings): section timing aggregation to free function 2025-11-20 18:39:55 -05:00
Weihang Lo
1f872aa373
refactor(timings): unit data conversion to free function 2025-11-20 18:39:54 -05:00
Weihang Lo
be81bb6a8f
refactor(timings): extract UnitData struct to module 2025-11-20 18:39:54 -05:00
Weihang Lo
79d5578d5a
refactor(timings): move timings into dedicated directory 2025-11-20 18:39:53 -05:00
Weihang Lo
14c6f0063c
test(build-std): Add test for LTO (#16277)
Add a test for https://github.com/rust-lang/rust/pull/146133. `cargo
+nightly-2025-08-29 test --test build-std -- lto` can reproduce the
regression.
This is not a bug from Cargo, but it requires `-Zbuild-std` in most use
cases.
The test case is from https://github.com/rust-lang/rust/issues/146109.
The point is that when rustc is invoked with -Clto=fat or -Clto=thin, it
should perform LTO with ALL bitcodes. However,
https://github.com/rust-lang/rust/pull/145368 emits bitcodes for
compiler_builtins but excludes it from LTO participation.
As a result, the compiler_builtins bitcodes library is passed to the
linker, but the linkers, such as the GNU ld or older versions of LLD,
are unable to process bitcodes.
2025-11-20 20:22:00 +00:00
Weihang Lo
b5b8b07719
fix(bindeps): do not propagate artifact dependency to proc macro or build deps (#15788)
_Thanks for the pull request 🎉!_
_Please read the contribution guide: <https://doc.crates.io/contrib/>._

### What does this PR try to resolve?

This PR fixes a bug for the nightly feature `bindeps`. Basically, if

- a package `foo` has an artifact dependency `artifact` with a specified
target TARGET_ARTIFACT different from host TARGET_HOST,
- `artifact` depends on proc macro `macro`,
- `macro` conditionally depends on `arch` on TARGET_HOST,

cargo build would panic on TARGET_HOST with the following error message:

```
did not find features for (PackageId { name: "arch", version: "0.0.1", source: "/Users/lencerf/Developer/cargo/target/tmp/cit/t0/foo/arch" }, ArtifactDep(CompileTarget { name: "x86_64-apple-darwin" })) within activated_features:
[
    (
        PackageId {
            name: "foo",
            version: "0.0.1",
            source: "/Users/lencerf/Developer/cargo/target/tmp/cit/t0/foo",
        },
        NormalOrDev,
    ),
    (
        PackageId {
            name: "macro",
            version: "0.0.1",
            source: "/Users/lencerf/Developer/cargo/target/tmp/cit/t0/foo/macro",
        },
        ArtifactDep(
            CompileTarget {
                name: "x86_64-apple-darwin",
            },
        ),
    ),
    (
        PackageId {
            name: "artifact",
            version: "0.0.1",
            source: "/Users/lencerf/Developer/cargo/target/tmp/cit/t0/foo/artifact",
        },
        ArtifactDep(
            CompileTarget {
                name: "x86_64-apple-darwin",
            },
        ),
    ),
]
```

Similar panic happens when

- a package `foo` has an artifact dependency `artifact` with a specified
target TARGET_ARTIFACT different from host TARGET_HOST,
- `artifact` has a build dependency `builder`,
- `builder` conditionally depends on `arch` on TARGET_HOST.

From the above message, it is clear that proc macro `macro` was wrongly
associated with `FeaturesFor::ArtifactDep` instead of
`FeaturesFor::HostDep`. Package `arch` was later ignored because cargo
thought `macro` should be built for TARGET_ARTIFACT
(x86_64-apple-darwin), while `arch` was conditionally needed on
TARGET_HOST (aarch64-apple-darwin).

Similar analyses apply to the other test case.

This commit fixes 2 paths:
- when resolving features, if we encounter build dependencies or proc
macros, always associate them with `FeaturesFor::HostDep`.
- when deriving UnitFor for dependencies, stop propagating
artifact_target_for_features if the the dependency is a build dependency
or a proc macro.

### How to test and review this PR?

This PR contains 2 commits

- the first commit adds 2 test cases to reproduce the issue above. Since
they cannot pass now, they are marked with `#[should_panic]`
- the second commit fixes the bug and removes the `#[should_panic]` from
the 2 test cases.

`cargo test` can pass on each commit.
2025-11-20 13:31:14 +00:00
dianqk
374368d2ac
test(build-std): Add test for LTO 2025-11-20 21:28:29 +08:00
Changyuan Lyu
03603099f5 fix(bindeps): do not propagate artifact dependency to proc macro or build deps
As reproduced in the 2 fixed test cases of this commit, cargo panicked
when

- a package `foo` has an artifact dependency `artifact` with a specified
  target TARGET_ARTIFACT different from host TARGET_HOST,
- `artifact` depends on proc macro `macro`,
- `macro` conditionally depends on `arch` on TARGET_HOST,

with the following message

```
did not find features for (PackageId { name: "arch", version: "0.0.1", source: "/Users/lencerf/Developer/cargo/target/tmp/cit/t0/foo/arch" }, ArtifactDep(CompileTarget { name: "x86_64-apple-darwin" })) within activated_features:
[
    (
        PackageId {
            name: "foo",
            version: "0.0.1",
            source: "/Users/lencerf/Developer/cargo/target/tmp/cit/t0/foo",
        },
        NormalOrDev,
    ),
    (
        PackageId {
            name: "macro",
            version: "0.0.1",
            source: "/Users/lencerf/Developer/cargo/target/tmp/cit/t0/foo/macro",
        },
        ArtifactDep(
            CompileTarget {
                name: "x86_64-apple-darwin",
            },
        ),
    ),
    (
        PackageId {
            name: "artifact",
            version: "0.0.1",
            source: "/Users/lencerf/Developer/cargo/target/tmp/cit/t0/foo/artifact",
        },
        ArtifactDep(
            CompileTarget {
                name: "x86_64-apple-darwin",
            },
        ),
    ),
]
```

From the above message, it is clear that proc macro `macro` was wrongly
associated with `FeaturesFor::ArtifactDep` instead of
`FeaturesFor::HostDep`. Package `arch` was later ignored because cargo
thought `macro` should be built for TARGET_ARTIFACT
(x86_64-apple-darwin), while `arch` was conditionally needed on
TARGET_HOST (aarch64-apple-darwin).

Similar analyses apply to the other test case.

This commit fixes 2 paths:
- when resolving features, if we encounter build dependencies or proc
  macros, always associate them with `FeaturesFor::HostDep`.
- when deriving UnitFor for dependencies, stop propagating
  artifact_target_for_features if the the dependency is a build
  dependency or a proc macro.

Signed-off-by: Changyuan Lyu <changyuan.lv@gmail.com>
2025-11-19 23:14:12 -08:00
Changyuan Lyu
a5bedb3462 test(bindeps): reveal a bug of the propagation of artifact dependency
Add 2 test cases to reproduce a bug of `-Zbindeps`.

Basically, if

- a package `foo` has an artifact dependency `artifact` with a specified
  target TARGET_ARTIFACT different from host TARGET_HOST,
- `artifact` depends on proc macro `macro`,
- `macro` conditionally depends on `arch` on TARGET_HOST,

cargo build would panic on TARGET_HOST with the following error message:

```
did not find features for (PackageId { name: "arch", version: "0.0.1", source: "/Users/lencerf/Developer/cargo/target/tmp/cit/t0/foo/arch" }, ArtifactDep(CompileTarget { name: "x86_64-apple-darwin" })) within activated_features:
[
    (
        PackageId {
            name: "foo",
            version: "0.0.1",
            source: "/Users/lencerf/Developer/cargo/target/tmp/cit/t0/foo",
        },
        NormalOrDev,
    ),
    (
        PackageId {
            name: "macro",
            version: "0.0.1",
            source: "/Users/lencerf/Developer/cargo/target/tmp/cit/t0/foo/macro",
        },
        ArtifactDep(
            CompileTarget {
                name: "x86_64-apple-darwin",
            },
        ),
    ),
    (
        PackageId {
            name: "artifact",
            version: "0.0.1",
            source: "/Users/lencerf/Developer/cargo/target/tmp/cit/t0/foo/artifact",
        },
        ArtifactDep(
            CompileTarget {
                name: "x86_64-apple-darwin",
            },
        ),
    ),
]
```

Similar panic happens when

- a package `foo` has an artifact dependency `artifact` with a specified
  target TARGET_ARTIFACT different from host TARGET_HOST,
- `artifact` has a build dependency `builder`,
- `builder` conditionally depends on `arch` on TARGET_HOST.

Signed-off-by: Changyuan Lyu <changyuan.lv@gmail.com>
2025-11-19 17:37:12 -08:00
Ed Page
7e42aecfd7 docs(guide): When suggesting alt dev profile, link to related issue
Having sections in the build performance chapter link out to their
issues is helpful for:
- giving hope that things will improve
- providing a place for people to subscribe to for updates
- raise visibility for ensuring we get appropriaet feedback (e.g. on
  degrading the debugger experience)

Noticed this was missing while writing up about this new chapter on the
blog post.
2025-11-18 13:52:15 -06:00
Ed Page
5c0343317c
feat: emit a warning when both package.publish and --index are specified (#16268)
Partially adresses #16231.

### What does this PR try to resolve?

`cargo publish` will fail, if `--registry` is passed and that index
isn't included in `package.publish` in Cargo.toml. However, as described
in linked issue, `--index` bypasses that check and may cause unexpected
publication of packages.

This PR implements warning that is shown when `--index` and
`package.publish` is set at the same time.
2025-11-18 19:05:44 +00:00
motorailgun
d4a80f30d2
feat: emit a warning when both package.publish and --index are specified 2025-11-19 03:28:42 +09:00
motorailgun
fa36e6e3c5
refactor: nits in resolve_registry_or_index() 2025-11-19 03:28:29 +09:00
motorailgun
3ec8f140e3
chore: add a test for publishing with both publish and index specified 2025-11-19 03:28:01 +09:00
Weihang Lo
9a303219f5
docs(cargo-yank): clarify yank behavior with leaked credentials (#16274)
Clarifies that yanking only affects Cargo's dependency resolution, not
crate availability.
Yanked crates remain fully downloadable, so yanking cannot prevent the
spread of leaked credentials.

Closes #16266
2025-11-18 18:22:16 +00:00
Mohamed Ali
4dc0493cfb docs(cargo-yank): clarify yank behavior with leaked credentials 2025-11-18 19:48:04 +02:00
Weihang Lo
6ce5357ace
feat(generate-lockfile): Add unstable --publish-time flag (#16265)
### What does this PR try to resolve?

Implementation for #5221, #15491

Tracking issues: #16270, #16271

Use cases:
- Improved reproduction steps using cargo scripts without including a
  lockfile
- Debugging issues in the past
- Manual stop gap for #15973

This seemed like the shortest path to testing the proposed `pubtime`
index entries (#15491) so we can unblock other work on it like #15973.
While this has some big caveats, the design is straightforward.
In contrast, #15973 has a lot more design questions (is this a
resolver-wide setting or a per-registry setting, what formats are
accepted, etc) that could slow down development and testing `pubtime`.

### How to test and review this PR?

Unresolved questions (deferred to the tracking issues):
- How do we compensate for the caveats, with one option being to leave
  this perma-unstable?
- How should we deal with Summary `pubtime` parse errors?
- How strict should we be on the Summary `pubtime` format?
- Should we offer a convenient way of getting a compatible timestamp?

Future possibilities:
- Ability to lock to a timestamp with `cargo update` updating the
  timestamp (could be useful for cargo scripts)
2025-11-18 17:46:32 +00:00
Ed Page
57d0592455 feat(generate-lockfile): Add unstable --publish-time flag
Implementation for #5221

Use cases:
- Improved reproduction steps using cargo scripts without including a
  lockfile
- Debugging issues in the past
- Manual stop gap for #15973

Unresolved questions:
- How do we compensate for the caveats, with one option being to leave
  this perma-unstable?
- How should we deal with Summary `pubtime` parse errors?
- How strict should we be on the Summary `pubtime` format?
- Should we offer a convenient way of getting a compatible timestamp?

Future possibilities:
- Ability to lock to a timestamp with `cargo update` updating the
  timestamp (could be useful for cargo scripts)

This seemed like the shortest path to testing the proposed `pubtime`
index entries so we can unblock other work on it like #15973.
While this has some big caveats, the design is straightforward.
In contrast, #15973 has a lot more design questions (is this a
resolver-wide setting or a per-registry setting, what formats are
accepted, etc) that could slow down development and testing `pubtime`.
2025-11-17 14:24:35 -06:00
Ed Page
b9bdb389c0 test(generate-lockfile): Add test to show --publish-time 2025-11-17 14:23:52 -06:00
Ed Page
1340d2258e feat(summary): Add unstable pubtime field 2025-11-17 14:23:52 -06:00
Ed Page
b5354b5686
Do not lock the artifact-dir for check builds (#16230)
### What does this PR try to resolve?

This PR modifies the locking logic to avoid locking `artifact-dir` for
check builds.
Part of #4282

Note: This change is **not** behind `-Zbuild-dir-new-layout` or
`-Zfine-grain-locking` unstable flags.

### How to test and review this PR?

See the tests included in the PR.
You can run `cargo check` to verify.

r? @epage
2025-11-17 18:35:43 +00:00
motorailgun
8057e622aa
refactor: extract registry/index resolution into a function 2025-11-18 01:30:10 +09:00
Ross Sullivan
9f5393a561
feat: Do not lock the artifact-dir for check builds 2025-11-15 21:00:49 +09:00
Ross Sullivan
bd3416261f
refactor: made artifact_dir optional in Layout 2025-11-15 20:57:20 +09:00
Ed Page
745aae6082
fix(fingerprint): force update mtime of cargo-check artifacts (#16262)
### What does this PR try to resolve?

This mtime shift for .rmeta is a workaround as rustc incremental build
since rust-lang/rust#114669 (1.90.0) skips unnecessary rmeta generation.

The situation is like this:

1. When build script execution's external dependendies
   (rerun-if-changed, rerun-if-env-changed) got updated,
   the execution unit reran and got a newer mtime.
2. rustc type-checked the associated crate, though with incremental
   compilation, no rmeta regeneration. Its `.rmeta` stays old.
3. Run `cargo check` again. Cargo found build script execution had
   a new mtime than existing crate rmeta, so re-checking the crate.
   However the check is a no-op (input has no change), so stuck.

Fixes #16104

### How to test and review this PR?

Tests pass.

There is a reproduction in
<https://github.com/rust-lang/cargo/issues/16104#issuecomment-3530739039>,but
actually a minimal one is touching a file of build script dependency,
than `cargo check`. It'll easily get stuck.

This is an ugly workaround. And `-Zchecksum-freshness` doesn't help
because build script is involved.
2025-11-14 17:08:05 +00:00
Ed Page
c802c3e22c feat(index): Add unstable pubtime field 2025-11-14 11:00:39 -06:00
Ed Page
a83ebb9857 chore(schemas): Bump to v0.11 2025-11-14 10:59:59 -06:00
Weihang Lo
3885b78666
fix(manifest): Point out when a key belongs to config (#16256)
### What does this PR try to resolve?

Inspired by #16251

### How to test and review this PR?
2025-11-14 15:26:02 +00:00
Ed Page
c24e1c1715
Use raw false during cfg test (#16261)
Due to https://github.com/rust-lang/rust/pull/146978, which has been
approved, this test would fail because `--cfg false` is denied now.
2025-11-14 14:47:04 +00:00
Weihang Lo
9e7e29e56d
fix(fingerprint): force update mtime of cargo-check artifacts
This mtime shift for .rmeta is a workaround as rustc incremental build
since rust-lang/rust 114669 (1.90.0) skips unnecessary rmeta generation.

The situation is like this:

1. When build script execution's external dependendies
   (rerun-if-changed, rerun-if-env-changed) got updated,
   the execution unit reran and got a newer mtime.
2. rustc type-checked the associated crate, though with incremental
   compilation, no rmeta regeneration. Its `.rmeta` stays old.
3. Run `cargo check` again. Cargo found build script execution had
   a new mtime than existing crate rmeta, so re-checking the crate.
   However the check is a no-op (input has no change), so stuck.
2025-11-14 04:58:42 -05:00
Weihang Lo
2a07c68eef
test: cargo-check stuck due to build script mtime too new
See rust-lang/cargo 16104 for what we're testing against
2025-11-14 04:52:05 -05:00