Skip to content

Commit

Permalink
[skip-ci] build: Fix MUSL performance issues via mimalloc
Browse files Browse the repository at this point in the history
  • Loading branch information
oreiche committed Apr 3, 2024
1 parent 34dde3d commit d87374b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/make-pkg/build-tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,30 @@ set -eu
NAME=justbuild-$VERSION-$TARGET_ARCH-linux
OUTDIR=$(pwd)/../$NAME

MI_CC="gcc"
if [ "$TARGET_ARCH" = "aarch64" ]; then
MI_CC="aarch64-linux-musl-gcc"
TARGET_ARCH="arm64"
fi

mkdir -p "${BUILDDIR}"
rm -rf "${BUILDDIR}"/*

# build mimalloc.o from source
( cd "${BUILDDIR}"
export GIT_SSL_NO_VERIFY=true
git clone --depth 1 -b v2.1.2 https://github.com/microsoft/mimalloc.git
MI_CFLAGS="-std=gnu11 -O3 -DNDEBUG -DMI_MALLOC_OVERRIDE -I./mimalloc/include \
-fPIC -fvisibility=hidden -ftls-model=initial-exec -fno-builtin-malloc"
${MI_CC} ${MI_CFLAGS} -c ./mimalloc/src/static.c -o mimalloc.o
)

MIMALLOC_OBJ="${BUILDDIR}/mimalloc.o"
if [ ! -f "$MIMALLOC_OBJ" ]; then
echo "Could not find mimalloc.o"
exit 1
fi

cat > build.conf << EOF
{ "TOOLCHAIN_CONFIG":
{ "FAMILY": "gnu"
Expand All @@ -19,6 +39,7 @@ cat > build.conf << EOF
, "TARGET_ARCH": "$TARGET_ARCH"
, "AR": "ar"
, "SOURCE_DATE_EPOCH": $SOURCE_DATE_EPOCH
, "FINAL_LDFLAGS": ["$MIMALLOC_OBJ"]
}
EOF

Expand Down

0 comments on commit d87374b

Please sign in to comment.