Skip to content

Commit 6fb9adc

Browse files
authored
Merge branch 'main' into crazywhalecc-patch-1
2 parents a94e550 + ef95e4f commit 6fb9adc

20 files changed

Lines changed: 238 additions & 63 deletions

config/source.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@
10001000
"openssl": {
10011001
"type": "ghrel",
10021002
"repo": "openssl/openssl",
1003-
"match": "openssl.+\\.tar\\.gz",
1003+
"match": "openssl-3.+\\.tar\\.gz",
10041004
"prefer-stable": true,
10051005
"alt": {
10061006
"type": "filelist",
@@ -1194,7 +1194,6 @@
11941194
"path": "php-src/ext/swoole",
11951195
"type": "ghtar",
11961196
"repo": "swoole/swoole-src",
1197-
"match": "v6\\.+",
11981197
"prefer-stable": true,
11991198
"license": {
12001199
"type": "file",

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.8.5';
37+
public const string VERSION = '2.8.6';
3838

3939
public function __construct()
4040
{

src/SPC/builder/Extension.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
use SPC\exception\WrongUsageException;
1212
use SPC\store\Config;
1313
use SPC\store\FileSystem;
14+
use SPC\toolchain\ToolchainManager;
15+
use SPC\toolchain\ZigToolchain;
16+
use SPC\util\GlobalEnvManager;
1417
use SPC\util\SPCConfigUtil;
1518
use SPC\util\SPCTarget;
1619

@@ -231,7 +234,7 @@ public function patchBeforeSharedMake(): bool
231234
if (preg_match('/^(.*_SHARED_LIBADD\s*=\s*)(.*)$/m', $makefileContent, $matches)) {
232235
$prefix = $matches[1];
233236
$currentLibs = trim($matches[2]);
234-
$newLibs = trim("{$currentLibs} {$staticLibs} {$lstdcpp}");
237+
$newLibs = clean_spaces("{$currentLibs} {$staticLibs} {$lstdcpp}");
235238
$deduplicatedLibs = deduplicate_flags($newLibs);
236239

237240
FileSystem::replaceFileRegex(
@@ -543,6 +546,11 @@ public function getLibraryDependencies(bool $recursive = false): array
543546
*/
544547
protected function getSharedExtensionEnv(): array
545548
{
549+
$compiler_extra = getenv('SPC_COMPILER_EXTRA') ?: '';
550+
if (!str_contains($compiler_extra, '-lcompiler_rt') && ToolchainManager::getToolchainClass() === ZigToolchain::class) {
551+
$compiler_extra = trim($compiler_extra . ' -lcompiler_rt');
552+
GlobalEnvManager::putenv("SPC_COMPILER_EXTRA={$compiler_extra}");
553+
}
546554
$config = (new SPCConfigUtil($this->builder, ['no_php' => true]))->getExtensionConfig($this);
547555
[$staticLibs, $sharedLibs] = $this->splitLibsIntoStaticAndShared($config['libs']);
548556
$preStatic = PHP_OS_FAMILY === 'Darwin' ? '' : '-Wl,--start-group ';

src/SPC/builder/extension/decimal.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ public function patchBeforeBuildconf(): bool
1616
{
1717
FileSystem::replaceFileStr(
1818
$this->source_dir . '/php_decimal.c',
19-
'zend_module_entry decimal_module_entry',
20-
'zend_module_entry php_decimal_module_entry'
19+
[
20+
'zend_module_entry decimal_module_entry',
21+
'ZEND_GET_MODULE(decimal)',
22+
],
23+
[
24+
'zend_module_entry php_decimal_module_entry',
25+
'ZEND_GET_MODULE(php_decimal)',
26+
]
2127
);
2228
FileSystem::replaceFileStr(
2329
$this->source_dir . '/config.w32',

src/SPC/builder/extension/mongodb.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,22 @@
55
namespace SPC\builder\extension;
66

77
use SPC\builder\Extension;
8+
use SPC\store\FileSystem;
89
use SPC\util\CustomExt;
910

1011
#[CustomExt('mongodb')]
1112
class mongodb extends Extension
1213
{
14+
public function patchBeforeBuildconf(): bool
15+
{
16+
FileSystem::replaceFileRegex(
17+
SOURCE_PATH . '/php-src/ext/mongodb/config.m4',
18+
'/^(\s+)(src\/libmongoc\/)/m',
19+
'$1${ac_config_dir}/$2'
20+
);
21+
return true;
22+
}
23+
1324
public function getUnixConfigureArg(bool $shared = false): string
1425
{
1526
$arg = ' --enable-mongodb' . ($shared ? '=shared' : '') . ' ';

src/SPC/builder/linux/LinuxBuilder.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use SPC\store\DirDiff;
1212
use SPC\store\FileSystem;
1313
use SPC\store\SourcePatcher;
14+
use SPC\toolchain\ToolchainManager;
15+
use SPC\toolchain\ZigToolchain;
1416
use SPC\util\GlobalEnvManager;
1517
use SPC\util\SPCConfigUtil;
1618
use SPC\util\SPCTarget;
@@ -65,7 +67,8 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
6567
// php 8.5 contains opcache extension by default,
6668
// if opcache_jit is enabled for 8.5 or opcache enabled,
6769
// we need to disable undefined behavior sanitizer.
68-
f_putenv('SPC_COMPILER_EXTRA=-fno-sanitize=undefined');
70+
$compiler_extra = getenv('SPC_COMPILER_EXTRA') ?: '';
71+
f_putenv('SPC_COMPILER_EXTRA=' . trim($compiler_extra . ' -fno-sanitize=undefined'));
6972
}
7073

7174
if ($this->getOption('enable-zts', false)) {
@@ -266,6 +269,11 @@ protected function buildFpm(): void
266269
*/
267270
protected function buildEmbed(): void
268271
{
272+
$compiler_extra = getenv('SPC_COMPILER_EXTRA') ?: '';
273+
if (!str_contains($compiler_extra, '-lcompiler_rt') && ToolchainManager::getToolchainClass() === ZigToolchain::class) {
274+
$compiler_extra = trim($compiler_extra . ' -lcompiler_rt');
275+
GlobalEnvManager::putenv("SPC_COMPILER_EXTRA={$compiler_extra}");
276+
}
269277
$sharedExts = array_filter($this->exts, static fn ($ext) => $ext->isBuildShared());
270278
$sharedExts = array_filter($sharedExts, static function ($ext) {
271279
return Config::getExt($ext->getName(), 'build-with-php') === true;

src/SPC/builder/traits/UnixSystemUtilTrait.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static function exportDynamicSymbols(string $lib_file): void
5050
$defined = array_unique($defined);
5151
sort($defined);
5252
// export
53-
if (SPCTarget::getTargetOS() === 'Linux') {
53+
if (SPCTarget::getTargetOS() === 'Linux' && ToolchainManager::getToolchainClass() !== ZigToolchain::class) {
5454
file_put_contents("{$lib_file}.dynsym", "{\n" . implode("\n", array_map(fn ($x) => " {$x};", $defined)) . "};\n");
5555
} else {
5656
file_put_contents("{$lib_file}.dynsym", implode("\n", $defined) . "\n");
@@ -72,10 +72,6 @@ public static function getDynamicExportedSymbols(string $lib_file): ?string
7272
if (!is_file($symbol_file)) {
7373
throw new SPCInternalException("The symbol file {$symbol_file} does not exist, please check if nm command is available.");
7474
}
75-
// https://github.com/ziglang/zig/issues/24662
76-
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
77-
return '-Wl,--export-dynamic'; // needs release 0.16, can be removed then
78-
}
7975
// macOS/zig
8076
if (SPCTarget::getTargetOS() !== 'Linux' || ToolchainManager::getToolchainClass() === ZigToolchain::class) {
8177
return "-Wl,-exported_symbols_list,{$symbol_file}";

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace SPC\builder\unix\library;
66

7+
use SPC\store\FileSystem;
78
use SPC\util\executor\UnixCMakeExecutor;
89

910
trait curl
@@ -32,8 +33,16 @@ protected function build(): void
3233
)
3334
->build();
3435

35-
// patch pkgconf
3636
$this->patchPkgconfPrefix(['libcurl.pc']);
37+
// On glibc <2.28 without built-in pthreads, FindThreads sets
38+
// INTERFACE_LINK_LIBRARIES to '-lpthread'
39+
// curls .pc generator walks and prepends '-l' to each
40+
// entry, resulting in -l-lpthread
41+
FileSystem::replaceFileRegex(
42+
BUILD_LIB_PATH . '/pkgconfig/libcurl.pc',
43+
'/-l(-l\S+)/',
44+
'$1'
45+
);
3746
shell()->cd(BUILD_LIB_PATH . '/cmake/CURL/')
3847
->exec("sed -ie 's|\"/lib/libcurl.a\"|\"" . BUILD_LIB_PATH . "/libcurl.a\"|g' CURLTargets-release.cmake");
3948
}

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace SPC\builder\unix\library;
66

7+
use SPC\toolchain\ToolchainManager;
8+
use SPC\toolchain\ZigToolchain;
79
use SPC\util\executor\UnixAutoconfExecutor;
810
use SPC\util\SPCConfigUtil;
911

@@ -39,12 +41,16 @@ protected function build(): void
3941
$extraEnv['LDFLAGS'] = '-framework Kerberos';
4042
$args[] = 'ac_cv_func_secure_getenv=no';
4143
}
42-
UnixAutoconfExecutor::create($this)
44+
$make = UnixAutoconfExecutor::create($this)
4345
->appendEnv($extraEnv)
4446
->optionalLib('ldap', '--with-ldap', '--without-ldap')
4547
->optionalLib('libedit', '--with-libedit', '--without-libedit')
46-
->configure(...$args)
47-
->make();
48+
->configure(...$args);
49+
50+
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
51+
$make->exec('find . -name Makefile -exec sed -i "s/-Werror=incompatible-pointer-types//g" {} +');
52+
}
53+
$make->make();
4854
$this->patchPkgconfPrefix([
4955
'krb5-gssapi.pc',
5056
'krb5.pc',

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ protected function build(): void
1313
UnixCMakeExecutor::create($this)
1414
->addConfigureArgs(
1515
'-DENABLE_SDL=OFF',
16-
'-DENABLE_DECODER=OFF'
16+
'-DENABLE_DECODER=OFF',
17+
'-DHAVE_NEON=OFF',
1718
)
1819
->build();
1920
$this->patchPkgconfPrefix(['libde265.pc']);

0 commit comments

Comments
 (0)