mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
better patching for libstdc++ when extensions forget they need it
This commit is contained in:
parent
30e174ac95
commit
df8b2dbf16
@ -414,9 +414,17 @@
|
||||
"libmemcached",
|
||||
"fastlz"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"zstd"
|
||||
],
|
||||
"ext-depends": [
|
||||
"session",
|
||||
"zlib"
|
||||
],
|
||||
"ext-suggests": [
|
||||
"igbinary",
|
||||
"msgpack",
|
||||
"session"
|
||||
]
|
||||
},
|
||||
"mongodb": {
|
||||
|
||||
@ -5,11 +5,14 @@ declare(strict_types=1);
|
||||
namespace SPC\builder;
|
||||
|
||||
use SPC\exception\EnvironmentException;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\SPCException;
|
||||
use SPC\exception\ValidationException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\Config;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\toolchain\ClangNativeToolchain;
|
||||
use SPC\toolchain\GccNativeToolchain;
|
||||
use SPC\toolchain\ToolchainManager;
|
||||
use SPC\toolchain\ZigToolchain;
|
||||
use SPC\util\SPCConfigUtil;
|
||||
@ -418,8 +421,24 @@ class Extension
|
||||
'LIBS' => clean_spaces("{$preStatic} {$staticLibs} {$postStatic} {$sharedLibs}"),
|
||||
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
||||
];
|
||||
if (ToolchainManager::getToolchainClass() === ZigToolchain::class && SPCTarget::getTargetOS() === 'Linux') {
|
||||
$env['SPC_COMPILER_EXTRA'] = '-lstdc++';
|
||||
if (str_contains($env['LIBS'], '-lstdc++') && SPCTarget::getTargetOS() === 'Linux') {
|
||||
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
|
||||
$env['SPC_COMPILER_EXTRA'] = '-lstdc++';
|
||||
} elseif (ToolchainManager::getToolchainClass() === GccNativeToolchain::class || ToolchainManager::getToolchainClass() === ClangNativeToolchain::class) {
|
||||
try {
|
||||
$content = FileSystem::readFile($this->source_dir . '/config.m4');
|
||||
if ($content && !str_contains($content, 'PHP_ADD_LIBRARY(stdc++')) {
|
||||
$pattern = '/(PHP_NEW_EXTENSION\(' . $this->name . ',.*\))/m';
|
||||
$replacement = "$1\nPHP_ADD_LIBRARY(stdc++, 1, " . strtoupper($this->name) . '_SHARED_LIBADD)';
|
||||
FileSystem::replaceFileRegex(
|
||||
$this->source_dir . '/config.m4',
|
||||
$pattern,
|
||||
$replacement
|
||||
);
|
||||
}
|
||||
} catch (FileSystemException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->patchBeforeSharedPhpize()) {
|
||||
|
||||
@ -17,6 +17,10 @@ class memcached extends Extension
|
||||
'--with-libmemcached-dir=' . BUILD_ROOT_PATH . ' ' .
|
||||
'--disable-memcached-sasl ' .
|
||||
'--enable-memcached-json ' .
|
||||
($this->builder->getLib('zstd') ? '--with-zstd ' : '') .
|
||||
($this->builder->getExt('igbinary') ? '--enable-memcached-igbinary ' : '') .
|
||||
($this->builder->getExt('session') ? '--enable-memcached-session ' : '') .
|
||||
($this->builder->getExt('msgpack') ? '--enable-memcached-msgpack ' : '') .
|
||||
'--with-system-fastlz';
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user