mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
add source patch for ffi on centos 7
This commit is contained in:
parent
6b689f1584
commit
a9d37bb2a2
@ -22,6 +22,7 @@ class SourcePatcher
|
||||
FileSystem::addSourceExtractHook('swoole', [SourcePatcher::class, 'patchSwoole']);
|
||||
FileSystem::addSourceExtractHook('php-src', [SourcePatcher::class, 'patchPhpLibxml212']);
|
||||
FileSystem::addSourceExtractHook('php-src', [SourcePatcher::class, 'patchGDWin32']);
|
||||
FileSystem::addSourceExtractHook('php-src', [SourcePatcher::class, 'patchFfiCentos7FixO3strncmp']);
|
||||
FileSystem::addSourceExtractHook('sqlsrv', [SourcePatcher::class, 'patchSQLSRVWin32']);
|
||||
FileSystem::addSourceExtractHook('pdo_sqlsrv', [SourcePatcher::class, 'patchSQLSRVWin32']);
|
||||
FileSystem::addSourceExtractHook('yaml', [SourcePatcher::class, 'patchYamlWin32']);
|
||||
@ -451,6 +452,15 @@ class SourcePatcher
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function patchFfiCentos7FixO3strncmp(): bool
|
||||
{
|
||||
if (PHP_OS_FAMILY === 'Linux' && SystemUtil::getLibcVersionIfExists() === '2.17') {
|
||||
SourcePatcher::patchFile('ffi_centos7_fix_O3_strncmp.patch', SOURCE_PATH . '/php-src');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function patchLibaomForAlpine(): bool
|
||||
{
|
||||
if (PHP_OS_FAMILY === 'Linux' && SystemUtil::isMuslDist()) {
|
||||
|
||||
31
src/globals/patch/ffi_centos7_fix_O3_strncmp.patch
Normal file
31
src/globals/patch/ffi_centos7_fix_O3_strncmp.patch
Normal file
@ -0,0 +1,31 @@
|
||||
--- a/ext/ffi/ffi.c 2025-01-17 10:37:37
|
||||
+++ a/ext/ffi/ffi.c 2025-01-17 10:39:17
|
||||
@@ -57,6 +57,8 @@
|
||||
/* XXX need something better, perhaps with regard to SIMD, etc. */
|
||||
# define __BIGGEST_ALIGNMENT__ sizeof(size_t)
|
||||
#endif
|
||||
+
|
||||
+#define ZEND_STRNCMP(s,str) strncmp((s),(str),(sizeof(str)-1))
|
||||
|
||||
ZEND_DECLARE_MODULE_GLOBALS(ffi)
|
||||
|
||||
@@ -5046,16 +5048,16 @@ static char *zend_ffi_parse_directives(const char *fil
|
||||
*scope_name = NULL;
|
||||
*lib = NULL;
|
||||
while (*code_pos == '#') {
|
||||
- if (strncmp(code_pos, ZEND_STRL("#define")) == 0) {
|
||||
+ if (ZEND_STRNCMP(code_pos, "#define") == 0) {
|
||||
p = zend_ffi_skip_ws_and_comments(code_pos + sizeof("#define") - 1, false);
|
||||
|
||||
char **target = NULL;
|
||||
const char *target_name = NULL;
|
||||
- if (strncmp(p, ZEND_STRL("FFI_SCOPE")) == 0) {
|
||||
+ if (ZEND_STRNCMP(p, "FFI_SCOPE") == 0) {
|
||||
p = zend_ffi_skip_ws_and_comments(p + sizeof("FFI_SCOPE") - 1, false);
|
||||
target = scope_name;
|
||||
target_name = "FFI_SCOPE";
|
||||
- } else if (strncmp(p, ZEND_STRL("FFI_LIB")) == 0) {
|
||||
+ } else if (ZEND_STRNCMP(p, "FFI_LIB") == 0) {
|
||||
p = zend_ffi_skip_ws_and_comments(p + sizeof("FFI_LIB") - 1, false);
|
||||
target = lib;
|
||||
target_name = "FFI_LIB";
|
||||
Loading…
x
Reference in New Issue
Block a user