Skip to content

Commit

Permalink
Default to mold linker
Browse files Browse the repository at this point in the history
  • Loading branch information
TerrorJack committed Sep 7, 2023
1 parent 59403a5 commit c6886be
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ jobs:
rust:alpine-mimalloc \
sh -c 'cargo install names && mv $CARGO_HOME/bin/names .'
MIMALLOC_VERBOSE=1 ./names
ldd ./names
file ./names
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ or C/C++ static executables in this image, the resulting executables
will automatically link with `mimalloc` without needing any special
build flags.

Supported & tested archs: `amd64` and `arm64v8`.

For more details, see this [blog
post](https://www.tweag.io/blog/2023-08-10-rust-static-link-with-mimalloc).
6 changes: 6 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ apk upgrade --no-cache
apk add --no-cache \
alpine-sdk \
cmake \
mold \
samurai

{
echo "[target.$(rustup target list --installed)]"
echo 'rustflags = ["-C", "link-arg=-fuse-ld=mold"]'
} > $CARGO_HOME/config.toml

curl -f -L --retry 5 https://github.com/microsoft/mimalloc/archive/refs/tags/v$MIMALLOC_VERSION.tar.gz | tar xz --strip-components=1

patch -p1 < mimalloc.diff
Expand Down

0 comments on commit c6886be

Please sign in to comment.