Skip to content

Establish Infrastructure #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions .github/scripts/run_own_tests.sh

This file was deleted.

116 changes: 0 additions & 116 deletions .github/scripts/run_rustc_tests.sh

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Run a job to ensure formatting is OK
# Run a job to ensure Demo is OK
name: Run demo
on:
pull_request:
Expand All @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Run Demo
run: ./demo/run_demo.sh
2 changes: 1 addition & 1 deletion .github/workflows/deploy_mdbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install mdbook
run: cargo install mdbook --version "^0.4" --locked
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Run Rust Format
run: cargo fmt --check
run: ./x fmt --check
41 changes: 21 additions & 20 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,29 @@ on:
workflow_dispatch: # Allow manual dispatching
pull_request:

defaults:
run:
shell: bash

jobs:
compile-test:
name: Rust Compiler Tests
msrv:
name: MSRV Nightly Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install latest nightly
uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly

- name: Test local suites
run: ./.github/scripts/run_own_tests.sh
env:
TOOLS_BIN: "/tmp/smir/bin"
# Note that this is the release date, which means the downloaded version is 2025-08-09.
toolchain: nightly-2025-08-10
components: rust-src
- run: ./x test

- name: Test rustc suites
run: ./.github/scripts/run_rustc_tests.sh
env:
RUST_REPO: "/tmp/rustc"
TOOLS_BIN: "/tmp/smir/bin"
# Don't fail CI for now. See: https://github.com/rust-lang/project-stable-mir/issues/39
continue-on-error: true
latest:
name: Latest Nightly Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- run: ./x test
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
/book/build
**/target

# direnv
.envrc
/.direnv

.idea
*.swp
*.swo
.vscode

Cargo.lock
48 changes: 41 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,47 @@
[package]
name = "rustc_public"
version = "0.1.0"
authors = ["rustc_public team"]
description = "Define compiler intermediate representation usable by external tools"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/project-stable-mir"
edition = "2024"

[lib]
path = "src/lib.rs"

[dependencies]
scoped-tls = "1.0"
serde = { version = "1.0.125", features = [ "derive" ] }
tracing = "0.1"

[build-dependencies]
rustversion = "1"

[dev-dependencies]
regex = "1.5.5"
ui_test = "0.30.2"

[[test]]
name = "compiletest"
harness = false

# Cargo workspace for utility tools used to check stable-mir in CI
[workspace]
resolver = "2"
members = [
"tools/compiletest",
"tools/test-drive",
"test-drive",
]

exclude = [
"build",
"target",
"demo",
]
[features]
# tidy-alphabetical-start
# Provides access to APIs that expose internals of the rust compiler.
# APIs enabled by this feature are unstable. They can be removed or modified
# at any point and they are not included in the crate's semantic versioning.
rustc_internal = []
# tidy-alphabetical-end

[package.metadata.rust-analyzer]
# This crate uses #[feature(rustc_private)].
# See https://github.com/rust-analyzer/rust-analyzer/pull/7891
rustc_private = true
30 changes: 30 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use std::process::{self, Command};
use std::{env, str};

use rustversion;

const MSRV: &str = "2025-08-09";
const SUPPORTED: bool = rustversion::cfg!(since(2025-08-09));

fn main() {
if !SUPPORTED {
let current = rustc_version().unwrap_or(String::from("unknown"));
eprintln!(
"\nERROR: rustc_public requires rustc nightly-{MSRV} or newer\n\
current: {current}\n\
help: run `rustup update nightly`.\n"
);
process::exit(1);
}
println!("cargo:rerun-if-changed=build.rs");
}

fn rustc_version() -> Option<String> {
let rustc = env::var_os("RUSTC").unwrap_or_else(|| {
eprintln!("RUSTC is not set during build script execution.\n");
process::exit(1);
});
let output = Command::new(rustc).arg("--version").output().ok()?;
let version = str::from_utf8(&output.stdout).ok()?;
version.parse().ok()
}
7 changes: 0 additions & 7 deletions demo/Cargo.lock

This file was deleted.

3 changes: 3 additions & 0 deletions demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ version = "0.0.0"
edition = "2021"

[dependencies]
rustc_public = { path = "../", features = ["rustc_internal"] }

[workspace]

[package.metadata.rust-analyzer]
# This crate uses #[feature(rustc_private)].
Expand Down
2 changes: 1 addition & 1 deletion demo/run_demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ REPO_DIR=$(git rev-parse --show-toplevel)
DEMO_DIR="${REPO_DIR}/demo"

cd "${DEMO_DIR}"
cargo run -- src/main.rs --crate-name demo --edition 2021 -C panic=abort
cargo run -- ../tests/print/basic_function.rs --crate-name bf --edition 2021 -C panic=abort

Loading
Loading