Skip to content

Commit 329bc1c

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 8dac4bf + e8fd761 commit 329bc1c

File tree

983 files changed

+14656
-7143
lines changed

Some content is hidden

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

983 files changed

+14656
-7143
lines changed

.github/workflows/ci.yml

Lines changed: 100 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,94 @@ 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
48+
- host_target: aarch64-pc-windows-msvc
49+
os: windows-11-arm
2750
runs-on: ${{ matrix.os }}
2851
env:
2952
HOST_TARGET: ${{ matrix.host_target }}
3053
steps:
3154
- uses: actions/checkout@v4
55+
- name: apt update
56+
if: ${{ startsWith(matrix.os, 'ubuntu') }}
57+
# The runners seem to have outdated apt repos sometimes
58+
run: sudo apt update
59+
- name: install qemu
60+
if: ${{ matrix.qemu }}
61+
run: sudo apt install qemu-user qemu-user-binfmt
62+
- name: install multiarch
63+
if: ${{ matrix.multiarch != '' }}
64+
run: |
65+
# s390x, ppc64el need Ubuntu Ports to be in the mirror list
66+
sudo bash -c "echo 'https://ports.ubuntu.com/ priority:4' >> /etc/apt/apt-mirrors.txt"
67+
# Add architecture
68+
sudo dpkg --add-architecture ${{ matrix.multiarch }}
69+
sudo apt update
70+
# Install needed packages
71+
sudo apt install $(echo "libatomic1: zlib1g-dev:" | sed 's/:/:${{ matrix.multiarch }}/g')
72+
- name: Install rustup on Windows ARM
73+
if: ${{ matrix.os == 'windows-11-arm' }}
74+
run: |
75+
curl -LOs https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe
76+
./rustup-init.exe -y --no-modify-path
77+
echo "$USERPROFILE/.cargo/bin" >> "$GITHUB_PATH"
3278
- uses: ./.github/workflows/setup
3379
with:
3480
toolchain_flags: "--host ${{ matrix.host_target }}"
3581

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
82+
# We set up the cross-compiler *after* the basic setup as setting CC would otherwise
83+
# cause confusion.
84+
- name: install gcc-cross
85+
if: ${{ matrix.gcc_cross != '' }}
86+
run: |
87+
sudo apt install gcc-${{ matrix.gcc_cross }}
88+
echo "Setting environment variables:"
89+
echo "CC_${{ matrix.host_target }}=${{ matrix.gcc_cross }}-gcc" | tee -a $GITHUB_ENV
90+
TARGET_UPPERCASE=$(echo ${{ matrix.host_target }} | tr '[:lower:]-' '[:upper:]_')
91+
echo "CARGO_TARGET_${TARGET_UPPERCASE}_LINKER=${{ matrix.gcc_cross }}-gcc" | tee -a $GITHUB_ENV
4192
42-
- name: Test Miri
93+
# The main test job! We don't run this in qemu as that is quite slow,
94+
# so those targets only get the clippy check below.
95+
- name: test Miri
96+
if: ${{ !matrix.qemu }}
4397
run: ./ci/ci.sh
4498

99+
# The `style` job only runs on Linux; this makes sure the host-specific
100+
# code is also covered by clippy.
101+
- name: clippy
102+
run: ./miri clippy -- -D warnings
103+
45104
style:
46105
name: style checks
47106
runs-on: ubuntu-latest
@@ -51,8 +110,6 @@ jobs:
51110

52111
- name: rustfmt
53112
run: ./miri fmt --check
54-
- name: clippy
55-
run: ./miri clippy -- -D warnings
56113
- name: clippy (no features)
57114
run: ./miri clippy --no-default-features -- -D warnings
58115
- name: clippy (all features)
@@ -73,7 +130,7 @@ jobs:
73130
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
74131
# And they should be added below in `cron-fail-notify` as well.
75132
conclusion:
76-
needs: [build, style, coverage]
133+
needs: [test, style, coverage]
77134
# We need to ensure this job does *not* get skipped if its dependencies fail,
78135
# because a skipped job is considered a success by GitHub. So we have to
79136
# overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run
@@ -102,40 +159,53 @@ jobs:
102159
- uses: actions/checkout@v4
103160
with:
104161
fetch-depth: 256 # get a bit more of the history
105-
- name: install josh-proxy
106-
run: cargo +stable install josh-proxy --git https://github.com/josh-project/josh --tag r24.10.04
162+
- name: install josh-sync
163+
run: cargo +stable install --locked --git https://github.com/rust-lang/josh-sync
107164
- name: setup bot git name and email
108165
run: |
109166
git config --global user.name 'The Miri Cronjob Bot'
110167
git config --global user.email '[email protected]'
111168
- name: Install nightly toolchain
112169
run: rustup toolchain install nightly --profile minimal
113-
- name: get changes from rustc
114-
run: ./miri rustc-pull
115170
- name: Install rustup-toolchain-install-master
116171
run: cargo install -f rustup-toolchain-install-master
117-
- name: format changes (if any)
172+
- name: Push changes to a branch and create PR
118173
run: |
174+
# Make it easier to see what happens.
175+
set -x
176+
# Temporarily disable early exit to examine the status code of rustc-josh-sync
177+
set +e
178+
rustc-josh-sync pull
179+
exitcode=$?
180+
set -e
181+
182+
# If there were no changes to pull, rustc-josh-sync returns status code 2.
183+
# In that case, skip the rest of the job.
184+
if [ $exitcode -eq 2 ]; then
185+
echo "Nothing changed in rustc, skipping PR"
186+
exit 0
187+
elif [ $exitcode -ne 0 ]; then
188+
# If return code was not 0 or 2, rustc-josh-sync actually failed
189+
echo "error: rustc-josh-sync failed"
190+
exit ${exitcode}
191+
fi
192+
193+
# Format changes
119194
./miri toolchain
120195
./miri fmt --check || (./miri fmt && git commit -am "fmt")
121-
- name: Push changes to a branch and create PR
122-
run: |
123-
# `git diff --exit-code` "succeeds" if the diff is empty.
124-
if git diff --exit-code HEAD^; then echo "Nothing changed in rustc, skipping PR"; exit 0; fi
125-
# The diff is non-empty, create a PR.
196+
197+
# Create a PR
126198
BRANCH="rustup-$(date -u +%Y-%m-%d)"
127199
git switch -c $BRANCH
128200
git push -u origin $BRANCH
129201
gh pr create -B master --title 'Automatic Rustup' --body 'Please close and re-open this PR to trigger CI, then enable auto-merge.'
130202
env:
131203
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132-
ZULIP_BOT_EMAIL: ${{ secrets.ZULIP_BOT_EMAIL }}
133-
ZULIP_API_TOKEN: ${{ secrets.ZULIP_API_TOKEN }}
134204

135205
cron-fail-notify:
136206
name: cronjob failure notification
137207
runs-on: ubuntu-latest
138-
needs: [build, style, coverage]
208+
needs: [test, style, coverage]
139209
if: ${{ github.event_name == 'schedule' && failure() }}
140210
steps:
141211
# Send a Zulip notification
@@ -153,7 +223,7 @@ jobs:
153223
It would appear that the [Miri cron job build]('"https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"') failed.
154224
155225
This likely means that rustc changed the miri directory and
156-
we now need to do a [`./miri rustc-pull`](https://github.com/rust-lang/miri/blob/master/CONTRIBUTING.md#importing-changes-from-the-rustc-repo).
226+
we now need to do a [`rustc-josh-sync pull`](https://github.com/rust-lang/miri/blob/master/CONTRIBUTING.md#importing-changes-from-the-rustc-repo).
157227
158228
Would you mind investigating this issue?
159229

.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

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
target
2-
/doc
32
tex/*/out
43
*.dot
54
*.out
@@ -9,6 +8,9 @@ tex/*/out
98
*.mm_profdata
109
perf.data
1110
perf.data.old
12-
flamegraph.svg
11+
flamegraph*.svg
12+
rustc-ice*.txt
1313
tests/native-lib/libtestlib.so
1414
.auto-*
15+
16+
/genmc/

CONTRIBUTING.md

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,20 @@ for a list of Miri maintainers.
1313

1414
[Rust Zulip]: https://rust-lang.zulipchat.com
1515

16-
### Pull review process
16+
### PR review process
1717

1818
When you get a review, please take care of the requested changes in new commits. Do not amend
1919
existing commits. Generally avoid force-pushing. The only time you should force push is when there
2020
is a conflict with the master branch (in that case you should rebase across master, not merge), and
2121
all the way at the end of the review process when the reviewer tells you that the PR is done and you
22-
should squash the commits. For the latter case, use `git rebase --keep-base ...` to squash without
23-
changing the base commit your PR branches off of. Use your own judgment and the reviewer's guidance
24-
to decide whether the PR should be squashed into a single commit or multiple logically separate
25-
commits. (All this is to work around the fact that Github is quite bad at dealing with force pushes
26-
and does not support `git range-diff`. Maybe one day Github will be good at git and then life can
27-
become easier.)
22+
should squash the commits. (All this is to work around the fact that Github is quite bad at
23+
dealing with force pushes and does not support `git range-diff`.)
24+
25+
The recommended way to squash commits is to use `./miri squash`, which will make everything into a
26+
single commit. You will be asked for the commit message; please ensure it describes the entire PR.
27+
You can also use `git rebase` manually if you need more control (e.g. if there should be more than
28+
one commit at the end), but then please use `--keep-base` to ensure the PR remains based on the same
29+
upstream commit.
2830

2931
Most PRs bounce back and forth between the reviewer and the author several times, so it is good to
3032
keep track of who is expected to take the next step. We are using the `S-waiting-for-review` and
@@ -160,6 +162,15 @@ compiler that has `debug=true` set in `bootstrap.toml`.
160162
You can set `MIRI_BACKTRACE=1` to get a backtrace of where an
161163
evaluation error was originally raised.
162164

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

164175
### UI testing
165176

@@ -286,25 +297,27 @@ You can also directly run Miri on a Rust source file:
286297

287298
## Advanced topic: Syncing with the rustc repo
288299

289-
We use the [`josh` proxy](https://github.com/josh-project/josh) to transmit changes between the
300+
We use the [`josh-sync`](https://github.com/rust-lang/josh-sync) tool to transmit changes between the
290301
rustc and Miri repositories. You can install it as follows:
291302

292303
```sh
293-
cargo +stable install josh-proxy --git https://github.com/josh-project/josh --tag r24.10.04
304+
cargo install --locked --git https://github.com/rust-lang/josh-sync
294305
```
295306

296-
Josh will automatically be started and stopped by `./miri`.
307+
The commands below will automatically install and manage the [Josh](https://github.com/josh-project/josh) proxy that performs the actual work.
297308

298309
### Importing changes from the rustc repo
299310

300311
*Note: this usually happens automatically, so these steps rarely have to be done by hand.*
301312

302313
We assume we start on an up-to-date master branch in the Miri repo.
303314

315+
1) First, create a branch for the pull, e.g. `git checkout -b rustup`
316+
2) Then run the following:
304317
```sh
305318
# Fetch and merge rustc side of the history. Takes ca 5 min the first time.
306319
# This will also update the `rustc-version` file.
307-
./miri rustc-pull
320+
rustc-josh-sync pull
308321
# Update local toolchain and apply formatting.
309322
./miri toolchain && ./miri fmt
310323
git commit -am "rustup"
@@ -317,12 +330,12 @@ needed.
317330

318331
### Exporting changes to the rustc repo
319332

320-
We will use the josh proxy to push to your fork of rustc. Run the following in the Miri repo,
333+
We will use the `josh-sync` tool to push to your fork of rustc. Run the following in the Miri repo,
321334
assuming we are on an up-to-date master branch:
322335

323336
```sh
324337
# Push the Miri changes to your rustc fork (substitute your github handle for YOUR_NAME).
325-
./miri rustc-push YOUR_NAME miri
338+
rustc-josh-sync push miri YOUR_NAME
326339
```
327340

328341
This will create a new branch called `miri` in your fork, and the output should include a link that
@@ -341,6 +354,7 @@ https. Add the following to your `.gitconfig`:
341354

342355
The following environment variables are relevant to `./miri`:
343356

357+
* `CARGO` sets the binary used to execute Cargo; if none is specified, defaults to `cargo`.
344358
* `MIRI_AUTO_OPS` indicates whether the automatic execution of rustfmt, clippy and toolchain setup
345359
(as controlled by the `./auto-*` files) should be skipped. If it is set to `no`, they are skipped.
346360
This is used to allow automated IDE actions to avoid the auto ops.

0 commit comments

Comments
 (0)