Skip to content

Commit 03f01bb

Browse files
authored
Merge pull request rust-lang#1105 from bjorn3/test_rustc_bootstrapping
Test bootstrapping of rustc using cg_clif
2 parents 646b00f + 54b1d10 commit 03f01bb

File tree

3 files changed

+116
-5
lines changed

3 files changed

+116
-5
lines changed

.github/workflows/bootstrap_rustc.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Bootstrap rustc using cg_clif
2+
3+
on:
4+
- push
5+
6+
jobs:
7+
bootstrap_rustc:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- name: Cache cargo installed crates
14+
uses: actions/cache@v2
15+
with:
16+
path: ~/.cargo/bin
17+
key: ${{ runner.os }}-cargo-installed-crates
18+
19+
- name: Cache cargo registry and index
20+
uses: actions/cache@v2
21+
with:
22+
path: |
23+
~/.cargo/registry
24+
~/.cargo/git
25+
key: ${{ runner.os }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }}
26+
27+
- name: Cache cargo target dir
28+
uses: actions/cache@v2
29+
with:
30+
path: target
31+
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
32+
33+
- name: Prepare dependencies
34+
run: |
35+
git config --global user.email "[email protected]"
36+
git config --global user.name "User"
37+
./prepare.sh
38+
39+
- name: Test
40+
run: |
41+
# Enable backtraces for easier debugging
42+
export RUST_BACKTRACE=1
43+
44+
./scripts/test_bootstrap.sh

scripts/test_bootstrap.sh

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
set -e
3+
4+
cd $(dirname "$0")/../
5+
6+
./build.sh
7+
source build/config.sh
8+
9+
echo "[TEST] Bootstrap of rustc"
10+
git clone https://github.com/rust-lang/rust.git || true
11+
pushd rust
12+
git fetch
13+
git checkout -- .
14+
git checkout $(rustc -V | cut -d' ' -f3 | tr -d '(')
15+
16+
git apply - <<EOF
17+
diff --git a/.gitmodules b/.gitmodules
18+
index 984113151de..c1e9d960d56 100644
19+
--- a/.gitmodules
20+
+++ b/.gitmodules
21+
@@ -34,10 +34,6 @@
22+
[submodule "src/doc/edition-guide"]
23+
path = src/doc/edition-guide
24+
url = https://github.com/rust-lang/edition-guide.git
25+
-[submodule "src/llvm-project"]
26+
- path = src/llvm-project
27+
- url = https://github.com/rust-lang/llvm-project.git
28+
- branch = rustc/11.0-2020-10-12
29+
[submodule "src/doc/embedded-book"]
30+
path = src/doc/embedded-book
31+
url = https://github.com/rust-embedded/book.git
32+
diff --git a/compiler/rustc_data_structures/Cargo.toml b/compiler/rustc_data_structures/Cargo.toml
33+
index 23e689fcae7..5f077b765b6 100644
34+
--- a/compiler/rustc_data_structures/Cargo.toml
35+
+++ b/compiler/rustc_data_structures/Cargo.toml
36+
@@ -32,7 +32,6 @@ tempfile = "3.0.5"
37+
38+
[dependencies.parking_lot]
39+
version = "0.11"
40+
-features = ["nightly"]
41+
42+
[target.'cfg(windows)'.dependencies]
43+
winapi = { version = "0.3", features = ["fileapi", "psapi"] }
44+
EOF
45+
46+
cat > config.toml <<EOF
47+
[llvm]
48+
ninja = false
49+
50+
[build]
51+
rustc = "$(pwd)/../build/cg_clif"
52+
cargo = "$(rustup which cargo)"
53+
full-bootstrap = true
54+
local-rebuild = true
55+
56+
[rust]
57+
codegen-backends = ["cranelift"]
58+
EOF
59+
60+
rm -r compiler/rustc_codegen_cranelift/{Cargo.*,src}
61+
cp ../Cargo.* compiler/rustc_codegen_cranelift/
62+
cp -r ../src compiler/rustc_codegen_cranelift/src
63+
64+
./x.py build --stage 1 library/std
65+
popd

src/bin/cg_clif.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ impl rustc_driver::Callbacks for CraneliftPassesCallbacks {
2727
config.opts.cg.panic = Some(PanicStrategy::Abort);
2828
config.opts.debugging_opts.panic_abort_tests = true;
2929
config.opts.maybe_sysroot = Some(
30-
std::env::current_exe()
31-
.unwrap()
32-
.parent()
33-
.unwrap()
34-
.join("sysroot"),
30+
config.opts.maybe_sysroot.clone().unwrap_or(
31+
std::env::current_exe()
32+
.unwrap()
33+
.parent()
34+
.unwrap()
35+
.join("sysroot"),
36+
),
3537
);
3638
}
3739
}

0 commit comments

Comments
 (0)