-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·48 lines (36 loc) · 1.03 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
set -eu
MIMALLOC_VERSION=2.1.7
cd /tmp
apk upgrade --no-cache
apk add --no-cache \
alpine-sdk \
cargo \
cmake \
curl \
mold \
ninja-is-really-ninja
find /usr -type f -executable -name "ld" -exec sh -c 'ln -sf /usr/bin/ld.mold {}' \;
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
cmake \
-Bout \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DMI_BUILD_OBJECT=OFF \
-DMI_BUILD_TESTS=OFF \
-DMI_SKIP_COLLECT_ON_EXIT=ON \
-G Ninja \
.
cmake --build out --target install -- -v
for libc_path in $(find /usr -name libc.a); do
{
echo "CREATE libc.a"
echo "ADDLIB $libc_path"
echo "DELETE aligned_alloc.lo calloc.lo donate.lo free.lo libc_calloc.lo lite_malloc.lo malloc.lo malloc_usable_size.lo memalign.lo posix_memalign.lo realloc.lo reallocarray.lo valloc.lo"
echo "ADDLIB out/libmimalloc.a"
echo "SAVE"
} | ar -M
mv libc.a $libc_path
done
rm -rf /tmp/*