From f69f5e29ce9d951cac5ad367cd860a768098439f Mon Sep 17 00:00:00 2001 From: Carlo Supina Date: Wed, 24 Apr 2024 18:36:39 -0500 Subject: [PATCH 1/2] use mold and dynamic linking to increase compile times --- .cargo/config.toml | 23 +---------------------- .github/workflows/release.yml | 4 ++-- .github/workflows/web_release.yml | 2 +- Cargo.toml | 3 +++ build_wasm.sh | 2 +- 5 files changed, 8 insertions(+), 26 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 068615b9..53aec996 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,30 +1,9 @@ -# Add the contents of this file to `config.toml` to enable "fast build" configuration. Please read the notes below. - -# NOTE: For maximum performance, build using a nightly compiler -# If you are using rust stable, remove the "-Zshare-generics=y" below. - [target.x86_64-unknown-linux-gnu] linker = "clang" -#rustflags = ["-Clink-arg=-fuse-ld=lld", "-Zshare-generics=y"] -rustflags = ["-Clink-arg=-fuse-ld=lld"] - - -# NOTE: you must manually install https://github.com/michaeleisel/zld on mac. you can easily do this with the "brew" package manager: -# `brew install michaeleisel/zld/zld` -#[target.x86_64-apple-darwin] -#rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/zld", "-Zshare-generics=y"] - -#[target.aarch64-apple-darwin] -#rustflags = ["-C", "link-arg=-fuse-ld=/opt/homebrew/bin/zld", "-Zshare-generics=y"] +rustflags = ["-Clink-arg=-fuse-ld=/usr/bin/mold"] [target.x86_64-pc-windows-msvc] linker = "rust-lld.exe" -#rustflags = ["-Zshare-generics=n"] [target.wasm32-unknown-unknown] runner = "wasm-server-runner" - -# Optional: Uncommenting the following improves compile times, but reduces the amount of debug info to 'line number tables only' -# In most cases the gains are negligible, but if you are on macos and have slow compile times you should see significant gains. -#[profile.dev] -#debug = 1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 80010b6a..528b9590 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,7 +35,7 @@ jobs: if: matrix.config.os == 'ubuntu-latest' run: | set -euxo pipefail - sudo apt update && sudo apt upgrade && sudo apt install -y lld g++ pkg-config libx11-dev libasound2-dev libudev-dev + sudo apt update && sudo apt upgrade && sudo apt install -y mold g++ pkg-config libx11-dev libasound2-dev libudev-dev - name: 🦀 Setup Rust uses: actions-rs/toolchain@v1 @@ -48,7 +48,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: build - args: --release --target ${{ matrix.config.target }} --features storage --features cli --features arcade + args: --release --target ${{ matrix.config.target }} --no-default-features --features storage --features cli --features arcade - name: Assume AWS IAM role uses: aws-actions/configure-aws-credentials@v4 diff --git a/.github/workflows/web_release.yml b/.github/workflows/web_release.yml index 327903ce..5c7d7ee6 100644 --- a/.github/workflows/web_release.yml +++ b/.github/workflows/web_release.yml @@ -40,7 +40,7 @@ jobs: - name: Install bevy deps and binaryen for wasm optimization run: | set -euxo pipefail - sudo apt update && sudo apt upgrade && sudo apt install -y lld g++ pkg-config libx11-dev libasound2-dev libudev-dev binaryen + sudo apt update && sudo apt upgrade && sudo apt install -y mold g++ pkg-config libx11-dev libasound2-dev libudev-dev binaryen - name: Build wasm assets run: ./build_wasm.sh - name: Publish deployment to netlify website diff --git a/Cargo.toml b/Cargo.toml index 172876a7..1081863b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.1" edition = "2021" [workspace] +resolver = "2" members = [ "crates/thetawave_interface", "crates/thetawave_storage", @@ -111,6 +112,8 @@ opt-level = 1 codegen-units = 1 [features] +default = ["fast-compile", "storage"] arcade = ["thetawave_arcade"] storage = ["thetawave_storage"] cli = ["argh"] +fast-compile = ["bevy/dynamic_linking"] diff --git a/build_wasm.sh b/build_wasm.sh index 9765a670..701928d7 100755 --- a/build_wasm.sh +++ b/build_wasm.sh @@ -3,7 +3,7 @@ set -euo pipefail rm -rf ./out/ mkdir ./out rustup target add wasm32-unknown-unknown -cargo build --release --target wasm32-unknown-unknown +cargo build --release --target wasm32-unknown-unknown --no-default-features cargo install wasm-bindgen-cli wasm-bindgen --out-dir ./out/ --target web --split-linked-modules ./target/wasm32-unknown-unknown/release/thetawave.wasm wasm-opt out/thetawave_bg.wasm -Oz -o thetawave_bg.wasm From ec2eef9433dd509e267427ac92a81e0d50f8bcc4 Mon Sep 17 00:00:00 2001 From: Carlo Supina Date: Thu, 25 Apr 2024 00:52:41 -0500 Subject: [PATCH 2/2] add -C argument to rustflags --- .cargo/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 53aec996..39f8abbe 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,6 +1,6 @@ [target.x86_64-unknown-linux-gnu] linker = "clang" -rustflags = ["-Clink-arg=-fuse-ld=/usr/bin/mold"] +rustflags = ["-C", "link-arg=-fuse-ld=mold"] [target.x86_64-pc-windows-msvc] linker = "rust-lld.exe"