From 92470a35da579d915231522f5e7ac6a860d7f006 Mon Sep 17 00:00:00 2001 From: Marc Henderkes Date: Thu, 20 Mar 2025 06:22:11 +0100 Subject: [PATCH] replace allocator with mimalloc (works for cli/fpm, embed needs to be tested) --- src/SPC/builder/linux/LinuxBuilder.php | 3 ++- src/SPC/builder/unix/library/mimalloc.php | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 671bb28b..3e0edb2d 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -150,12 +150,13 @@ class LinuxBuilder extends UnixBuilderBase $enable_micro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; $enable_embed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; + $mimalloc = $this->getLib('mimalloc') !== null ? BUILD_LIB_PATH . '/mimalloc.o ' : ''; // prepare build php envs $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' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_LIBS'), + 'LIBS' => $mimalloc . getenv('SPC_CMD_VAR_PHP_CONFIGURE_LIBS'), ]); // process micro upx patch if micro sapi enabled diff --git a/src/SPC/builder/unix/library/mimalloc.php b/src/SPC/builder/unix/library/mimalloc.php index 495ce632..40790a98 100644 --- a/src/SPC/builder/unix/library/mimalloc.php +++ b/src/SPC/builder/unix/library/mimalloc.php @@ -24,7 +24,7 @@ trait mimalloc $args .= '-DMI_INSTALL_TOPLEVEL=ON '; FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') - ->exec( + ->execWithEnv( 'cmake ' . '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . @@ -32,7 +32,7 @@ trait mimalloc $args . '..' ) - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install'); + ->execWithEnv("make -j{$this->builder->concurrency}") + ->execWithEnv('make install'); } }