diff --git a/config/pkg/lib/librdkafka.yml b/config/pkg/lib/librdkafka.yml index cb83fb43c..76566bf68 100644 --- a/config/pkg/lib/librdkafka.yml +++ b/config/pkg/lib/librdkafka.yml @@ -4,6 +4,11 @@ librdkafka: source: type: ghtar repo: confluentinc/librdkafka + source-mirror: + type: url + url: 'https://github.com/confluentinc/librdkafka/archive/refs/tags/v2.16.0.tar.gz' + filename: librdkafka-2.16.0.tar.gz + version: 2.16.0 metadata: license-files: [LICENSE] license: BSD-2-Clause diff --git a/src/Package/Extension/gmssl.php b/src/Package/Extension/gmssl.php index ee23eed00..59e128a9c 100644 --- a/src/Package/Extension/gmssl.php +++ b/src/Package/Extension/gmssl.php @@ -16,10 +16,14 @@ class gmssl extends PhpExtensionPackage { #[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-gmssl')] #[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-gmssl')] - #[PatchDescription('Fix ext-gmssl v1.1.1 compatibility with GmSSL >= 3.1.0 where SM2_VERIFY_CTX was removed (unified into SM2_SIGN_CTX)')] + #[PatchDescription('Fix ext-gmssl compatibility with GmSSL versions where SM2_VERIFY_CTX was removed (unified into SM2_SIGN_CTX)')] public function patchSm2VerifyCtx(): void { // See: https://github.com/crazywhalecc/static-php-cli/issues/1182 + $header = BUILD_INCLUDE_PATH . '/gmssl/sm2.h'; + if (file_exists($header) && str_contains(FileSystem::readFile($header), 'SM2_VERIFY_CTX')) { + return; + } FileSystem::replaceFileStr( "{$this->getBuildDir()}/gmssl.c", 'SM2_VERIFY_CTX', diff --git a/src/Package/Extension/openssl.php b/src/Package/Extension/openssl.php index 3453b5f5a..c5c6f5c60 100644 --- a/src/Package/Extension/openssl.php +++ b/src/Package/Extension/openssl.php @@ -33,7 +33,7 @@ public function getUnixConfigureArg(PackageBuilder $builder, bool $shared = fals $openssl_dir = php::getPHPVersionID() >= 80400 ? '' : ' --with-openssl-dir=' . BUILD_ROOT_PATH; $args = '--with-openssl=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $openssl_dir; if (php::getPHPVersionID() >= 80500 || (php::getPHPVersionID() >= 80400 && !$builder->getOption('enable-zts'))) { - $args .= ' --with-openssl-argon2 OPENSSL_LIBS="-lz"'; + $args .= ' --with-openssl-argon2 OPENSSL_LIBS="-lssl -lcrypto -lz"'; } return $args; } diff --git a/src/Package/Target/php/unix.php b/src/Package/Target/php/unix.php index 9bda4dac2..a05ef7dc9 100644 --- a/src/Package/Target/php/unix.php +++ b/src/Package/Target/php/unix.php @@ -144,9 +144,16 @@ public function configureForUnix(TargetPackage $package, PackageInstaller $insta } // Configure probes need macOS frameworks, but not static libraries that expose polyfills. + $config_util = new SPCConfigUtil(); + $resolved_package_names = array_keys($installer->getResolvedPackages()); $libs = SystemTarget::getRuntimeLibs(); + // Extension configure checks link against static C++ libraries (e.g. -lgearman, -lsnappy), + // so the probe link lines need the C++ runtime for the same reason the final link does. + if ($libcpp = $config_util->getCppRuntimeLib($resolved_package_names)) { + $libs = trim("{$libs} {$libcpp}"); + } if (SystemTarget::getTargetOS() === 'Darwin') { - $frameworks = new SPCConfigUtil()->getFrameworksString(array_keys($installer->getResolvedPackages())); + $frameworks = $config_util->getFrameworksString($resolved_package_names); $libs = trim("{$libs} {$frameworks}"); } diff --git a/src/StaticPHP/Util/SPCConfigUtil.php b/src/StaticPHP/Util/SPCConfigUtil.php index 78232b135..b040bbbc5 100644 --- a/src/StaticPHP/Util/SPCConfigUtil.php +++ b/src/StaticPHP/Util/SPCConfigUtil.php @@ -237,17 +237,8 @@ public function configWithResolvedPackages(array $resolved_package_names): array } // C++ - if ($this->hasCpp($resolved_package_names)) { - $target_os = SystemTarget::getTargetOS(); - if ($target_os === 'Darwin') { - $libcpp = '-lc++'; - $libs = str_replace($libcpp, '', $libs) . " {$libcpp}"; - } elseif ($target_os !== 'Windows') { - // Linux and other Unix-like systems use libstdc++ - $libcpp = '-lstdc++'; - $libs = str_replace($libcpp, '', $libs) . " {$libcpp}"; - } - // Windows (MSVC): C++ runtime is linked automatically, no explicit lib needed + if ($libcpp = $this->getCppRuntimeLib($resolved_package_names)) { + $libs = str_replace($libcpp, '', $libs) . " {$libcpp}"; } if ($this->libs_only_deps) { @@ -304,6 +295,30 @@ public function getFrameworksString(array $package_names): string return implode(' ', $list); } + /** + * Get the C++ runtime linker flag for the given resolved packages. + * + * Static archives of C++ dependencies (e.g. libgearman, libsnappy) keep references to the + * C++ runtime, so every link that pulls them needs this flag - including the throwaway + * conftests configure runs while probing an extension configure arg. + * + * @param string[] $package_names Resolved package names (build order) + * @return null|string Linker flag, or null when no C++ package is resolved + */ + public function getCppRuntimeLib(array $package_names): ?string + { + if (!$this->hasCpp($package_names)) { + return null; + } + return match (SystemTarget::getTargetOS()) { + 'Darwin' => '-lc++', + // Windows (MSVC): C++ runtime is linked automatically, no explicit lib needed + 'Windows' => null, + // Linux and other Unix-like systems use libstdc++ + default => '-lstdc++', + }; + } + /** @param string[] $package_names */ private function hasCpp(array $package_names): bool {