Skip to content

Commit 1f281cd

Browse files
authored
Fix gettext multithread segment fault bug (#603)
* Fix gettext included with multithreaded bug * Change --enable-zts to BuildCommand
1 parent 95d7414 commit 1f281cd

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,21 @@ protected function build(): void
1010
{
1111
$extra = $this->builder->getLib('ncurses') ? ('--with-libncurses-prefix=' . BUILD_ROOT_PATH . ' ') : '';
1212
$extra .= $this->builder->getLib('libxml2') ? ('--with-libxml2-prefix=' . BUILD_ROOT_PATH . ' ') : '';
13+
14+
$zts = $this->builder->getOption('enable-zts') ? '--enable-threads=isoc+posix ' : '--disable-threads ';
15+
16+
$cflags = $this->builder->getOption('enable-zts') ? '-lpthread -D_REENTRANT' : '';
17+
$ldflags = $this->builder->getOption('enable-zts') ? '-lpthread' : '';
18+
1319
shell()->cd($this->source_dir)
14-
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
20+
->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $cflags, 'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags, 'LIBS' => $this->getLibExtraLibs()])
1521
->execWithEnv(
1622
'./configure ' .
1723
'--enable-static ' .
1824
'--disable-shared ' .
1925
'--disable-java ' .
2026
'--disable-c+ ' .
27+
$zts .
2128
$extra .
2229
'--with-included-gettext ' .
2330
'--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' .

src/SPC/command/BuildCliCommand.php

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public function configure(): void
3232
$this->addOption('build-embed', null, null, 'Build embed SAPI');
3333
$this->addOption('build-all', null, null, 'Build all SAPI');
3434
$this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions');
35-
$this->addOption('enable-zts', null, null, 'enable ZTS support');
3635
$this->addOption('disable-opcache-jit', null, null, 'disable opcache jit');
3736
$this->addOption('with-config-file-path', null, InputOption::VALUE_REQUIRED, 'Set the path in which to look for php.ini', $isWindows ? null : '/usr/local/etc/php');
3837
$this->addOption('with-config-file-scan-dir', null, InputOption::VALUE_REQUIRED, 'Set the directory to scan for .ini files after reading php.ini', $isWindows ? null : '/usr/local/etc/php/conf.d');

src/SPC/command/BuildCommand.php

+1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ public function __construct(?string $name = null)
3131
$this->addOption('with-clean', null, null, 'fresh build, remove `source` dir before `make`');
3232
$this->addOption('bloat', null, null, 'add all libraries into binary');
3333
$this->addOption('rebuild', 'r', null, 'Delete old build and rebuild');
34+
$this->addOption('enable-zts', null, null, 'enable ZTS support');
3435
}
3536
}

src/globals/test-extensions.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
// test os (macos-13, macos-14, ubuntu-latest, windows-latest are available)
2323
$test_os = [
2424
// 'macos-13',
25-
// 'macos-14',
26-
// 'ubuntu-latest',
27-
'windows-latest',
25+
'macos-14',
26+
'ubuntu-latest',
27+
// 'windows-latest',
2828
];
2929

3030
// whether enable thread safe
@@ -40,8 +40,8 @@
4040

4141
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
4242
$extensions = match (PHP_OS_FAMILY) {
43-
'Linux', 'Darwin' => 'curl',
44-
'Windows' => 'curl',
43+
'Linux', 'Darwin' => 'gettext',
44+
'Windows' => 'gettext',
4545
};
4646

4747
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).

0 commit comments

Comments
 (0)