Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/SPC/builder/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
use SPC\exception\WrongUsageException;
use SPC\store\Config;
use SPC\store\FileSystem;
use SPC\toolchain\ToolchainManager;
use SPC\toolchain\ZigToolchain;
use SPC\util\GlobalEnvManager;
use SPC\util\SPCConfigUtil;
use SPC\util\SPCTarget;

Expand Down Expand Up @@ -231,7 +234,7 @@ public function patchBeforeSharedMake(): bool
if (preg_match('/^(.*_SHARED_LIBADD\s*=\s*)(.*)$/m', $makefileContent, $matches)) {
$prefix = $matches[1];
$currentLibs = trim($matches[2]);
$newLibs = trim("{$currentLibs} {$staticLibs} {$lstdcpp}");
$newLibs = clean_spaces("{$currentLibs} {$staticLibs} {$lstdcpp}");
$deduplicatedLibs = deduplicate_flags($newLibs);

FileSystem::replaceFileRegex(
Expand Down Expand Up @@ -543,6 +546,11 @@ public function getLibraryDependencies(bool $recursive = false): array
*/
protected 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($this->builder, ['no_php' => true]))->getExtensionConfig($this);
[$staticLibs, $sharedLibs] = $this->splitLibsIntoStaticAndShared($config['libs']);
$preStatic = PHP_OS_FAMILY === 'Darwin' ? '' : '-Wl,--start-group ';
Expand Down
10 changes: 9 additions & 1 deletion src/SPC/builder/linux/LinuxBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use SPC\store\DirDiff;
use SPC\store\FileSystem;
use SPC\store\SourcePatcher;
use SPC\toolchain\ToolchainManager;
use SPC\toolchain\ZigToolchain;
use SPC\util\GlobalEnvManager;
use SPC\util\SPCConfigUtil;
use SPC\util\SPCTarget;
Expand Down Expand Up @@ -65,7 +67,8 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
// php 8.5 contains opcache extension by default,
// if opcache_jit is enabled for 8.5 or opcache enabled,
// we need to disable undefined behavior sanitizer.
f_putenv('SPC_COMPILER_EXTRA=-fno-sanitize=undefined');
$compiler_extra = getenv('SPC_COMPILER_EXTRA') ?: '';
f_putenv('SPC_COMPILER_EXTRA=' . trim($compiler_extra . ' -fno-sanitize=undefined'));
}

if ($this->getOption('enable-zts', false)) {
Expand Down Expand Up @@ -266,6 +269,11 @@ protected function buildFpm(): void
*/
protected function buildEmbed(): void
{
$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}");
}
$sharedExts = array_filter($this->exts, static fn ($ext) => $ext->isBuildShared());
$sharedExts = array_filter($sharedExts, static function ($ext) {
return Config::getExt($ext->getName(), 'build-with-php') === true;
Expand Down
13 changes: 4 additions & 9 deletions src/globals/common-tests/embed.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
#include <sapi/embed/php_embed.h>

int main(int argc,char **argv){

PHP_EMBED_START_BLOCK(argc,argv)

int main(int argc, char **argv) {
PHP_EMBED_START_BLOCK(argc, argv)
zend_file_handle file_handle;

zend_stream_init_filename(&file_handle,"embed.php");

if(!php_execute_script(&file_handle)){
zend_stream_init_filename(&file_handle, "embed.php");
if(!php_execute_script(&file_handle)) {
php_printf("Failed to execute PHP script.\n");
}

PHP_EMBED_END_BLOCK()
return 0;
}
Loading