Skip to content

Commit e942b13

Browse files
authored
Merge branch 'main' into libedit
2 parents 26ccaa4 + c5ae719 commit e942b13

File tree

11 files changed

+130
-114
lines changed

11 files changed

+130
-114
lines changed

.github/workflows/build-unix.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@ jobs:
136136
macos-x86_64)
137137
DOWN_CMD="composer update --no-dev --classmap-authoritative && ./bin/spc doctor --auto-fix && ./bin/spc download"
138138
BUILD_CMD="./bin/spc build"
139-
RUNS_ON="macos-13"
139+
RUNS_ON="macos-15-intel"
140140
;;
141141
macos-aarch64)
142142
DOWN_CMD="composer update --no-dev --classmap-authoritative && ./bin/spc doctor --auto-fix && ./bin/spc download"
143143
BUILD_CMD="./bin/spc build"
144-
RUNS_ON="macos-14"
144+
RUNS_ON="macos-15"
145145
;;
146146
esac
147147
DOWN_CMD="$DOWN_CMD --with-php=${{ inputs.php-version }} --for-extensions=${{ inputs.extensions }} --ignore-cache-sources=php-src"

.github/workflows/ext-matrix-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ jobs:
8585
- "8.4"
8686
operating-system:
8787
- "ubuntu-latest"
88-
#- "macos-13"
88+
#- "macos-15-intel"
8989
#- "debian-arm64-self-hosted"
90-
- "macos-14"
90+
- "macos-15"
9191

9292
steps:
9393
- name: "Checkout"
@@ -99,11 +99,11 @@ jobs:
9999
OS=""
100100
if [ "${{ matrix.operating-system }}" = "ubuntu-latest" ]; then
101101
OS="linux-x86_64"
102-
elif [ "${{ matrix.operating-system }}" = "macos-13" ]; then
102+
elif [ "${{ matrix.operating-system }}" = "macos-15-intel" ]; then
103103
OS="macos-x86_64"
104104
elif [ "${{ matrix.operating-system }}" = "debian-arm64-self-hosted" ]; then
105105
OS="linux-aarch64"
106-
elif [ "${{ matrix.operating-system }}" = "macos-14" ]; then
106+
elif [ "${{ matrix.operating-system }}" = "macos-15" ]; then
107107
OS="macos-aarch64"
108108
fi
109109
echo "OS=$OS" >> $GITHUB_ENV

.github/workflows/release-build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
os: "ubuntu-latest"
2828
filename: "spc-linux-x86_64.tar.gz"
2929
- name: "macos-x86_64"
30-
os: "macos-13"
30+
os: "macos-15-intel"
3131
filename: "spc-macos-x86_64.tar.gz"
3232
- name: "linux-aarch64"
3333
os: "ubuntu-latest"
@@ -147,11 +147,11 @@ jobs:
147147
- name: "linux-x86_64"
148148
os: "ubuntu-latest"
149149
- name: "macos-x86_64"
150-
os: "macos-13"
150+
os: "macos-15-intel"
151151
- name: "linux-aarch64"
152152
os: "ubuntu-24.04-arm"
153153
- name: "macos-aarch64"
154-
os: "macos-latest"
154+
os: "macos-15"
155155
- name: "windows-x64"
156156
os: "windows-latest"
157157
steps:

config/ext.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,8 +1152,9 @@
11521152
"support": {
11531153
"BSD": "wip"
11541154
},
1155-
"type": "builtin",
1156-
"arg-type": "with-path",
1155+
"type": "external",
1156+
"source": "ext-zip",
1157+
"arg-type": "custom",
11571158
"arg-type-windows": "enable",
11581159
"lib-depends-unix": [
11591160
"libzip"

config/source.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@
263263
"path": "LICENSE"
264264
}
265265
},
266+
"ext-zip": {
267+
"type": "url",
268+
"url": "https://pecl.php.net/get/zip",
269+
"filename": "ext-zip.tgz",
270+
"license": {
271+
"type": "file",
272+
"path": "LICENSE"
273+
}
274+
},
266275
"ext-zstd": {
267276
"type": "git",
268277
"path": "php-src/ext/zstd",
@@ -890,7 +899,7 @@
890899
"postgresql": {
891900
"type": "ghtagtar",
892901
"repo": "postgres/postgres",
893-
"match": "REL_16_\\d+",
902+
"match": "REL_18_\\d+",
894903
"license": {
895904
"type": "file",
896905
"path": "COPYRIGHT"

src/SPC/ConsoleApplication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535
final class ConsoleApplication extends Application
3636
{
37-
public const string VERSION = '2.7.4';
37+
public const string VERSION = '2.7.5';
3838

3939
public function __construct()
4040
{

src/SPC/builder/extension/zip.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\extension;
6+
7+
use SPC\builder\Extension;
8+
use SPC\util\CustomExt;
9+
10+
#[CustomExt('zip')]
11+
class zip extends Extension
12+
{
13+
public function getUnixConfigureArg(bool $shared = false): string
14+
{
15+
return !$shared ? '--with-zip=' . BUILD_ROOT_PATH : '--enable-zip=shared';
16+
}
17+
}

src/SPC/builder/linux/LinuxBuilder.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,14 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
156156
}
157157
$shared_extensions = array_map('trim', array_filter(explode(',', $this->getOption('build-shared'))));
158158
if (!empty($shared_extensions)) {
159-
logger()->info('Building shared extensions ...');
159+
if (SPCTarget::isStatic()) {
160+
throw new WrongUsageException(
161+
"You're building against musl libc statically (the default on Linux), but you're trying to build shared extensions.\n" .
162+
'Static musl libc does not implement `dlopen`, so your php binary is not able to load shared extensions.' . "\n" .
163+
'Either use SPC_LIBC=glibc to link against glibc on a glibc OS, or use SPC_TARGET="native-native-musl -dynamic" to link against musl libc dynamically using `zig cc`.'
164+
);
165+
}
166+
logger()->info('Building shared extensions...');
160167
$this->buildSharedExts();
161168
}
162169
}

src/SPC/builder/unix/library/postgresql.php

Lines changed: 74 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -4,93 +4,83 @@
44

55
namespace SPC\builder\unix\library;
66

7-
use SPC\builder\linux\library\LinuxLibraryBase;
8-
use SPC\exception\BuildFailureException;
97
use SPC\exception\FileSystemException;
108
use SPC\store\FileSystem;
9+
use SPC\util\PkgConfigUtil;
10+
use SPC\util\SPCConfigUtil;
1111
use SPC\util\SPCTarget;
1212

1313
trait postgresql
1414
{
15-
protected function build(): void
15+
public function patchBeforeBuild(): bool
1616
{
17-
$builddir = BUILD_ROOT_PATH;
18-
$envs = '';
19-
$packages = 'zlib openssl readline libxml-2.0';
20-
$optional_packages = [
21-
'zstd' => 'libzstd',
22-
'ldap' => 'ldap',
23-
'libxslt' => 'libxslt',
24-
'icu' => 'icu-i18n',
25-
];
26-
$error_exec_cnt = 0;
27-
28-
foreach ($optional_packages as $lib => $pkg) {
29-
if ($this->getBuilder()->getLib($lib)) {
30-
$packages .= ' ' . $pkg;
31-
$output = shell()->execWithResult("pkg-config --static {$pkg}");
32-
$error_exec_cnt += $output[0] === 0 ? 0 : 1;
33-
logger()->info(var_export($output[1], true));
17+
// fix aarch64 build on glibc 2.17 (e.g. CentOS 7)
18+
if (SPCTarget::getLibcVersion() === '2.17' && GNU_ARCH === 'aarch64') {
19+
try {
20+
FileSystem::replaceFileStr("{$this->source_dir}/src/port/pg_popcount_aarch64.c", 'HWCAP_SVE', '0');
21+
FileSystem::replaceFileStr(
22+
"{$this->source_dir}/src/port/pg_crc32c_armv8_choose.c",
23+
'#if defined(__linux__) && !defined(__aarch64__) && !defined(HWCAP2_CRC32)',
24+
'#if defined(__linux__) && !defined(HWCAP_CRC32)'
25+
);
26+
} catch (FileSystemException) {
27+
// allow file not-existence to make it compatible with old and new version
3428
}
3529
}
30+
// skip the test on platforms where libpq infrastructure may be provided by statically-linked libraries
31+
FileSystem::replaceFileStr("{$this->source_dir}/src/interfaces/libpq/Makefile", 'invokes exit\'; exit 1;', 'invokes exit\';');
32+
// disable shared libs build
33+
FileSystem::replaceFileStr(
34+
"{$this->source_dir}/src/Makefile.shlib",
35+
[
36+
'$(LINK.shared) -o $@ $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK)',
37+
'$(INSTALL_SHLIB) $< \'$(DESTDIR)$(pkglibdir)/$(shlib)\'',
38+
'$(INSTALL_SHLIB) $< \'$(DESTDIR)$(libdir)/$(shlib)\'',
39+
'$(INSTALL_SHLIB) $< \'$(DESTDIR)$(bindir)/$(shlib)\'',
40+
],
41+
''
42+
);
43+
return true;
44+
}
3645

37-
$output = shell()->execWithResult("pkg-config --cflags-only-I --static {$packages}");
38-
$error_exec_cnt += $output[0] === 0 ? 0 : 1;
39-
$macos_15_bug_cflags = PHP_OS_FAMILY === 'Darwin' ? ' -Wno-unguarded-availability-new' : '';
40-
$cflags = '';
41-
if (!empty($output[1][0])) {
42-
$cflags = $output[1][0];
43-
$envs .= ' CPPFLAGS="-DPIC"';
44-
$cflags = "{$cflags} -fno-ident{$macos_15_bug_cflags}";
45-
}
46-
$output = shell()->execWithResult("pkg-config --libs-only-L --static {$packages}");
47-
$error_exec_cnt += $output[0] === 0 ? 0 : 1;
48-
if (!empty($output[1][0])) {
49-
$ldflags = $output[1][0];
50-
$envs .= SPCTarget::isStatic() ? " LDFLAGS=\"{$ldflags} -static\" " : " LDFLAGS=\"{$ldflags}\" ";
51-
}
52-
$output = shell()->execWithResult("pkg-config --libs-only-l --static {$packages}");
53-
$error_exec_cnt += $output[0] === 0 ? 0 : 1;
54-
if (!empty($output[1][0])) {
55-
$libs = $output[1][0];
56-
$libcpp = '';
57-
if ($this->builder->getLib('icu')) {
58-
$libcpp = $this instanceof LinuxLibraryBase ? ' -lstdc++' : ' -lc++';
59-
}
60-
$envs .= " LIBS=\"{$libs}{$libcpp}\" ";
61-
}
62-
if ($error_exec_cnt > 0) {
63-
throw new BuildFailureException('Failed to get pkg-config information!');
46+
protected function build(): void
47+
{
48+
$libs = array_map(fn ($x) => $x->getName(), $this->getDependencies());
49+
$spc = new SPCConfigUtil($this->getBuilder(), ['no_php' => true, 'libs_only_deps' => true]);
50+
$config = $spc->config(libraries: $libs, include_suggest_lib: $this->builder->getOption('with-suggested-libs'));
51+
52+
$env_vars = [
53+
'CFLAGS' => $config['cflags'],
54+
'CPPFLAGS' => '-DPIC',
55+
'LDFLAGS' => $config['ldflags'],
56+
'LIBS' => $config['libs'],
57+
];
58+
59+
if ($ldLibraryPath = getenv('SPC_LD_LIBRARY_PATH')) {
60+
$env_vars['LD_LIBRARY_PATH'] = $ldLibraryPath;
6461
}
6562

6663
FileSystem::resetDir($this->source_dir . '/build');
6764

68-
$version = $this->getVersion();
69-
// 16.1 workaround
70-
if (version_compare($version, '16.1') >= 0) {
71-
# 有静态链接配置 参考文件: src/interfaces/libpq/Makefile
72-
shell()->cd($this->source_dir . '/build')
73-
->exec('sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile')
74-
->exec('sed -i.backup "278 s/^/# /" ../src/Makefile.shlib')
75-
->exec('sed -i.backup "402 s/^/# /" ../src/Makefile.shlib');
76-
} else {
77-
throw new BuildFailureException('Unsupported version for postgresql: ' . $version . ' !');
78-
}
65+
// php source relies on the non-private encoding functions in libpgcommon.a
66+
FileSystem::replaceFileStr(
67+
"{$this->source_dir}/src/common/Makefile",
68+
'$(OBJS_FRONTEND): CPPFLAGS += -DUSE_PRIVATE_ENCODING_FUNCS',
69+
'$(OBJS_FRONTEND): CPPFLAGS += -UUSE_PRIVATE_ENCODING_FUNCS -DFRONTEND',
70+
);
7971

8072
// configure
81-
shell()->cd($this->source_dir . '/build')->initializeEnv($this)
82-
->appendEnv(['CFLAGS' => $cflags])
73+
$shell = shell()->cd("{$this->source_dir}/build")->initializeEnv($this)
74+
->appendEnv($env_vars)
8375
->exec(
84-
"{$envs} ../configure " .
85-
"--prefix={$builddir} " .
86-
($this->builder->getOption('enable-zts') ? '--enable-thread-safety ' : '--disable-thread-safety ') .
76+
'../configure ' .
77+
"--prefix={$this->getBuildRootPath()} " .
8778
'--enable-coverage=no ' .
8879
'--with-ssl=openssl ' .
8980
'--with-readline ' .
9081
'--with-libxml ' .
9182
($this->builder->getLib('icu') ? '--with-icu ' : '--without-icu ') .
9283
($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') .
93-
// '--without-ldap ' .
9484
($this->builder->getLib('libxslt') ? '--with-libxslt ' : '--without-libxslt ') .
9585
($this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd ') .
9686
'--without-lz4 ' .
@@ -99,32 +89,29 @@ protected function build(): void
9989
'--without-pam ' .
10090
'--without-bonjour ' .
10191
'--without-tcl '
102-
)
103-
->exec($envs . ' make -C src/bin/pg_config install')
104-
->exec($envs . ' make -C src/include install')
105-
->exec($envs . ' make -C src/common install')
106-
->exec($envs . ' make -C src/port install')
107-
->exec($envs . ' make -C src/interfaces/libpq install');
92+
);
93+
94+
// patch ldap lib
95+
if ($this->builder->getLib('ldap')) {
96+
$libs = PkgConfigUtil::getLibsArray('ldap');
97+
$libs = clean_spaces(implode(' ', $libs));
98+
FileSystem::replaceFileStr($this->source_dir . '/build/config.status', '-lldap', $libs);
99+
FileSystem::replaceFileStr($this->source_dir . '/build/src/Makefile.global', '-lldap', $libs);
100+
}
101+
102+
$shell
103+
->exec('make -C src/bin/pg_config install')
104+
->exec('make -C src/include install')
105+
->exec('make -C src/common install')
106+
->exec('make -C src/port install')
107+
->exec('make -C src/interfaces/libpq install');
108108

109109
// remove dynamic libs
110110
shell()->cd($this->source_dir . '/build')
111-
->exec("rm -rf {$builddir}/lib/*.so.*")
112-
->exec("rm -rf {$builddir}/lib/*.so")
113-
->exec("rm -rf {$builddir}/lib/*.dylib");
111+
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so.*")
112+
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so")
113+
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.dylib");
114114

115-
FileSystem::replaceFileStr(BUILD_LIB_PATH . '/pkgconfig/libpq.pc', '-lldap', '-lldap -llber');
116-
}
117-
118-
private function getVersion(): string
119-
{
120-
try {
121-
$file = FileSystem::readFile($this->source_dir . '/meson.build');
122-
if (preg_match("/^\\s+version:\\s?'(.*)'/m", $file, $match)) {
123-
return $match[1];
124-
}
125-
return 'unknown';
126-
} catch (FileSystemException) {
127-
return 'unknown';
128-
}
115+
FileSystem::replaceFileStr("{$this->getLibDir()}/pkgconfig/libpq.pc", '-lldap', '-lldap -llber');
129116
}
130117
}

src/SPC/store/source/PhpSource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function fetch(bool $force = false, ?array $config = null, int $lock_as =
1616
{
1717
$major = defined('SPC_BUILD_PHP_VERSION') ? SPC_BUILD_PHP_VERSION : '8.4';
1818
if ($major === '8.5') {
19-
Downloader::downloadSource('php-src', ['type' => 'url', 'url' => 'https://downloads.php.net/~edorian/php-8.5.0beta3.tar.xz'], $force);
19+
Downloader::downloadSource('php-src', ['type' => 'url', 'url' => 'https://github.com/php/php-src/archive/refs/tags/php-8.5.0RC2.tar.gz'], $force);
2020
} elseif ($major === 'git') {
2121
Downloader::downloadSource('php-src', ['type' => 'git', 'url' => 'https://github.com/php/php-src.git', 'rev' => 'master'], $force);
2222
} else {

0 commit comments

Comments
 (0)