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
5 changes: 5 additions & 0 deletions config/pkg/lib/librdkafka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/Package/Extension/gmssl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/Package/Extension/openssl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bit surprised but no objection

}
return $args;
}
Expand Down
9 changes: 8 additions & 1 deletion src/Package/Target/php/unix.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}

Expand Down
37 changes: 26 additions & 11 deletions src/StaticPHP/Util/SPCConfigUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
{
Expand Down
Loading