mimalloc WIP

This commit is contained in:
Marc Henderkes 2025-03-20 04:36:46 +01:00
parent 0bc143cac3
commit 6447fec028
5 changed files with 81 additions and 7 deletions

View File

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

View File

@ -636,6 +636,16 @@
"path": "LICENSE"
}
},
"mimalloc": {
"type": "ghtagtar",
"repo": "microsoft/mimalloc",
"match": "v2.+",
"provide-pre-built": false,
"license": {
"type": "file",
"path": "LICENSE"
}
},
"mongodb": {
"type": "ghrel",
"repo": "mongodb/mongo-php-driver",

View File

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

View File

@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
trait mimalloc
{
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void
{
$args = '';
if (getenv('SPC_LIBC') === 'musl') {
$args .= '-DMI_LIBC_MUSL=ON ';
}
$args .= '-DMI_BUILD_SHARED=OFF ';
$args .= '-DMI_INSTALL_TOPLEVEL=ON ';
FileSystem::resetDir($this->source_dir . '/build');
shell()->cd($this->source_dir . '/build')
->exec(
'cmake ' .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'-DCMAKE_BUILD_TYPE=Release ' .
$args .
'..'
)
->exec("make -j{$this->builder->concurrency}")
->exec('make install');
}
}

View File

@ -69,14 +69,19 @@ class Downloader
retry: self::getRetryTime()
), true);
if (($source['prefer-stable'] ?? false) === false) {
$url = $data[0]['tarball_url'];
} else {
$id = 0;
while ($data[$id]['prerelease'] === true) {
++$id;
$url = null;
for ($i = 0; $i < count($data); ++$i) {
if (($data[$i]['prerelease'] ?? false) === true && ($source['prefer-stable'] ?? false)) {
continue;
}
if (!($source['match'] ?? null)) {
$url = $data[$i]['tarball_url'] ?? null;
break;
}
if (preg_match('|' . $source['match'] . '|', $data[$i]['tarball_url'])) {
$url = $data[$i]['tarball_url'];
break;
}
$url = $data[$id]['tarball_url'] ?? null;
}
if (!$url) {
throw new DownloaderException("failed to find {$name} source");