diff --git a/.gitignore b/.gitignore index 7585238..f059356 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +.DS_Store book diff --git a/README.md b/README.md index 52c3b17..43a1249 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Gear projects navigator for Rust developers. -👉 https://gear.rs +⚙️🦀 https://gear.rs ## Build Locally diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 007d8f7..92db588 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -1,3 +1,7 @@ # Summary [Introduction](introduction.md) + +# Tips and Tricks + +- [Accelerate the node building](accelerate-build.md) diff --git a/src/accelerate-build.md b/src/accelerate-build.md new file mode 100644 index 0000000..6c98796 --- /dev/null +++ b/src/accelerate-build.md @@ -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: ** +- Secret access 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= +export AWS_SECRET_ACCESS_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. diff --git a/theme/favicon.png b/theme/favicon.png new file mode 100644 index 0000000..da202c2 Binary files /dev/null and b/theme/favicon.png differ