Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
12aadf1
refactor: replace SPC_LIBC with SPC_TARGET and update related logic
crazywhalecc Jun 28, 2025
924da6a
extension test
crazywhalecc Jun 28, 2025
604131b
Use own exception
crazywhalecc Jun 28, 2025
3357f28
Remove libgomp deps
crazywhalecc Jun 28, 2025
90823e3
Use explict glibc toolchain target
crazywhalecc Jun 28, 2025
e41d789
Add comments, re-trigger tests
crazywhalecc Jun 28, 2025
8145a75
Fix spc-gnu-docker path
crazywhalecc Jun 28, 2025
454b5a7
Add SPC_LIBC mapping to SPC_TARGET
crazywhalecc Jun 28, 2025
c23c5ae
Disable openmp for imagemagick
crazywhalecc Jun 28, 2025
a636438
Add suffix support for SPC_TARGET
crazywhalecc Jun 28, 2025
0598eff
Add suffix support for SPC_TARGET
crazywhalecc Jun 28, 2025
977fbaa
Suggestions
crazywhalecc Jun 29, 2025
e36800b
phpunit fix
crazywhalecc Jun 29, 2025
fcaa7c5
Add no-env-check for builder
crazywhalecc Jun 29, 2025
7f45f4a
Fix phpunit, add SPC_SKIP_TOOLCHAIN_CHECK
crazywhalecc Jun 29, 2025
956688d
Fix CI again
crazywhalecc Jun 29, 2025
e1e4892
Use isStatic instead of isStaticTarget
crazywhalecc Jun 29, 2025
ab5828a
Remove redundant path in gnu docker
crazywhalecc Jun 30, 2025
138e558
Update bin/spc-gnu-docker
crazywhalecc Jun 30, 2025
e584808
Update bin/spc-gnu-docker
crazywhalecc Jun 30, 2025
44c6d62
Refactor LinuxMuslCheck to use MuslToolchain class for toolchain check
crazywhalecc Jun 30, 2025
51e23d2
remove w32 patches (other branch isn't merged yet)
henderkes Jun 30, 2025
956667b
fix alpine doctor saying gettext-dev isn't installed
henderkes Jun 30, 2025
68e500e
Merge branch 'main' into refactor/spc-target
henderkes Jun 30, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: "Run PHPUnit Tests"
run: SPC_LIBC=glibc vendor/bin/phpunit tests/ --no-coverage
run: SPC_TARGET=glibc vendor/bin/phpunit tests/ --no-coverage

define-matrix:
name: "Define Matrix"
Expand Down
4 changes: 2 additions & 2 deletions bin/build-static-frankenphp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ ADD ./bin/spc /app/bin/spc
RUN /app/bin/setup-runtime
RUN /app/bin/php /app/bin/composer install --no-dev --classmap-authoritative
ENV PATH="/app/bin:/cmake/bin:/usr/local/go/bin:$PATH"
ENV SPC_LIBC=glibc
ENV SPC_TARGET=glibc

ADD ./config/env.ini /app/config/env.ini
RUN bin/spc doctor --auto-fix --debug
Expand Down Expand Up @@ -146,7 +146,7 @@ echo 'CXX=/opt/rh/devtoolset-10/root/usr/bin/g++' >> /tmp/spc-gnu-docker.env
echo 'AR=/opt/rh/devtoolset-10/root/usr/bin/ar' >> /tmp/spc-gnu-docker.env
echo 'LD=/opt/rh/devtoolset-10/root/usr/bin/ld' >> /tmp/spc-gnu-docker.env
echo 'SPC_DEFAULT_C_FLAGS=-fPIE -fPIC' >> /tmp/spc-gnu-docker.env
echo 'SPC_LIBC=glibc' >> /tmp/spc-gnu-docker.env
echo 'SPC_TARGET=glibc' >> /tmp/spc-gnu-docker.env
echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-Wl,-O1 -pie"' >> /tmp/spc-gnu-docker.env
echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm -lresolv -lutil -lrt"' >> /tmp/spc-gnu-docker.env

Expand Down
4 changes: 2 additions & 2 deletions bin/spc-gnu-docker
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ ADD ./bin/spc /app/bin/spc
RUN /app/bin/setup-runtime
RUN /app/bin/php /app/bin/composer install --no-dev
ENV PATH="/app/bin:/cmake/bin:$PATH"
ENV SPC_LIBC=glibc
ENV SPC_TARGET=glibc

ADD ./config/env.ini /app/config/env.ini
RUN CC=gcc bin/spc doctor --auto-fix --debug
Expand Down Expand Up @@ -159,7 +159,7 @@ echo 'CXX=/opt/rh/devtoolset-10/root/usr/bin/g++' >> /tmp/spc-gnu-docker.env
echo 'AR=/opt/rh/devtoolset-10/root/usr/bin/ar' >> /tmp/spc-gnu-docker.env
echo 'LD=/opt/rh/devtoolset-10/root/usr/bin/ld' >> /tmp/spc-gnu-docker.env
echo 'SPC_DEFAULT_C_FLAGS=-fPIC' >> /tmp/spc-gnu-docker.env
echo 'SPC_LIBC=glibc' >> /tmp/spc-gnu-docker.env
echo 'SPC_TARGET=glibc' >> /tmp/spc-gnu-docker.env
echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-Wl,-O1 -pie"' >> /tmp/spc-gnu-docker.env
echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm -lresolv -lutil -lrt"' >> /tmp/spc-gnu-docker.env

Expand Down
18 changes: 16 additions & 2 deletions config/env.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES="--with github.com/dunglas/frankenphp/cadd
; EXTENSION_DIR=

[windows]
; build target: win7-static
SPC_TARGET=msvc-static
; php-sdk-binary-tools path
PHP_SDK_PATH="${WORKING_DIR}\php-sdk-binary-tools"
; upx executable path
Expand All @@ -63,8 +65,17 @@ UPX_EXEC="${PKG_ROOT_PATH}\bin\upx.exe"
SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,cli_static

[linux]
; include PATH for musl libc.
SPC_LIBC=musl
; Linux can use different build toolchain, but the toolchain can not be changed in this file:
; - musl (default): used for general linux distros, can build `musl-static` target only.
; - zig (WIP): used for general linux distros, can build `musl` and `glibc` targets.
; - musl-native: used for alpine linux, can build `musl-static` and `musl`(WIP) target.
; - gnu-native (assume): used for general linux distros, can build `glibc` target only and have portability issues.

; build target:
; - musl-static (default): pure static linking, using musl-libc, can run on any linux distro.
; - musl: static linking with dynamic linking to musl-libc, can run on musl-based linux distro.
; - glibc: static linking with dynamic linking to glibc, can run on glibc-based linux distro.
SPC_TARGET=musl-static
; compiler environments
CC=${SPC_LINUX_DEFAULT_CC}
CXX=${SPC_LINUX_DEFAULT_CXX}
Expand Down Expand Up @@ -109,6 +120,9 @@ SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS=""
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-all-static -Wl,-O1 -pie"

[macos]
; build target: macho or macho (possibly we could support macho-universal in the future)
; Currently we do not support universal and cross-compilation for macOS.
SPC_TARGET=macho
; compiler environments
CC=clang
CXX=clang++
Expand Down
2 changes: 1 addition & 1 deletion docs/en/guide/extension-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ and this extension cannot be compiled into php by static linking, so it cannot b

## xdebug

1. Xdebug is only buildable as a shared extension. On Linux, you need to use static-php-cli with SPC_LIBC=glibc.
1. Xdebug is only buildable as a shared extension. You need to use a build target other than `musl-static` for SPC_TARGET.
2. When using Linux/glibc or macOS, you can compile Xdebug as a shared extension using --build-shared="xdebug".
The compiled `./php` binary can be configured and run by specifying the INI, eg `./php -d 'zend_extension=/path/to/xdebug.so' your-code.php`.

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/guide/extension-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ bin/spc build gd --with-libs=freetype,libjpeg,libavif,libwebp --build-cli

## xdebug

1. Xdebug 只能作为共享扩展进行构建。在 Linux 上,您需要使用 static-php-cli 并设置 SPC_LIBC=glibc
1. Xdebug 只能作为共享扩展进行构建。您需要使用除了 `musl-static` 外的其他 `SPC_TARGET` 构建目标
2. 使用 Linux/glibc 或 macOS 时,您可以使用 `--build-shared=xdebug` 将 Xdebug 编译为共享扩展。
编译后的 `./php` 二进制文件可以通过指定 INI 文件进行配置和运行,例如 `./php -d 'zend_extension=/path/to/xdebug.so' your-code.php`。

Expand Down
2 changes: 2 additions & 0 deletions src/SPC/ConsoleApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use SPC\command\CraftCommand;
use SPC\command\DeleteDownloadCommand;
use SPC\command\dev\AllExtCommand;
use SPC\command\dev\EnvCommand;
use SPC\command\dev\ExtVerCommand;
use SPC\command\dev\GenerateExtDepDocsCommand;
use SPC\command\dev\GenerateExtDocCommand;
Expand Down Expand Up @@ -70,6 +71,7 @@ public function __construct()
new GenerateExtDepDocsCommand(),
new GenerateLibDepDocsCommand(),
new PackLibCommand(),
new EnvCommand(),
]
);
}
Expand Down
19 changes: 3 additions & 16 deletions src/SPC/builder/extension/imagick.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,22 @@

use SPC\builder\Extension;
use SPC\util\CustomExt;
use SPC\util\SPCTarget;

#[CustomExt('imagick')]
class imagick extends Extension
{
public function patchBeforeMake(): bool
{
if (PHP_OS_FAMILY !== 'Linux') {
return false;
}
if (getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10')) {
return false;
}
// imagick with calls omp_pause_all, which requires openmp, on non-musl we build imagick without openmp
$extra_libs = trim(getenv('SPC_EXTRA_LIBS') . ' -lgomp');
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
return true;
}

public function getUnixConfigureArg(bool $shared = false): string
{
$disable_omp = !(getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10')) ? '' : ' ac_cv_func_omp_pause_resource_all=no';
$disable_omp = ' ac_cv_func_omp_pause_resource_all=no';
return '--with-imagick=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $disable_omp;
}

protected function getStaticAndSharedLibs(): array
{
// on centos 7, it will use the symbol _ZTINSt6thread6_StateE, which is not defined in system libstdc++.so.6
[$static, $shared] = parent::getStaticAndSharedLibs();
if (getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10')) {
if (SPCTarget::isTarget(SPCTarget::GLIBC)) {
$static .= ' -lstdc++';
$shared = str_replace('-lstdc++', '', $shared);
}
Expand Down
16 changes: 1 addition & 15 deletions src/SPC/builder/linux/LinuxBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,8 @@ public function __construct(array $options = [])
{
$this->options = $options;

// check musl-cross make installed if we use musl-cross-make
$arch = arch2gnu(php_uname('m'));

GlobalEnvManager::init();

if (getenv('SPC_LIBC') === 'musl' && !SystemUtil::isMuslDist()) {
$this->setOptionIfNotExist('library_path', "LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\"");
$this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\"");
$configure = getenv('SPC_CMD_PREFIX_PHP_CONFIGURE');
$configure = "LD_LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\" " . $configure;
GlobalEnvManager::putenv("SPC_CMD_PREFIX_PHP_CONFIGURE={$configure}");

if (!file_exists("/usr/local/musl/{$arch}-linux-musl/lib/libc.a")) {
throw new WrongUsageException('You are building with musl-libc target in glibc distro, but musl-toolchain is not installed, please install musl-toolchain first. (You can use `doctor` command to install it)');
}
}
GlobalEnvManager::afterInit();

// concurrency
$this->concurrency = intval(getenv('SPC_CONCURRENCY'));
Expand Down
5 changes: 3 additions & 2 deletions src/SPC/builder/linux/SystemUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use SPC\builder\traits\UnixSystemUtilTrait;
use SPC\exception\RuntimeException;
use SPC\util\SPCTarget;

class SystemUtil
{
Expand Down Expand Up @@ -193,7 +194,7 @@ public static function getLibcVersionIfExists(): ?string
if (self::$libc_version !== null) {
return self::$libc_version;
}
if (PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') === 'glibc') {
if (SPCTarget::isTarget(SPCTarget::GLIBC)) {
$result = shell()->execWithResult('ldd --version', false);
if ($result[0] !== 0) {
return null;
Expand All @@ -208,7 +209,7 @@ public static function getLibcVersionIfExists(): ?string
}
return null;
}
if (PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') === 'musl') {
if (SPCTarget::isTarget(SPCTarget::MUSL_STATIC)) {
if (self::isMuslDist()) {
$result = shell()->execWithResult('ldd 2>&1', false);
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/SPC/builder/linux/library/icu.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace SPC\builder\linux\library;

use SPC\store\FileSystem;
use SPC\util\SPCTarget;

class icu extends LinuxLibraryBase
{
Expand All @@ -16,7 +17,7 @@ protected function build(): void
{
$cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1 -DPIC -fPIC"';
$cxxflags = 'CXXFLAGS="-std=c++17 -DPIC -fPIC -fno-ident"';
$ldflags = getenv('SPC_LIBC') !== 'glibc' ? 'LDFLAGS="-static"' : '';
$ldflags = SPCTarget::isTarget(SPCTarget::MUSL_STATIC) ? 'LDFLAGS="-static"' : '';
shell()->cd($this->source_dir . '/source')->initializeEnv($this)
->exec(
"{$cppflags} {$cxxflags} {$ldflags} " .
Expand Down
5 changes: 3 additions & 2 deletions src/SPC/builder/unix/UnixBuilderBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use SPC\store\FileSystem;
use SPC\util\DependencyUtil;
use SPC\util\SPCConfigUtil;
use SPC\util\SPCTarget;

abstract class UnixBuilderBase extends BuilderBase
{
Expand Down Expand Up @@ -200,7 +201,7 @@ protected function sanityCheck(int $build_target): void
$util = new SPCConfigUtil($this);
$config = $util->config($this->ext_list, $this->lib_list, $this->getOption('with-suggested-exts'), $this->getOption('with-suggested-libs'));
$lens = "{$config['cflags']} {$config['ldflags']} {$config['libs']}";
if (PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') === 'musl') {
if (SPCTarget::isTarget(SPCTarget::MUSL_STATIC)) {
$lens .= ' -static';
}
[$ret, $out] = shell()->cd($sample_file_path)->execWithResult(getenv('CC') . ' -o embed embed.c ' . $lens);
Expand Down Expand Up @@ -334,7 +335,7 @@ protected function buildFrankenphp(): void
$debugFlags = $this->getOption('no-strip') ? "'-w -s' " : '';
$extLdFlags = "-extldflags '-pie'";
$muslTags = '';
if (PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') === 'musl') {
if (SPCTarget::isTarget(SPCTarget::MUSL_STATIC)) {
$extLdFlags = "-extldflags '-static-pie -Wl,-z,stack-size=0x80000'";
$muslTags = 'static_build,';
}
Expand Down
11 changes: 5 additions & 6 deletions src/SPC/builder/unix/library/imagemagick.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

namespace SPC\builder\unix\library;

use SPC\builder\linux\library\LinuxLibraryBase;
use SPC\builder\macos\library\MacOSLibraryBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
use SPC\util\executor\UnixAutoconfExecutor;
use SPC\util\SPCTarget;

trait imagemagick
{
Expand All @@ -33,16 +32,16 @@ protected function build(): void
->optionalLib('bzip2', ...ac_with_args('bzlib'))
->addConfigureArgs(
// TODO: glibc rh 10 toolset's libgomp.a was built without -fPIC so we can't use openmp without depending on libgomp.so
getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10') ? '--disable-openmp' : '--enable-openmp',
SPCTarget::isTarget(SPCTarget::GLIBC) ? '--disable-openmp' : '--enable-openmp',
'--without-jxl',
'--without-x',
);

// special: linux musl needs `-static`
$ldflags = ($this instanceof LinuxLibraryBase) && getenv('SPC_LIBC') !== 'glibc' ? ('-static -ldl') : '-ldl';
// special: linux musl-static needs `-static`
$ldflags = !SPCTarget::isTarget(SPCTarget::MUSL_STATIC) ? ('-static -ldl') : '-ldl';

// special: macOS needs -iconv
$libs = $this instanceof MacOSLibraryBase ? '-liconv' : '';
$libs = SPCTarget::isTarget(SPCTarget::MACHO) ? '-liconv' : '';

$ac->appendEnv([
'LDFLAGS' => $ldflags,
Expand Down
3 changes: 2 additions & 1 deletion src/SPC/builder/unix/library/ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

use SPC\store\FileSystem;
use SPC\util\executor\UnixAutoconfExecutor;
use SPC\util\SPCTarget;

trait ldap
{
public function patchBeforeBuild(): bool
{
$extra = getenv('SPC_LIBC') === 'glibc' ? '-ldl -lpthread -lm -lresolv -lutil' : '';
$extra = SPCTarget::isTarget(SPCTarget::GLIBC) ? '-ldl -lpthread -lm -lresolv -lutil' : '';
FileSystem::replaceFileStr($this->source_dir . '/configure', '"-lssl -lcrypto', '"-lssl -lcrypto -lz ' . $extra);
return true;
}
Expand Down
8 changes: 7 additions & 1 deletion src/SPC/builder/unix/library/libxslt.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ protected function build(): void
'--without-debugger',
"--with-libxml-prefix={$this->getBuildRootPath()}",
);
$ac->exec("{$this->builder->getOption('library_path')} {$this->builder->getOption('ld_library_path')} ./configure {$ac->getConfigureArgsString()}")->make();
if (getenv('SPC_LINUX_DEFAULT_LD_LIBRARY_PATH') && getenv('SPC_LINUX_DEFAULT_LIBRARY_PATH')) {
$ac->appendEnv([
'LD_LIBRARY_PATH' => getenv('SPC_LINUX_DEFAULT_LD_LIBRARY_PATH'),
'LIBRARY_PATH' => getenv('SPC_LINUX_DEFAULT_LIBRARY_PATH'),
]);
}
$ac->configure()->make();

$this->patchPkgconfPrefix(['libexslt.pc']);
$this->patchLaDependencyPrefix();
Expand Down
3 changes: 2 additions & 1 deletion src/SPC/builder/unix/library/mimalloc.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace SPC\builder\unix\library;

use SPC\util\executor\UnixCMakeExecutor;
use SPC\util\SPCTarget;

trait mimalloc
{
Expand All @@ -15,7 +16,7 @@ protected function build(): void
'-DMI_BUILD_SHARED=OFF',
'-DMI_INSTALL_TOPLEVEL=ON'
);
if (getenv('SPC_LIBC') === 'musl') {
if (SPCTarget::isTarget(SPCTarget::MUSL) || SPCTarget::isTarget(SPCTarget::MUSL_STATIC)) {
$cmake->addConfigureArgs('-DMI_LIBC_MUSL=ON');
}
$cmake->build();
Expand Down
4 changes: 2 additions & 2 deletions src/SPC/builder/unix/library/pkgconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace SPC\builder\unix\library;

use SPC\builder\linux\library\LinuxLibraryBase;
use SPC\util\executor\UnixAutoconfExecutor;
use SPC\util\SPCTarget;

trait pkgconfig
{
Expand All @@ -14,7 +14,7 @@ protected function build(): void
UnixAutoconfExecutor::create($this)
->appendEnv([
'CFLAGS' => PHP_OS_FAMILY !== 'Linux' ? '-Wimplicit-function-declaration -Wno-int-conversion' : '',
'LDFLAGS' => !($this instanceof LinuxLibraryBase) || getenv('SPC_LIBC') === 'glibc' ? '' : '--static',
'LDFLAGS' => SPCTarget::isStaticTarget() ? '--static' : '',
])
->configure(
'--with-internal-glib',
Expand Down
3 changes: 2 additions & 1 deletion src/SPC/builder/unix/library/postgresql.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
use SPC\util\SPCTarget;

trait postgresql
{
Expand Down Expand Up @@ -50,7 +51,7 @@ protected function build(): void
$error_exec_cnt += $output[0] === 0 ? 0 : 1;
if (!empty($output[1][0])) {
$ldflags = $output[1][0];
$envs .= !($this instanceof LinuxLibraryBase) || getenv('SPC_LIBC') === 'glibc' ? " LDFLAGS=\"{$ldflags}\" " : " LDFLAGS=\"{$ldflags} -static\" ";
$envs .= SPCTarget::isTarget(SPCTarget::MUSL_STATIC) ? " LDFLAGS=\"{$ldflags} -static\" " : " LDFLAGS=\"{$ldflags}\" ";
}
$output = shell()->execWithResult("pkg-config --libs-only-l --static {$packages}");
$error_exec_cnt += $output[0] === 0 ? 0 : 1;
Expand Down
5 changes: 4 additions & 1 deletion src/SPC/command/BuildPHPCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use SPC\util\DependencyUtil;
use SPC\util\GlobalEnvManager;
use SPC\util\LicenseDumper;
use SPC\util\SPCTarget;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
Expand Down Expand Up @@ -63,7 +64,7 @@ public function handle(): int

// check dynamic extension build env
// linux must build with glibc
if (!empty($shared_extensions) && PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') !== 'glibc') {
if (!empty($shared_extensions) && SPCTarget::isTarget(SPCTarget::MUSL_STATIC)) {
$this->output->writeln('Linux does not support dynamic extension loading with musl-libc full-static build, please build with glibc!');
return static::FAILURE;
}
Expand Down Expand Up @@ -133,6 +134,8 @@ public function handle(): int
// print info
$indent_texts = [
'Build OS' => PHP_OS_FAMILY . ' (' . php_uname('m') . ')',
'Build Target' => getenv('SPC_TARGET'),
'Build Toolchain' => getenv('SPC_TOOLCHAIN'),
'Build SAPI' => $builder->getBuildTypeName($rule),
'Static Extensions (' . count($static_extensions) . ')' => implode(',', $static_extensions),
'Shared Extensions (' . count($shared_extensions) . ')' => implode(',', $shared_extensions),
Expand Down
Loading
Loading