Rollup of 9 pull requests
Successful merges:
- #126063 (Remove some unused crate dependencies.)
- #126115 (Fix ICE due to `unwrap` in `probe_for_name_many`)
- #126159 (ScalarInt: size mismatches are a bug, do not delay the panic)
- #126184 (interpret: do not ICE on padded non-pow2 SIMD vectors)
- #126191 (Fix `NonZero` doctest inconsistencies)
- #126211 (migrate tests/run-make/llvm-outputs to use rmake.rs)
- #126212 (fix: build on haiku)
- #126215 (Add explanatory note to async block type mismatch error)
- #126223 (run-make: add `run_in_tmpdir` self-test)
r? `@ghost`
`@rustbot` modify labels: rollup
Add Rust for Linux `auto` CI job
This PR adds an `auto` CI job that checks if Rust for Linux (RfL) still compiles with the latest version of the compiler and the standard library. If not, we should ideally ping the RfL ping group.
try-job: rfl
run-make: add `run_in_tmpdir` self-test
Add a basic sanity test for `run_in_tmpdir` to make sure that files (including read-only files) and directories created inside the "scratch" tmpdir are removed after the closure returns.
r? ghost (while i run a try job)
try-job: x86_64-msvc
Add explanatory note to async block type mismatch error
The async block type mismatch error might leave the user wondering as to why it occurred. The new note should give them the needed context.
Changes this diagnostic:
```
error[E0308]: mismatched types
--> src/main.rs:5:23
|
2 | let a = async { 1 };
| ----------- the expected `async` block
3 | let b = async { 2 };
| ----------- the found `async` block
4 |
5 | let bad = vec![a, b];
| ^ expected `async` block, found a different `async` block
|
= note: expected `async` block `{async block@src/main.rs:2:13: 2:24}`
found `async` block `{async block@src/main.rs:3:13: 3:24}`
```
to this:
```
error[E0308]: mismatched types
--> src/main.rs:5:23
|
2 | let a = async { 1 };
| ----------- the expected `async` block
3 | let b = async { 2 };
| ----------- the found `async` block
4 |
5 | let bad = vec![a, b];
| ^ expected `async` block, found a different `async` block
|
= note: expected `async` block `{async block@src/main.rs:2:13: 2:24}`
found `async` block `{async block@src/main.rs:3:13: 3:24}`
= note: no two async blocks, even if identical, have the same type
= help: consider pinning your async block and and casting it to a trait object
```
Fixes#125737
fix: build on haiku
## What does this PR do
The std is broken on haiku, this PR fixes it.
## To reproduce the issue
```sh
$ cargo +nightly --version
cargo 1.81.0-nightly (b1feb75d0 2024-06-07)
$ cargo new hello
$ cd hello
$ cargo +nightly check -Zbuild-std --target x86_64-unknown-haiku -q
error[E0433]: failed to resolve: use of undeclared crate or module `std`
--> ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/pal/unix/os.rs:468:13
|
468 | std::ptr::null_mut(),
| ^^^ use of undeclared crate or module `std`
|
help: consider importing one of these items
|
8 + use core::ptr;
|
8 + use crate::ptr;
|
help: if you import `ptr`, refer to it directly
|
468 - std::ptr::null_mut(),
468 + ptr::null_mut(),
|
error[E0433]: failed to resolve: use of undeclared crate or module `std`
--> ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/pal/unix/os.rs:470:13
|
470 | std::ptr::null_mut(),
| ^^^ use of undeclared crate or module `std`
|
help: consider importing one of these items
|
8 + use core::ptr;
```
migrate tests/run-make/llvm-outputs to use rmake.rs
part of #121876
<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.
This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using
r? <reviewer name>
-->
Fix `NonZero` doctest inconsistencies
<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.
This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using
r? <reviewer name>
-->
`NonZero`'s doctests contain both `?` and `.unwrap()` with no obvious reason for the difference, so this changes all of them to `?`. Also removes an explicit `std::num::NonZero`.
Fix ICE due to `unwrap` in `probe_for_name_many`
Fixes#125876
Now `probe_for_name_many` bubbles up the error returned by `probe_op` instead of calling `unwrap` on it.
Remove libstdc++ version check error
This keeps the error message from https://github.com/rust-lang/rust/pull/125411, but removes the `exit(1)` call.
This PR is mostly a hotfix to unblock bootstrap benchmarks in rustc-perf.
However, I think that it might be better to just print a warning, in general. If the ABI version does not match, the build might or might not work locally (as we can see on rustc-perf, where it works even if the reported ABI is 7).
If it does not work (and **if** we can always recognize this during the LLVM wrapper build, instead of having some silent miscompilations), then the user will have to update their libstdc++ anyway, the error does not help them out on its own. So it should be enough to just provide a better error message, without blocking the build.
But I'm not adamant on that, I just want to unblock bootstrap benchmarks until we can find a way to update libstdc++ on the collector machine.
CC `@onur-ozkan`
r? `@Mark-Simulacrum`
resolve rustdoc incompatibility with `rust.download-rustc=true` + `rust.channel= beta/stable`
Previously, we were unable to use `rust.download-rustc` with the beta or stable
channel settings through `rust.channel` due to breaking rustdoc UI tests.
This was because when using a precompiled nightly compiler from CI, we must use the
channel of precompiled compiler and ignore `rust.channel` from the configuration.
This change addresses that issue in `Builder::doc_rust_lang_org_channel` and allows rustdoc
UI tests to work with the precompiled compiler even if the channel specified in config.toml is
"beta" or "stable".
Blocker for https://github.com/rust-lang/rust/pull/122709
rustdoc: Add support for --remap-path-prefix
Adds `--remap-path-prefix` as an unstable option. This is implemented to mimic the behavior of `rustc`'s `--remap-path-prefix`.
This flag similarly takes in two paths, a prefix to replace and a replacement string.
This is useful for build tools (e.g. Buck) other than cargo that can run doc tests.
cc: `@dtolnay`
Rollup of 4 pull requests
Successful merges:
- #126172 (Weekly `cargo update`)
- #126176 (rustdoc-search: use lowercase, non-normalized name for type search)
- #126190 (Autolabel run-make tests, remind to update tracking issue)
- #126194 (Migrate more things to `WinError`)
r? `@ghost`
`@rustbot` modify labels: rollup
Migrate more things to `WinError`
In `library/std/src/sys/pal/windows`, we prefer to use the `WinError` type in place of using either `io::Result` or `unsafe { GetLastError }`. The latter is unsafe and weakly typed whereas the former is larger and requires unwrapping because it returns an `Option`.
I also fixed up a couple of places where we were unnecessarily defining error constants that are already defined.
Autolabel run-make tests, remind to update tracking issue
- Autolabel PRs modifying `tests/run-make/` and `src/tools/run-make-support/` with `A-run-make` label.
- Add reminder to update the tracking issue <https://github.com/rust-lang/rust/issues/121876> if applicable when `tests/run-make/` is modified by a PR.
r? `@Kobzol`
rustdoc-search: use lowercase, non-normalized name for type search
The type name ID map has underscores in its names, so the query element should have them, too.
Fixes#125993
Weekly `cargo update`
Replaces #125562
`r-efi` needs to be bumped in two places.
The `icu4x` dependencies also added a SPDX license identifer, so remove the license checking exception and add `Unicode-3.0` to the list.
Previously, we were unable to use `rust.download-rustc` with the beta or stable
channel settings through `rust.channel` due to breaking rustdoc UI tests.
This was because when using a precompiled nightly compiler from CI, we must use the
channel of precompiled compiler and ignore `rust.channel` from the configuration.
This change addresses that issue in `Builder::doc_rust_lang_org_channel` and allows rustdoc
UI tests to work with the precompiled compiler even if the channel specified in config.toml is
"beta" or "stable".
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Remove hard-coded hashes from codegen tests
This removes hard-coded hashes from the codegen and assembly tests. These use FileCheck, which supports eliding part of the pattern being matched, including by capturing it as a pattern parameter for later matching-on. This is much more appropriate than asking contributors to engage with deliberately-opaque identifier schemes.
In order to reduce the likelihood of error, every hash-coded segment I've touched now expects a certain length. This correctly represents these cases, as our hash outputs have a predetermined amount of entropy attached to them.
This is not done for the UI test suite as those are comparatively easy to simply `--bless`, whereas that would be inappropriate for codegen tests. It is also not done for debuginfo tests as those tests do not support such elision in a correct and useful way.
bootstrap: vendor crates required by opt-dist to collect profiles
These are the default package set required by opt-dist to correctly work,
hence for people wanting to build a production grade of rustc in a
sandboxed / air-gapped environment, these need to be vendored.
The size of `rustc-src-nightly.tar.xz` before and after this change:
* Before: 298M
* After: 323M (+8%)
Size change might or might not be a concern.
See the previous discussion: https://github.com/rust-lang/rust/pull/125166#issuecomment-2113626468
Previous efforts on making:
* https://github.com/rust-lang/rust/pull/125125
* https://github.com/rust-lang/rust/pull/125166
---
Note that extra works still need to be done to make it fully vendored.
* The current pinned rustc-perf uses `tempfile::Tempdir` as the working
directory when collecting profiles from some of these packages.
This "tmp" working directory usage make it impossible for Cargo to pick
up the correct vendor sources setting in `.cargo/config.toml` bundled
in the rustc-src tarball. [^1]
* opt-dist verifies the final built rustc against a subset of rustc test
suite. However it rolls out its own `config.toml` without setting
`vendor = true`, and that results in `./vendor/` directory removed.
[^2]
[^1]: 4f313add60/collector/src/compile/benchmark/mod.rs (L164-L173)
[^2]: 606afbb617/src/tools/opt-dist/src/tests.rs (L62-L77)
Add `FRAC_1_SQRT_2PI` constant to f16/f32/f64/f128
This adds the `FRAC_1_SQRT_2PI` to the `f16`, `f32`, `f64` and `f128` as [`1/√(2π)`](https://www.wolframalpha.com/input?i=1%2Fsqrt%282*pi%29). The rationale is that while `FRAC_1_SQRT_PI` already exists, [Gaussian calculations](https://en.wikipedia.org/wiki/Gaussian_function) for random normal distributions require a `1/(σ√(2π))` term, which could then be directly expressed e.g. as `f32::FRAC_1_SQRT_2PI / sigma`.
The actual value is approximately `1/√(2π) = 0.3989422804014326779399460599343818684758586311649346576659258296…`. Truncated/rounded forms were used for the individual types.
---
~~I did not any of the `#[unstable]` attributes since I am not aware of their implications.~~
**Edit:** I applied the stability attributes from the surrounding types according to what seemed most likely correct. I believe the `more_float_constants` feature marker is incorrectly applied, but I wasn't sure how to proceed.
Enable GVN for `AggregateKind::RawPtr`
Looks like I was worried for nothing; this seems like it's much easier than I was originally thinking it would be.
r? `@cjgillot`
This should be useful for `x[..4]`-like things, should those start inlining enough to expose the lengths.
Adds --remap-path-prefix as an unstable option. This is implemented to
mimic the behavior of rustc's --remap-path-prefix but with minor
adjustments.
This flag similarly takes in two paths, a prefix to replace and a
replacement string.
ci: use GCC 13 as cross compiler in `dist-aarch64-linux`
I'm proposing this GCC upgrade since it addresses bug https://github.com/rust-lang/rust/issues/125619. The
regression in question affects stable release consumers who tend to have
no exposure to Rust build tools, so if at all possible, I would like to
have it resolved in the next stable release. I have tried to fix the bug
in `compiler-builtins`, which led to submitting a PR for `compiler-rt`
in upstream LLVM, but it may take a long time before these upstreams
address this regression.
A summary of why upgrading GCC solves the regression follows.
`__multc3()` is a builtin function `compiler-builtins` exposes for
specifically aarch64, non-Windows targets [1]. The object file for it is
included in `staticlib` archives through `libstd`. The implementation
for `__multc3()` is from `multc3.c`, part of LLVM's `compiler-rt`.
Upstream `compiler-rt` normally builds the C file using the Clang
from the same LLVM version. On the other hand, `compiler-builtins`
builds the C file using GCC, outside of the usual LLVM build system.
The upstream implementation doesn't have feature detection which
works for GCC version older than 10, and ends up producing an
unlinkable object.
Upstream LLVM might be slow to respond to this issue as they might deem
`compiler-builtin` as doing something out of the ordinary from their
perspective. They might reasonably assume everyone builds `compiler-rt`
through LLVM's build system.
I have done the following to test this change:
- verified that a local build without this patch exhibits the
regression.
- verified that with this patch, the object for `__multc3()` has no
reference to undefined functions in the symbol table.
- verified that with this patch, `rustc` is usable to build Ruby with
YJIT, and that the reported regression is resolved.
Since `loongarch64-linux-gnu` already uses GCC 13.2.0, I hope we can upgrade without issues.
try-job: dist-aarch64-linux
[1]: c04eb9e1af/build.rs (L524-L539)
`ring` is included because it is an optional dependency of `hyper`,
which is a training data in rustc-pref for optimized build.
The license of it is generally `ISC AND MIT AND OpenSSL`,
though the `package.license` field is not set.
See https://github.com/briansmith/ring/issues/902
`git+https://github.com/rust-lang/team` git source is from
`rust_team_data`, which is used by `site` in src/tools/rustc-perf.
This doesn't really a part of the compiler,
so doesn't really affect the bootstrapping process.
See https://github.com/rust-lang/rustc-perf/pull/1914.
These are the default package set required by opt-dist to correctly work,
hence for people wanting to build a production grade of rustc in a
sandboxed / air-gapped environment, these need to be vendored.
The size of `rustc-src-nightly.tar.xz` before and after this change:
* Before: 298M
* After: 323M (+8%)
These crates are the default set of packages required by opt-dist
to correctly work, hence for people wanting to build a production grade
of rustc in an sandboxed / air-gapped environment, these need to be vendored.
The size of `rustc-src-nightly.tar.xz` before and after this change:
* Before: 298M
* After: 323M (+8%)
Size change might or might not be a concern.
See the previous discussion: https://github.com/rust-lang/rust/pull/125166#issuecomment-2113626468
Previous efforts on making:
* https://github.com/rust-lang/rust/pull/125125
* https://github.com/rust-lang/rust/pull/125166
---
Note that extra works still need to be done to make it fully vendored.
* The current pinned rustc-perf uses `tempfile::Tempdir` as the working
directory when collecting profiles from some of these packages.
This "tmp" working directory usage make it impossible for Cargo to pick
up the correct vendor sources setting in `.cargo/config.toml` bundled
in the rustc-src tarball. [^1]
* opt-dist verifies the final built rustc against a subset of rustc test
suite. However it rolls out its own `config.toml` without setting
`vendor = true`, and that results in `./vendor/` directory removed.
[^2]
[^1]: 4f313add60/collector/src/compile/benchmark/mod.rs (L164-L173)
[^2]: 606afbb617/src/tools/opt-dist/src/tests.rs (L62-L77)
- Autolabel PRs modifying `tests/run-make/` and
`src/tools/run-make-support/` with `X-run-make` label.
- Add reminder to update the tracking issue
<https://github.com/rust-lang/rust/issues/121876>
if applicable when `tests/run-make/` is modified by a PR.