mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
*full* shared extension build linked against musl libc dynamically works!
This commit is contained in:
parent
2ac20cf3af
commit
93d6a45a78
@ -192,12 +192,12 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
->exec('sed -i "s|//lib|/lib|g" Makefile')
|
->exec('sed -i "s|//lib|/lib|g" Makefile')
|
||||||
->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} cli");
|
->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} cli");
|
||||||
|
|
||||||
|
if (!$this->getOption('no-strip', false)) {
|
||||||
|
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')->exec('strip --strip-all php');
|
||||||
|
}
|
||||||
if ($this->getOption('with-upx-pack')) {
|
if ($this->getOption('with-upx-pack')) {
|
||||||
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')
|
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')
|
||||||
->exec('strip --strip-all php')
|
|
||||||
->exec(getenv('UPX_EXEC') . ' --best php');
|
->exec(getenv('UPX_EXEC') . ' --best php');
|
||||||
} elseif (!$this->getOption('no-strip', false)) {
|
|
||||||
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')->exec('strip --strip-all php');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->deployBinary(BUILD_TARGET_CLI);
|
$this->deployBinary(BUILD_TARGET_CLI);
|
||||||
@ -255,12 +255,12 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
->exec('sed -i "s|//lib|/lib|g" Makefile')
|
->exec('sed -i "s|//lib|/lib|g" Makefile')
|
||||||
->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} fpm");
|
->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} fpm");
|
||||||
|
|
||||||
|
if (!$this->getOption('no-strip', false)) {
|
||||||
|
shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')->exec('strip --strip-all php-fpm');
|
||||||
|
}
|
||||||
if ($this->getOption('with-upx-pack')) {
|
if ($this->getOption('with-upx-pack')) {
|
||||||
shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')
|
shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')
|
||||||
->exec('strip --strip-all php-fpm')
|
|
||||||
->exec(getenv('UPX_EXEC') . ' --best php-fpm');
|
->exec(getenv('UPX_EXEC') . ' --best php-fpm');
|
||||||
} elseif (!$this->getOption('no-strip', false)) {
|
|
||||||
shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')->exec('strip --strip-all php-fpm');
|
|
||||||
}
|
}
|
||||||
$this->deployBinary(BUILD_TARGET_FPM);
|
$this->deployBinary(BUILD_TARGET_FPM);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -256,14 +256,23 @@ class SourcePatcher
|
|||||||
*/
|
*/
|
||||||
public static function patchBeforeMake(BuilderBase $builder): void
|
public static function patchBeforeMake(BuilderBase $builder): void
|
||||||
{
|
{
|
||||||
// Try to fix debian environment build lack HAVE_STRLCAT problem
|
|
||||||
if ($builder instanceof LinuxBuilder) {
|
|
||||||
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_STRLCPY 1$/m', '');
|
|
||||||
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_STRLCAT 1$/m', '');
|
|
||||||
}
|
|
||||||
if ($builder instanceof UnixBuilderBase) {
|
if ($builder instanceof UnixBuilderBase) {
|
||||||
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'install-micro', '');
|
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'install-micro', '');
|
||||||
}
|
}
|
||||||
|
if (!SPCTarget::isStatic() && SPCTarget::getLibc() === 'musl') {
|
||||||
|
// we need to patch the symbol to global visibility, otherwise extensions with `initial-exec` TLS model will fail to load
|
||||||
|
FileSystem::replaceFileStr(
|
||||||
|
SOURCE_PATH . '/php-src/TSRM/TSRM.h',
|
||||||
|
'#define TSRMLS_MAIN_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR = NULL;',
|
||||||
|
'#define TSRMLS_MAIN_CACHE_DEFINE() TSRM_TLS __attribute__((visibility("default"))) void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR = NULL;',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
FileSystem::replaceFileStr(
|
||||||
|
SOURCE_PATH . '/php-src/TSRM/TSRM.h',
|
||||||
|
'#define TSRMLS_MAIN_CACHE_DEFINE() TSRM_TLS __attribute__((visibility("default"))) void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR = NULL;',
|
||||||
|
'#define TSRMLS_MAIN_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR = NULL;',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// no asan
|
// no asan
|
||||||
// if (strpos(file_get_contents(SOURCE_PATH . '/php-src/Makefile'), 'CFLAGS_CLEAN = -g') === false) {
|
// if (strpos(file_get_contents(SOURCE_PATH . '/php-src/Makefile'), 'CFLAGS_CLEAN = -g') === false) {
|
||||||
|
|||||||
@ -158,8 +158,8 @@ if ($shared_extensions) {
|
|||||||
break;
|
break;
|
||||||
case 'ubuntu-24.04':
|
case 'ubuntu-24.04':
|
||||||
case 'ubuntu-24.04-arm':
|
case 'ubuntu-24.04-arm':
|
||||||
putenv('SPC_TARGET=native-native-gnu');
|
putenv('SPC_TARGET=native-native-musl -dynamic');
|
||||||
if (getenv('SPC_TARGET') && !str_contains((string) getenv('SPC_TARGET'), '-musl')) {
|
if (getenv('SPC_TARGET') && !str_contains(getenv('SPC_TARGET'), '-musl') || str_contains(getenv('SPC_TARGET'), '-dynamic')) {
|
||||||
$shared_cmd = ' --build-shared=' . quote2($shared_extensions) . ' ';
|
$shared_cmd = ' --build-shared=' . quote2($shared_extensions) . ' ';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user