Skip to content

Commit d345f21

Browse files
committed
ci: add x86_64-linux-musl release
1 parent 92ccdcb commit d345f21

File tree

2 files changed

+118
-0
lines changed

2 files changed

+118
-0
lines changed

.github/workflows/musl.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: musl
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
musl:
8+
name: wasmtime-x86_64-linux-musl
9+
runs-on: ubuntu-latest
10+
steps:
11+
12+
- name: checkout
13+
uses: actions/checkout@v3
14+
with:
15+
submodules: true
16+
17+
- name: install-deps
18+
run: |
19+
sudo apt install -y \
20+
llvm \
21+
musl-tools
22+
rustup target add x86_64-unknown-linux-musl
23+
24+
- name: patch-musl
25+
run: |
26+
pushd $(mktemp -d)
27+
28+
git clone -b v2.1.2 --depth=1 https://github.com/microsoft/mimalloc.git .
29+
30+
git apply $GITHUB_WORKSPACE/mimalloc.diff
31+
32+
cmake \
33+
-Bout \
34+
-DCMAKE_BUILD_TYPE=Release \
35+
-DCMAKE_C_COMPILER=x86_64-linux-musl-gcc \
36+
-DMI_BUILD_SHARED=OFF \
37+
-DMI_BUILD_OBJECT=OFF \
38+
-DMI_BUILD_TESTS=OFF \
39+
.
40+
41+
cmake --build out -- -j3
42+
43+
readonly LIBC_PATH=$(find ~/.rustup -name libc.a)
44+
45+
{
46+
echo "CREATE libc.a"
47+
echo "ADDLIB $LIBC_PATH"
48+
echo "DELETE aligned_alloc.lo"
49+
echo "DELETE calloc.lo"
50+
echo "DELETE donate.lo"
51+
echo "DELETE free.lo"
52+
echo "DELETE libc_calloc.lo"
53+
echo "DELETE lite_malloc.lo"
54+
echo "DELETE malloc.lo"
55+
echo "DELETE malloc_usable_size.lo"
56+
echo "DELETE memalign.lo"
57+
echo "DELETE posix_memalign.lo"
58+
echo "DELETE realloc.lo"
59+
echo "DELETE reallocarray.lo"
60+
echo "ADDLIB out/libmimalloc.a"
61+
echo "SAVE"
62+
} | llvm-ar -M
63+
64+
mv libc.a $LIBC_PATH
65+
66+
popd
67+
68+
- name: build
69+
run: |
70+
cargo build \
71+
--target x86_64-unknown-linux-musl \
72+
--release \
73+
--bin wasmtime \
74+
--all-features \
75+
--config 'profile.release.lto = "thin"' \
76+
--config 'profile.release.strip = "symbols"'
77+
78+
mkdir wasmtime-v11.0.0-x86_64-linux-musl
79+
mv target/x86_64-unknown-linux-musl/release/wasmtime wasmtime-v11.0.0-x86_64-linux-musl
80+
XZ_OPT=-9 \
81+
tar \
82+
--sort=name \
83+
--mtime=1970-01-01T00:00:00Z \
84+
--owner=0 \
85+
--group=0 \
86+
--numeric-owner \
87+
-cJf wasmtime-v11.0.0-x86_64-linux-musl.tar.xz wasmtime-v11.0.0-x86_64-linux-musl
88+
89+
- name: upload-artifact
90+
uses: actions/upload-artifact@v3
91+
with:
92+
name: wasmtime-x86_64-linux-musl
93+
path: wasmtime-v11.0.0-x86_64-linux-musl.tar.xz

mimalloc.diff

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 2bcd1ef..6521343 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -422,7 +422,6 @@ endif()
6+
# static library
7+
if (MI_BUILD_STATIC)
8+
add_library(mimalloc-static STATIC ${mi_sources})
9+
- set_property(TARGET mimalloc-static PROPERTY POSITION_INDEPENDENT_CODE ON)
10+
target_compile_definitions(mimalloc-static PRIVATE ${mi_defines} MI_STATIC_LIB)
11+
target_compile_options(mimalloc-static PRIVATE ${mi_cflags})
12+
target_link_libraries(mimalloc-static PRIVATE ${mi_libraries})
13+
diff --git a/src/alloc-override.c b/src/alloc-override.c
14+
index 873065d..d3716b9 100644
15+
--- a/src/alloc-override.c
16+
+++ b/src/alloc-override.c
17+
@@ -272,7 +272,7 @@ void* _aligned_malloc(size_t alignment, size_t size) { return mi_aligned_allo
18+
void __libc_free(void* p) MI_FORWARD0(mi_free, p)
19+
void* __libc_memalign(size_t alignment, size_t size) { return mi_memalign(alignment, size); }
20+
21+
-#elif defined(__GLIBC__) && defined(__linux__)
22+
+#elif defined(__linux__)
23+
// forward __libc interface (needed for glibc-based Linux distributions)
24+
void* __libc_malloc(size_t size) MI_FORWARD1(mi_malloc,size)
25+
void* __libc_calloc(size_t count, size_t size) MI_FORWARD2(mi_calloc,count,size)

0 commit comments

Comments
 (0)