Skip to content

Commit 6c47065

Browse files
authored
Merge pull request #782 from crazywhalecc/fix/aarch64-uv-pthread
fix uv missing pthread_atfork in aarch64 centos 7
2 parents a0f9985 + 9bfcea6 commit 6c47065

File tree

7 files changed

+44
-28
lines changed

7 files changed

+44
-28
lines changed

src/SPC/builder/Extension.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function patchBeforeMake(): bool
193193
* If you need to patch some code, overwrite this
194194
* return true if you patched something, false if not
195195
*/
196-
public function patchBeforeSharedBuild(): bool
196+
public function patchBeforeSharedPhpize(): bool
197197
{
198198
return false;
199199
}
@@ -208,6 +208,16 @@ public function patchBeforeSharedConfigure(): bool
208208
return false;
209209
}
210210

211+
/**
212+
* Patch code before shared extension make
213+
* If you need to patch some code, overwrite this
214+
* return true if you patched something, false if not
215+
*/
216+
public function patchBeforeSharedMake(): bool
217+
{
218+
return false;
219+
}
220+
211221
/**
212222
* @return string
213223
* returns a command line string with all required shared extensions to load
@@ -387,13 +397,17 @@ public function buildUnixShared(): void
387397
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
388398
];
389399

400+
if ($this->patchBeforeSharedPhpize()) {
401+
logger()->info("Extension [{$this->getName()}] patched before shared phpize");
402+
}
403+
390404
// prepare configure args
391405
shell()->cd($this->source_dir)
392406
->setEnv($env)
393407
->exec(BUILD_BIN_PATH . '/phpize');
394408

395409
if ($this->patchBeforeSharedConfigure()) {
396-
logger()->info('ext [ . ' . $this->getName() . '] patching before shared configure');
410+
logger()->info("Extension [{$this->getName()}] patched before shared configure");
397411
}
398412

399413
shell()->cd($this->source_dir)
@@ -411,6 +425,10 @@ public function buildUnixShared(): void
411425
'$1 ' . $staticLibString
412426
);
413427

428+
if ($this->patchBeforeSharedMake()) {
429+
logger()->info("Extension [{$this->getName()}] patched before shared make");
430+
}
431+
414432
shell()->cd($this->source_dir)
415433
->setEnv($env)
416434
->exec('make clean')

src/SPC/builder/extension/intl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function patchBeforeBuildconf(): bool
2222
return true;
2323
}
2424

25-
public function patchBeforeSharedBuild(): bool
25+
public function patchBeforeSharedPhpize(): bool
2626
{
2727
return $this->patchBeforeBuildconf();
2828
}

src/SPC/builder/extension/uv.php

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

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

1011
#[CustomExt('uv')]
@@ -16,4 +17,13 @@ public function validate(): void
1617
throw new \RuntimeException('The latest uv extension requires PHP 8.0 or later');
1718
}
1819
}
20+
21+
public function patchBeforeSharedMake(): bool
22+
{
23+
if (PHP_OS_FAMILY !== 'Linux' || arch2gnu(php_uname('m')) !== 'aarch64') {
24+
return false;
25+
}
26+
FileSystem::replaceFileRegex($this->source_dir . '/Makefile', '/^(LDFLAGS =.*)$/m', '$1 -luv -ldl -lrt -pthread');
27+
return true;
28+
}
1929
}

src/SPC/command/BuildPHPCommand.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,6 @@ public function handle(): int
207207
// start to build
208208
$builder->buildPHP($rule);
209209

210-
SourcePatcher::patchBeforeSharedBuild($builder);
211-
212210
// build dynamic extensions if needed
213211
if (!empty($shared_extensions)) {
214212
logger()->info('Building shared extensions ...');

src/SPC/doctor/item/LinuxToolCheckList.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ public function checkCliTools(): ?CheckResult
6161

6262
$required = match ($distro['dist']) {
6363
'alpine' => self::TOOLS_ALPINE,
64-
'redhat' => self::TOOLS_RHEL,
65-
'centos' => array_merge(self::TOOLS_RHEL, ['perl-IPC-Cmd']),
64+
'redhat', 'centos' => self::TOOLS_RHEL,
6665
'arch' => self::TOOLS_ARCH,
6766
default => self::TOOLS_DEBIAN,
6867
};

src/SPC/store/SourcePatcher.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ public static function patchBeforeBuildconf(BuilderBase $builder): void
4646
{
4747
foreach ($builder->getExts() as $ext) {
4848
if ($ext->patchBeforeBuildconf() === true) {
49-
logger()->info('Extension [' . $ext->getName() . '] patched before buildconf');
49+
logger()->info("Extension [{$ext->getName()}] patched before buildconf");
5050
}
5151
}
5252
foreach ($builder->getLibs() as $lib) {
5353
if ($lib->patchBeforeBuildconf() === true) {
54-
logger()->info('Library [' . $lib->getName() . '] patched before buildconf');
54+
logger()->info("Library [{$lib->getName()}]patched before buildconf");
5555
}
5656
}
5757
// patch windows php 8.1 bug
@@ -79,15 +79,6 @@ public static function patchBeforeBuildconf(BuilderBase $builder): void
7979
}
8080
}
8181

82-
public static function patchBeforeSharedBuild(BuilderBase $builder): void
83-
{
84-
foreach ($builder->getExts() as $ext) {
85-
if ($ext->patchBeforeSharedBuild() === true) {
86-
logger()->info('Extension [' . $ext->getName() . '] patched before shared build');
87-
}
88-
}
89-
}
90-
9182
/**
9283
* Source patcher runner before configure
9384
*
@@ -98,12 +89,12 @@ public static function patchBeforeConfigure(BuilderBase $builder): void
9889
{
9990
foreach ($builder->getExts() as $ext) {
10091
if ($ext->patchBeforeConfigure() === true) {
101-
logger()->info('Extension [' . $ext->getName() . '] patched before configure');
92+
logger()->info("Extension [{$ext->getName()}] patched before configure");
10293
}
10394
}
10495
foreach ($builder->getLibs() as $lib) {
10596
if ($lib->patchBeforeConfigure() === true) {
106-
logger()->info('Library [' . $lib->getName() . '] patched before configure');
97+
logger()->info("Library [{$lib->getName()}] patched before configure");
10798
}
10899
}
109100
// patch capstone
@@ -279,12 +270,12 @@ public static function patchBeforeMake(BuilderBase $builder): void
279270
// call extension patch before make
280271
foreach ($builder->getExts(false) as $ext) {
281272
if ($ext->patchBeforeMake() === true) {
282-
logger()->info('Extension [' . $ext->getName() . '] patched before make');
273+
logger()->info("Extension [{$ext->getName()}] patched before make");
283274
}
284275
}
285276
foreach ($builder->getLibs() as $lib) {
286277
if ($lib->patchBeforeMake() === true) {
287-
logger()->info('Library [' . $lib->getName() . '] patched before make');
278+
logger()->info("Library [{$lib->getName()}] patched before make");
288279
}
289280
}
290281
}

src/globals/test-extensions.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@
2121

2222
// test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available)
2323
$test_os = [
24-
'macos-13',
24+
// 'macos-13',
2525
// 'macos-14',
26-
'macos-15',
26+
// 'macos-15',
2727
// 'ubuntu-latest',
2828
// 'ubuntu-22.04',
2929
// 'ubuntu-24.04',
30-
// 'ubuntu-22.04-arm',
30+
'ubuntu-22.04-arm',
3131
// 'ubuntu-24.04-arm',
3232
// 'windows-latest',
3333
];
3434

3535
// whether enable thread safe
36-
$zts = false;
36+
$zts = true;
3737

3838
$no_strip = false;
3939

@@ -54,13 +54,13 @@
5454

5555
// If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`).
5656
$shared_extensions = match (PHP_OS_FAMILY) {
57-
'Linux' => '',
57+
'Linux' => 'uv',
5858
'Darwin' => '',
5959
'Windows' => '',
6060
};
6161

6262
// If you want to test lib-suggests for all extensions and libraries, set it to true.
63-
$with_suggested_libs = true;
63+
$with_suggested_libs = false;
6464

6565
// If you want to test extra libs for extensions, add them below (comma separated, example `libwebp,libavif`). Unnecessary, when $with_suggested_libs is true.
6666
$with_libs = match (PHP_OS_FAMILY) {

0 commit comments

Comments
 (0)