Fix PostgreSQL build compatibility for aarch64 on glibc 2.17 and update test configurations

This commit is contained in:
crazywhalecc 2025-10-13 17:34:35 +08:00 committed by Jerry Ma
parent ec9364db69
commit 0114700dad
2 changed files with 18 additions and 16 deletions

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\PkgConfigUtil; use SPC\util\PkgConfigUtil;
use SPC\util\SPCConfigUtil; use SPC\util\SPCConfigUtil;
@ -13,17 +14,18 @@ trait postgresql
{ {
public function patchBeforeBuild(): bool public function patchBeforeBuild(): bool
{ {
// fix aarch64 build on glibc 2.17 (e.g. CentOS 7)
if (SPCTarget::getLibcVersion() === '2.17' && GNU_ARCH === 'aarch64') { if (SPCTarget::getLibcVersion() === '2.17' && GNU_ARCH === 'aarch64') {
FileSystem::replaceFileStr( try {
$this->source_dir . '/src/port/pg_popcount_aarch64.c', FileSystem::replaceFileStr("{$this->source_dir}/src/port/pg_popcount_aarch64.c", 'HWCAP_SVE', '0');
'HWCAP_SVE', FileSystem::replaceFileStr(
'0', "{$this->source_dir}/src/port/pg_crc32c_armv8_choose.c",
); '#if defined(__linux__) && !defined(__aarch64__) && !defined(HWCAP2_CRC32)',
FileSystem::replaceFileStr( '#if defined(__linux__) && !defined(HWCAP_CRC32)'
$this->source_dir . '/src/port/pg_crc32c_armv8_choose.c', );
'#if defined(__linux__) && !defined(__aarch64__) && !defined(HWCAP2_CRC32)', } catch (FileSystemException) {
'#if defined(__linux__) && !defined(HWCAP_CRC32)', // allow file not-existence to make it compatible with old and new version
); }
} }
// skip the test on platforms where libpq infrastructure may be provided by statically-linked libraries // skip the test on platforms where libpq infrastructure may be provided by statically-linked libraries
FileSystem::replaceFileStr("{$this->source_dir}/src/interfaces/libpq/Makefile", 'invokes exit\'; exit 1;', 'invokes exit\';'); FileSystem::replaceFileStr("{$this->source_dir}/src/interfaces/libpq/Makefile", 'invokes exit\'; exit 1;', 'invokes exit\';');
@ -47,7 +49,7 @@ trait postgresql
$spc = new SPCConfigUtil($this->getBuilder(), ['no_php' => true, 'libs_only_deps' => true]); $spc = new SPCConfigUtil($this->getBuilder(), ['no_php' => true, 'libs_only_deps' => true]);
$config = $spc->config(libraries: $libs, include_suggest_lib: $this->builder->getOption('with-suggested-libs')); $config = $spc->config(libraries: $libs, include_suggest_lib: $this->builder->getOption('with-suggested-libs'));
$macos_15_bug_cflags = PHP_OS_FAMILY === 'Darwin' ? ' -Wno-unguarded-availability-new' : ''; $macos_15_bug_cflags = PHP_OS_FAMILY === 'Darwin' ? '' : '';
$env_vars = [ $env_vars = [
'CFLAGS' => "{$config['cflags']} -fno-ident{$macos_15_bug_cflags}", 'CFLAGS' => "{$config['cflags']} -fno-ident{$macos_15_bug_cflags}",

View File

@ -13,9 +13,9 @@ declare(strict_types=1);
// test php version (8.1 ~ 8.4 available, multiple for matrix) // test php version (8.1 ~ 8.4 available, multiple for matrix)
$test_php_version = [ $test_php_version = [
'8.1', // '8.1',
'8.2', // '8.2',
'8.3', // '8.3',
'8.4', '8.4',
// '8.5', // '8.5',
// 'git', // 'git',
@ -49,7 +49,7 @@ $prefer_pre_built = false;
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) { $extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'pgsql', 'Linux', 'Darwin' => 'pdo_pgsql',
'Windows' => 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pdo,pdo_mysql,pdo_sqlite,phar,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip', 'Windows' => 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pdo,pdo_mysql,pdo_sqlite,phar,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip',
}; };
@ -73,7 +73,7 @@ $with_libs = match (PHP_OS_FAMILY) {
// You can use `common`, `bulk`, `minimal` or `none`. // You can use `common`, `bulk`, `minimal` or `none`.
// note: combination is only available for *nix platform. Windows must use `none` combination // note: combination is only available for *nix platform. Windows must use `none` combination
$base_combination = match (PHP_OS_FAMILY) { $base_combination = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'common', 'Linux', 'Darwin' => 'none',
'Windows' => 'none', 'Windows' => 'none',
}; };