ensure liburing is only pulled in by suggested libs when glibc >= 2.30 (or musl)

This commit is contained in:
DubbleClick 2025-08-26 14:07:49 +07:00
parent 43352ab986
commit 4eac953c71
5 changed files with 35 additions and 4 deletions

View File

@ -939,6 +939,7 @@
"headers-linux": [ "headers-linux": [
"liburing/", "liburing/",
"liburing.h" "liburing.h"
] ],
"glibc-min": "2.30"
} }
} }

View File

@ -69,8 +69,10 @@ class swoole extends Extension
$arg .= $this->builder->getExt('swoole-hook-mysql') ? ' --enable-mysqlnd' : ' --disable-mysqlnd'; $arg .= $this->builder->getExt('swoole-hook-mysql') ? ' --enable-mysqlnd' : ' --disable-mysqlnd';
$arg .= $this->builder->getExt('swoole-hook-sqlite') ? ' --enable-swoole-sqlite' : ' --disable-swoole-sqlite'; $arg .= $this->builder->getExt('swoole-hook-sqlite') ? ' --enable-swoole-sqlite' : ' --disable-swoole-sqlite';
$config = (new SPCConfigUtil($this->builder, ['libs_only_deps' => true]))->config([], ['unixodbc']); if ($this->builder->getExt('swoole-hook-odbc')) {
$arg .= $this->builder->getExt('swoole-hook-odbc') ? ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH . ' SWOOLE_ODBC_LIBS="' . $config['libs'] . '"' : ''; $config = (new SPCConfigUtil($this->builder, ['libs_only_deps' => true]))->config([], ['unixodbc']);
$arg .= ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH . ' SWOOLE_ODBC_LIBS="' . $config['libs'] . '"';
}
return $arg; return $arg;
} }
} }

View File

@ -4,7 +4,9 @@ declare(strict_types=1);
namespace SPC\builder\linux\library; namespace SPC\builder\linux\library;
use SPC\exception\WrongUsageException;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
use SPC\util\SPCTarget;
class liburing extends LinuxLibraryBase class liburing extends LinuxLibraryBase
{ {
@ -12,8 +14,14 @@ class liburing extends LinuxLibraryBase
protected function build(): void protected function build(): void
{ {
// Build liburing with static linking via autoconf if (SPCTarget::getLibc() === 'glibc' && SPCTarget::getLibcVersion() < 2.30) {
throw new WrongUsageException('liburing requires glibc >= 2.30');
}
UnixAutoconfExecutor::create($this) UnixAutoconfExecutor::create($this)
->appendEnv([
'CFLAGS' => '-D_GNU_SOURCE'
])
->removeConfigureArgs( ->removeConfigureArgs(
'--disable-shared', '--disable-shared',
'--enable-static', '--enable-static',

View File

@ -76,6 +76,14 @@ class DependencyUtil
$del_list = []; $del_list = [];
foreach ($obj['suggests'] as $id => $suggest) { foreach ($obj['suggests'] as $id => $suggest) {
if (!str_starts_with($suggest, 'ext@')) { if (!str_starts_with($suggest, 'ext@')) {
$glibcMin = Config::getLib($suggest, 'glibc-min');
if ($glibcMin !== null) {
$libc = SPCTarget::getLibc();
$ver = SPCTarget::getLibcVersion();
if ($libc === 'glibc' && version_compare($ver, (string) $glibcMin, '<')) {
continue;
}
}
$dep_list[$name]['depends'][] = $suggest; $dep_list[$name]['depends'][] = $suggest;
$del_list[] = $id; $del_list[] = $id;
} }
@ -134,6 +142,14 @@ class DependencyUtil
$del_list = []; $del_list = [];
foreach ($obj['suggests'] as $id => $suggest) { foreach ($obj['suggests'] as $id => $suggest) {
if (!str_starts_with($suggest, 'ext@')) { if (!str_starts_with($suggest, 'ext@')) {
$glibcMin = Config::getLib($suggest, 'glibc-min');
if ($glibcMin !== null) {
$libc = SPCTarget::getLibc();
$ver = SPCTarget::getLibcVersion();
if ($libc === 'glibc' && version_compare($ver, (string) $glibcMin, '<')) {
continue;
}
}
$dep_list[$name]['depends'][] = $suggest; $dep_list[$name]['depends'][] = $suggest;
$del_list[] = $id; $del_list[] = $id;
} }

View File

@ -100,6 +100,10 @@ class SPCTarget
public static function getLibcVersion(): ?string public static function getLibcVersion(): ?string
{ {
if (PHP_OS_FAMILY === 'Linux') { if (PHP_OS_FAMILY === 'Linux') {
$target = getenv('SPC_TARGET');
if (str_contains($target, '-gnu.2.')) {
return preg_match('/-gnu\.(2\.\d+)/', $target, $matches) ? $matches[1] : null;
}
$libc = self::getLibc(); $libc = self::getLibc();
return SystemUtil::getLibcVersionIfExists($libc); return SystemUtil::getLibcVersionIfExists($libc);
} }