Skip to content

Commit

Permalink
Set up default cargo config.toml
Browse files Browse the repository at this point in the history
- Default to 8M default stack size, musl's 128K default is too small
- Default to +crt-static
  • Loading branch information
TerrorJack committed Jan 12, 2025
1 parent baaaeb4 commit d69504a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
11 changes: 11 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -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"]
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d69504a

Please sign in to comment.