Fix wrongly constructed class

This commit is contained in:
crazywhalecc
2026-05-10 15:50:21 +08:00
parent 02d8f51bb2
commit 7107566da7
3 changed files with 15 additions and 6 deletions

View File

@@ -265,9 +265,9 @@ jobs:
./bin/spc doctor --auto-fix
${{ matrix.combo.build-args }} --dl-with-php=${{ matrix.combo.php-version }}
- name: Setup upterm session
if: ${{ failure() }}
uses: owenthereal/action-upterm@v1
# - name: Setup upterm session
# if: ${{ failure() }}
# uses: owenthereal/action-upterm@v1
- name: Upload logs
if: always() && hashFiles('log/**') != ''

View File

@@ -169,18 +169,18 @@ trait unix
#[BeforeStage('php', [self::class, 'makeForUnix'], 'php')]
#[PatchDescription('Patch Makefile to fix //lib path for Linux builds')]
#[PatchDescription('Patch BUILD_CC to disable auto-vectorization when zig-cc is used (prevents minilua segfault)')]
public function tryPatchMakefileUnix(ToolchainInterface $toolchain): void
public function tryPatchMakefileUnix(TargetPackage $package, ToolchainInterface $toolchain): void
{
if (SystemTarget::getTargetOS() !== 'Linux') {
return;
}
// replace //lib with /lib in Makefile
shell()->cd(SOURCE_PATH . '/php-src')->exec('sed -i "s|//lib|/lib|g" Makefile');
shell()->cd($package->getSourceDir())->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";
$makefile = "{$package->getSourceDir()}/Makefile";
FileSystem::replaceFileRegex($makefile, '/^(BUILD_CC\s*=\s*zig-cc)\s*$/m', '$1 -fno-vectorize -fno-slp-vectorize');
}
}

View File

@@ -499,6 +499,10 @@ class PackageLoader
throw new RegistryException('Package name must not be empty when no package context is available for BeforeStage attribute.');
}
$package_name = $method_instance->package_name === '' ? $pkg->getName() : $method_instance->package_name;
if ($instance_class instanceof Package && isset(self::$packages[$package_name])) {
$instance_class = self::$packages[$package_name];
}
$conditionals = array_map(
fn (\ReflectionAttribute $a) => $a->newInstance()->class,
[...$method->getDeclaringClass()->getAttributes(ConditionalOn::class), ...$method->getAttributes(ConditionalOn::class)],
@@ -529,6 +533,11 @@ class PackageLoader
throw new RegistryException('Package name must not be empty when no package context is available for AfterStage attribute.');
}
$package_name = $method_instance->package_name === '' ? $pkg->getName() : $method_instance->package_name;
if ($instance_class instanceof Package && isset(self::$packages[$package_name])) {
$instance_class = self::$packages[$package_name];
}
$conditionals = array_map(
fn (\ReflectionAttribute $a) => $a->newInstance()->class,
[...$method->getDeclaringClass()->getAttributes(ConditionalOn::class), ...$method->getAttributes(ConditionalOn::class)],