diff --git a/src/SPC/builder/extension/readline.php b/src/SPC/builder/extension/readline.php index dc4d15f7..939484da 100644 --- a/src/SPC/builder/extension/readline.php +++ b/src/SPC/builder/extension/readline.php @@ -27,7 +27,12 @@ class readline extends Extension public function getUnixConfigureArg(bool $shared = false): string { - return '--without-libedit --with-readline=' . BUILD_ROOT_PATH; + $enable = '--without-libedit --with-readline=' . BUILD_ROOT_PATH; + if ($this->builder->getPHPVersionID() < 84000) { + // the check uses `char rl_pending_input()` instead of `extern int rl_pending_input`, which makes LTO fail + $enable .= ' ac_cv_lib_readline_rl_pending_input=yes'; + } + return $enable; } public function buildUnixShared(): void diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index da3e12fb..28edeb22 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -104,10 +104,6 @@ class LinuxBuilder extends UnixBuilderBase ); } - $extra = ''; - if ($this->getPHPVersionID() < 84000 && $this->getExt('readline') && $this->getLib('libreadline') !== null) { - $extra = 'ac_cv_lib_readline_rl_pending_input=yes'; - } shell()->cd(SOURCE_PATH . '/php-src') ->exec( $php_configure_env . ' ' . @@ -122,8 +118,7 @@ class LinuxBuilder extends UnixBuilderBase $json_74 . $zts . $maxExecutionTimers . - $this->makeStaticExtensionArgs() . ' ' . - $extra + $this->makeStaticExtensionArgs() . ' ' ); $this->emitPatchPoint('before-php-make'); diff --git a/src/SPC/builder/unix/library/librdkafka.php b/src/SPC/builder/unix/library/librdkafka.php index 3df7a931..e2c3b46e 100644 --- a/src/SPC/builder/unix/library/librdkafka.php +++ b/src/SPC/builder/unix/library/librdkafka.php @@ -11,11 +11,7 @@ use SPC\util\executor\UnixAutoconfExecutor; trait librdkafka { - /** - * @throws FileSystemException - * @throws RuntimeException - */ - protected function build(): void + public function patchBeforeBuild(): bool { FileSystem::replaceFileStr( $this->source_dir . '/lds-gen.py', @@ -27,6 +23,15 @@ trait librdkafka '#error "IOV_MAX not defined"', "#define IOV_MAX 1024\n#define __GNU__" ); + return true; + } + + /** + * @throws FileSystemException + * @throws RuntimeException + */ + protected function build(): void + { UnixAutoconfExecutor::create($this) ->appendEnv(['CFLAGS' => '-Wno-int-conversion -Wno-unused-but-set-variable -Wno-unused-variable']) ->optionalLib( diff --git a/src/SPC/toolchain/ToolchainManager.php b/src/SPC/toolchain/ToolchainManager.php index ad40b61d..0c92c58a 100644 --- a/src/SPC/toolchain/ToolchainManager.php +++ b/src/SPC/toolchain/ToolchainManager.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace SPC\toolchain; use SPC\builder\linux\SystemUtil; -use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\util\GlobalEnvManager; use SPC\util\SPCTarget; @@ -55,10 +54,10 @@ class ToolchainManager } $musl_wrapper_lib = sprintf('/lib/ld-musl-%s.so.1', php_uname('m')); if (SPCTarget::getLibc() === 'musl' && !SPCTarget::isStatic() && !file_exists($musl_wrapper_lib)) { - throw new RuntimeException('You are linking against musl libc dynamically, but musl libc is not installed. Please install it with `sudo dnf install musl-libc` or `sudo apt install musl`'); + throw new WrongUsageException('You are linking against musl libc dynamically, but musl libc is not installed. Please use `bin/spc doctor` to install it.'); } if (SPCTarget::getLibc() === 'glibc' && SystemUtil::isMuslDist()) { - throw new RuntimeException('You are linking against glibc dynamically, which is only supported on musl distros.'); + throw new WrongUsageException('You are linking against glibc dynamically, which is only supported on glibc distros.'); } $toolchain = getenv('SPC_TOOLCHAIN'); /* @var ToolchainInterface $toolchain */