From d69504ad4a49e669000cc32cbf5f21934a434458 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Sun, 12 Jan 2025 14:28:41 +0000 Subject: [PATCH] Set up default cargo config.toml - Default to 8M default stack size, musl's 128K default is too small - Default to +crt-static --- .cargo/config.toml | 11 +++++++++++ Dockerfile | 4 +++- README.md | 2 +- test.sh | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..643bda9 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,11 @@ +[env] +CC = "clang" +CXX = "clang++" + +[target.x86_64-alpine-linux-musl] +linker = "clang" +rustflags = ["-C", "target-feature=+crt-static", "-C", "link-arg=-Wl,-z,stack-size=8388608"] + +[target.aarch64-alpine-linux-musl] +linker = "clang" +rustflags = ["-C", "target-feature=+crt-static", "-C", "link-arg=-Wl,-z,stack-size=8388608"] diff --git a/Dockerfile b/Dockerfile index d9c4370..2551163 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ FROM alpine:latest -COPY build.sh mimalloc.diff /tmp/ +COPY .cargo /root/.cargo + +COPY build.sh mimalloc.diff /tmp RUN /tmp/build.sh diff --git a/README.md b/README.md index 31738fc..146e46e 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ continue to link against `mimalloc` as intended, but you need extra command-line arguments to ensure they are indeed static: ```sh -$ RUSTFLAGS="-C target-feature=+crt-static" cargo install --target x86_64-alpine-linux-musl foo +$ cargo install --target x86_64-alpine-linux-musl foo ``` The `--target` flag is required. The default target is either diff --git a/test.sh b/test.sh index c53313e..ee1b616 100755 --- a/test.sh +++ b/test.sh @@ -4,4 +4,4 @@ set -eu TARGET=$(rustc -vV | sed -n "s|host: ||p") -RUSTFLAGS="-C target-feature=+crt-static" exec cargo install --root "$PWD" --target "$TARGET" names +exec cargo install --root "$PWD" --target "$TARGET" names