Skip to content

Commit f187250

Browse files
committed
disable opcache jit automatically on alpine target (only required for php < 8.5)
1 parent 20fbbb1 commit f187250

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

src/SPC/builder/extension/mongodb.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ class mongodb extends Extension
1212
{
1313
public function getUnixConfigureArg(bool $shared = false): string
1414
{
15-
$arg = ' --enable-mongodb ';
15+
$arg = ' --enable-mongodb' . ($shared ? '=shared' : '') . ' ';
1616
$arg .= ' --with-mongodb-system-libs=no --with-mongodb-client-side-encryption=no ';
17-
$arg .= ' --with-mongodb-sasl=no ';
17+
$arg .= ' --with-mongodb-sasl=no ';
1818
if ($this->builder->getLib('openssl')) {
1919
$arg .= '--with-mongodb-ssl=openssl';
2020
}
2121
$arg .= $this->builder->getLib('icu') ? ' --with-mongodb-icu=yes ' : ' --with-mongodb-icu=no ';
2222
$arg .= $this->builder->getLib('zstd') ? ' --with-mongodb-zstd=yes ' : ' --with-mongodb-zstd=no ';
2323
// $arg .= $this->builder->getLib('snappy') ? ' --with-mongodb-snappy=yes ' : ' --with-mongodb-snappy=no ';
2424
$arg .= $this->builder->getLib('zlib') ? ' --with-mongodb-zlib=yes ' : ' --with-mongodb-zlib=bundled ';
25-
return $arg;
25+
return clean_spaces($arg);
2626
}
2727
}

src/SPC/builder/extension/opcache.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use SPC\exception\WrongUsageException;
99
use SPC\store\SourcePatcher;
1010
use SPC\util\CustomExt;
11+
use SPC\util\SPCTarget;
1112

1213
#[CustomExt('opcache')]
1314
class opcache extends Extension
@@ -46,7 +47,17 @@ public function patchBeforeBuildconf(): bool
4647

4748
public function getUnixConfigureArg(bool $shared = false): string
4849
{
49-
return '--enable-opcache';
50+
$phpVersionID = $this->builder->getPHPVersionID();
51+
$opcache_jit = ' --enable-opcache-jit';
52+
if ((SPCTarget::getTargetOS() === 'Linux' &&
53+
SPCTarget::getLibc() === 'musl' &&
54+
$this->builder->getOption('enable-zts') &&
55+
$phpVersionID < 80500) ||
56+
$this->builder->getOption('disable-opcache-jit')
57+
) {
58+
$opcache_jit = ' --disable-opcache-jit';
59+
}
60+
return '--enable-opcache' . ($shared ? '=shared' : '') . $opcache_jit;
5061
}
5162

5263
public function getDistName(): string

src/SPC/builder/linux/LinuxBuilder.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
6464
// if opcache_jit is enabled for 8.5 or opcache enabled,
6565
// we need to disable undefined behavior sanitizer.
6666
f_putenv('SPC_COMPILER_EXTRA=-fno-sanitize=undefined');
67-
} elseif ($opcache_jit) {
68-
$opcache_jit = false;
6967
}
70-
$opcache_jit_arg = $opcache_jit ? '--enable-opcache-jit ' : '--disable-opcache-jit ';
7168

7269
if ($this->getOption('enable-zts', false)) {
7370
$maxExecutionTimers = $phpVersionID >= 80100 ? '--enable-zend-max-execution-timers ' : '';
@@ -115,7 +112,6 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
115112
($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') .
116113
$config_file_path .
117114
$config_file_scan_dir .
118-
$opcache_jit_arg .
119115
$json_74 .
120116
$zts .
121117
$maxExecutionTimers .

src/SPC/builder/macos/MacOSBuilder.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,6 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
9090
$json_74 = $phpVersionID < 80000 ? '--enable-json ' : '';
9191
$zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : '';
9292

93-
$opcache_jit = !$this->getOption('disable-opcache-jit', false);
94-
// disable opcache jit for PHP < 8.5.0 when opcache is not enabled
95-
if ($opcache_jit && $phpVersionID < 80500 && !$this->getExt('opcache')) {
96-
$opcache_jit = false;
97-
}
98-
$opcache_jit_arg = $opcache_jit ? '--enable-opcache-jit ' : '--disable-opcache-jit ';
99-
10093
$config_file_path = $this->getOption('with-config-file-path', false) ?
10194
('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : '';
10295
$config_file_scan_dir = $this->getOption('with-config-file-scan-dir', false) ?
@@ -131,7 +124,6 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
131124
($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
132125
($enableEmbed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
133126
($enableMicro ? '--enable-micro ' : '--disable-micro ') .
134-
$opcache_jit_arg .
135127
$config_file_path .
136128
$config_file_scan_dir .
137129
$json_74 .

0 commit comments

Comments
 (0)