Skip to content

Commit

Permalink
ci: use mold linker (#17)
Browse files Browse the repository at this point in the history
* ci: use lld and mold linker

* install mold

* use sudo

* use github actions

* install mold by curl

* remove sudo

* mold for coverage

* show error

* hardcode

* use env

* export

* put in a script

* relative root

* not array

* move to script

* pre-build to build

* add linker

* update cross

* check

* check

* debian

* library

* only cargo

* cargobin

* build

* only linux gnu
  • Loading branch information
vnghia authored Jan 23, 2024
1 parent e8de942 commit 870401f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#TODO: enable mold for other target
[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "link-arg=-fuse-ld=mold"]
1 change: 1 addition & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: rui314/setup-mold@v1
- name: Install Rust
run: rustup update stable
- name: Install cargo-llvm-cov
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Install mold
uses: rui314/setup-mold@v1
if: matrix.platform.command == 'cargo'
- uses: cargo-bins/cargo-binstall@main
- name: Install cross
run: cargo binstall cross --no-confirm
if: matrix.platform.command == 'cross'
- name: Build and test
run: ${{ matrix.platform.command }} test --locked --target ${{ matrix.platform.target }}

Expand Down
7 changes: 2 additions & 5 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[build.env]
passthrough = ["DATABASE_URL"]

[target.aarch64-unknown-linux-gnu]
pre-build = [
"dpkg --add-architecture $CROSS_DEB_ARCH",
"apt-get update && apt-get --assume-yes install libpq-dev:$CROSS_DEB_ARCH",
]
[build]
pre-build = "ci/cross-pre-build.sh"
7 changes: 7 additions & 0 deletions ci/cross-pre-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euxo pipefail

if [[ "$CROSS_TARGET" == "aarch64-unknown-linux-gnu" ]]; then
dpkg --add-architecture $CROSS_DEB_ARCH
apt-get update && apt-get --assume-yes install libpq-dev:$CROSS_DEB_ARCH
fi

0 comments on commit 870401f

Please sign in to comment.