diff --git a/config/source.json b/config/source.json
index 2f1e2e418..3c052a26d 100644
--- a/config/source.json
+++ b/config/source.json
@@ -249,7 +249,7 @@
},
"libxml2": {
"type": "url",
- "url": "https://gitlab.gnome.org/GNOME/libxml2/-/archive/v2.9.14/libxml2-v2.9.14.tar.gz",
+ "url": "https://github.com/GNOME/libxml2/archive/refs/tags/v2.9.14.tar.gz",
"license": {
"type": "file",
"path": "Copyright"
diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php
index 1c3c84fb9..472d93821 100644
--- a/src/SPC/builder/BuilderBase.php
+++ b/src/SPC/builder/BuilderBase.php
@@ -252,6 +252,9 @@ public function getBuildTypeName(int $type): string
if (($type & BUILD_TARGET_FPM) === BUILD_TARGET_FPM) {
$ls[] = 'fpm';
}
+ if (($type & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED) {
+ $ls[] = 'embed';
+ }
return implode(', ', $ls);
}
diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php
index 431fe4901..7859139e1 100644
--- a/src/SPC/builder/linux/LinuxBuilder.php
+++ b/src/SPC/builder/linux/LinuxBuilder.php
@@ -179,6 +179,11 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
$zts = '';
}
+ $enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI;
+ $enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM;
+ $enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
+ $enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
+
shell()->cd(SOURCE_PATH . '/php-src')
->exec(
'./configure ' .
@@ -189,12 +194,13 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
'--disable-all ' .
'--disable-cgi ' .
'--disable-phpdbg ' .
- '--enable-cli ' .
- '--enable-fpm ' .
+ ($enableCli ? '--enable-cli ' : '--disable-cli ') .
+ ($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
+ ($enableEmbed ? '--enable-embed=static --disable-opcache-jit ' : '--disable-embed ') .
$json_74 .
$zts .
$maxExecutionTimers .
- '--enable-micro=all-static ' .
+ ($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') .
$this->makeExtensionArgs() . ' ' .
$envs
);
@@ -203,18 +209,22 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
$this->cleanMake();
- if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) {
+ if ($enableCli) {
logger()->info('building cli');
$this->buildCli($extra_libs, $use_lld);
}
- if (($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM) {
+ if ($enableFpm) {
logger()->info('building fpm');
$this->buildFpm($extra_libs, $use_lld);
}
- if (($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO) {
+ if ($enableMicro) {
logger()->info('building micro');
$this->buildMicro($extra_libs, $use_lld, $cflags);
}
+ if ($enableEmbed) {
+ logger()->info('building embed');
+ $this->buildEmbed($extra_libs, $use_lld);
+ }
if (php_uname('m') === $this->getOption('arch')) {
$this->sanityCheck($build_target);
@@ -306,4 +316,18 @@ public function buildFpm(string $extra_libs, string $use_lld): void
$this->deployBinary(BUILD_TARGET_FPM);
}
+
+ public function buildEmbed(string $extra_libs, string $use_lld): void
+ {
+ $vars = SystemUtil::makeEnvVarString([
+ 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)),
+ 'EXTRA_LIBS' => $extra_libs,
+ 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static",
+ ]);
+
+ shell()
+ ->cd(SOURCE_PATH . '/php-src')
+ ->exec('sed -i "s|//lib|/lib|g" Makefile')
+ ->exec('make INSTALL_ROOT=' . BUILD_ROOT_PATH . " -j{$this->concurrency} {$vars} install");
+ }
}
diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php
index 0e8c98f00..d179a1bcc 100644
--- a/src/SPC/builder/macos/MacOSBuilder.php
+++ b/src/SPC/builder/macos/MacOSBuilder.php
@@ -151,6 +151,11 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
$json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : '';
$zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : '';
+ $enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI;
+ $enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM;
+ $enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
+ $enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
+
shell()->cd(SOURCE_PATH . '/php-src')
->exec(
'./configure ' .
@@ -162,9 +167,10 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
'--disable-all ' .
'--disable-cgi ' .
'--disable-phpdbg ' .
- '--enable-cli ' .
- '--enable-fpm ' .
- '--enable-micro ' .
+ ($enableCli ? '--enable-cli ' : '--disable-cli ') .
+ ($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
+ ($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') .
+ ($enableMicro ? '--enable-micro ' : '--disable-micro ') .
$json_74 .
$zts .
$this->makeExtensionArgs() . ' ' .
@@ -175,18 +181,22 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
$this->cleanMake();
- if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) {
+ if ($enableCli) {
logger()->info('building cli');
$this->buildCli();
}
- if (($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM) {
+ if ($enableFpm) {
logger()->info('building fpm');
$this->buildFpm();
}
- if (($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO) {
+ if ($enableMicro) {
logger()->info('building micro');
$this->buildMicro();
}
+ if ($enableEmbed) {
+ logger()->info('building embed');
+ $this->buildEmbed();
+ }
if (php_uname('m') === $this->getOption('arch')) {
$this->sanityCheck($build_target);
@@ -207,7 +217,7 @@ public function buildCli(): void
{
$vars = SystemUtil::makeEnvVarString([
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
- 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS need it)
+ 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS needs it)
]);
$shell = shell()->cd(SOURCE_PATH . '/php-src');
@@ -237,7 +247,7 @@ public function buildMicro(): void
$vars = [
// with debug information, optimize for size, remove identifiers, patch fake cli for micro
'EXTRA_CFLAGS' => '-g -Os -fno-ident' . $enable_fake_cli,
- // link resolv library (macOS need it)
+ // link resolv library (macOS needs it)
'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv",
];
if (!$this->getOption('no-strip', false)) {
@@ -260,7 +270,7 @@ public function buildFpm(): void
{
$vars = SystemUtil::makeEnvVarString([
'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
- 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS need it)
+ 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS needs it)
]);
$shell = shell()->cd(SOURCE_PATH . '/php-src');
@@ -270,4 +280,24 @@ public function buildFpm(): void
}
$this->deployBinary(BUILD_TARGET_FPM);
}
+
+ public function buildEmbed(): void
+ {
+ $vars = SystemUtil::makeEnvVarString([
+ 'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size
+ 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS needs it)
+ ]);
+
+ shell()
+ ->cd(SOURCE_PATH . '/php-src')
+ ->exec('make INSTALL_ROOT=' . BUILD_ROOT_PATH . " -j{$this->concurrency} {$vars} install")
+ // Workaround for https://github.com/php/php-src/issues/12082
+ ->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o')
+ ->exec('mkdir ' . BUILD_ROOT_PATH . '/lib/php-o')
+ ->cd(BUILD_ROOT_PATH . '/lib/php-o')
+ ->exec('ar x ' . BUILD_ROOT_PATH . '/lib/libphp.a')
+ ->exec('rm ' . BUILD_ROOT_PATH . '/lib/libphp.a')
+ ->exec('ar rcs ' . BUILD_ROOT_PATH . '/lib/libphp.a *.o')
+ ->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o');
+ }
}
diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php
index 517f30d76..ee461793a 100644
--- a/src/SPC/command/BuildCliCommand.php
+++ b/src/SPC/command/BuildCliCommand.php
@@ -25,7 +25,8 @@ public function configure(): void
$this->addOption('build-micro', null, null, 'build micro');
$this->addOption('build-cli', null, null, 'build cli');
$this->addOption('build-fpm', null, null, 'build fpm');
- $this->addOption('build-all', null, null, 'build cli, micro, fpm');
+ $this->addOption('build-embed', null, null, 'build embed');
+ $this->addOption('build-all', null, null, 'build cli, micro, fpm, embed');
$this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions');
$this->addOption('enable-zts', null, null, 'enable ZTS support');
$this->addOption('with-hardcoded-ini', 'I', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Patch PHP source code, inject hardcoded INI');
@@ -43,13 +44,15 @@ public function handle(): int
$rule = $rule | ($this->getOption('build-cli') ? BUILD_TARGET_CLI : BUILD_TARGET_NONE);
$rule = $rule | ($this->getOption('build-micro') ? BUILD_TARGET_MICRO : BUILD_TARGET_NONE);
$rule = $rule | ($this->getOption('build-fpm') ? BUILD_TARGET_FPM : BUILD_TARGET_NONE);
+ $rule = $rule | ($this->getOption('build-embed') ? BUILD_TARGET_EMBED : BUILD_TARGET_NONE);
$rule = $rule | ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE);
if ($rule === BUILD_TARGET_NONE) {
$this->output->writeln('Please add at least one build target!');
$this->output->writeln("\t--build-cli\tBuild php-cli SAPI");
$this->output->writeln("\t--build-micro\tBuild phpmicro SAPI");
$this->output->writeln("\t--build-fpm\tBuild php-fpm SAPI");
- $this->output->writeln("\t--build-all\tBuild all SAPI: cli, micro, fpm");
+ $this->output->writeln("\t--build-embed\tBuild embed SAPI/libphp");
+ $this->output->writeln("\t--build-all\tBuild all SAPI: cli, micro, fpm, embed");
return static::FAILURE;
}
try {
diff --git a/src/globals/defines.php b/src/globals/defines.php
index 28473296a..150b27533 100644
--- a/src/globals/defines.php
+++ b/src/globals/defines.php
@@ -43,7 +43,8 @@
const BUILD_TARGET_CLI = 1; // build cli
const BUILD_TARGET_MICRO = 2; // build micro
const BUILD_TARGET_FPM = 4; // build fpm
-const BUILD_TARGET_ALL = 7; // build all
+const BUILD_TARGET_EMBED = 8; // build embed
+const BUILD_TARGET_ALL = 15; // build all
// doctor error fix policy
const FIX_POLICY_DIE = 1; // die directly