From c6886be27d2e0ffe678ab28dcbe8396307759eeb Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Thu, 7 Sep 2023 03:55:45 +0200 Subject: [PATCH] Default to mold linker --- .github/workflows/build.yml | 2 +- README.md | 2 ++ build.sh | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 67b6255..3ff2fc9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/README.md b/README.md index 1cc7f2e..6fe29d0 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/build.sh b/build.sh index 5b9b27d..348111a 100755 --- a/build.sh +++ b/build.sh @@ -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