mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-09 01:45:36 +08:00
Forward-port #1110
This commit is contained in:
@@ -443,7 +443,7 @@ trait unix
|
|||||||
|
|
||||||
#[BuildFor('Darwin')]
|
#[BuildFor('Darwin')]
|
||||||
#[BuildFor('Linux')]
|
#[BuildFor('Linux')]
|
||||||
public function build(TargetPackage $package): void
|
public function build(TargetPackage $package, PackageInstaller $installer): void
|
||||||
{
|
{
|
||||||
// frankenphp is not a php sapi, it's a standalone Go binary that depends on libphp.a (embed)
|
// frankenphp is not a php sapi, it's a standalone Go binary that depends on libphp.a (embed)
|
||||||
if ($package->getName() === 'frankenphp') {
|
if ($package->getName() === 'frankenphp') {
|
||||||
@@ -457,9 +457,21 @@ trait unix
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$package->runStage([$this, 'buildconfForUnix']);
|
// maintainer can skip build though ...
|
||||||
$package->runStage([$this, 'configureForUnix']);
|
$skip_build = false;
|
||||||
$package->runStage([$this, 'makeForUnix']);
|
if ($installer->isPackageResolved('php-embed')
|
||||||
|
&& $installer->getTargetPackage('php-embed')->getBuildOption('maintainer-skip-build')
|
||||||
|
) {
|
||||||
|
$suffix = SystemTarget::getTargetOS() === 'Darwin' ? 'dylib' : 'so';
|
||||||
|
$skip_build = file_exists(BUILD_LIB_PATH . '/libphp.a')
|
||||||
|
|| file_exists(BUILD_LIB_PATH . "/libphp.{$suffix}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$skip_build) {
|
||||||
|
$package->runStage([$this, 'buildconfForUnix']);
|
||||||
|
$package->runStage([$this, 'configureForUnix']);
|
||||||
|
$package->runStage([$this, 'makeForUnix']);
|
||||||
|
}
|
||||||
|
|
||||||
$package->runStage([$this, 'unixBuildSharedExt']);
|
$package->runStage([$this, 'unixBuildSharedExt']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ use StaticPHP\DI\ApplicationContext;
|
|||||||
use StaticPHP\Exception\ValidationException;
|
use StaticPHP\Exception\ValidationException;
|
||||||
use StaticPHP\Exception\WrongUsageException;
|
use StaticPHP\Exception\WrongUsageException;
|
||||||
use StaticPHP\Runtime\SystemTarget;
|
use StaticPHP\Runtime\SystemTarget;
|
||||||
|
use StaticPHP\Toolchain\ToolchainManager;
|
||||||
|
use StaticPHP\Toolchain\ZigToolchain;
|
||||||
|
use StaticPHP\Util\GlobalEnvManager;
|
||||||
use StaticPHP\Util\SPCConfigUtil;
|
use StaticPHP\Util\SPCConfigUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -266,6 +269,11 @@ class PhpExtensionPackage extends Package
|
|||||||
*/
|
*/
|
||||||
public function getSharedExtensionEnv(): array
|
public function getSharedExtensionEnv(): array
|
||||||
{
|
{
|
||||||
|
$compiler_extra = getenv('SPC_COMPILER_EXTRA') ?: '';
|
||||||
|
if (!str_contains($compiler_extra, '-lcompiler_rt') && ToolchainManager::getToolchainClass() === ZigToolchain::class) {
|
||||||
|
$compiler_extra = trim($compiler_extra . ' -lcompiler_rt');
|
||||||
|
GlobalEnvManager::putenv("SPC_COMPILER_EXTRA={$compiler_extra}");
|
||||||
|
}
|
||||||
$config = (new SPCConfigUtil())->getExtensionConfig($this);
|
$config = (new SPCConfigUtil())->getExtensionConfig($this);
|
||||||
[$staticLibs, $sharedLibs] = $this->splitLibsIntoStaticAndShared($config['libs']);
|
[$staticLibs, $sharedLibs] = $this->splitLibsIntoStaticAndShared($config['libs']);
|
||||||
$preStatic = PHP_OS_FAMILY === 'Darwin' ? '' : '-Wl,--start-group ';
|
$preStatic = PHP_OS_FAMILY === 'Darwin' ? '' : '-Wl,--start-group ';
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ use StaticPHP\Exception\ExecutionException;
|
|||||||
use StaticPHP\Exception\SPCInternalException;
|
use StaticPHP\Exception\SPCInternalException;
|
||||||
use StaticPHP\Exception\WrongUsageException;
|
use StaticPHP\Exception\WrongUsageException;
|
||||||
use StaticPHP\Runtime\SystemTarget;
|
use StaticPHP\Runtime\SystemTarget;
|
||||||
|
use StaticPHP\Toolchain\ToolchainManager;
|
||||||
|
use StaticPHP\Toolchain\ZigToolchain;
|
||||||
|
|
||||||
abstract class UnixUtil
|
abstract class UnixUtil
|
||||||
{
|
{
|
||||||
@@ -70,7 +72,8 @@ abstract class UnixUtil
|
|||||||
if (!is_file($symbol_file)) {
|
if (!is_file($symbol_file)) {
|
||||||
throw new SPCInternalException("The symbol file {$symbol_file} does not exist, please check if nm command is available.");
|
throw new SPCInternalException("The symbol file {$symbol_file} does not exist, please check if nm command is available.");
|
||||||
}
|
}
|
||||||
if (SystemTarget::getTargetOS() !== 'Linux') {
|
// macOS/zig
|
||||||
|
if (SystemTarget::getTargetOS() === 'Darwin' || ToolchainManager::getToolchainClass() === ZigToolchain::class) {
|
||||||
return "-Wl,-exported_symbols_list,{$symbol_file}";
|
return "-Wl,-exported_symbols_list,{$symbol_file}";
|
||||||
}
|
}
|
||||||
return "-Wl,--dynamic-list={$symbol_file}";
|
return "-Wl,--dynamic-list={$symbol_file}";
|
||||||
|
|||||||
Reference in New Issue
Block a user