summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md8
-rw-r--r--doc/COMPILERS.md5
-rw-r--r--etc/repos.json12
-rw-r--r--src/compilers/gcc-13-musl.TARGETS8
4 files changed, 33 insertions, 0 deletions
diff --git a/README.md b/README.md
index 19f4c9c..6bc005f 100644
--- a/README.md
+++ b/README.md
@@ -198,6 +198,14 @@ Example configuration for bootstrapping on NixOS (hashes may vary):
}
~~~
+## Musl Performance Issues
+
+Musl has huge allocator contention issues with multithreading. For that reason,
+all our `musl` compilers are shipped with the alternative allocator
+[mimalloc](https://github.com/microsoft/mimalloc) that solves these issues. If
+you notice any performance slowdowns with your Musl-linked binaries, consider
+using the alternative allocator by appending `-l:mimalloc.o` to your `LDFLAGS`.
+
## License
All files are copyright Huawei Cloud Computing Technology Co., Ltd., license
diff --git a/doc/COMPILERS.md b/doc/COMPILERS.md
index 6fd4d64..4c1e756 100644
--- a/doc/COMPILERS.md
+++ b/doc/COMPILERS.md
@@ -30,6 +30,11 @@ binutils and GCC versions.
Unfortunately, *musl-cross-make* does not call the `install-strip` target.
Therefore, we apply manual stripping to achieve reproducibility.
+Additionally, the alternative allocator object
+[`mimalloc.o`](https://github.com/microsoft/mimalloc) is also built and added to
+GCC's lib folder. Linking it can solve Musl's slowdowns with allocator
+contention in multithreaded applications.
+
## GCC Musl Static
Static building is achieved by using the GCC 13.2.0 Musl toolchain
diff --git a/etc/repos.json b/etc/repos.json
index 090d101..d7bf9b6 100644
--- a/etc/repos.json
+++ b/etc/repos.json
@@ -200,6 +200,17 @@
, "target_root": "imports"
, "target_file_name": "files.TARGETS"
}
+ , "imports/mimalloc-2.1.2":
+ { "repository":
+ { "type": "archive"
+ , "content": "da9d9ced476e35074380f3e240b59970dc443cd8"
+ , "fetch": "https://github.com/microsoft/mimalloc/archive/refs/tags/v2.1.2.tar.gz"
+ , "sha256": "2b1bff6f717f9725c70bf8d79e4786da13de8a270059e4ba0bdd262ae7be46eb"
+ , "subdir": "mimalloc-2.1.2"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "files.TARGETS"
+ }
, "imports/boringssl":
{ "repository":
{ "type": "archive"
@@ -334,6 +345,7 @@
, "mpc": "imports/mpc-1.3.1"
, "mpfr": "imports/mpfr-4.2.1"
, "gcc": "compilers/gcc-13.2.0-native"
+ , "mimalloc": "imports/mimalloc-2.1.2"
}
}
, "compilers/gcc-13.2.0-musl-static":
diff --git a/src/compilers/gcc-13-musl.TARGETS b/src/compilers/gcc-13-musl.TARGETS
index 7d564e7..b8e1e07 100644
--- a/src/compilers/gcc-13-musl.TARGETS
+++ b/src/compilers/gcc-13-musl.TARGETS
@@ -118,6 +118,7 @@
, [["@", "mpc", "", "files"], "mpc"]
, [["@", "mpfr", "", "files"], "mpfr"]
, [["@", "gcc", "", "patched_sources"], "gcc"]
+ , [["@", "mimalloc", "", "files"], "mimalloc"]
]
}
, "combined_patched_sources":
@@ -131,6 +132,7 @@
, "mv mpc ${DESTDIR}/mpc-latest.orig"
, "mv mpfr ${DESTDIR}/mpfr-latest.orig"
, "mv gcc ${DESTDIR}/gcc-13.orig"
+ , "mv mimalloc ${DESTDIR}/mimalloc"
, "chmod +w ${DESTDIR}/config.mak"
, "printf 'GCC_VER = 13\n' >> ${DESTDIR}/config.mak"
]
@@ -283,8 +285,14 @@
[ "for f in $(ls ./bin/${TARGET}-*); do"
, " ln -s $(basename $f) $(echo $f | sed 's|/'${TARGET}-'|/|g')"
, "done"
+ , "# set CC for building alternative allocator"
+ , "export CC_FOR_TARGET=\"$(pwd)/bin/gcc\""
]
}
+ , [ "# provide alternative allocator mimalloc"
+ , "export MI_CFLAGS=\"-DMI_MALLOC_OVERRIDE -I${WORKDIR}/mimalloc/include -O3 -DNDEBUG -fPIC -fvisibility=hidden -ftls-model=initial-exec -fno-builtin-malloc -std=gnu11\""
+ , "${CC_FOR_TARGET} ${MI_CFLAGS} -c ${WORKDIR}/mimalloc/src/static.c -o ./${TARGET}/lib/mimalloc.o"
+ ]
]
}
}