-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add article about building acceleration (#3)
- Loading branch information
Showing
5 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.DS_Store | ||
book |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
Gear projects navigator for Rust developers. | ||
|
||
👉 https://gear.rs | ||
⚙️🦀 https://gear.rs | ||
|
||
## Build Locally | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# Summary | ||
|
||
[Introduction](introduction.md) | ||
|
||
# Tips and Tricks | ||
|
||
- [Accelerate the node building](accelerate-build.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Accelerate the Gear node building | ||
|
||
## Using `sccache` | ||
|
||
Using `sccache` configured with AWS S3 allows decreasing build time. | ||
|
||
## Install `sccache` | ||
|
||
macOS: | ||
|
||
```bash | ||
brew install sccache | ||
``` | ||
|
||
## Add S3 config | ||
|
||
We consider we have already configured AWS S3 storage with the following settings: | ||
|
||
- Region: `us-west-1` | ||
- Bucket: `gear-sccache` | ||
- Access key ID: *<AWS_KEY_ID>* | ||
- Secret access key: *<AWS_SECRET_KEY>* | ||
|
||
We will use environment variables added to the profile file. For example, if using `zsh`, we need to add the following to the `~/.zshrc`: | ||
|
||
```bash | ||
export SCCACHE_BUCKET=gear-sccache | ||
export SCCACHE_REGION=us-west-1 | ||
export SCCACHE_S3_KEY_PREFIX=gear | ||
export AWS_ACCESS_KEY_ID=<AWS_KEY_ID> | ||
export AWS_SECRET_ACCESS_KEY="<AWS_SECRET_KEY>" | ||
``` | ||
|
||
Run to apply these settings immediately: | ||
|
||
```bash | ||
source ~/.zshrc | ||
``` | ||
|
||
## Build Gear node using `sccache` | ||
|
||
We need to set the `RUSTC_WRAPPER` environment variable to `sccache`. Also, we need to set `CARGO_INCREMENTAL` to `0` as `sccache` doesn't work well when using incremental building. We can set these environment variables by prepending the `cargo` command in the shell: | ||
|
||
```bash | ||
cd gear | ||
|
||
# Debug build: | ||
RUSTC_WRAPPER=sccache CARGO_INCREMENTAL=0 cargo b | ||
|
||
# Release build: | ||
RUSTC_WRAPPER=sccache CARGO_INCREMENTAL=0 cargo b -r | ||
``` | ||
|
||
## Using `mold/sold` | ||
|
||
`mold` is the linker that uses multiple CPU cores when linking. | ||
|
||
## Install `mold/sold` | ||
|
||
### macOS | ||
|
||
As `mold` doesn't support macOS we need to build `sold` manually. | ||
|
||
```bash | ||
git clone https://github.com/bluewhalesystems/sold.git | ||
mkdir sold/build | ||
cd sold/build | ||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=c++ .. | ||
cmake --build . -j $(sysctl -n hw.ncpu) | ||
sudo cmake --build . --target install | ||
``` | ||
|
||
## Configure `cargo` to use `mold/sold` | ||
|
||
To use `mold/sold` with Rust, create (or update) `.cargo/config.toml` at your home directory with the following: | ||
|
||
```toml | ||
# macOS on M-series: | ||
[target.aarch64-apple-darwin] | ||
rustflags = ["-C", "link-arg=--ld-path=/usr/local/bin/ld64.sold"] | ||
``` | ||
|
||
Then just run `cargo b [-r]` as usually. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.