mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-07 08:45:40 +08:00
*full* shared extension build linked against musl libc dynamically works!
This commit is contained in:
@@ -256,14 +256,23 @@ class SourcePatcher
|
||||
*/
|
||||
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) {
|
||||
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
|
||||
// if (strpos(file_get_contents(SOURCE_PATH . '/php-src/Makefile'), 'CFLAGS_CLEAN = -g') === false) {
|
||||
|
||||
Reference in New Issue
Block a user