Skip to content

Commit 8c86f11

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 5088561 + 3a23d5b commit 8c86f11

39 files changed

+1717
-73
lines changed

.github/scripts/run_own_tests.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
# Execute our own set of tests using a local `compiletest` tool based on `ui_test`.
3+
# This will run cargo under the repository path and, by default, will run the toolchain
4+
# specified in the `rust-toolchain.toml` file.
5+
set -e
6+
set -u
7+
8+
# Where we will store the SMIR tools (Optional).
9+
TOOLS_BIN="${TOOLS_BIN:-"/tmp/smir/bin"}"
10+
# Assume we are inside SMIR repository
11+
SMIR_PATH=$(git rev-parse --show-toplevel)
12+
REPO_TOOLCHAIN=$(rustup show active-toolchain | (read toolchain _; echo $toolchain))
13+
TOOLCHAIN="${TOOLCHAIN:-${REPO_TOOLCHAIN}}"
14+
export RUST_BACKTRACE=1
15+
16+
# Build stable_mir tools
17+
function build_smir_tools() {
18+
echo "#### Build tools. Toolchain: ${TOOLCHAIN}"
19+
cargo +${TOOLCHAIN} build -Z unstable-options --out-dir "${TOOLS_BIN}"
20+
export PATH="${TOOLS_BIN}":"${PATH}"
21+
}
22+
23+
# Run tests
24+
function run_tests() {
25+
SUITES=(
26+
"sanity-checks pass"
27+
"fixme fix-me"
28+
)
29+
for suite_cfg in "${SUITES[@]}"; do
30+
# Hack to work on older bash like the ones on MacOS.
31+
suite_pair=($suite_cfg)
32+
suite=${suite_pair[0]}
33+
mode=${suite_pair[1]}
34+
echo "#### Running suite: ${suite} mode: ${mode}"
35+
compiletest \
36+
--driver-path="${TOOLS_BIN}/test-drive" \
37+
--mode=${mode} \
38+
--src-base="tests/${suite}" \
39+
--output-dir="target/tests/" \
40+
--no-capture
41+
done
42+
}
43+
44+
pushd "${SMIR_PATH}" > /dev/null
45+
build_smir_tools
46+
run_tests

.github/scripts/run_rustc_tests.sh

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/usr/bin/env bash
2+
3+
# Run rustc test suites using our test driver using nightly.
4+
# This script leverages the rustc's repo compiletest crate.
5+
#
6+
# The suites configuration should match:
7+
# https://github.com/rust-lang/rust/blob/master/src/bootstrap/test.rs
8+
9+
set -e
10+
set -u
11+
export RUST_BACKTRACE=1
12+
13+
# Location of a rust repository. Clone one if path doesn't exist.
14+
RUST_REPO="${RUST_REPO:-"/tmp/rustc"}"
15+
16+
# Where we will store the SMIR tools (Optional).
17+
TOOLS_BIN="${TOOLS_BIN:-"/tmp/smir/bin"}"
18+
19+
# Assume we are inside SMIR repository
20+
SMIR_PATH=$(git rev-parse --show-toplevel)
21+
22+
# Set the toolchain to be used in this script
23+
REPO_TOOLCHAIN=$(rustup show active-toolchain | (read toolchain _; echo $toolchain))
24+
TOOLCHAIN="${TOOLCHAIN:-${REPO_TOOLCHAIN}}"
25+
26+
# Build stable_mir tools
27+
function build_smir_tools() {
28+
pushd "${SMIR_PATH}"
29+
cargo +${TOOLCHAIN} build -Z unstable-options --out-dir "${TOOLS_BIN}"
30+
export PATH="${TOOLS_BIN}":"${PATH}"
31+
}
32+
33+
# Set up rustc repository
34+
function setup_rustc_repo() {
35+
if [[ ! -e "${RUST_REPO}" ]]; then
36+
mkdir -p "$(dirname ${RUST_REPO})"
37+
git clone -b master https://github.com/rust-lang/rust.git "${RUST_REPO}"
38+
pushd "${RUST_REPO}"
39+
commit="$(rustc +${TOOLCHAIN} -vV | awk '/^commit-hash/ { print $2 }')"
40+
if [[ "${commit}" != "unknown" ]]; then
41+
# For custom toolchain, this may return "unknown". Skip this step if that's the case.
42+
# In that case, we will use the HEAD of the main branch.
43+
git checkout "${commit}"
44+
fi
45+
git submodule init -- "library/stdarch"
46+
git submodule update
47+
else
48+
pushd "${RUST_REPO}"
49+
fi
50+
}
51+
52+
function run_tests() {
53+
# Run the following suite configuration for now (test suite + mode)
54+
SUITES=(
55+
"codegen codegen"
56+
"codegen-units codegen-units"
57+
# -- The suites below are failing because of fully qualified paths for standard library
58+
# E.g.:
59+
# - _10 = _eprint(move _11) -> [return: bb6, unwind unreachable];
60+
# + _10 = std::io::_eprint(move _11) -> [return: bb6, unwind unreachable];
61+
#
62+
#"ui ui"
63+
#"mir-opt mir-opt"
64+
#"pretty pretty" -- 2 failing tests
65+
)
66+
67+
SYSROOT=$(rustc +${TOOLCHAIN} --print sysroot)
68+
PY_PATH=$(type -P python3)
69+
HOST=$(rustc +${TOOLCHAIN} -vV | awk '/^host/ { print $2 }')
70+
FILE_CHECK="$(which FileCheck-12 || which FileCheck-13 || which FileCheck-14)"
71+
72+
echo "#---------- Variables -------------"
73+
echo "RUST_REPO: ${RUST_REPO}"
74+
echo "TOOLS_BIN: ${TOOLS_BIN}"
75+
echo "TOOLCHAIN: ${TOOLCHAIN}"
76+
echo "SYSROOT: ${SYSROOT}"
77+
echo "FILE_CHECK: ${FILE_CHECK}"
78+
echo "-----------------------------------"
79+
80+
for suite_cfg in "${SUITES[@]}"; do
81+
# Hack to work on older bash like the ones on MacOS.
82+
suite_pair=($suite_cfg)
83+
suite=${suite_pair[0]}
84+
mode=${suite_pair[1]}
85+
86+
echo "#### Running suite: ${suite} mode: ${mode}"
87+
cargo +${TOOLCHAIN} run -p compiletest -- \
88+
--compile-lib-path="${SYSROOT}/lib" \
89+
--run-lib-path="${SYSROOT}/lib"\
90+
--python="${PY_PATH}" \
91+
--rustc-path="${TOOLS_BIN}/test-drive" \
92+
--mode=${mode} \
93+
--suite="${suite}" \
94+
--src-base="tests/${suite}" \
95+
--build-base="$(pwd)/build/${HOST}/stage1/tests/${suite}" \
96+
--sysroot-base="$SYSROOT" \
97+
--stage-id=stage1-${HOST} \
98+
--cc= \
99+
--cxx= \
100+
--cflags= \
101+
--cxxflags= \
102+
--llvm-components= \
103+
--android-cross-path= \
104+
--target=${HOST} \
105+
--llvm-filecheck="${FILE_CHECK}" \
106+
--channel=nightly \
107+
--git-repository="rust-lang/project-stable-mir" \
108+
--nightly-branch="main" \
109+
--target-rustcflags="--smir-check" \
110+
--host-rustcflags="--smir-check"
111+
done
112+
}
113+
114+
build_smir_tools
115+
setup_rustc_repo
116+
run_tests

.github/workflows/demo.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Run a job to ensure formatting is OK
2+
name: Run demo
3+
on:
4+
pull_request:
5+
paths:
6+
- demo/**
7+
8+
push:
9+
paths:
10+
- demo/**
11+
12+
jobs:
13+
check_demo:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
19+
- name: Run Demo
20+
run: ./demo/run_demo.sh

.github/workflows/deploy_mdbook.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Deploy Book
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build-book:
10+
name: Build Book
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
18+
- name: Install mdbook
19+
run: cargo install mdbook --version "^0.4" --locked
20+
21+
- name: Run mdbook
22+
run: mdbook build book
23+
24+
- name: Upload book
25+
uses: actions/upload-pages-artifact@v2
26+
with:
27+
path: book/build
28+
retention-days: "3"
29+
30+
- name: Deploy Book
31+
uses: JamesIves/github-pages-deploy-action@v4
32+
if: ${{ github.event_name == 'push' && startsWith('refs/heads/main', github.ref) }}
33+
with:
34+
branch: gh-pages
35+
folder: book/build
36+
single-commit: true

.github/workflows/format.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Run a job to ensure formatting is OK
2+
name: Format Check
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
format-check:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
16+
- name: Run Rust Format
17+
run: cargo fmt --check

.github/workflows/nightly.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Run compiler tests
2+
3+
on:
4+
schedule:
5+
- cron: "0 6 * * *" # Run daily at 06:00 UTC
6+
workflow_dispatch: # Allow manual dispatching
7+
pull_request:
8+
9+
jobs:
10+
compile-test:
11+
name: Rust Compiler Tests
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
17+
- name: Install latest nightly
18+
uses: actions-rs/toolchain@v1
19+
with:
20+
toolchain: nightly
21+
22+
- name: Test local suites
23+
run: ./.github/scripts/run_own_tests.sh
24+
env:
25+
TOOLS_BIN: "/tmp/smir/bin"
26+
27+
- name: Test rustc suites
28+
run: ./.github/scripts/run_rustc_tests.sh
29+
env:
30+
RUST_REPO: "/tmp/rustc"
31+
TOOLS_BIN: "/tmp/smir/bin"
32+
# Don't fail CI for now. See: https://github.com/rust-lang/project-stable-mir/issues/39
33+
continue-on-error: true

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/book/build
2+
**/target
3+
4+
.idea
5+
*.swp
6+
*.swo
7+
.vscode

CHARTER.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Stable MIR Librarification Charter
2+
<!--
3+
Provide an introduction summarising the goals and motivation behind your
4+
project group.
5+
-->
6+
7+
## Goals
8+
9+
<!--
10+
Explain what changes you'd like to see your group your group to focus on, and
11+
how you plan to approach these issues. Focus on explaining the highest possible
12+
level of your change.
13+
-->
14+
15+
## Constraints And Considerations
16+
17+
<!--
18+
Explain the scope of your group, what you have chosen not to include in
19+
your goals, and your motivations behind making them non-goals.
20+
-->
21+
22+
23+
## Membership
24+
25+
<!--
26+
Mention your initial membership and who has decided take the roles of
27+
shepherd(s) and liason.
28+
-->
29+
30+
**Shepherd:**
31+
**Team Liason:**
32+
**Members:**

CODE_OF_CONDUCT.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# The Rust Code of Conduct
2+
3+
The Code of Conduct for this repository [can be found online](https://www.rust-lang.org/conduct.html).

Cargo.toml

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,13 @@
1-
[package]
2-
name = "rustc_public"
3-
version = "0.1.0-preview"
4-
edition = "2024"
1+
# Cargo workspace for utility tools used to check stable-mir in CI
2+
[workspace]
3+
resolver = "2"
4+
members = [
5+
"tools/compiletest",
6+
"tools/test-drive",
7+
]
58

6-
[dependencies]
7-
# tidy-alphabetical-start
8-
rustc_abi = { path = "../rustc_abi" }
9-
rustc_hir = { path = "../rustc_hir" }
10-
rustc_middle = { path = "../rustc_middle" }
11-
rustc_public_bridge = { path = "../rustc_public_bridge" }
12-
rustc_session = { path = "../rustc_session" }
13-
rustc_span = { path = "../rustc_span" }
14-
rustc_target = { path = "../rustc_target" }
15-
scoped-tls = "1.0"
16-
serde = { version = "1.0.125", features = [ "derive" ] }
17-
tracing = "0.1"
18-
# tidy-alphabetical-end
19-
20-
[features]
21-
# tidy-alphabetical-start
22-
# Provides access to APIs that expose internals of the rust compiler.
23-
# APIs enabled by this feature are unstable. They can be removed or modified
24-
# at any point and they are not included in the crate's semantic versioning.
25-
rustc_internal = []
26-
# tidy-alphabetical-end
9+
exclude = [
10+
"build",
11+
"target",
12+
"demo",
13+
]

0 commit comments

Comments
 (0)