mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-04 07:15:38 +08:00
Enhance Unix Makefile patch to disable auto-vectorization for zig-cc to prevent minilua segfault
This commit is contained in:
@@ -20,6 +20,7 @@ use StaticPHP\Package\PhpExtensionPackage;
|
||||
use StaticPHP\Package\TargetPackage;
|
||||
use StaticPHP\Runtime\SystemTarget;
|
||||
use StaticPHP\Toolchain\Interface\ToolchainInterface;
|
||||
use StaticPHP\Toolchain\ZigToolchain;
|
||||
use StaticPHP\Util\DirDiff;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
use StaticPHP\Util\GlobalEnvManager;
|
||||
@@ -167,7 +168,8 @@ trait unix
|
||||
|
||||
#[BeforeStage('php', [self::class, 'makeForUnix'], 'php')]
|
||||
#[PatchDescription('Patch Makefile to fix //lib path for Linux builds')]
|
||||
public function tryPatchMakefileUnix(): void
|
||||
#[PatchDescription('Patch BUILD_CC to disable auto-vectorization when zig-cc is used (prevents minilua segfault)')]
|
||||
public function tryPatchMakefileUnix(ToolchainInterface $toolchain): void
|
||||
{
|
||||
if (SystemTarget::getTargetOS() !== 'Linux') {
|
||||
return;
|
||||
@@ -175,6 +177,12 @@ trait unix
|
||||
|
||||
// replace //lib with /lib in Makefile
|
||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('sed -i "s|//lib|/lib|g" Makefile');
|
||||
|
||||
// try to fix minilua with zig-cc, disable vectorize for some edge cases
|
||||
if ($toolchain instanceof ZigToolchain) {
|
||||
$makefile = "{$this->getSourceDir()}/Makefile";
|
||||
FileSystem::replaceFileRegex($makefile, '/^(BUILD_CC\s*=\s*zig-cc)\s*$/m', '$1 -fno-vectorize -fno-slp-vectorize');
|
||||
}
|
||||
}
|
||||
|
||||
#[BeforeStage('php', [self::class, 'makeForUnix'], 'php')]
|
||||
|
||||
Reference in New Issue
Block a user