Commit graph

7250 commits

Author SHA1 Message Date
Matthias Krüger
ad378be221
Rollup merge of #142160 - Urgau:check-cfg-bootstrap-only-rustc, r=Kobzol
Only allow `bootstrap` cfg in rustc & related

Fixes https://github.com/rust-lang/rust/issues/142150
r? bootstrap
2025-06-09 10:20:52 +02:00
Matthias Krüger
45cf4fb8d7
Rollup merge of #141751 - jieyouxu:remap, r=Kobzol
Remap compiler vs non-compiler sources differently (bootstrap side)

See [#t-compiler/help > Span pointing to wrong file location (`rustc-dev` component)](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/Span.20pointing.20to.20wrong.20file.20location.20.28.60rustc-dev.60.20component.29/with/521087083).

The path remapping and unremapping for compiler sources (distributed via `rustc-dev` dist component) is broken because bootstrap currently remaps all sources unconditionally (if remapping is enabled) to the `/rustc/{hash}` form. However, the `rustc-dev` dist component (compiler sources) and `rust-src` dist component (library sources) unpacks differently:

- `rust-src` unpacks sources to a path like `$sysroot/lib/rustlib/src/rust`, whereas
- `rustc-dev` unpacks sources to a path like `$sysroot/lib/rustlib/rustc-src/rust`[^note],

meaning that the compiler need to unremap them differently. But the same remapping means that the compiler has no way to distinguish between compiler and non-compiler (esp. standard library) sources. To remedy this, this PR adopts the approach of:

- remapping compiler sources (corresponding to `rustc-dev` dist component) with `/rustc-dev/{hash}` (this is `RemapScheme::Compiler`), and
- remapping non-compiler sources (corresponding to `rust-src` dist component or other non-compiler sources) with `/rustc/{hash}` (this is `RemapScheme::NonCompiler`).

A different remapping allows the compiler to reverse the remapping differently.

This PR implements the bootstrap side. A follow-up compiler-side change is needed to implement the unremapping change to address the reported issue completely.

This PR introduces another env var `CFG_VIRTUAL_RUSTC_DEV_SOURCE_BASE_DIR` that is made available to the compiler when building compiler sources to know what the remap scheme for `rustc-dev` (`RemapScheme::Compiler`) is. Compiler sources are built with the compiler remapping scheme.

As far as I know, this change should not introduce new regressions, because the compiler source unremapping (through `rustc-dev`) is already broken.

[^note]: (Notice the `src` vs `rustc-src` difference.)
2025-06-09 10:20:51 +02:00
Jubilee
840baa46ff
Rollup merge of #142053 - heiher:loong32-none, r=wesleywiser
Add new Tier-3 targets: `loongarch32-unknown-none*`

MCP: https://github.com/rust-lang/compiler-team/issues/865

NOTE: LoongArch32 ELF object support is available starting with object v0.37.0.
2025-06-08 17:17:53 -07:00
Guillaume Gomez
215dc8c499
Rollup merge of #142116 - jieyouxu:fix-tracing, r=Mark-Simulacrum
Fix bootstrap tracing imports
2025-06-07 22:22:58 +02:00
Urgau
b283394db1 Only allow bootstrap cfg in rustc, related and tool-std 2025-06-07 18:11:53 +02:00
bors
321dde1252 Auto merge of #141917 - petrochenkov:nobinroot, r=jieyouxu
bootstrap: Remove `rustc_snapshot_libdir` from PATH in one more place

Same as https://github.com/rust-lang/rust/pull/141657 but in a different part of the build system, with the same goal of addressing [#t-infra/bootstrap > Build broken in MSYS2 @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Build.20broken.20in.20MSYS2/near/520709527).

It seems to work on windows-{gnu,msvc} and linux-gnu at least.

r? jieyouxu
2025-06-07 09:21:38 +00:00
bors
868bf2da31 Auto merge of #141800 - workingjubilee:build-std-with-less-leaf-pointers, r=saethlin
bootstrap: build std sans leaf frame pointers

Sometimes leaf frame-pointers can impact LLVM inlining choices, and that can be a real problem for things like `mul_add`.
2025-06-06 21:21:59 +00:00
Jieyou Xu
46a936a353
bootstrap: fix tracing imports 2025-06-06 20:49:55 +08:00
bors
d00435f223 Auto merge of #141272 - Shourya742:2025-05-18-modularize-config-module, r=Kobzol
modularize the config module bootstrap

Currently, our `config` module is quite large over 3,000 lines, and handles a wide range of responsibilities. This PR aims to break it down into smaller, more focused submodules to improve readability and maintainability:

* **`toml`**: Introduces a dedicated `toml` submodule within the `config` module. Its sole purpose is to define configuration-related structs along with their corresponding deserialization logic. It also contains the `parse_inner` method, which serves as the central function for extracting relevant information from the TOML structs and constructing the final configuration.

* **`rust`, `dist`, `install`, `llvm`, `build`, `gcc`, and others**: Each of these modules contains TOML subsections specific to their domain, along with the logic necessary to convert them into parts of the final configuration struct.

* **`config/mod.rs`**: Contains shared types and enums used across multiple TOML subsections.

* **`config/config.rs`**: Houses the logic that integrates all the TOML subsections into the complete configuration struct.

r? `@kobzol`
2025-06-06 04:32:56 +00:00
WANG Rui
38d69c3f57 Add new Tier-3 targets: loongarch32-unknown-none*
MCP: https://github.com/rust-lang/compiler-team/issues/865
2025-06-06 08:19:38 +08:00
bors
076ec59ff1 Auto merge of #142081 - matthiaskrgr:rollup-secpezz, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#141709 (jsondocck: Refactor directive handling)
 - rust-lang/rust#141974 (`tests/ui`: A New Order [4/N])
 - rust-lang/rust#141989 (rustdoc-json-type: Depend on `serde` and `serde_derive` seperately)
 - rust-lang/rust#142015 (Report the actual item that evaluation failed for)
 - rust-lang/rust#142026 (bootstrap: Fix file permissions when dereferencing symlinks)
 - rust-lang/rust#142032 (Fix parsing of frontmatters with inner hyphens)
 - rust-lang/rust#142036 (Update the `compiler-builtins` subtree)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-05 16:46:32 +00:00
Matthias Krüger
19798d62dc
Rollup merge of #142026 - smpdt:master, r=Kobzol
bootstrap: Fix file permissions when dereferencing symlinks

## Problem
When copying files in the bootstrap process with `dereference_symlinks = true`, we're incorrectly using the symlink's metadata to set permissions on the copied regular file, which results in the following error:
```
Warning: Failed to set file times for "/build/nix-build-rustc-1.86.0.drv-0/rustc-1.86.0-src/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-strip" (permissions: Permissions(FilePermissions { mode: 0o100000 (----------) })) error: Permission denied (os error 13)
```

Verbose Logs confirming the error:
```
TRACE: Found llvm-strip copy operation
  Source: /n/nix/tech/store/n34yzv2n50p6lbjmx089vjym121wbl4j-llvm-19.1.7/bin/llvm-strip
  Destination: /build/nix-build-rustc-1.86.0.drv-0/rustc-1.86.0-src/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-strip
  Source is_symlink (via symlink_metadata): true
  Source symlink_metadata permissions: 120000
  Source symlink_metadata file_type: FileType { is_file: false, is_dir: false, is_symlink: true, .. }

  Source is symlink pointing to: llvm-objcopy
  Source raw mode: 120000
  Source filetype: 120000

  Setting permissions: Permissions(FilePermissions { mode: 0o120000 (l---------) })
  Permission mode to set: 120000
  Raw permission bits: 120000
  File type bits being set: 120000
  Permission bits being set: 0

  WARNING: Attempting to set symlink file type (120000) on regular file!
  WARNING: Setting zero permission bits will make file inaccessible!
  Destination permissions after set_permissions: 100000
```

## Solution
After canonicalizing a symlink path, fetch the metadata of the target file instead of continuing to use the symlink's metadata. This ensures:
- Correct file type detection
- Proper permission bits for the target file
- Maintains existing behavior for non-symlink cases

## Testing
Verified fix resolves permission errors:
```
rustc> llvm-strip: Original metadata mode: 120000, is_symlink: true
rustc> llvm-strip: Target metadata mode after fix: 100555
rustc> llvm-strip: Final permissions mode: 100555
```
2025-06-05 16:02:04 +02:00
bit-aloo
3667dbd5f9
correct the imports in flags, tests and download 2025-06-05 16:27:20 +05:30
Matthias Krüger
cfe78d99ae
Rollup merge of #141970 - onur-ozkan:skip-stage1-std, r=Kobzol
implement new `x` flag: `--skip-std-check-if-no-download-rustc`

One of our developers (``@RalfJung)`` [reported](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Surprising.20stages.20for.20check.20build.20after.20stage.20reorg/with/521925606)[#t-infra/bootstrap > Surprising stages for check build after stage reorg](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Surprising.20stages.20for.20check.20build.20after.20stage.20reorg/with/521925606) that working on both the compiler and the library simultaneously with RA enabled is extremely difficult because checking library creates a heavy load on machines (by building stage1 compiler) on each modification. `--skip-std-check-if-no-download-rustc` flag is intended to reduce this heavy load on their IDE integration as much as possible.

Fixes: rust-lang/rust#141955
2025-06-05 12:21:34 +02:00
Matthias Krüger
7852d99768
Rollup merge of #141938 - ZuseZ4:offload-updates, r=Kobzol
update rust offload bootstrap

r? ``@ghost``
2025-06-05 12:21:31 +02:00
bors
df8102fe5f Auto merge of #142002 - onur-ozkan:follow-ups2, r=jieyouxu
redesign stage 0 std follow-ups part2

Fixes three bugs:

1. `x check` fails when run on rustdoc without `download-rustc` enabled. (1st commit)
2. `x check` fails when run on the compiler with `download-rustc` enabled. (2nd commit)
3. `x test library` fails with `download-rustc` enabled. (3rd commit)

Fixes rust-lang/rust#142018 (case 1)
Fixes https://github.com/rust-lang/rust/issues/141983 (case 3)
2025-06-04 14:15:44 +00:00
smpdt
9091a94ff0 bootstrap: Fix file permissions when dereferencing symlinks 2025-06-04 10:00:20 -04:00
onur-ozkan
c843bec230 update skip_std_check_if_no_download_rustc doc-comments
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-06-04 15:29:00 +03:00
onur-ozkan
7af12a19a8 remove outdated RUSTC_SYSROOT handling for ci-rustc
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-06-04 07:16:25 +03:00
Aleksey Kliger
556c0962ed bootstrap: don't symlink source dir into stage0 sysroot
In StdLink::run we subsequently recursively copy the initial sysroot
lib directory into the stage0-sysroot lib directory.  If the initial
sysroot is a toolchain that includes the `rust-src` component (in
lib/rustlib/src/rust), if we add this symlink, that recursive copy
will overwrite the repo sources with the toolchain's sources.
2025-06-04 00:06:01 -04:00
onur-ozkan
e66948c4fe make it possible to request stage 0 std with Builder::ensure
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-06-04 06:58:28 +03:00
onur-ozkan
bded7010e8 run check::Std as the final step
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-06-04 06:57:12 +03:00
Manuel Drehwald
674a4358e8 update gpu offload build command 2025-06-03 13:10:58 -07:00
bors
a124fb3cb7 Auto merge of #141961 - matthiaskrgr:rollup-r09j2sp, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#141724 (fix(rust-lang/rust#141141): When expanding `PartialEq`, check equality of scalar types first.)
 - rust-lang/rust#141833 (`tests/ui`: A New Order [2/N])
 - rust-lang/rust#141861 (Switch `x86_64-msvc-{1,2}` back to Windows Server 2025 images)
 - rust-lang/rust#141914 (redesign stage 0 std follow-ups)
 - rust-lang/rust#141918 (Deconstruct values in the THIR visitor)
 - rust-lang/rust#141923 (Update books)
 - rust-lang/rust#141931 (Deconstruct values in the THIR visitor)
 - rust-lang/rust#141956 (Remove two trait methods from cg_ssa)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-03 16:31:44 +00:00
onur-ozkan
9e162fe0ab add change-entry
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-06-03 19:22:33 +03:00
onur-ozkan
f1e6afdc4c bless tidy
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-06-03 19:22:28 +03:00
onur-ozkan
143d81362b implement new x flag: --skip-std-check-if-no-download-rustc
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-06-03 19:12:51 +03:00
bors
aae43c4532 Auto merge of #136942 - Kobzol:stage0-sccache, r=jieyouxu
Use ccache for stage0 tool builds

Now after the stage0 redesign, we can actually start ccaching the build of the compiler itself. We can also cache the bootstrap tools, since these are also built with the stage0 compiler.

Stage0 compiler builds are now being cached: https://github.com/rust-lang/rust/actions/runs/15397246267#summary-43321151192 (`..bootstrap::core::build_steps::compile::Rustc	483.10s	40.41s	-91.6%`). It's not a gigantic win everywhere, but it should help. It seems to make the Linux jobs ~10 minute faster. It should be especially useful on PR builds after https://github.com/rust-lang/rust/pull/141948.

r? `@jieyouxu`

try-job: `x86_64-gnu-llvm-19*`
try-job: `x86_64-msvc*`
try-job: `x86_64-apple*`
try-job: `dist-x86_64-linux`
2025-06-03 13:09:57 +00:00
Matthias Krüger
72f60fb700
Rollup merge of #141914 - onur-ozkan:follow-ups, r=Kobzol
redesign stage 0 std follow-ups

Various follow-ups pointed out on Zulip during post-merge discussions of [redesign stage 0 std #119899](https://github.com/rust-lang/rust/pull/119899).

r? `@jieyouxu`

Fixes https://github.com/rust-lang/rust/issues/141902.
Fixes https://github.com/rust-lang/rust/issues/141905.

cc `@jyn514`
2025-06-03 15:00:34 +02:00
onur-ozkan
59d993b6c7 use better default stage for check::Std when stage isn't explicit
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-06-03 12:59:33 +03:00
Matthias Krüger
2fa33b0624
Rollup merge of #141949 - onur-ozkan:move-test-float-parse, r=Kobzol
move `test-float-parse` tool into `src/tools` dir

Obviously `test-float-parse` is a tool like any other in `src/tools`.

cc `@tgross35`
2025-06-03 11:33:37 +02:00
onur-ozkan
ecc7dde80a handle stage0 on Std::check
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-06-03 08:51:19 +00:00
bit-aloo
edada367a0
add config.rs with new module structuring 2025-06-03 13:53:05 +05:30
bit-aloo
0de60ddd2a
Move all common types, macros and utility method to config/mod.rs 2025-06-03 13:46:54 +05:30
bit-aloo
cc30123364
move target selection to its separate module 2025-06-03 13:46:23 +05:30
bit-aloo
8a807cd498
This commit adds a toml module that represents various subsections of bootstrap.toml.
The module primarily defines the TOML representations of these subsections and their corresponding
configuration parsing implementations, which are ultimately integrated into the main configuration.

- `mod.rs` – Serves as the entry point for the TOML configuration and defines the `TomlConfig` struct along with its parsing implementation.
- `rust.rs` – Defines the `Rust` subsection struct and its configuration parsing implementation.
- `target.rs` – Defines the `Target` subsection struct and its configuration parsing implementation.
- `llvm.rs` – Defines the `Llvm` subsection struct and its configuration parsing implementation.
- `install.rs` – Defines the `Install` subsection struct and its configuration parsing implementation.
- `gcc.rs` – Defines the `Gcc` subsection struct and its configuration parsing implementation.
- `dist.rs` – Defines the `Dist` subsection struct and its configuration parsing implementation.
- `build.rs` – Defines the `Build` subsection struct and its configuration parsing implementation.
2025-06-03 13:45:23 +05:30
onur-ozkan
59fbe04a52 move test-float-parse tool into src/tools dir
Obviously `test-float-parse` is a tool like any other in `src/tools`.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-06-03 11:05:51 +03:00
onur-ozkan
8a65d9febb make library profile to use stage 1 on x check
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-06-03 11:00:33 +03:00
onur-ozkan
4e71f24a6b make x check to use stage0 by default
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-06-03 11:00:30 +03:00
bors
b17dba4518 Auto merge of #141210 - RalfJung:miri-std-doctests, r=saethlin
tools-aux ci runner: also cross-test doctests in Miri

Miri now supports running doctests across different targets. Let's use that to run the std doctests on aarch64-apple-darwin, i686-pc-windows-msvc.

try-job: x86_64-gnu-aux
2025-06-03 03:14:19 +00:00
Vadim Petrochenkov
65730a3c4b bootstrap: Remove rustc_snapshot_libdir from PATH in one more place 2025-06-02 15:35:57 +03:00
Jakub Beránek
0505ee514b
Use ccache for stage0 tool and rustc builds 2025-06-02 14:10:17 +02:00
bors
52882f6522 Auto merge of #119899 - onur-ozkan:redesign-stage0-std, r=albertlarsan68,jieyouxu,mark-simulacrum,kobzol,jyn514,Noratrieb,WaffleLapkin,RalfJung,bjorn3
redesign stage 0 std

### Summary

**Blog post: https://blog.rust-lang.org/inside-rust/2025/05/29/redesigning-the-initial-bootstrap-sequence/**

This PR changes how bootstrap builds the stage 1 compiler by switching to precompiled stage 0 standard library instead of building the in-tree one. The goal was to update bootstrap to use the beta standard library at stage 0 rather than compiling it from source (see the motivation at https://github.com/rust-lang/compiler-team/issues/619).

Previously, to build a stage 1 compiler bootstrap followed this path:

```
download stage0 compiler -> build in-tree std -> compile stage1 compiler with in-tree std
```

With this PR, the new path is:

```
download stage0 compiler -> compile stage1 compiler with precompiled stage0 std
```

This also means that `cfg(bootstrap)`/`cfg(not(bootstrap))` is no longer needed for library development.

### Building "library"

Since stage0 `std` is no longer in-tree `x build/test/check library --stage 0` is now no-op. The minimum supported stage to build `std` is now 1. For the same reason, default stage values in the library profile is no longer 0.

Because building the in-tree library now requires a stage1 compiler, I highly recommend library developers to enable `download-rustc` to speed up compilation time.

<hr>

**Blog post: https://blog.rust-lang.org/inside-rust/2025/05/29/redesigning-the-initial-bootstrap-sequence/**

If you encounter a bug or unexpected results please open a topic in the [#t-infra/bootstrap](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap) Zulip channel or create a [bootstrap issue](https://github.com/rust-lang/rust/issues/new?template=bootstrap.md).

(Review thread: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Review.20thread.3A.20stage.200.20redesign.20PR/with/508271433)

~~Blocked on https://github.com/rust-lang/rust/pull/122709~~

try-job: dist-x86_64-linux
try-job: `x86_64-msvc*`
try-job: `x86_64-apple-*`
try-job: `aarch64-apple`
try-job: x86_64-gnu
try-job: `x86_64-gnu-llvm*`
2025-06-02 07:49:18 +00:00
Guillaume Gomez
90f418fbb3
Rollup merge of #141852 - onur-ozkan:resolve-if-let-fixme, r=jieyouxu
resolve if-let-chain FIXME on bootstrap

self-explanatory
2025-06-01 19:35:46 +02:00
Guillaume Gomez
f714b34000
Rollup merge of #141846 - Berrysoft:cygwin-bootstrap-tls, r=mati865
Fix TLS model on bootstrap for cygwin

There aren't other targets that both use emutls and enable `has_thread_local`, so cygwin triggers this bug first.

r? mati865

See: https://github.com/rust-lang/rust/pull/141719#issuecomment-2925445263

``@jeremyd2019`` Could you check if this PR fixes the issue? I just found my pre-built stage-0 rustc was too old to build the current rustc :(
2025-06-01 19:35:45 +02:00
Guillaume Gomez
fec5c8fd7c
Rollup merge of #141789 - ferrocene:hoverbear/exclude-cargo-home-from-in-tree-consideration, r=clubby789
Exclude `CARGO_HOME` from `generate-copyright` in-tree determination

On Ferrocene, we noticed that in our releases the out-of-tree notices were not being included. When `x.py run generate-copyright` was ran on local development machines, it worked fine.

After some investigations ``@tshepang`` and I determined that the problem was that the cargo registry (located in `CARGO_HOME`) started with the source directory on CI jobs, and was being excluded by this line:

15825b7161/src/tools/generate-copyright/src/cargo_metadata.rs (L85-L88)

In Ferrocene's `run.sh` we set `CARGO_HOME` to be `build/cargo-home`: 96a45dd9a1/ferrocene/ci/run.sh (L34-L46) which caused this issue.

This PR passes the `CARGO_HOME` variable to the `generate-copyright` tool and expands the consideration of in-tree-ness to be aware of `CARGO_HOME`. It is an upstreaming of https://github.com/ferrocene/ferrocene/pull/1491.

## Testing

Run `CARGO_HOME=build/cargo-home ./x.py run generate-copyright` on `master`, then check `build/host/doc/COPYRIGHT` and look for out of tree dependencies (at the bottom).

Then, try running the same command in this branch.
2025-06-01 19:35:44 +02:00
onur-ozkan
a71c00a713 resolve if-let-chain FIXME on bootstrap
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-06-01 14:43:02 +03:00
王宇逸
810a564d9b Fix TLS model on bootstrap for cygwin 2025-06-01 14:56:54 +08:00
Matthias Krüger
23cc24e0bf
Rollup merge of #141819 - mati865:windows-gnullvm-host-fixes, r=jieyouxu
Fixes for building windows-gnullvm hosts

Split out from: https://github.com/rust-lang/rust/pull/140772
2025-05-31 18:51:51 +02:00
Matthias Krüger
ec39208527
Rollup merge of #141646 - jieyouxu:distcheck, r=Mark-Simulacrum
Document what `distcheck` is intended to exercise

Or at least attempt to.

Closes rust-lang/rust#141387.

cc `@marcoieni` (re. [#t-infra/bootstrap > Speed up distcheck](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Speed.20up.20distcheck/with/520208870))
r? `@Mark-Simulacrum` (as you may have some clues about if this is accurate)
2025-05-31 18:51:48 +02:00