rust/src
bors 8387095803 Auto merge of #152677 - ehuss:bootstrap-json-target-spec, r=davidtwco,jieyouxu
Support JSON target specs in bootstrap

JSON target specs were destabilized in https://github.com/rust-lang/rust/pull/150151 and https://github.com/rust-lang/rust/pull/151534. However, this broke trying to build rustc itself with a JSON target spec. This is because in a few places bootstrap is manually calling `rustc` without the ability for the user to provide additional flags (primarily, `-Zunstable-options` to enable JSON targets).

There's a few different ways to fix this. One would be to change these calls to `rustc` to include flags provided by the user (such as `RUSTFLAGS_NOT_BOOTSTRAP`). Just to keep things simple, this PR proposes to just unconditionally pass `-Zunstable-options`.

Another consideration here is how maintainable this is. A possible improvement here would be to have a function somewhere (BootstrapCommand, TargetSelection, free function) that would handle appropriately adding the `--target` flag. For example, that's what cargo does in [`CompileKind::add_target_arg`](592058c7ce/src/cargo/core/compiler/compile_kind.rs (L144-L154)).

I have only tested building the compiler and a few tools like rustdoc. I have not tested doing things like building other tools, running tests, etc.

This would be much easier if there was a Docker image for testing the use case of building rustc with a custom target spec (and even better if that ran in CI).

After the next beta branch, using target JSON specs will become more cumbersome because target specs with the `.json` extension will now require passing `-Zjson-target-spec` (from
https://github.com/rust-lang/cargo/pull/16557). This does not affect target specs without the `.json` extension (such as those from RUST_TARGET_PATH). From my testing, it should be sufficient to pass `CARGOFLAGS_NOT_BOOTSTRAP="-Zjson-target-spec"`. I think that should be fine, since this is not a particularly common use case AFAIK. We could extend bootstrap to auto-detect if the target is a file path, and pass `-Zjson-target-spec` appropriately. I tried something similar in f0bdd35483, which could be adapted if desired.

It would be nice if all of this is documented somewhere. https://rustc-dev-guide.rust-lang.org/building/new-target.html does not really say how to build the compiler with a custom json target.

Fixes https://github.com/rust-lang/rust/issues/151729
2026-02-17 17:35:50 +00:00
..
bootstrap Auto merge of #152677 - ehuss:bootstrap-json-target-spec, r=davidtwco,jieyouxu 2026-02-17 17:35:50 +00:00
build_helper citool: report debuginfo test statistics 2026-02-04 06:44:09 +05:30
ci Rollup merge of #152609 - mati865:gnullvm-llvm-dll, r=bjorn3 2026-02-17 14:18:43 +01:00
doc Remove last remnants of rustc_query_system. 2026-02-16 22:56:47 +11:00
etc fixup debugger files wrt to MaybeDangling 2025-12-26 22:02:17 +01:00
gcc@efdd0a7290 Update GCC submodule 2026-02-14 16:59:09 +01:00
librustdoc Rollup merge of #152664 - Embers-of-the-Fire:fix-152601, r=GuillaumeGomez 2026-02-17 13:02:24 +11:00
llvm-project@a306f6a8c5 Update to LLVM 22 rc 3 2026-02-10 10:11:25 +01:00
rustc-std-workspace Generalize branch references to HEAD 2025-11-02 11:15:55 +01:00
rustdoc-json-types rustdoc-json: add rlib path to ExternalCrate to enable robust crate resolution 2025-11-21 09:22:59 +00:00
tools Update sysinfo version to 0.38.2 2026-02-17 10:57:34 +01:00
README.md
stage0 Bump stage0 2026-01-21 20:03:56 -05:00
version Bump version to 1.95.0 2026-01-17 10:19:26 -05:00

This directory contains some source code for the Rust project, including:

  • The bootstrapping build system
  • Various submodules for tools, like cargo, tidy, etc.

For more information on how various parts of the compiler work, see the rustc dev guide.