Skip to content

Commit 970343b

Browse files
authored
Fix old PHP extension with newer C standard bug (crazywhalecc#1089)
2 parents 5b5861c + e21bb52 commit 970343b

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/SPC/store/SourcePatcher.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ public static function patchBeforeConfigure(BuilderBase $builder): void
129129
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/have_capstone="yes"/', 'have_capstone="no"');
130130
}
131131

132+
// PHP 8.2 and below: bcmath libbcmath uses K&R style C function
133+
if (is_unix() && $builder->getPHPVersionID() < 80300) {
134+
FileSystem::replaceFileStr(
135+
SOURCE_PATH . '/php-src/configure',
136+
"for ac_arg in '' -std=gnu23",
137+
"for ac_arg in '' -std=gnu17",
138+
);
139+
}
140+
132141
if (file_exists(SOURCE_PATH . '/php-src/configure.ac.bak')) {
133142
// restore configure.ac
134143
FileSystem::restoreBackupFile(SOURCE_PATH . '/php-src/configure.ac');

src/SPC/util/executor/UnixCMakeExecutor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private function makeCmakeToolchainFile(): string
182182
$target_arch = arch2gnu(php_uname('m'));
183183
$cflags = getenv('SPC_DEFAULT_C_FLAGS');
184184
$cc = getenv('CC');
185-
$cxx = getenv('CCX');
185+
$cxx = getenv('CXX');
186186
$include = BUILD_INCLUDE_PATH;
187187
logger()->debug("making cmake tool chain file for {$os} {$target_arch} with CFLAGS='{$cflags}'");
188188
$root = BUILD_ROOT_PATH;

0 commit comments

Comments
 (0)