mimalloc on mac (untested)

This commit is contained in:
Marc Henderkes 2025-03-20 07:41:13 +01:00
parent 0ce2c894e9
commit 3477857584
4 changed files with 21 additions and 4 deletions

View File

@ -593,9 +593,6 @@
"source": "mimalloc",
"static-libs-unix": [
"mimalloc.o"
],
"static-libs-windows": [
"mimalloc.lib"
]
},
"ncurses": {

View File

@ -148,10 +148,12 @@ class MacOSBuilder extends UnixBuilderBase
$enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
// prepare build php envs
$mimallocLibs = $this->getLib('mimalloc') !== null ? BUILD_LIB_PATH . '/mimalloc.o ' : '';
$envs_build_php = SystemUtil::makeEnvVarString([
'CFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS'),
'CPPFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS'),
'LDFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS'),
'LIBS' => $mimallocLibs . getenv('SPC_CMD_VAR_PHP_CONFIGURE_LIBS'),
]);
if ($this->getLib('postgresql')) {
@ -298,6 +300,12 @@ class MacOSBuilder extends UnixBuilderBase
->exec('rm ' . BUILD_ROOT_PATH . '/lib/libphp.a')
->exec('ar rcs ' . BUILD_ROOT_PATH . '/lib/libphp.a *.o')
->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o');
$php_config_str = FileSystem::readFile(BUILD_BIN_PATH . '/php-config');
str_replace('prefix=""', 'prefix="' . BUILD_ROOT_PATH . '"', $php_config_str);
// move mimalloc to the beginning of libs
$php_config_str = preg_replace('/(libs=")(.*?)\s*(' . preg_quote(BUILD_LIB_PATH, '/') . '\/mimalloc\.o)\s*(.*?)"/', '$1$3 $2 $4"', $php_config_str);
FileSystem::writeFile(BUILD_BIN_PATH . '/php-config', $php_config_str);
}
private function getMakeExtraVars(): array

View File

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
class mimalloc extends MacOSLibraryBase
{
use \SPC\builder\unix\library\mimalloc;
public const NAME = 'mimalloc';
}

View File

@ -46,7 +46,7 @@ $extensions = match (PHP_OS_FAMILY) {
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
$with_libs = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'freetype',
'Linux', 'Darwin' => 'mimalloc',
'Windows' => 'libjpeg,libavif,freetype,libwebp',
};