Merge branch 'main' into fix/grpc-build

This commit is contained in:
Jerry Ma 2026-03-10 14:52:21 +09:00 committed by GitHub
commit 2350d2d5ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 47 additions and 15 deletions

View File

@ -862,6 +862,9 @@
}, },
"openssl": { "openssl": {
"source": "openssl", "source": "openssl",
"pkg-configs": [
"openssl"
],
"static-libs-unix": [ "static-libs-unix": [
"libssl.a", "libssl.a",
"libcrypto.a" "libcrypto.a"
@ -974,6 +977,11 @@
}, },
"unixodbc": { "unixodbc": {
"source": "unixodbc", "source": "unixodbc",
"pkg-configs": [
"odbc",
"odbccr",
"odbcinst"
],
"static-libs-unix": [ "static-libs-unix": [
"libodbc.a", "libodbc.a",
"libodbccr.a", "libodbccr.a",
@ -1015,6 +1023,9 @@
}, },
"zlib": { "zlib": {
"source": "zlib", "source": "zlib",
"pkg-configs": [
"zlib"
],
"static-libs-unix": [ "static-libs-unix": [
"libz.a" "libz.a"
], ],
@ -1028,6 +1039,9 @@
}, },
"zstd": { "zstd": {
"source": "zstd", "source": "zstd",
"pkg-configs": [
"libzstd"
],
"static-libs-unix": [ "static-libs-unix": [
"libzstd.a" "libzstd.a"
], ],

View File

@ -96,7 +96,8 @@ class Extension
fn ($x) => $x->getStaticLibFiles(), fn ($x) => $x->getStaticLibFiles(),
$this->getLibraryDependencies(recursive: true) $this->getLibraryDependencies(recursive: true)
); );
return implode(' ', $ret); $libs = implode(' ', $ret);
return deduplicate_flags($libs);
} }
/** /**

View File

@ -365,6 +365,27 @@ abstract class LibraryBase
protected function isLibraryInstalled(): bool protected function isLibraryInstalled(): bool
{ {
if ($pkg_configs = Config::getLib(static::NAME, 'pkg-configs', [])) {
$pkg_config_path = getenv('PKG_CONFIG_PATH') ?: '';
$search_paths = array_unique(array_filter(explode(is_unix() ? ':' : ';', $pkg_config_path)));
foreach ($pkg_configs as $name) {
$found = false;
foreach ($search_paths as $path) {
if (file_exists($path . "/{$name}.pc")) {
$found = true;
break;
}
}
if (!$found) {
return false;
}
}
// allow using system dependencies if pkg_config_path is explicitly defined
if (count($search_paths) > 1) {
return true;
}
}
foreach (Config::getLib(static::NAME, 'static-libs', []) as $name) { foreach (Config::getLib(static::NAME, 'static-libs', []) as $name) {
if (!file_exists(BUILD_LIB_PATH . "/{$name}")) { if (!file_exists(BUILD_LIB_PATH . "/{$name}")) {
return false; return false;

View File

@ -72,6 +72,10 @@ trait UnixSystemUtilTrait
if (!is_file($symbol_file)) { if (!is_file($symbol_file)) {
throw new SPCInternalException("The symbol file {$symbol_file} does not exist, please check if nm command is available."); throw new SPCInternalException("The symbol file {$symbol_file} does not exist, please check if nm command is available.");
} }
// https://github.com/ziglang/zig/issues/24662
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
return '-Wl,--export-dynamic'; // needs release 0.16, can be removed then
}
// macOS/zig // macOS/zig
if (SPCTarget::getTargetOS() !== 'Linux' || ToolchainManager::getToolchainClass() === ZigToolchain::class) { if (SPCTarget::getTargetOS() !== 'Linux' || ToolchainManager::getToolchainClass() === ZigToolchain::class) {
return "-Wl,-exported_symbols_list,{$symbol_file}"; return "-Wl,-exported_symbols_list,{$symbol_file}";

View File

@ -458,6 +458,7 @@ abstract class UnixBuilderBase extends BuilderBase
'-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . '-ldflags \"-linkmode=external ' . $extLdFlags . ' ' .
'-X \'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy\' ' . '-X \'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy\' ' .
'-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' . '-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' .
'-X \'github.com/caddyserver/caddy/v2.CustomBinaryName=frankenphp ' .
"v{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " . "v{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " .
"-tags={$muslTags}nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}", "-tags={$muslTags}nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}",
'LD_LIBRARY_PATH' => BUILD_LIB_PATH, 'LD_LIBRARY_PATH' => BUILD_LIB_PATH,

View File

@ -93,8 +93,7 @@ trait postgresql
// remove dynamic libs // remove dynamic libs
shell()->cd($this->source_dir . '/build') shell()->cd($this->source_dir . '/build')
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so.*") ->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so*")
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so")
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.dylib"); ->exec("rm -rf {$this->getBuildRootPath()}/lib/*.dylib");
FileSystem::replaceFileStr("{$this->getLibDir()}/pkgconfig/libpq.pc", '-lldap', '-lldap -llber'); FileSystem::replaceFileStr("{$this->getLibDir()}/pkgconfig/libpq.pc", '-lldap', '-lldap -llber');

View File

@ -16,12 +16,11 @@ class UnixAutoconfExecutor extends Executor
protected array $configure_args = []; protected array $configure_args = [];
protected array $ignore_args = [];
public function __construct(protected BSDLibraryBase|LinuxLibraryBase|MacOSLibraryBase $library) public function __construct(protected BSDLibraryBase|LinuxLibraryBase|MacOSLibraryBase $library)
{ {
parent::__construct($library); parent::__construct($library);
$this->initShell(); $this->initShell();
$this->configure_args = $this->getDefaultConfigureArgs();
} }
/** /**
@ -29,19 +28,12 @@ class UnixAutoconfExecutor extends Executor
*/ */
public function configure(...$args): static public function configure(...$args): static
{ {
// remove all the ignored args $args = array_merge($args, $this->configure_args);
$args = array_merge($args, $this->getDefaultConfigureArgs(), $this->configure_args);
$args = array_diff($args, $this->ignore_args);
$configure_args = implode(' ', $args); $configure_args = implode(' ', $args);
return $this->seekLogFileOnException(fn () => $this->shell->exec("./configure {$configure_args}")); return $this->seekLogFileOnException(fn () => $this->shell->exec("./configure {$configure_args}"));
} }
public function getConfigureArgsString(): string
{
return implode(' ', array_merge($this->getDefaultConfigureArgs(), $this->configure_args));
}
/** /**
* Run make * Run make
* *
@ -111,7 +103,7 @@ class UnixAutoconfExecutor extends Executor
*/ */
public function removeConfigureArgs(...$args): static public function removeConfigureArgs(...$args): static
{ {
$this->ignore_args = [...$this->ignore_args, ...$args]; $this->configure_args = array_diff($this->configure_args, $args);
return $this; return $this;
} }
@ -133,8 +125,8 @@ class UnixAutoconfExecutor extends Executor
private function getDefaultConfigureArgs(): array private function getDefaultConfigureArgs(): array
{ {
return [ return [
'--disable-shared',
'--enable-static', '--enable-static',
'--disable-shared',
"--prefix={$this->library->getBuildRootPath()}", "--prefix={$this->library->getBuildRootPath()}",
'--with-pic', '--with-pic',
'--enable-pic', '--enable-pic',