Merged
Conversation
This changes the index parsing code to pass around CliUnstable instead of the bindeps bool to make it easier to check for multiple unstable options.
This changes CompileTarget to an enum to better differentiate when it is a JSON path versus when it is a target tuple. This should help ensure that the correct behavior is being used without constantly needing to check if the suffix is `.json`. This also adds an `CompileKind::add_target_arg` helper to centralize where the `--target` arg adding is done.
This adds the `-Z json-target-spec` CLI flag to assist with using custom `.json` target spec files. `rustc` recently switched so that it requires `-Z unstable-options` when using custom spec files (rust-lang/rust#151534). This can make it rather awkward to use spec files with cargo because it then requires setting RUSTFLAGS and RUSTDOCFLAGS to pass `-Zunstable-options`. It also ends up causing some confusing error messages. Now, using `--target` with `.json` extension files generates an error that explains you need `-Zjson-target-spec`. The only thing this flag does is disable that error, and automatically passes `-Zunstable-options` with the `--target` flag. This does not 100% cover json target spec files, because they can be placed in RUST_TARGET_PATH or the sysroot, and `rustc` will automatically search for them (without the `.json` extension in the `--target` arg). The user will just need to use RUSTFLAGS/RUSTDOCFLAGS in that situation (but I expect that to be rare). The majority of this change is changing `CompileTarget::new` to take a flag if `-Zjson-target-spec` is enabled, and then threading through all the places that call it. `CompileTarget::new` is responsible for generating an error if json is used without the Z flag.
Collaborator
epage
approved these changes
Jan 25, 2026
weihanglo
approved these changes
Jan 25, 2026
Member
|
Ah Ed got it already |
ranger-ross
pushed a commit
to ranger-ross/cargo
that referenced
this pull request
Jan 25, 2026
This adds the `-Z json-target-spec` CLI flag to assist with using custom `.json` target spec files. `rustc` recently switched so that it requires `-Z unstable-options` when using custom spec files (rust-lang/rust#151534). This can make it rather awkward to use spec files with cargo because it then requires setting RUSTFLAGS and RUSTDOCFLAGS to pass `-Zunstable-options`. It also ends up causing some confusing error messages. See the individual commits for more details. This ended up being a larger diff than I wanted. I'm not 100% certain this is worth it, but I think it significantly improves the experience using `.json` files, so I I'm leaning towards it. Testing can be done with `rustc` built from rust-lang/rust#151534 to ensure that everything passes after that PR (including setting `CARGO_RUN_BUILD_STD_TESTS=1`).
rust-bors bot
pushed a commit
to rust-lang/rust
that referenced
this pull request
Jan 28, 2026
Update cargo submodule 11 commits in efcd9f58636c1990393d495159045d9c35e43b8f..0f3a1e9099aecdf95f144e842d96dc1827c1985 2026-01-23 13:50:59 +0000 to 2026-01-27 20:14:45 +0000 - feat(lints): Add redundant_homepage lint (rust-lang/cargo#16561) - feat(lints): Add `non_*_case_features` (rust-lang/cargo#16560) - Update build_std::basic test to ensure index doesn't update (rust-lang/cargo#16559) - feat(lints): Add mutually exclusive `non_{kebab,snake}_case_packages` (rust-lang/cargo#16554) - fix(lints): Pluralize non_kebab_case_bins (rust-lang/cargo#16553) - Add -Z json-target-spec (rust-lang/cargo#16557) - feat(lint): Add redundant_readme lint (rust-lang/cargo#16552) - chore(deps): update msrv (rust-lang/cargo#16387) - tests: add regression test for --artifact-dir on stable (rust-lang/cargo#16541) - Don't check the specific build-std output (rust-lang/cargo#16551) - Fix build-std lto test to run on other platforms (rust-lang/cargo#16550)
rust-bors bot
pushed a commit
to rust-lang/rust
that referenced
this pull request
Jan 29, 2026
Update cargo submodule 11 commits in efcd9f58636c1990393d495159045d9c35e43b8f..0f3a1e9099aecdf95f144e842d96dc1827c1985 2026-01-23 13:50:59 +0000 to 2026-01-27 20:14:45 +0000 - feat(lints): Add redundant_homepage lint (rust-lang/cargo#16561) - feat(lints): Add `non_*_case_features` (rust-lang/cargo#16560) - Update build_std::basic test to ensure index doesn't update (rust-lang/cargo#16559) - feat(lints): Add mutually exclusive `non_{kebab,snake}_case_packages` (rust-lang/cargo#16554) - fix(lints): Pluralize non_kebab_case_bins (rust-lang/cargo#16553) - Add -Z json-target-spec (rust-lang/cargo#16557) - feat(lint): Add redundant_readme lint (rust-lang/cargo#16552) - chore(deps): update msrv (rust-lang/cargo#16387) - tests: add regression test for --artifact-dir on stable (rust-lang/cargo#16541) - Don't check the specific build-std output (rust-lang/cargo#16551) - Fix build-std lto test to run on other platforms (rust-lang/cargo#16550)
rust-bors bot
pushed a commit
to rust-lang/rust
that referenced
this pull request
Jan 31, 2026
Update cargo submodule 18 commits in efcd9f58636c1990393d495159045d9c35e43b8f..fe2f314aef06e688a9517da1ac0577bb1854d01f 2026-01-23 13:50:59 +0000 to 2026-01-30 21:52:01 +0000 - feat(lints): Add unused workspace dependency lint (rust-lang/cargo#16571) - docs: Remove redundant homepage link (rust-lang/cargo#16572) - refactor: Remove unused workspace dependencies (rust-lang/cargo#16573) - Re-downgrade curl-sys (rust-lang/cargo#16570) - docs(report): enhance man pages for `cargo report *` (rust-lang/cargo#16430) - fix(lints): Refine redundant metadata lints (rust-lang/cargo#16564) - Prevent `cargo init` in home directory (rust-lang/cargo#16566) - feat(lints): Add redundant_homepage lint (rust-lang/cargo#16561) - feat(lints): Add `non_*_case_features` (rust-lang/cargo#16560) - Update build_std::basic test to ensure index doesn't update (rust-lang/cargo#16559) - feat(lints): Add mutually exclusive `non_{kebab,snake}_case_packages` (rust-lang/cargo#16554) - fix(lints): Pluralize non_kebab_case_bins (rust-lang/cargo#16553) - Add -Z json-target-spec (rust-lang/cargo#16557) - feat(lint): Add redundant_readme lint (rust-lang/cargo#16552) - chore(deps): update msrv (rust-lang/cargo#16387) - tests: add regression test for --artifact-dir on stable (rust-lang/cargo#16541) - Don't check the specific build-std output (rust-lang/cargo#16551) - Fix build-std lto test to run on other platforms (rust-lang/cargo#16550)
rust-bors bot
pushed a commit
to rust-lang/rust
that referenced
this pull request
Jan 31, 2026
Update cargo submodule 18 commits in efcd9f58636c1990393d495159045d9c35e43b8f..fe2f314aef06e688a9517da1ac0577bb1854d01f 2026-01-23 13:50:59 +0000 to 2026-01-30 21:52:01 +0000 - feat(lints): Add unused workspace dependency lint (rust-lang/cargo#16571) - docs: Remove redundant homepage link (rust-lang/cargo#16572) - refactor: Remove unused workspace dependencies (rust-lang/cargo#16573) - Re-downgrade curl-sys (rust-lang/cargo#16570) - docs(report): enhance man pages for `cargo report *` (rust-lang/cargo#16430) - fix(lints): Refine redundant metadata lints (rust-lang/cargo#16564) - Prevent `cargo init` in home directory (rust-lang/cargo#16566) - feat(lints): Add redundant_homepage lint (rust-lang/cargo#16561) - feat(lints): Add `non_*_case_features` (rust-lang/cargo#16560) - Update build_std::basic test to ensure index doesn't update (rust-lang/cargo#16559) - feat(lints): Add mutually exclusive `non_{kebab,snake}_case_packages` (rust-lang/cargo#16554) - fix(lints): Pluralize non_kebab_case_bins (rust-lang/cargo#16553) - Add -Z json-target-spec (rust-lang/cargo#16557) - feat(lint): Add redundant_readme lint (rust-lang/cargo#16552) - chore(deps): update msrv (rust-lang/cargo#16387) - tests: add regression test for --artifact-dir on stable (rust-lang/cargo#16541) - Don't check the specific build-std output (rust-lang/cargo#16551) - Fix build-std lto test to run on other platforms (rust-lang/cargo#16550)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds the
-Z json-target-specCLI flag to assist with using custom.jsontarget spec files.rustcrecently switched so that it requires-Z unstable-optionswhen using custom spec files (rust-lang/rust#151534). This can make it rather awkward to use spec files with cargo because it then requires setting RUSTFLAGS and RUSTDOCFLAGS to pass-Zunstable-options. It also ends up causing some confusing error messages.See the individual commits for more details.
This ended up being a larger diff than I wanted. I'm not 100% certain this is worth it, but I think it significantly improves the experience using
.jsonfiles, so I I'm leaning towards it.How to test and review this PR?
Testing can be done with
rustcbuilt from rust-lang/rust#151534 to ensure that everything passes after that PR (including settingCARGO_RUN_BUILD_STD_TESTS=1).