Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Use rust-lld as linker to speed up test execution in CI as well as locally #341

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ jobs:
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
with:
cache-workspaces: "./libs -> ./target"
components: llvm-tools-preview
- name: Install linker (Windows)
if: ${{ matrix.os == 'windows-2022' }}
uses: taiki-e/install-action@v2
with:
tool: cargo-binutils
- name: Install linker (Linux)
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: |
sudo apt-get update
sudo apt-get install lld clang
- name: Install linker (MacOS)
if: ${{ matrix.os == 'macos-12' || matrix.os == 'macos-14' }}
run: |
brew install llvm
- name: Build CLI
run: |
cd libs
Expand Down Expand Up @@ -215,9 +230,23 @@ jobs:
- name: Install Rust stable toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
with:
components: rustfmt
components: rustfmt, llvm-tools-preview
rustflags: ""
cache-workspaces: "./libs -> ./target"
- name: Install linker (Windows)
if: ${{ matrix.os == 'windows-2022' }}
uses: taiki-e/install-action@v2
with:
tool: cargo-binutils
- name: Install linker (Linux)
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: |
sudo apt-get update
sudo apt-get install lld clang
- name: Install linker (MacOS)
if: ${{ matrix.os == 'macos-12' || matrix.os == 'macos-14' }}
run: |
brew install llvm
- name: Download pavex CLI artifact
uses: actions/download-artifact@v4
with:
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/libs/ui_test_envs
/libs/target
/libs/vendor
/libs/.cargo
/doc_examples/tutorial_envs/
/doc_examples/**/target
/examples/**/vendor
Expand All @@ -14,4 +13,4 @@
trace-*.json
/.cache/
/docs/api_reference/
.direnv/
.direnv/
20 changes: 20 additions & 0 deletions libs/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# On Windows
# ```
# cargo install -f cargo-binutils
# rustup component add llvm-tools-preview
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]
[target.x86_64-pc-windows-gnu]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]

# On Linux:
# - Ubuntu, `sudo apt-get install lld clang`
# - Arch, `sudo pacman -S lld clang`
[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "linker=clang", "-C", "link-arg=-fuse-ld=lld"]

# On MacOS, `brew install llvm` and follow steps in `brew info llvm`
[target.x86_64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]
[target.aarch64-apple-darwin]
linker = "/opt/homebrew/opt/llvm/bin/ld64.lld"
14 changes: 11 additions & 3 deletions libs/pavex_test_runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,17 @@ impl TestData {
let mut cargo_config = toml! {
[build]
incremental = false

[registries.crates-io]
protocol = "sparse"

[target.x86_64-pc-windows-msvc]
linker = "rust-lld"
[target.x86_64-pc-windows-gnu]
linker = "rust-lld"
[target.x86_64-unknown-linux-gnu]
linker = "rust-lld"
[target.x86_64-apple-darwin]
linker = "rust-lld"
[target.aarch64-apple-darwin]
linker = "rust-lld"
};
cargo_config["build"]
.as_table_mut()
Expand Down