Skip to content

Commit

Permalink
chore: custom cargo config to reduce build time
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 committed Oct 20, 2022
1 parent 0f123ef commit 128d3f3
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 57 deletions.
29 changes: 29 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[alias]
b = "build"
c = "check"
d = "doc"
t = "test"
r = "run"

[build]
incremental = true
# might be helpful but we don't enforce sccache installation atm
# https://github.com/mozilla/sccache
# rustc-wrapper = "sccache"

# For details checkout https://jondot.medium.com/8-steps-for-troubleshooting-your-rust-build-times-2ffc965fd13e
[target.x86_64-unknown-linux-gnu]
# clang has been listed as prerequisite in the doc
linker = "clang"
rustflags = ["-Clink-arg=-fuse-ld=lld", "-Zshare-generics=y"]

[target.x86_64-apple-darwin]
# zld might help here
# brew install michaeleisel/zld/zld
# "-Clink-arg=-fuse-ld=zld"
# For details checkout https://jondot.medium.com/8-steps-for-troubleshooting-your-rust-build-times-2ffc965fd13e
rustflags = ["-Zshare-generics=y"]

[net]
git-fetch-with-cli = true
retry = 5
8 changes: 3 additions & 5 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ jobs:
name: Cover
runs-on: buildjet-8vcpu-ubuntu-2004
timeout-minutes: 30
steps:
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential clang ocl-icd-opencl-dev
steps:
- name: Checkout Sources
uses: actions/checkout@v3
with:
submodules: true
- name: Install Dependencies
run: sudo make install-deps
- name: Rust Cache
uses: Swatinem/rust-cache@v2
timeout-minutes: 5
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ jobs:
check-publish-docs:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Apt Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential clang ocl-icd-opencl-dev
steps:
- name: Checkout Sources
uses: actions/checkout@v3
- name: Apt Dependencies
run: sudo make install-deps
- name: Link Checker (Repo)
uses: lycheeverse/lychee-action@v1.5.1
with:
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ jobs:
- os: macos-latest
file: forest-${{ github.ref_name }}-macos-amd64.zip
steps:
- name: Checkout Sources
uses: actions/checkout@v3
- name: Apt Dependencies
if: startsWith(matrix.os, 'Ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y build-essential clang ocl-icd-opencl-dev
run: sudo make install-deps
- name: Homebrew Utils
if: startsWith(matrix.os, 'macOS')
run: |
brew install --verbose coreutils
- name: Checkout Sources
uses: actions/checkout@v3
- name: Rust Cache
uses: Swatinem/rust-cache@v2
timeout-minutes: 5
Expand Down
45 changes: 26 additions & 19 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ jobs:
env:
RUSTFLAGS: "-D warnings"
steps:
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential clang ocl-icd-opencl-dev
- name: Checkout Sources
uses: actions/checkout@v3
- name: Install Dependencies
run: sudo make install-deps
- name: install nextest
uses: taiki-e/install-action@nextest
- name: Rust Cache
Expand All @@ -44,12 +42,10 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Apt Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential clang ocl-icd-opencl-dev
- name: Checkout Sources
uses: actions/checkout@v3
- name: Apt Dependencies
run: sudo make install-deps
- name: Rust Cache
uses: Swatinem/rust-cache@v2
timeout-minutes: ${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }}
Expand Down Expand Up @@ -110,36 +106,47 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
#rv: [1.58.1, stable, beta, nightly]
rv: [nightly]
steps:
- name: Install Dependencies
if: startsWith(matrix.os, 'Ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y build-essential clang ocl-icd-opencl-dev
- name: Checkout Sources
uses: actions/checkout@v3
- uses: visvirial/sccache-action@v1
if: startsWith(matrix.os, 'Ubuntu')
with:
arch: x86_64-unknown-linux-musl
- uses: visvirial/sccache-action@v1
if: startsWith(matrix.os, 'macOS')
with:
arch: x86_64-apple-darwin
- name: Install Linux Dependencies
if: startsWith(matrix.os, 'Ubuntu')
run: |
lscpu # the job may run on different CPUs, list cpu here for analysing build time
sudo make install-deps
- name: Rust Cache
uses: Swatinem/rust-cache@v2
timeout-minutes: ${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }}
continue-on-error: true
- uses: actions/cache@v3
with:
path: |
~/.cache/sccache/
key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }}
- name: Cargo Build
run: cargo build --profile dev
env:
CC: "/tmp/sccache/sccache clang"

calibnet-check:
name: Calibnet sync check
runs-on: buildjet-8vcpu-ubuntu-2004
timeout-minutes: 30
steps:
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential clang ocl-icd-opencl-dev
- name: Checkout Sources
uses: actions/checkout@v3
with:
submodules: true
- name: Install Dependencies
run: sudo make install-deps
- name: Rust Cache
uses: Swatinem/rust-cache@v2
timeout-minutes: ${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }}
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ config*.toml
*.orig
criterion
genesis.json
/.cargo
/.cargo/*
!/.cargo/*.toml
node/rpc-api/static/ast.ron
documentation/book/**/*
40 changes: 20 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
FROM rust:1-buster AS build-env

# Install dependencies
RUN apt-get update && apt-get install --no-install-recommends -y build-essential clang ocl-icd-opencl-dev cmake
RUN apt-get update && apt-get install --no-install-recommends -y build-essential clang lld ocl-icd-opencl-dev cmake

WORKDIR /usr/src/forest
COPY . .
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ install-daemon:

install: install-cli install-daemon

install-deps:
apt-get update -y
apt-get install --no-install-recommends -y build-essential clang lld ocl-icd-opencl-dev cmake

clean-all:
cargo clean

Expand Down Expand Up @@ -115,4 +119,4 @@ mdbook-build:
rustdoc:
cargo doc --workspace --all-features --no-deps

.PHONY: clean clean-all lint build release test test-all test-release license test-vectors run-vectors pull-serialization-tests install-cli install-daemon install docs run-serialization-vectors rustdoc
.PHONY: clean clean-all lint build release test test-all test-release license test-vectors run-vectors pull-serialization-tests install-cli install-daemon install install-deps docs run-serialization-vectors rustdoc
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ rustup install nightly

```shell
# Ubuntu
sudo make install-deps
# Or
sudo apt install build-essential clang ocl-icd-opencl-dev libssl-dev

# Archlinux
Expand Down

0 comments on commit 128d3f3

Please sign in to comment.