Skip to content

Commit

Permalink
Update rust toolchain from 1.68 to 1.70 (-2076 bytes). (chipsalliance…
Browse files Browse the repository at this point in the history
…#367)

Set the desired toolchain in rust-toolchain.toml, so everyone uses the
same toolchain by default, and we can remove the explicit risv32imc
target install steps.

The improved risc-v codegen in this release reduces the size of the ROM
by 2076 bytes.

As part of this change, we can remove the cargo index cache, as in 1.70
cargo switched to the "sparse index protocol":

https://github.com/rust-lang/rust/blob/642c92e63008ffb49f6ad8344e07bfa7d5b0d9bb/RELEASES.md?plain=1#L101
  • Loading branch information
korran authored Jun 8, 2023
1 parent c1745df commit 9598287
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 76 deletions.
28 changes: 1 addition & 27 deletions .github/workflows/build-test-verilator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
SCCACHE_GHA_CACHE_TO: sccache-verilator-10000
SCCACHE_GHA_CACHE_FROM: sccache-verilator-
# Change this to a new random value if you suspect the cache is corrupted
SCCACHE_C_CUSTOM_CACHE_BUSTER: f3e6951f0c1d
SCCACHE_C_CUSTOM_CACHE_BUSTER: 3962471045e8

# Compiler warnings should fail to compile
EXTRA_CARGO_CONFIG: "target.'cfg(all())'.rustflags = [\"-Dwarnings\"]"
Expand All @@ -32,21 +32,6 @@ jobs:
with:
submodules: 'true'

- name: Set Rust ${{ env.RUST_TOOLCHAIN_VERSION }} as the default toolchain.
run: |
rustup default ${RUST_TOOLCHAIN_VERSION}
rustup component add rustfmt clippy
rustc --version
cargo fmt --version
cargo clippy --version
- name: Restore Cargo index from cache
uses: actions/cache/restore@v3
id: cargo_index_restore
with:
path: ~/.cargo/registry/index
key: cargo-index-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}-${{ hashFiles('Cargo.lock') }}

- name: Restore sccache binary
uses: actions/cache/restore@v3
id: sccache_bin_restore
Expand Down Expand Up @@ -103,24 +88,13 @@ jobs:
run: |
echo /opt/verilator/bin >> $GITHUB_PATH
- name: Install risv32imc target
run: |
rustup target add riscv32imc-unknown-none-elf
- name: Update Cargo index
run: |
cargo tree --locked > /dev/null || (
echo "Please include required changes to Cargo.lock in your pull request"
exit 1
)
- name: Save Cargo index to cache
uses: actions/cache/save@v3
if: steps.cargo_index_restore.outputs.cache-hit != 'true'
with:
path: ~/.cargo/registry/index
key: cargo-index-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}-${{ hashFiles('Cargo.lock') }}

- name: Check that generated register code matches caliptra-rtl submodule
run: |
cargo run --locked -p caliptra_registers_generator -- --check hw-latest/caliptra-rtl registers/src
Expand Down
29 changes: 1 addition & 28 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,20 @@ jobs:
runs-on: ubuntu-20.04

env:
RUST_TOOLCHAIN_VERSION: 1.68.0
CARGO_INCREMENTAL: 0
SCCACHE_VERSION: 0.3.3
SCCACHE_GHA_CACHE_TO: sccache-caliptra-sw
SCCACHE_GHA_CACHE_FROM: sccache-caliptra-sw

# Change this to a new random value if you suspect the cache is corrupted
SCCACHE_C_CUSTOM_CACHE_BUSTER: 68a6835b420c
SCCACHE_C_CUSTOM_CACHE_BUSTER: 4eeb97ca753a

# Compiler warnings should fail to compile
EXTRA_CARGO_CONFIG: "target.'cfg(all())'.rustflags = [\"-Dwarnings\"]"

steps:
- uses: actions/checkout@v3

- name: Restore Cargo index from cache
uses: actions/cache/restore@v3
id: cargo_index_restore
with:
path: ~/.cargo/registry/index
key: cargo-index-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}-${{ hashFiles('Cargo.lock') }}

- name: Restore sccache binary
uses: actions/cache/restore@v3
id: sccache_bin_restore
Expand Down Expand Up @@ -65,14 +57,6 @@ jobs:
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Set Rust ${{ env.RUST_TOOLCHAIN_VERSION }} as the default toolchain.
run: |
rustup default ${RUST_TOOLCHAIN_VERSION}
rustup component add rustfmt clippy
rustc --version
cargo fmt --version
cargo clippy --version
- name: Check that Cargo.lock doesn't need to be updated
# Note: this isn't the same as checking that Cargo.lock is up to date
# (cargo update --locked), which makes sure that every package is the
Expand All @@ -90,13 +74,6 @@ jobs:
exit 1
)
- name: Save Cargo index to cache
uses: actions/cache/save@v3
if: steps.cargo_index_restore.outputs.cache-hit != 'true'
with:
path: ~/.cargo/registry/index
key: cargo-index-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}-${{ hashFiles('Cargo.lock') }}

- name: Check source-code formatting (run "cargo fmt" if this fails)
run: |
cargo fmt --check --all
Expand All @@ -105,10 +82,6 @@ jobs:
run: |
cargo run -p file-header-fix --locked -- --check
- name: Install risv32imc target
run: |
rustup target add riscv32imc-unknown-none-elf
- name: Build
run: |
cargo --config "$EXTRA_CARGO_CONFIG" build --locked
Expand Down
14 changes: 0 additions & 14 deletions .github/workflows/nightly-verilator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ on:
# 2:11 AM PST tuesday-saturday
- cron: '11 10 * * 2-6'


jobs:
smoke_test:
name: Smoke Test
runs-on: ubuntu-22.04
timeout-minutes: 360

env:
RUST_TOOLCHAIN_VERSION: 1.68.0
VERILATOR_VERSION: v5.006
PKG_CONFIG_PATH: /opt/verilator/share/pkgconfig
# Change this to a new random value if you suspect the cache is corrupted
Expand All @@ -24,14 +22,6 @@ jobs:
with:
submodules: 'true'

- name: Set Rust ${{ env.RUST_TOOLCHAIN_VERSION }} as the default toolchain.
run: |
rustup default ${RUST_TOOLCHAIN_VERSION}
rustup component add rustfmt clippy
rustc --version
cargo fmt --version
cargo clippy --version
- name: Restore verilator dir
uses: actions/cache/restore@v3
id: verilator_restore
Expand Down Expand Up @@ -62,10 +52,6 @@ jobs:
run: |
echo /opt/verilator/bin >> $GITHUB_PATH
- name: Install risv32imc target
run: |
rustup target add riscv32imc-unknown-none-elf
- name: Run smoke test inside verilator (will take hours)
run: |
export CALIPTRA_VERILATOR_JOBS=2
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/size-history.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
runs-on: ubuntu-22.04

env:
RUST_TOOLCHAIN_VERSION: 1.68.0
CARGO_INCREMENTAL: 0
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
PR_TITLE: ${{github.event.pull_request.title}}
Expand All @@ -35,11 +34,6 @@ jobs:
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Set Rust ${{ env.RUST_TOOLCHAIN_VERSION }} as the default toolchain.
run: |
rustup default ${RUST_TOOLCHAIN_VERSION}
rustup target add riscv32imc-unknown-none-elf
- name: Run size analysis (look at workflow "Summary" tab for results)
run: |
cargo run --release -p caliptra-size-history
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ used by firmware running on Caliptra's RISC-V cpu.
To build Caliptra firmware or tools, you need a Linux installation with a recent
Rust toolchain. See [Getting started with
Rust](https://www.rust-lang.org/learn/get-started) for more information on
installing an up-to-date Rust toolchain. We use version 1.68 of the Rust
installing an up-to-date Rust toolchain. We use version 1.70 of the Rust
toolchain for all continuous integration.

## Checkout and build
Expand Down
1 change: 1 addition & 0 deletions rom/dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
name = "caliptra-rom"
version = "0.1.0"
edition = "2021"
rust-version = "1.70"

[dependencies]
caliptra-drivers = { path = "../../drivers" }
Expand Down
7 changes: 7 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Licensed under the Apache-2.0 license

[toolchain]
channel = "1.70"
targets = ["riscv32imc-unknown-none-elf"]
profile = "minimal"
components = ["rustfmt", "clippy"]

0 comments on commit 9598287

Please sign in to comment.