Skip to content

Commit c909d74

Browse files
authored
Merge pull request #2508 from rust-lang/rustc-pull
Rustc pull update
2 parents e352150 + a222fe3 commit c909d74

File tree

99 files changed

+2888
-1084
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+2888
-1084
lines changed

.github/workflows/ci.yml

Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,82 @@ defaults:
1313
shell: bash
1414

1515
jobs:
16-
build:
16+
test:
17+
name: test (${{ matrix.host_target }})
1718
strategy:
1819
fail-fast: false
1920
matrix:
2021
include:
21-
- os: ubuntu-latest
22-
host_target: x86_64-unknown-linux-gnu
23-
- os: macos-14
24-
host_target: aarch64-apple-darwin
25-
- os: windows-latest
26-
host_target: i686-pc-windows-msvc
22+
- host_target: x86_64-unknown-linux-gnu
23+
os: ubuntu-latest
24+
- host_target: i686-unknown-linux-gnu
25+
os: ubuntu-latest
26+
multiarch: i386
27+
gcc_cross: i686-linux-gnu
28+
- host_target: aarch64-unknown-linux-gnu
29+
os: ubuntu-24.04-arm
30+
- host_target: armv7-unknown-linux-gnueabihf
31+
os: ubuntu-24.04-arm
32+
multiarch: armhf
33+
gcc_cross: arm-linux-gnueabihf
34+
- host_target: riscv64gc-unknown-linux-gnu
35+
os: ubuntu-latest
36+
multiarch: riscv64
37+
gcc_cross: riscv64-linux-gnu
38+
qemu: true
39+
- host_target: s390x-unknown-linux-gnu
40+
os: ubuntu-latest
41+
multiarch: s390x
42+
gcc_cross: s390x-linux-gnu
43+
qemu: true
44+
- host_target: aarch64-apple-darwin
45+
os: macos-latest
46+
- host_target: i686-pc-windows-msvc
47+
os: windows-latest
2748
runs-on: ${{ matrix.os }}
2849
env:
2950
HOST_TARGET: ${{ matrix.host_target }}
3051
steps:
3152
- uses: actions/checkout@v4
53+
- name: install qemu
54+
if: ${{ matrix.qemu }}
55+
run: sudo apt install qemu-user qemu-user-binfmt
56+
- name: install multiarch
57+
if: ${{ matrix.multiarch != '' }}
58+
run: |
59+
# s390x, ppc64el need Ubuntu Ports to be in the mirror list
60+
sudo bash -c "echo 'https://ports.ubuntu.com/ priority:4' >> /etc/apt/apt-mirrors.txt"
61+
# Add architecture
62+
sudo dpkg --add-architecture ${{ matrix.multiarch }}
63+
sudo apt update
64+
# Install needed packages
65+
sudo apt install $(echo "libatomic1: zlib1g-dev:" | sed 's/:/:${{ matrix.multiarch }}/g')
3266
- uses: ./.github/workflows/setup
3367
with:
3468
toolchain_flags: "--host ${{ matrix.host_target }}"
3569

36-
# The `style` job only runs on Linux; this makes sure the Windows-host-specific
37-
# code is also covered by clippy.
38-
- name: Check clippy
39-
if: ${{ matrix.os == 'windows-latest' }}
40-
run: ./miri clippy -- -D warnings
70+
# We set up the cross-compiler *after* the basic setup as setting CC would otherwise
71+
# cause confusion.
72+
- name: install gcc-cross
73+
if: ${{ matrix.gcc_cross != '' }}
74+
run: |
75+
sudo apt install gcc-${{ matrix.gcc_cross }}
76+
echo "Setting environment variables:"
77+
echo "CC_${{ matrix.host_target }}=${{ matrix.gcc_cross }}-gcc" | tee -a $GITHUB_ENV
78+
TARGET_UPPERCASE=$(echo ${{ matrix.host_target }} | tr '[:lower:]-' '[:upper:]_')
79+
echo "CARGO_TARGET_${TARGET_UPPERCASE}_LINKER=${{ matrix.gcc_cross }}-gcc" | tee -a $GITHUB_ENV
4180
42-
- name: Test Miri
81+
# The main test job! We don't run this in qemu as that is quite slow,
82+
# so those targets only get the clippy check below.
83+
- name: test Miri
84+
if: ${{ !matrix.qemu }}
4385
run: ./ci/ci.sh
4486

87+
# The `style` job only runs on Linux; this makes sure the host-specific
88+
# code is also covered by clippy.
89+
- name: clippy
90+
run: ./miri clippy -- -D warnings
91+
4592
style:
4693
name: style checks
4794
runs-on: ubuntu-latest
@@ -51,8 +98,6 @@ jobs:
5198

5299
- name: rustfmt
53100
run: ./miri fmt --check
54-
- name: clippy
55-
run: ./miri clippy -- -D warnings
56101
- name: clippy (no features)
57102
run: ./miri clippy --no-default-features -- -D warnings
58103
- name: clippy (all features)
@@ -73,7 +118,7 @@ jobs:
73118
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
74119
# And they should be added below in `cron-fail-notify` as well.
75120
conclusion:
76-
needs: [build, style, coverage]
121+
needs: [test, style, coverage]
77122
# We need to ensure this job does *not* get skipped if its dependencies fail,
78123
# because a skipped job is considered a success by GitHub. So we have to
79124
# overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run
@@ -135,7 +180,7 @@ jobs:
135180
cron-fail-notify:
136181
name: cronjob failure notification
137182
runs-on: ubuntu-latest
138-
needs: [build, style, coverage]
183+
needs: [test, style, coverage]
139184
if: ${{ github.event_name == 'schedule' && failure() }}
140185
steps:
141186
# Send a Zulip notification

.github/workflows/setup/action.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: "Miri CI setup"
22
description: "Sets up Miri CI"
33
inputs:
44
toolchain_flags:
5+
description: extra flags to pass to rustup-toolchain-install-master
56
required: false
67
default: ''
78
runs:
@@ -31,18 +32,15 @@ runs:
3132
~/.cargo/bin
3233
~/.cargo/.crates.toml
3334
~/.cargo/.crates2.json
34-
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', '.github/workflows/**/*.yml') }}
35-
restore-keys: cargo-${{ runner.os }}
35+
# Bump the version when something here changes that needs a cache reset.
36+
key: cargo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/Cargo.lock') }}-v1
37+
restore-keys: cargo-${{ runner.os }}-${{ runner.arch }}
3638

37-
- name: Install rustup-toolchain-install-master
39+
- name: Install the tools we need
3840
if: steps.cache.outputs.cache-hit != 'true'
3941
run: cargo install -f rustup-toolchain-install-master hyperfine
4042
shell: bash
4143

42-
- name: Install nightly toolchain
43-
run: rustup toolchain install nightly --profile minimal
44-
shell: bash
45-
4644
- name: Install "master" toolchain
4745
run: |
4846
if [[ ${{ github.event_name }} == 'schedule' ]]; then

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,15 @@ compiler that has `debug=true` set in `bootstrap.toml`.
158158
You can set `MIRI_BACKTRACE=1` to get a backtrace of where an
159159
evaluation error was originally raised.
160160

161+
#### Tracing
162+
163+
You can generate a Chrome trace file from a Miri execution by passing `--features=tracing` during the
164+
build and then setting `MIRI_TRACING=1` when running Miri. This will generate a `.json` file that
165+
you can visualize in [Perfetto](https://ui.perfetto.dev/). For example:
166+
167+
```sh
168+
MIRI_TRACING=1 ./miri run --features=tracing tests/pass/hello.rs
169+
```
161170

162171
### UI testing
163172

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ chrono = { version = "0.4.38", default-features = false }
2727
chrono-tz = "0.10"
2828
directories = "6"
2929
bitflags = "2.6"
30+
serde_json = { version = "1.0", optional = true }
3031

3132
# Copied from `compiler/rustc/Cargo.toml`.
3233
# But only for some targets, it fails for others. Rustc configures this in its CI, but we can't
@@ -67,6 +68,7 @@ default = ["stack-cache"]
6768
genmc = []
6869
stack-cache = []
6970
stack-cache-consistency-check = ["stack-cache"]
71+
tracing = ["serde_json"]
7072

7173
[lints.rust.unexpected_cfgs]
7274
level = "warn"

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ instance:
1111
* Not sufficiently aligned memory accesses and references
1212
* Violation of basic type invariants (a `bool` that is not 0 or 1, for example,
1313
or an invalid enum discriminant)
14+
* Data races and emulation of *some* weak memory effects, i.e.,
15+
atomic reads can return outdated values
1416
* **Experimental**: Violations of the [Stacked Borrows] rules governing aliasing
1517
for reference types
1618
* **Experimental**: Violations of the [Tree Borrows] aliasing rules, as an optional
1719
alternative to [Stacked Borrows]
18-
* **Experimental**: Data races and emulation of weak memory effects, i.e.,
19-
atomic reads can return outdated values.
2020

2121
On top of that, Miri will also tell you about memory leaks: when there is memory
2222
still allocated at the end of the execution, and that memory is not reachable
@@ -342,9 +342,9 @@ environment variable. We first document the most relevant and most commonly used
342342
is enabled (the default), this is also used to emulate system entropy. The default seed is 0. You
343343
can increase test coverage by running Miri multiple times with different seeds.
344344
* `-Zmiri-strict-provenance` enables [strict
345-
provenance](https://github.com/rust-lang/rust/issues/95228) checking in Miri. This means that
346-
casting an integer to a pointer will stop execution because the provenance of the pointer
347-
cannot be determined.
345+
provenance](https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance) checking in
346+
Miri. This means that casting an integer to a pointer will stop execution because the provenance
347+
of the pointer cannot be determined.
348348
* `-Zmiri-symbolic-alignment-check` makes the alignment check more strict. By default, alignment is
349349
checked by casting the pointer to an integer, and making sure that is a multiple of the alignment.
350350
This can lead to cases where a program passes the alignment check by pure chance, because things

ci/ci.sh

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -143,42 +143,53 @@ case $HOST_TARGET in
143143
GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
144144
# Extra tier 1
145145
MANY_SEEDS=64 TEST_TARGET=i686-unknown-linux-gnu run_tests
146-
MANY_SEEDS=64 TEST_TARGET=aarch64-unknown-linux-gnu run_tests
147146
MANY_SEEDS=64 TEST_TARGET=x86_64-apple-darwin run_tests
148147
MANY_SEEDS=64 TEST_TARGET=x86_64-pc-windows-gnu run_tests
148+
;;
149+
i686-unknown-linux-gnu)
150+
# Host
151+
# Without GC_STRESS as this is a slow runner.
152+
MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
153+
# Partially supported targets (tier 2)
154+
BASIC="empty_main integer heap_alloc libc-mem vec string btreemap" # ensures we have the basics: pre-main code, system allocator
155+
UNIX="hello panic/panic panic/unwind concurrency/simple atomic libc-mem libc-misc libc-random env num_cpus" # the things that are very similar across all Unixes, and hence easily supported there
156+
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX time hashmap random thread sync concurrency epoll eventfd
157+
TEST_TARGET=wasm32-wasip2 run_tests_minimal $BASIC wasm
158+
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std empty_main wasm # this target doesn't really have std
159+
TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std
160+
;;
161+
aarch64-unknown-linux-gnu)
162+
# Host
163+
GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
149164
# Extra tier 1 candidate
150165
MANY_SEEDS=64 TEST_TARGET=aarch64-pc-windows-msvc run_tests
166+
# Extra tier 2
167+
MANY_SEEDS=16 TEST_TARGET=arm-unknown-linux-gnueabi run_tests # 32bit ARM
168+
MANY_SEEDS=16 TEST_TARGET=aarch64-pc-windows-gnullvm run_tests # gnullvm ABI
169+
MANY_SEEDS=16 TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture of choice
170+
# Custom target JSON file
171+
TEST_TARGET=tests/x86_64-unknown-kernel.json MIRI_NO_STD=1 run_tests_minimal no_std
172+
;;
173+
armv7-unknown-linux-gnueabihf)
174+
# Host
175+
GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
151176
;;
152177
aarch64-apple-darwin)
153178
# Host
154179
GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
155180
# Extra tier 1
156181
MANY_SEEDS=64 TEST_TARGET=i686-pc-windows-gnu run_tests
157182
MANY_SEEDS=64 TEST_TARGET=x86_64-pc-windows-msvc CARGO_MIRI_ENV=1 run_tests
158-
# Extra tier 2
159-
MANY_SEEDS=16 TEST_TARGET=arm-unknown-linux-gnueabi run_tests # 32bit ARM
160-
MANY_SEEDS=16 TEST_TARGET=aarch64-pc-windows-gnullvm run_tests # gnullvm ABI
161-
MANY_SEEDS=16 TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture of choice
162183
# Not officially supported tier 2
163184
MANY_SEEDS=16 TEST_TARGET=mips-unknown-linux-gnu run_tests # a 32bit big-endian target, and also a target without 64bit atomics
164185
MANY_SEEDS=16 TEST_TARGET=x86_64-unknown-illumos run_tests
165186
MANY_SEEDS=16 TEST_TARGET=x86_64-pc-solaris run_tests
166187
MANY_SEEDS=16 TEST_TARGET=x86_64-unknown-freebsd run_tests
167188
MANY_SEEDS=16 TEST_TARGET=i686-unknown-freebsd run_tests
168-
# Partially supported targets (tier 2)
169-
BASIC="empty_main integer heap_alloc libc-mem vec string btreemap" # ensures we have the basics: pre-main code, system allocator
170-
UNIX="hello panic/panic panic/unwind concurrency/simple atomic libc-mem libc-misc libc-random env num_cpus" # the things that are very similar across all Unixes, and hence easily supported there
171-
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX time hashmap random thread sync concurrency epoll eventfd
172-
TEST_TARGET=wasm32-wasip2 run_tests_minimal $BASIC wasm
173-
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std empty_main wasm # this target doesn't really have std
174-
TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std
175-
# Custom target JSON file
176-
TEST_TARGET=tests/x86_64-unknown-kernel.json MIRI_NO_STD=1 run_tests_minimal no_std
177189
;;
178190
i686-pc-windows-msvc)
179191
# Host
180-
# Without GC_STRESS and with reduced many-seeds count as this is the slowest runner.
181-
# (The macOS runner checks windows-msvc with full many-seeds count.)
192+
# Without GC_STRESS as this is the slowest runner.
182193
MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 run_tests
183194
# Extra tier 1
184195
# We really want to ensure a Linux target works on a Windows host,

etc/rust_analyzer_helix.toml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,21 @@ linkedProjects = [
99
]
1010

1111
[language-server.rust-analyzer.config.check]
12-
invocationLocation = "root"
1312
invocationStrategy = "once"
1413
overrideCommand = [
15-
"env",
16-
"MIRI_AUTO_OPS=no",
1714
"./miri",
1815
"clippy", # make this `check` when working with a locally built rustc
1916
"--message-format=json",
2017
]
2118

19+
[language-server.rust-analyzer.config.cargo.extraEnv]
20+
MIRI_AUTO_OPS = "no"
21+
MIRI_IN_RA = "1"
22+
2223
# Contrary to what the name suggests, this also affects proc macros.
23-
[language-server.rust-analyzer.config.buildScripts]
24-
invocationLocation = "root"
24+
[language-server.rust-analyzer.config.cargo.buildScripts]
2525
invocationStrategy = "once"
2626
overrideCommand = [
27-
"env",
28-
"MIRI_AUTO_OPS=no",
2927
"./miri",
3028
"check",
3129
"--message-format=json",

miri

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,24 @@
22
set -e
33
# We want to call the binary directly, so we need to know where it ends up.
44
ROOT_DIR="$(dirname "$0")"
5-
MIRI_SCRIPT_TARGET_DIR="$ROOT_DIR"/miri-script/target
6-
TOOLCHAIN="+nightly"
5+
TARGET_DIR="$ROOT_DIR"/miri-script/target
6+
# Prepare cargo invocation.
7+
# We have to overwrite the toolchain since `+miri` might be activated and not installed.
8+
TOOLCHAIN="+stable"
9+
CARGO_FLAGS=("-q")
710
# If we are being invoked for RA, use JSON output and the default toolchain (to make proc-macros
811
# work in RA). This needs a different target dir to avoid mixing up the builds.
12+
# Also set `-Zroot-dir` so that RA can identify where the error occurred.
913
if [ -n "$MIRI_IN_RA" ]; then
10-
MESSAGE_FORMAT="--message-format=json"
1114
TOOLCHAIN=""
12-
MIRI_SCRIPT_TARGET_DIR="$MIRI_SCRIPT_TARGET_DIR"/ra
15+
CARGO_FLAGS+=("--message-format=json" "-Zroot-dir=$ROOT_DIR")
16+
TARGET_DIR="$ROOT_DIR"/target
1317
fi
14-
# We need a nightly toolchain, for `-Zroot-dir`.
15-
cargo $TOOLCHAIN build $CARGO_EXTRA_FLAGS --manifest-path "$ROOT_DIR"/miri-script/Cargo.toml \
16-
-Zroot-dir="$ROOT_DIR" \
17-
-q --target-dir "$MIRI_SCRIPT_TARGET_DIR" $MESSAGE_FORMAT || \
18-
( echo "Failed to build miri-script. Is the 'nightly' toolchain installed?"; exit 1 )
19-
# Instead of doing just `cargo run --manifest-path .. $@`, we invoke miri-script binary directly. Invoking `cargo run` goes through
20-
# rustup (that sets it's own environmental variables), which is undesirable.
21-
"$MIRI_SCRIPT_TARGET_DIR"/debug/miri-script "$@"
18+
# Run cargo.
19+
cargo $TOOLCHAIN build --manifest-path "$ROOT_DIR"/miri-script/Cargo.toml \
20+
--target-dir "$TARGET_DIR" "${CARGO_FLAGS[@]}" || \
21+
( echo "Failed to build miri-script. Is the 'stable' toolchain installed?"; exit 1 )
22+
# Instead of doing just `cargo run --manifest-path .. $@`, we invoke miri-script binary directly.
23+
# Invoking `cargo run` goes through rustup (that sets it's own environmental variables), which is
24+
# undesirable.
25+
"$TARGET_DIR"/debug/miri-script "$@"

miri-script/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ repository = "https://github.com/rust-lang/miri"
77
version = "0.1.0"
88
default-run = "miri-script"
99
edition = "2024"
10+
rust-version = "1.85"
1011

1112
[workspace]
1213
# We make this a workspace root so that cargo does not go looking in ../Cargo.toml for the workspace root.

0 commit comments

Comments
 (0)