Compare commits

...

59 Commits

Author SHA1 Message Date
Marc
f680731f9d fix: Postgres build with ancient libc (#1029) 2026-02-11 17:42:36 +01:00
Jerry Ma
0fe1442f7e Bump version from 2.8.0 to 2.8.2 2026-02-12 00:02:38 +08:00
Jerry Ma
1e4780397b Update test-extensions.php for PHP versions and extensions
Commented out older PHP versions and Windows 2025 in the test configuration. Updated the extensions to test for Linux and Darwin.
2026-02-11 23:32:19 +08:00
Kévin Dunglas
6b67cb90fc fix: Postgres build with ancient libc 2026-02-11 16:24:13 +01:00
Jerry Ma
b89ff3c083 Add com_dotnet extension (#1023) 2026-02-03 19:08:19 +08:00
Marc
0cfa2036f0 fix spx shared libadd (#1022) 2026-01-30 20:23:18 +01:00
henderkes
c5882c1f8e fix gettext v1.0 release 2026-01-30 19:41:39 +01:00
henderkes
4531c9fe57 add option to allow linking musl dynamically on alpine 2026-01-27 00:57:58 +01:00
henderkes
223dd10ac6 fix spx shared libadd 2026-01-24 20:26:19 +01:00
Marc
1c28f0f455 bunch of fixes/changes to make packages build (#1006) 2026-01-19 12:46:24 +01:00
henderkes
b3c450291a up version 2026-01-19 12:00:06 +01:00
crazywhalecc
372760e469 Update patch point docs 2026-01-19 18:56:28 +08:00
henderkes
6cf4c40cd2 Merge remote-tracking branch 'origin/main' into henderkes-patch-1 2026-01-19 11:22:03 +01:00
henderkes
af75ffaf24 suggestions, change openssldir 2026-01-19 10:22:33 +01:00
Marc
ae0217b3a1 add excimer extension (#1018) 2026-01-19 09:25:30 +01:00
henderkes
1e2b4017ac test excimer 2026-01-17 11:28:47 +01:00
henderkes
19f941797e zig now supports -Wl,-exported_symbols_list 2026-01-17 11:28:05 +01:00
Marc
0b863cbc70 Merge branch 'main' into feat/excimer 2026-01-17 10:53:35 +01:00
henderkes
b09337de09 add excimer extension 2026-01-17 10:51:21 +01:00
henderkes
d902e70b4d fix arm64 builds 2026-01-16 12:28:41 +01:00
Jerry Ma
cd2dc5bce4 Fix nghttp2 and curl build configurations for static linking (#1014) 2026-01-13 16:51:57 +08:00
henderkes
34910d18e9 add patch point for shared ext build 2026-01-04 02:31:41 +01:00
henderkes
3a17cec521 deploy extensions with -release flag too 2026-01-03 19:15:57 +01:00
henderkes
94644d374f fix 2026-01-03 19:12:16 +01:00
henderkes
f8b0c2c980 add release thing to extension build too 2026-01-03 19:08:14 +01:00
henderkes
6bbb3c969c remove -release handling functionality 2026-01-03 17:03:43 +01:00
henderkes
76025b95c1 missing space 2026-01-03 16:46:14 +01:00
henderkes
1be353fd13 more concise message 2026-01-03 16:45:55 +01:00
henderkes
54001ab868 simplify logic a bit 2026-01-03 16:33:40 +01:00
henderkes
890ff475f1 our memcache patch prevents shared building 2026-01-03 14:09:16 +01:00
henderkes
559a2909a9 use little trick to order libargon2 before libsodium 2026-01-02 23:21:29 +01:00
henderkes
fff2484529 postgresql doesn't build under c23 2026-01-02 22:52:03 +01:00
henderkes
d1b194999d use OPENSSL_CONF directory for openssl default configuration 2026-01-02 21:13:22 +01:00
henderkes
64f7a3553e don't need it anymore 2026-01-01 12:33:55 +01:00
henderkes
a06cc32491 pin libpng to released tags, not git 2025-12-30 11:58:57 +01:00
henderkes
022fdb2fc5 fix no-strip 2025-12-29 23:58:54 +01:00
henderkes
7688a55656 don't get zig master branch 2025-12-29 22:16:53 +01:00
henderkes
08388c0b15 force enable tailcall vm with zig 2025-12-29 22:12:25 +01:00
henderkes
e7a88f1df7 enable fat for gmp when next version releases 2025-12-29 21:15:53 +01:00
henderkes
2f3122627e make grpc php 8.5 compatible 2025-12-28 12:44:24 +01:00
henderkes
93a35908de factor grpc extension out to ext-grpc, keep library for now, even though unused 2025-12-28 12:11:56 +01:00
henderkes
5ef4623051 grpc will fail for php 8.5, it's not updated yet 2025-12-27 23:05:35 +01:00
henderkes
e952f1c76a we don't even need to build grpc library for grpc extension... 2025-12-27 22:36:24 +01:00
henderkes
09b89a30f9 WIP: use system libraries for grpc without building our own grpc lib 2025-12-27 22:20:02 +01:00
henderkes
9a681a9fa6 add mariadb mysqlnd plugins 2025-12-27 21:22:10 +01:00
Jerry Ma
8650ce4f8f Add MACOSX_DEPLOYMENT_TARGET to env.ini (#1009) 2025-12-26 17:15:45 +08:00
crazywhalecc
f7ca621efe Test 2025-12-26 15:03:54 +08:00
henderkes
6b5200002e fix downloader selecting drafts 2025-12-20 23:29:25 +01:00
henderkes
53f7cdefe0 fix swoole compilation with php 8.5.1 2025-12-18 20:12:01 +01:00
henderkes
e1a14bbb9f fix implicit include 2025-12-18 17:39:05 +01:00
henderkes
9e051c8c80 fix: check for link first before checking for is_dir 2025-12-18 17:32:02 +01:00
henderkes
e677be74d7 remove 2025-12-18 17:32:02 +01:00
henderkes
037d224fd7 why does phpstan think this is necessary? 2025-12-18 17:32:02 +01:00
henderkes
ce44e00bd4 @crazywhalecc how to use patch points to delete source dirs? 2025-12-18 17:32:01 +01:00
henderkes
0247458853 we were installing to wrong dir if source name != lib name 2025-12-18 17:32:01 +01:00
henderkes
656a58c3fa remove source dir after successful build in CI environment 2025-12-18 17:32:01 +01:00
Jerry Ma
9fdfef5057 macOS don't need to disable avx2 explicitly (#1007) 2025-12-18 21:21:47 +08:00
Marc
18c5ccfe9d the libwebp 1.6.0 bug affects centos 7 too (#1004) 2025-12-16 09:33:20 +01:00
henderkes
d064e1353c the libwebp 1.6.0 bug affects centos 7 too 2025-12-15 18:50:20 +01:00
40 changed files with 590 additions and 427 deletions

View File

@@ -108,8 +108,7 @@ RUN apk update; \
wget \ wget \
xz \ xz \
gettext-dev \ gettext-dev \
binutils-gold \ binutils-gold
patchelf
RUN curl -#fSL https://dl.static-php.dev/static-php-cli/bulk/php-8.4.4-cli-linux-\$(uname -m).tar.gz | tar -xz -C /usr/local/bin && \ RUN curl -#fSL https://dl.static-php.dev/static-php-cli/bulk/php-8.4.4-cli-linux-\$(uname -m).tar.gz | tar -xz -C /usr/local/bin && \
chmod +x /usr/local/bin/php chmod +x /usr/local/bin/php

View File

@@ -92,11 +92,6 @@ RUN echo "source scl_source enable devtoolset-10" >> /etc/bashrc
RUN source /etc/bashrc RUN source /etc/bashrc
RUN yum install -y which RUN yum install -y which
RUN curl -fsSL -o patchelf.tgz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0-$SPC_USE_ARCH.tar.gz && \
mkdir -p /patchelf && \
tar -xzf patchelf.tgz -C /patchelf --strip-components=1 && \
cp /patchelf/bin/patchelf /usr/bin/
RUN curl -o cmake.tgz -#fSL https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-$SPC_USE_ARCH.tar.gz && \ RUN curl -o cmake.tgz -#fSL https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-$SPC_USE_ARCH.tar.gz && \
mkdir /cmake && \ mkdir /cmake && \
tar -xzf cmake.tgz -C /cmake --strip-components 1 tar -xzf cmake.tgz -C /cmake --strip-components 1

428
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -75,8 +75,10 @@ SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime
; - musl-native: used for alpine linux, can build `musl` and `musl -dynamic` target. ; - musl-native: used for alpine linux, can build `musl` and `musl -dynamic` target.
; - gnu-native: used for general linux distros, can build gnu target for the installed glibc version only. ; - gnu-native: used for general linux distros, can build gnu target for the installed glibc version only.
; LEGACY option to specify the target ; option to specify the target, superceded by SPC_TARGET if set
SPC_LIBC=musl SPC_LIBC=musl
; uncomment to link libc dynamically on musl
; SPC_MUSL_DYNAMIC=true
; Recommended: specify your target here. Zig toolchain will be used. ; Recommended: specify your target here. Zig toolchain will be used.
; examples: ; examples:
@@ -115,6 +117,10 @@ SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fno-ident -fPIE
; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so ; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS="" SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS=""
; optional, path to openssl conf. This affects where openssl will look for the default CA.
; default on Debian/Alpine: /etc/ssl, default on RHEL: /etc/pki/tls
OPENSSLDIR=""
[macos] [macos]
; build target: macho or macho (possibly we could support macho-universal in the future) ; build target: macho or macho (possibly we could support macho-universal in the future)
; Currently we do not support universal and cross-compilation for macOS. ; Currently we do not support universal and cross-compilation for macOS.
@@ -142,6 +148,8 @@ SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-
SPC_CMD_VAR_PHP_EMBED_TYPE="static" SPC_CMD_VAR_PHP_EMBED_TYPE="static"
; EXTRA_CFLAGS for `configure` and `make` php ; EXTRA_CFLAGS for `configure` and `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie -Werror=unknown-warning-option ${SPC_DEFAULT_C_FLAGS}" SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie -Werror=unknown-warning-option ${SPC_DEFAULT_C_FLAGS}"
; minimum compatible macOS version (LLVM vars, availability not guaranteed)
MACOSX_DEPLOYMENT_TARGET=12.0
[freebsd] [freebsd]
; compiler environments ; compiler environments

View File

@@ -43,6 +43,14 @@
"calendar": { "calendar": {
"type": "builtin" "type": "builtin"
}, },
"com_dotnet": {
"support": {
"BSD": "no",
"Linux": "no",
"Darwin": "no"
},
"type": "builtin"
},
"ctype": { "ctype": {
"type": "builtin" "type": "builtin"
}, },
@@ -127,6 +135,14 @@
"sockets" "sockets"
] ]
}, },
"excimer": {
"support": {
"Windows": "wip",
"BSD": "wip"
},
"type": "external",
"source": "ext-excimer"
},
"exif": { "exif": {
"type": "builtin" "type": "builtin"
}, },
@@ -232,11 +248,13 @@
"BSD": "wip" "BSD": "wip"
}, },
"type": "external", "type": "external",
"source": "grpc", "source": "ext-grpc",
"arg-type-unix": "enable-path", "arg-type-unix": "enable-path",
"cpp-extension": true, "cpp-extension": true,
"lib-depends": [ "lib-depends": [
"grpc" "zlib",
"openssl",
"libcares"
] ]
}, },
"iconv": { "iconv": {
@@ -408,8 +426,7 @@
"ext-depends": [ "ext-depends": [
"zlib", "zlib",
"session" "session"
], ]
"build-with-php": true
}, },
"memcached": { "memcached": {
"support": { "support": {
@@ -487,6 +504,40 @@
"zlib" "zlib"
] ]
}, },
"mysqlnd_ed25519": {
"type": "external",
"source": "mysqlnd_ed25519",
"arg-type": "enable",
"target": [
"shared"
],
"ext-depends": [
"mysqlnd"
],
"lib-depends": [
"libsodium"
],
"lib-suggests": [
"openssl"
]
},
"mysqlnd_parsec": {
"type": "external",
"source": "mysqlnd_parsec",
"arg-type": "enable",
"target": [
"shared"
],
"ext-depends": [
"mysqlnd"
],
"lib-depends": [
"libsodium"
],
"lib-suggests": [
"openssl"
]
},
"oci8": { "oci8": {
"type": "wip", "type": "wip",
"support": { "support": {

View File

@@ -361,6 +361,9 @@
"source": "libargon2", "source": "libargon2",
"static-libs-unix": [ "static-libs-unix": [
"libargon2.a" "libargon2.a"
],
"lib-suggests": [
"libsodium"
] ]
}, },
"libavif": { "libavif": {

View File

@@ -126,13 +126,23 @@
}, },
"ext-event": { "ext-event": {
"type": "url", "type": "url",
"url": "https://bitbucket.org/osmanov/pecl-event/get/3.0.8.tar.gz", "url": "https://bitbucket.org/osmanov/pecl-event/get/3.1.4.tar.gz",
"path": "php-src/ext/event", "path": "php-src/ext/event",
"license": { "license": {
"type": "file", "type": "file",
"path": "LICENSE" "path": "LICENSE"
} }
}, },
"ext-excimer": {
"type": "url",
"url": "https://pecl.php.net/get/excimer",
"path": "php-src/ext/excimer",
"filename": "excimer.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-glfw": { "ext-glfw": {
"type": "git", "type": "git",
"url": "https://github.com/mario-deluna/php-glfw", "url": "https://github.com/mario-deluna/php-glfw",
@@ -151,6 +161,18 @@
"path": "LICENSE" "path": "LICENSE"
} }
}, },
"ext-grpc": {
"type": "url",
"url": "https://pecl.php.net/get/grpc",
"path": "php-src/ext/grpc",
"filename": "grpc.tgz",
"license": {
"type": "file",
"path": [
"LICENSE"
]
}
},
"ext-imagick": { "ext-imagick": {
"type": "url", "type": "url",
"url": "https://pecl.php.net/get/imagick", "url": "https://pecl.php.net/get/imagick",
@@ -670,9 +692,10 @@
} }
}, },
"libpng": { "libpng": {
"type": "git", "type": "ghtagtar",
"url": "https://github.com/glennrp/libpng.git", "repo": "pnggroup/libpng",
"rev": "libpng16", "match": "v1\\.6\\.\\d+",
"query": "?per_page=150",
"provide-pre-built": true, "provide-pre-built": true,
"license": { "license": {
"type": "file", "type": "file",
@@ -680,9 +703,9 @@
} }
}, },
"librabbitmq": { "librabbitmq": {
"type": "git", "type": "ghtar",
"url": "https://github.com/alanxz/rabbitmq-c.git", "repo": "alanxz/rabbitmq-c",
"rev": "master", "prefer-stable": true,
"license": { "license": {
"type": "file", "type": "file",
"path": "LICENSE" "path": "LICENSE"
@@ -699,7 +722,7 @@
"libsodium": { "libsodium": {
"type": "ghrel", "type": "ghrel",
"repo": "jedisct1/libsodium", "repo": "jedisct1/libsodium",
"match": "libsodium-\\d+(\\.\\d+)*\\.tar\\.gz", "match": "libsodium-(?!1\\.0\\.21)\\d+(\\.\\d+)*\\.tar\\.gz",
"prefer-stable": true, "prefer-stable": true,
"provide-pre-built": true, "provide-pre-built": true,
"license": { "license": {
@@ -871,6 +894,24 @@
"path": "LICENSE" "path": "LICENSE"
} }
}, },
"mysqlnd_ed25519": {
"type": "pie",
"repo": "mariadb/mysqlnd_ed25519",
"path": "php-src/ext/mysqlnd_ed25519",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"mysqlnd_parsec": {
"type": "pie",
"repo": "mariadb/mysqlnd_parsec",
"path": "php-src/ext/mysqlnd_parsec",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ncurses": { "ncurses": {
"type": "filelist", "type": "filelist",
"url": "https://ftp.gnu.org/pub/gnu/ncurses/", "url": "https://ftp.gnu.org/pub/gnu/ncurses/",

View File

@@ -549,22 +549,24 @@ otherwise it will be executed repeatedly in other events.
The following are the supported `patch_point` event names and corresponding locations: The following are the supported `patch_point` event names and corresponding locations:
| Event name | Event description | | Event name | Event description |
|------------------------------|----------------------------------------------------------------------------------------------------| |---------------------------------|----------------------------------------------------------------------------------------------------|
| before-libs-extract | Triggered before the dependent libraries extracted | | before-libs-extract | Triggered before the dependent libraries extracted |
| after-libs-extract | Triggered after the compiled dependent libraries extracted | | after-libs-extract | Triggered after the compiled dependent libraries extracted |
| before-php-extract | Triggered before PHP source code extracted | | before-php-extract | Triggered before PHP source code extracted |
| after-php-extract | Triggered after PHP source code extracted | | after-php-extract | Triggered after PHP source code extracted |
| before-micro-extract | Triggered before phpmicro extract | | before-micro-extract | Triggered before phpmicro extract |
| after-micro-extract | Triggered after phpmicro extracted | | after-micro-extract | Triggered after phpmicro extracted |
| before-exts-extract | Triggered before the extension (to be compiled) extracted to the PHP source directory | | before-exts-extract | Triggered before the extension (to be compiled) extracted to the PHP source directory |
| after-exts-extract | Triggered after the extension extracted to the PHP source directory | | after-exts-extract | Triggered after the extension extracted to the PHP source directory |
| before-library[*name*]-build | Triggered before the library named `name` is compiled (such as `before-library[postgresql]-build`) | | before-library[*name*]-build | Triggered before the library named `name` is compiled (such as `before-library[postgresql]-build`) |
| after-library[*name*]-build | Triggered after the library named `name` is compiled | | after-library[*name*]-build | Triggered after the library named `name` is compiled |
| before-php-buildconf | Triggered before compiling PHP command `./buildconf` | | after-shared-ext[*name*]-build | Triggered after the shared extension named `name` is compiled |
| before-php-configure | Triggered before compiling PHP command `./configure` | | before-shared-ext[*name*]-build | Triggered before the shared extension named `name` is compiled |
| before-php-make | Triggered before compiling PHP command `make` | | before-php-buildconf | Triggered before compiling PHP command `./buildconf` |
| before-sanity-check | Triggered after compiling PHP but before running extended checks | | before-php-configure | Triggered before compiling PHP command `./configure` |
| before-php-make | Triggered before compiling PHP command `make` |
| before-sanity-check | Triggered after compiling PHP but before running extended checks |
The following is a simple example of temporarily modifying the PHP source code. The following is a simple example of temporarily modifying the PHP source code.
Enable the CLI function to search for the `php.ini` configuration in the current working directory: Enable the CLI function to search for the `php.ini` configuration in the current working directory:

View File

@@ -500,6 +500,8 @@ bin/spc dev:sort-config ext
| after-exts-extract | 在要编译的扩展解压到 PHP 源码目录后触发 | | after-exts-extract | 在要编译的扩展解压到 PHP 源码目录后触发 |
| before-library[*name*]-build | 在名称为 `name` 的库编译前触发(如 `before-library[postgresql]-build` | | before-library[*name*]-build | 在名称为 `name` 的库编译前触发(如 `before-library[postgresql]-build` |
| after-library[*name*]-build | 在名称为 `name` 的库编译后触发 | | after-library[*name*]-build | 在名称为 `name` 的库编译后触发 |
| after-shared-ext[*name*]-build | 在名称为 `name` 的共享扩展编译后触发(如 `after-shared-ext[redis]-build` |
| before-shared-ext[*name*]-build | 在名称为 `name` 的共享扩展编译前触发 |
| before-php-buildconf | 在编译 PHP 命令 `./buildconf` 前触发 | | before-php-buildconf | 在编译 PHP 命令 `./buildconf` 前触发 |
| before-php-configure | 在编译 PHP 命令 `./configure` 前触发 | | before-php-configure | 在编译 PHP 命令 `./configure` 前触发 |
| before-php-make | 在编译 PHP 命令 `make` 前触发 | | before-php-make | 在编译 PHP 命令 `make` 前触发 |

View File

@@ -34,7 +34,7 @@ use Symfony\Component\Console\Application;
*/ */
final class ConsoleApplication extends Application final class ConsoleApplication extends Application
{ {
public const string VERSION = '2.7.10'; public const string VERSION = '2.8.2';
public function __construct() public function __construct()
{ {

View File

@@ -385,6 +385,9 @@ class Extension
logger()->info('Shared extension [' . $this->getName() . '] was already built, skipping (' . $this->getName() . '.so)'); logger()->info('Shared extension [' . $this->getName() . '] was already built, skipping (' . $this->getName() . '.so)');
return; return;
} }
if ((string) Config::getExt($this->getName(), 'type') === 'addon') {
return;
}
logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)'); logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)');
foreach ($this->dependencies as $dependency) { foreach ($this->dependencies as $dependency) {
if (!$dependency instanceof Extension) { if (!$dependency instanceof Extension) {
@@ -395,13 +398,12 @@ class Extension
$dependency->buildShared([...$visited, $this->getName()]); $dependency->buildShared([...$visited, $this->getName()]);
} }
} }
if (Config::getExt($this->getName(), 'type') === 'addon') { $this->builder->emitPatchPoint('before-shared-ext[' . $this->getName() . ']-build');
return;
}
match (PHP_OS_FAMILY) { match (PHP_OS_FAMILY) {
'Darwin', 'Linux' => $this->buildUnixShared(), 'Darwin', 'Linux' => $this->buildUnixShared(),
default => throw new WrongUsageException(PHP_OS_FAMILY . ' build shared extensions is not supported yet'), default => throw new WrongUsageException(PHP_OS_FAMILY . ' build shared extensions is not supported yet'),
}; };
$this->builder->emitPatchPoint('after-shared-ext[' . $this->getName() . ']-build');
} catch (SPCException $e) { } catch (SPCException $e) {
$e->bindExtensionInfo(['extension_name' => $this->getName()]); $e->bindExtensionInfo(['extension_name' => $this->getName()]);
throw $e; throw $e;
@@ -452,12 +454,17 @@ class Extension
// process *.so file // process *.so file
$soFile = BUILD_MODULES_PATH . '/' . $this->getName() . '.so'; $soFile = BUILD_MODULES_PATH . '/' . $this->getName() . '.so';
$soDest = $soFile;
preg_match('/-release\s+(\S*)/', getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'), $matches);
if (!empty($matches[1])) {
$soDest = str_replace('.so', '-' . $matches[1] . '.so', $soFile);
}
if (!file_exists($soFile)) { if (!file_exists($soFile)) {
throw new ValidationException("extension {$this->getName()} build failed: {$soFile} not found", validation_module: "Extension {$this->getName()} build"); throw new ValidationException("extension {$this->getName()} build failed: {$soFile} not found", validation_module: "Extension {$this->getName()} build");
} }
/** @var UnixBuilderBase $builder */ /** @var UnixBuilderBase $builder */
$builder = $this->builder; $builder = $this->builder;
$builder->deployBinary($soFile, $soFile, false); $builder->deployBinary($soFile, $soDest, false);
} }
/** /**
@@ -535,7 +542,7 @@ class Extension
*/ */
protected function getSharedExtensionEnv(): array protected function getSharedExtensionEnv(): array
{ {
$config = (new SPCConfigUtil($this->builder))->getExtensionConfig($this); $config = (new SPCConfigUtil($this->builder, ['no_php' => true]))->getExtensionConfig($this);
[$staticLibs, $sharedLibs] = $this->splitLibsIntoStaticAndShared($config['libs']); [$staticLibs, $sharedLibs] = $this->splitLibsIntoStaticAndShared($config['libs']);
$preStatic = PHP_OS_FAMILY === 'Darwin' ? '' : '-Wl,--start-group '; $preStatic = PHP_OS_FAMILY === 'Darwin' ? '' : '-Wl,--start-group ';
$postStatic = PHP_OS_FAMILY === 'Darwin' ? '' : ' -Wl,--end-group '; $postStatic = PHP_OS_FAMILY === 'Darwin' ? '' : ' -Wl,--end-group ';
@@ -543,6 +550,7 @@ class Extension
'CFLAGS' => $config['cflags'], 'CFLAGS' => $config['cflags'],
'CXXFLAGS' => $config['cflags'], 'CXXFLAGS' => $config['cflags'],
'LDFLAGS' => $config['ldflags'], 'LDFLAGS' => $config['ldflags'],
'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'),
'LIBS' => clean_spaces("{$preStatic} {$staticLibs} {$postStatic} {$sharedLibs}"), 'LIBS' => clean_spaces("{$preStatic} {$staticLibs} {$postStatic} {$sharedLibs}"),
'LD_LIBRARY_PATH' => BUILD_LIB_PATH, 'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
]; ];

View File

@@ -184,18 +184,18 @@ abstract class LibraryBase
// extract first if not exists // extract first if not exists
if (!is_dir($this->source_dir)) { if (!is_dir($this->source_dir)) {
$this->getBuilder()->emitPatchPoint('before-library[ ' . static::NAME . ']-extract'); $this->getBuilder()->emitPatchPoint('before-library[' . static::NAME . ']-extract');
SourceManager::initSource(libs: [static::NAME], source_only: true); SourceManager::initSource(libs: [static::NAME], source_only: true);
$this->getBuilder()->emitPatchPoint('after-library[ ' . static::NAME . ']-extract'); $this->getBuilder()->emitPatchPoint('after-library[' . static::NAME . ']-extract');
} }
if (!$this->patched && $this->patchBeforeBuild()) { if (!$this->patched && $this->patchBeforeBuild()) {
file_put_contents($this->source_dir . '/.spc.patched', 'PATCHED!!!'); file_put_contents($this->source_dir . '/.spc.patched', 'PATCHED!!!');
} }
$this->getBuilder()->emitPatchPoint('before-library[ ' . static::NAME . ']-build'); $this->getBuilder()->emitPatchPoint('before-library[' . static::NAME . ']-build');
$this->build(); $this->build();
$this->installLicense(); $this->installLicense();
$this->getBuilder()->emitPatchPoint('after-library[ ' . static::NAME . ']-build'); $this->getBuilder()->emitPatchPoint('after-library[' . static::NAME . ']-build');
return LIB_STATUS_OK; return LIB_STATUS_OK;
} }
@@ -346,19 +346,19 @@ abstract class LibraryBase
*/ */
protected function installLicense(): void protected function installLicense(): void
{ {
FileSystem::createDir(BUILD_ROOT_PATH . '/source-licenses/' . $this->getName());
$source = Config::getLib($this->getName(), 'source'); $source = Config::getLib($this->getName(), 'source');
FileSystem::createDir(BUILD_ROOT_PATH . "/source-licenses/{$source}");
$license_files = Config::getSource($source)['license'] ?? []; $license_files = Config::getSource($source)['license'] ?? [];
if (is_assoc_array($license_files)) { if (is_assoc_array($license_files)) {
$license_files = [$license_files]; $license_files = [$license_files];
} }
foreach ($license_files as $index => $license) { foreach ($license_files as $index => $license) {
if ($license['type'] === 'text') { if ($license['type'] === 'text') {
FileSystem::writeFile(BUILD_ROOT_PATH . '/source-licenses/' . $this->getName() . "/{$index}.txt", $license['text']); FileSystem::writeFile(BUILD_ROOT_PATH . "/source-licenses/{$source}/{$index}.txt", $license['text']);
continue; continue;
} }
if ($license['type'] === 'file') { if ($license['type'] === 'file') {
copy($this->source_dir . '/' . $license['path'], BUILD_ROOT_PATH . '/source-licenses/' . $this->getName() . "/{$index}.txt"); copy($this->source_dir . '/' . $license['path'], BUILD_ROOT_PATH . "/source-licenses/{$source}/{$index}.txt");
} }
} }
} }
@@ -375,8 +375,17 @@ abstract class LibraryBase
return false; return false;
} }
} }
$pkg_config_path = getenv('PKG_CONFIG_PATH') ?: '';
$search_paths = array_filter(explode(is_unix() ? ':' : ';', $pkg_config_path));
foreach (Config::getLib(static::NAME, 'pkg-configs', []) as $name) { foreach (Config::getLib(static::NAME, 'pkg-configs', []) as $name) {
if (!file_exists(BUILD_LIB_PATH . "/pkgconfig/{$name}.pc")) { $found = false;
foreach ($search_paths as $path) {
if (file_exists($path . "/{$name}.pc")) {
$found = true;
break;
}
}
if (!$found) {
return false; return false;
} }
} }

View File

@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('com_dotnet')]
class com_dotnet extends Extension
{
public function getWindowsConfigureArg(bool $shared = false): string
{
return '--enable-com-dotnet=yes';
}
}

View File

@@ -21,18 +21,14 @@ class grpc extends Extension
if ($this->builder instanceof WindowsBuilder) { if ($this->builder instanceof WindowsBuilder) {
throw new ValidationException('grpc extension does not support windows yet'); throw new ValidationException('grpc extension does not support windows yet');
} }
if (file_exists(SOURCE_PATH . '/php-src/ext/grpc')) { FileSystem::replaceFileStr(
return false; $this->source_dir . '/src/php/ext/grpc/call.c',
} 'zend_exception_get_default(TSRMLS_C),',
// soft link to the grpc source code 'zend_ce_exception,',
if (is_dir($this->source_dir . '/src/php/ext/grpc')) { );
shell()->exec('ln -s ' . $this->source_dir . '/src/php/ext/grpc ' . SOURCE_PATH . '/php-src/ext/grpc');
} else {
throw new ValidationException('Cannot find grpc source code in ' . $this->source_dir . '/src/php/ext/grpc');
}
if (SPCTarget::getTargetOS() === 'Darwin') { if (SPCTarget::getTargetOS() === 'Darwin') {
FileSystem::replaceFileRegex( FileSystem::replaceFileRegex(
SOURCE_PATH . '/php-src/ext/grpc/config.m4', $this->source_dir . '/config.m4',
'/GRPC_LIBDIR=.*$/m', '/GRPC_LIBDIR=.*$/m',
'GRPC_LIBDIR=' . BUILD_LIB_PATH . "\n" . 'LDFLAGS="$LDFLAGS -framework CoreFoundation"' 'GRPC_LIBDIR=' . BUILD_LIB_PATH . "\n" . 'LDFLAGS="$LDFLAGS -framework CoreFoundation"'
); );

View File

@@ -18,6 +18,9 @@ class memcache extends Extension
public function patchBeforeBuildconf(): bool public function patchBeforeBuildconf(): bool
{ {
if (!$this->isBuildStatic()) {
return false;
}
FileSystem::replaceFileStr( FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/ext/memcache/config9.m4', SOURCE_PATH . '/php-src/ext/memcache/config9.m4',
'if test -d $abs_srcdir/src ; then', 'if test -d $abs_srcdir/src ; then',
@@ -43,4 +46,27 @@ EOF
); );
return true; return true;
} }
public function patchBeforeSharedConfigure(): bool
{
if (!$this->isBuildShared()) {
return false;
}
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/ext/memcache/config9.m4',
'if test -d $abs_srcdir/main ; then',
'if test -d $abs_srcdir/src ; then',
);
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/ext/memcache/config9.m4',
'export CPPFLAGS="$CPPFLAGS $INCLUDES -I$abs_srcdir/main"',
'export CPPFLAGS="$CPPFLAGS $INCLUDES"',
);
return true;
}
protected function getExtraEnv(): array
{
return ['CFLAGS' => '-std=c17'];
}
} }

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('mysqlnd_ed25519')]
class mysqlnd_ed25519 extends Extension
{
public function getConfigureArg(bool $shared = false): string
{
return '--with-mysqlnd_ed25519' . ($shared ? '=shared' : '');
}
public function getUnixConfigureArg(bool $shared = false): string
{
return $this->getConfigureArg();
}
}

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('mysqlnd_parsec')]
class mysqlnd_parsec extends Extension
{
public function getConfigureArg(bool $shared = false): string
{
return '--enable-mysqlnd_parsec' . ($shared ? '=shared' : '');
}
public function getUnixConfigureArg(bool $shared = false): string
{
return $this->getConfigureArg();
}
}

View File

@@ -24,25 +24,6 @@ class password_argon2 extends Extension
} }
} }
public function patchBeforeMake(): bool
{
$patched = parent::patchBeforeMake();
if ($this->builder->getLib('libsodium') !== null) {
$extraLibs = getenv('SPC_EXTRA_LIBS');
if ($extraLibs !== false) {
$extraLibs = str_replace(
[BUILD_LIB_PATH . '/libargon2.a', BUILD_LIB_PATH . '/libsodium.a'],
['', BUILD_LIB_PATH . '/libargon2.a ' . BUILD_LIB_PATH . '/libsodium.a'],
$extraLibs,
);
$extraLibs = trim(preg_replace('/\s+/', ' ', $extraLibs)); // normalize spacing
f_putenv('SPC_EXTRA_LIBS=' . $extraLibs);
return true;
}
}
return $patched;
}
public function getConfigureArg(bool $shared = false): string public function getConfigureArg(bool $shared = false): string
{ {
if ($this->builder->getLib('openssl') !== null) { if ($this->builder->getLib('openssl') !== null) {

View File

@@ -45,4 +45,11 @@ class spx extends Extension
FileSystem::copy($this->source_dir . '/src/php_spx.h', $this->source_dir . '/php_spx.h'); FileSystem::copy($this->source_dir . '/src/php_spx.h', $this->source_dir . '/php_spx.h');
return true; return true;
} }
public function getSharedExtensionEnv(): array
{
$env = parent::getSharedExtensionEnv();
$env['SPX_SHARED_LIBADD'] = $env['LIBS'];
return $env;
}
} }

View File

@@ -17,6 +17,7 @@ class swoole extends Extension
public function patchBeforeMake(): bool public function patchBeforeMake(): bool
{ {
$patched = parent::patchBeforeMake(); $patched = parent::patchBeforeMake();
FileSystem::replaceFileStr($this->source_dir . '/ext-src/php_swoole_private.h', 'PHP_VERSION_ID > 80500', 'PHP_VERSION_ID >= 80600');
if ($this->builder instanceof MacOSBuilder) { if ($this->builder instanceof MacOSBuilder) {
// Fix swoole with event extension <util.h> conflict bug // Fix swoole with event extension <util.h> conflict bug
$util_path = shell()->execWithResult('xcrun --show-sdk-path', false)[1][0] . '/usr/include/util.h'; $util_path = shell()->execWithResult('xcrun --show-sdk-path', false)[1][0] . '/usr/include/util.h';

View File

@@ -283,11 +283,14 @@ class LinuxBuilder extends UnixBuilderBase
// process libphp.so for shared embed // process libphp.so for shared embed
$libphpSo = BUILD_LIB_PATH . '/libphp.so'; $libphpSo = BUILD_LIB_PATH . '/libphp.so';
$libphpSoDest = BUILD_LIB_PATH . '/libphp.so';
if (file_exists($libphpSo)) { if (file_exists($libphpSo)) {
// post actions: rename libphp.so to libphp-<release>.so if -release is set in LDFLAGS
$this->processLibphpSoFile($libphpSo);
// deploy libphp.so // deploy libphp.so
$this->deployBinary($libphpSo, $libphpSo, false); preg_match('/-release\s+(\S*)/', getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'), $matches);
if (!empty($matches[1])) {
$libphpSoDest = str_replace('.so', '-' . $matches[1] . '.so', $libphpSo);
}
$this->deployBinary($libphpSo, $libphpSoDest, false);
} }
// process shared extensions build-with-php // process shared extensions build-with-php
@@ -324,74 +327,6 @@ class LinuxBuilder extends UnixBuilderBase
]); ]);
} }
private function processLibphpSoFile(string $libphpSo): void
{
$ldflags = getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS') ?: '';
$libDir = BUILD_LIB_PATH;
$modulesDir = BUILD_MODULES_PATH;
$realLibName = 'libphp.so';
$cwd = getcwd();
if (preg_match('/-release\s+(\S+)/', $ldflags, $matches)) {
$release = $matches[1];
$realLibName = "libphp-{$release}.so";
$libphpRelease = "{$libDir}/{$realLibName}";
if (!file_exists($libphpRelease) && file_exists($libphpSo)) {
rename($libphpSo, $libphpRelease);
}
if (file_exists($libphpRelease)) {
chdir($libDir);
if (file_exists($libphpSo)) {
unlink($libphpSo);
}
symlink($realLibName, 'libphp.so');
shell()->exec(sprintf(
'patchelf --set-soname %s %s',
escapeshellarg($realLibName),
escapeshellarg($libphpRelease)
));
}
if (is_dir($modulesDir)) {
chdir($modulesDir);
foreach ($this->getExts() as $ext) {
if (!$ext->isBuildShared()) {
continue;
}
$name = $ext->getName();
$versioned = "{$name}-{$release}.so";
$unversioned = "{$name}.so";
$src = "{$modulesDir}/{$versioned}";
$dst = "{$modulesDir}/{$unversioned}";
if (is_file($src)) {
rename($src, $dst);
shell()->exec(sprintf(
'patchelf --set-soname %s %s',
escapeshellarg($unversioned),
escapeshellarg($dst)
));
}
}
}
chdir($cwd);
}
$target = "{$libDir}/{$realLibName}";
if (file_exists($target)) {
[, $output] = shell()->execWithResult('readelf -d ' . escapeshellarg($target));
$output = implode("\n", $output);
if (preg_match('/SONAME.*\[(.+)]/', $output, $sonameMatch)) {
$currentSoname = $sonameMatch[1];
if ($currentSoname !== basename($target)) {
shell()->exec(sprintf(
'patchelf --set-soname %s %s',
escapeshellarg(basename($target)),
escapeshellarg($target)
));
}
}
}
}
/** /**
* Patch micro.sfx after UPX compression. * Patch micro.sfx after UPX compression.
* micro needs special section handling in LinuxBuilder. * micro needs special section handling in LinuxBuilder.

View File

@@ -21,6 +21,7 @@ declare(strict_types=1);
namespace SPC\builder\linux\library; namespace SPC\builder\linux\library;
use SPC\builder\linux\SystemUtil;
use SPC\store\FileSystem; use SPC\store\FileSystem;
class openssl extends LinuxLibraryBase class openssl extends LinuxLibraryBase
@@ -51,6 +52,9 @@ class openssl extends LinuxLibraryBase
$zlib_extra = ''; $zlib_extra = '';
} }
$openssl_dir = getenv('OPENSSLDIR') ?: null;
// TODO: in v3 use the following: $openssl_dir ??= SystemUtil::getOSRelease()['dist'] === 'redhat' ? '/etc/pki/tls' : '/etc/ssl';
$openssl_dir ??= '/etc/ssl';
$ex_lib = trim($ex_lib); $ex_lib = trim($ex_lib);
shell()->cd($this->source_dir)->initializeEnv($this) shell()->cd($this->source_dir)->initializeEnv($this)
@@ -58,7 +62,7 @@ class openssl extends LinuxLibraryBase
"{$env} ./Configure no-shared {$extra} " . "{$env} ./Configure no-shared {$extra} " .
'--prefix=' . BUILD_ROOT_PATH . ' ' . '--prefix=' . BUILD_ROOT_PATH . ' ' .
'--libdir=' . BUILD_LIB_PATH . ' ' . '--libdir=' . BUILD_LIB_PATH . ' ' .
'--openssldir=/etc/ssl ' . "--openssldir={$openssl_dir} " .
"{$zlib_extra}" . "{$zlib_extra}" .
'enable-pie ' . 'enable-pie ' .
'no-legacy ' . 'no-legacy ' .

View File

@@ -34,7 +34,7 @@ trait UnixLibraryTrait
$files = array_map(fn ($x) => "{$x}.pc", $conf_pc); $files = array_map(fn ($x) => "{$x}.pc", $conf_pc);
} }
foreach ($files as $name) { foreach ($files as $name) {
$realpath = realpath(BUILD_ROOT_PATH . '/lib/pkgconfig/' . $name); $realpath = realpath(BUILD_LIB_PATH . '/pkgconfig/' . $name);
if ($realpath === false) { if ($realpath === false) {
throw new PatchException('pkg-config prefix patcher', 'Cannot find library [' . static::NAME . '] pkgconfig file [' . $name . '] in ' . BUILD_LIB_PATH . '/pkgconfig/ !'); throw new PatchException('pkg-config prefix patcher', 'Cannot find library [' . static::NAME . '] pkgconfig file [' . $name . '] in ' . BUILD_LIB_PATH . '/pkgconfig/ !');
} }

View File

@@ -72,12 +72,8 @@ 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 // macOS/zig
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) { if (SPCTarget::getTargetOS() !== 'Linux' || ToolchainManager::getToolchainClass() === ZigToolchain::class) {
return '-Wl,--export-dynamic';
}
// macOS
if (SPCTarget::getTargetOS() !== 'Linux') {
return "-Wl,-exported_symbols_list,{$symbol_file}"; return "-Wl,-exported_symbols_list,{$symbol_file}";
} }
return "-Wl,--dynamic-list={$symbol_file}"; return "-Wl,--dynamic-list={$symbol_file}";

View File

@@ -145,11 +145,10 @@ abstract class UnixBuilderBase extends BuilderBase
throw new SPCInternalException("Deploy failed. Cannot find file after copy: {$dst}"); throw new SPCInternalException("Deploy failed. Cannot find file after copy: {$dst}");
} }
// extract debug info
$this->extractDebugInfo($dst);
// strip
if (!$this->getOption('no-strip')) { if (!$this->getOption('no-strip')) {
// extract debug info
$this->extractDebugInfo($dst);
// extra strip
$this->stripBinary($dst); $this->stripBinary($dst);
} }
@@ -236,8 +235,10 @@ abstract class UnixBuilderBase extends BuilderBase
$lens .= ' -static'; $lens .= ' -static';
} }
$dynamic_exports = ''; $dynamic_exports = '';
$embedType = 'static';
// if someone changed to EMBED_TYPE=shared, we need to add LD_LIBRARY_PATH // if someone changed to EMBED_TYPE=shared, we need to add LD_LIBRARY_PATH
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') { if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') {
$embedType = 'shared';
if (PHP_OS_FAMILY === 'Darwin') { if (PHP_OS_FAMILY === 'Darwin') {
$ext_path = 'DYLD_LIBRARY_PATH=' . BUILD_LIB_PATH . ':$DYLD_LIBRARY_PATH '; $ext_path = 'DYLD_LIBRARY_PATH=' . BUILD_LIB_PATH . ':$DYLD_LIBRARY_PATH ';
} else { } else {
@@ -256,18 +257,19 @@ abstract class UnixBuilderBase extends BuilderBase
} }
} }
$cc = getenv('CC'); $cc = getenv('CC');
[$ret, $out] = shell()->cd($sample_file_path)->execWithResult("{$cc} -o embed embed.c {$lens} {$dynamic_exports}"); [$ret, $out] = shell()->cd($sample_file_path)->execWithResult("{$cc} -o embed embed.c {$lens} {$dynamic_exports}");
if ($ret !== 0) { if ($ret !== 0) {
throw new ValidationException( throw new ValidationException(
'embed failed sanity check: build failed. Error message: ' . implode("\n", $out), 'embed failed to build. Error message: ' . implode("\n", $out),
validation_module: 'static libphp.a sanity check' validation_module: $embedType . ' libphp embed build sanity check'
); );
} }
[$ret, $output] = shell()->cd($sample_file_path)->execWithResult($ext_path . './embed'); [$ret, $output] = shell()->cd($sample_file_path)->execWithResult($ext_path . './embed');
if ($ret !== 0 || trim(implode('', $output)) !== 'hello') { if ($ret !== 0 || trim(implode('', $output)) !== 'hello') {
throw new ValidationException( throw new ValidationException(
'embed failed sanity check: run failed. Error message: ' . implode("\n", $output), 'embed failed to run. Error message: ' . implode("\n", $output),
validation_module: 'static libphp.a sanity check' validation_module: $embedType . ' libphp embed run sanity check'
); );
} }
} }

View File

@@ -16,7 +16,11 @@ trait gettext
->addConfigureArgs( ->addConfigureArgs(
'--disable-java', '--disable-java',
'--disable-c++', '--disable-c++',
'--with-included-gettext', '--disable-d',
'--disable-rpath',
'--disable-modula2',
'--disable-libasprintf',
'--with-included-libintl',
"--with-iconv-prefix={$this->getBuildRootPath()}", "--with-iconv-prefix={$this->getBuildRootPath()}",
); );

View File

@@ -14,7 +14,9 @@ trait gmp
->appendEnv([ ->appendEnv([
'CFLAGS' => '-std=c17', 'CFLAGS' => '-std=c17',
]) ])
->configure() ->configure(
'--enable-fat'
)
->make(); ->make();
$this->patchPkgconfPrefix(['gmp.pc']); $this->patchPkgconfPrefix(['gmp.pc']);
} }

View File

@@ -5,12 +5,17 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
use SPC\util\SPCTarget;
trait libwebp trait libwebp
{ {
protected function build(): void protected function build(): void
{ {
$code = '#include <immintrin.h>
int main() { return _mm256_cvtsi256_si32(_mm256_setzero_si256()); }';
$cc = getenv('CC') ?: 'gcc';
[$ret] = shell()->execWithResult("printf '%s' '{$code}' | {$cc} -x c -mavx2 -o /dev/null - 2>&1");
$disableAvx2 = $ret !== 0 && GNU_ARCH === 'x86_64' && PHP_OS_FAMILY === 'Linux';
UnixCMakeExecutor::create($this) UnixCMakeExecutor::create($this)
->addConfigureArgs( ->addConfigureArgs(
'-DWEBP_BUILD_EXTRAS=OFF', '-DWEBP_BUILD_EXTRAS=OFF',
@@ -23,7 +28,7 @@ trait libwebp
'-DWEBP_BUILD_WEBPINFO=OFF', '-DWEBP_BUILD_WEBPINFO=OFF',
'-DWEBP_BUILD_WEBPMUX=OFF', '-DWEBP_BUILD_WEBPMUX=OFF',
'-DWEBP_BUILD_FUZZTEST=OFF', '-DWEBP_BUILD_FUZZTEST=OFF',
SPCTarget::getLibcVersion() === '2.31' && GNU_ARCH === 'x86_64' ? '-DWEBP_ENABLE_SIMD=OFF' : '' // fix an edge bug for debian 11 with gcc 10 $disableAvx2 ? '-DWEBP_ENABLE_SIMD=OFF' : ''
) )
->build(); ->build();
// patch pkgconfig // patch pkgconfig

View File

@@ -4,29 +4,14 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\PkgConfigUtil; use SPC\util\PkgConfigUtil;
use SPC\util\SPCConfigUtil; use SPC\util\SPCConfigUtil;
use SPC\util\SPCTarget;
trait postgresql trait postgresql
{ {
public function patchBeforeBuild(): bool public function patchBeforeBuild(): bool
{ {
// fix aarch64 build on glibc 2.17 (e.g. CentOS 7)
if (SPCTarget::getLibcVersion() === '2.17' && GNU_ARCH === 'aarch64') {
try {
FileSystem::replaceFileStr("{$this->source_dir}/src/port/pg_popcount_aarch64.c", 'HWCAP_SVE', '0');
FileSystem::replaceFileStr(
"{$this->source_dir}/src/port/pg_crc32c_armv8_choose.c",
'#if defined(__linux__) && !defined(__aarch64__) && !defined(HWCAP2_CRC32)',
'#if defined(__linux__) && !defined(HWCAP_CRC32)'
);
} catch (FileSystemException) {
// allow file not-existence to make it compatible with old and new version
}
}
// skip the test on platforms where libpq infrastructure may be provided by statically-linked libraries // skip the test on platforms where libpq infrastructure may be provided by statically-linked libraries
FileSystem::replaceFileStr("{$this->source_dir}/src/interfaces/libpq/Makefile", 'invokes exit\'; exit 1;', 'invokes exit\';'); FileSystem::replaceFileStr("{$this->source_dir}/src/interfaces/libpq/Makefile", 'invokes exit\'; exit 1;', 'invokes exit\';');
// disable shared libs build // disable shared libs build
@@ -50,7 +35,7 @@ trait postgresql
$config = $spc->config(libraries: $libs, include_suggest_lib: $this->builder->getOption('with-suggested-libs', false)); $config = $spc->config(libraries: $libs, include_suggest_lib: $this->builder->getOption('with-suggested-libs', false));
$env_vars = [ $env_vars = [
'CFLAGS' => $config['cflags'], 'CFLAGS' => $config['cflags'] . ' -std=c17',
'CPPFLAGS' => '-DPIC', 'CPPFLAGS' => '-DPIC',
'LDFLAGS' => $config['ldflags'], 'LDFLAGS' => $config['ldflags'],
'LIBS' => $config['libs'], 'LIBS' => $config['libs'],

View File

@@ -30,7 +30,6 @@ class curl extends WindowsLibraryBase
'-DCMAKE_BUILD_TYPE=Release ' . '-DCMAKE_BUILD_TYPE=Release ' .
'-DBUILD_SHARED_LIBS=OFF ' . '-DBUILD_SHARED_LIBS=OFF ' .
'-DBUILD_STATIC_LIBS=ON ' . '-DBUILD_STATIC_LIBS=ON ' .
'-DCURL_STATICLIB=ON ' .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
'-DBUILD_CURL_EXE=OFF ' . // disable curl.exe '-DBUILD_CURL_EXE=OFF ' . // disable curl.exe
'-DBUILD_TESTING=OFF ' . // disable tests '-DBUILD_TESTING=OFF ' . // disable tests
@@ -42,9 +41,9 @@ class curl extends WindowsLibraryBase
'-DCURL_USE_OPENSSL=OFF ' . // disable openssl due to certificate issue '-DCURL_USE_OPENSSL=OFF ' . // disable openssl due to certificate issue
'-DCURL_ENABLE_SSL=ON ' . '-DCURL_ENABLE_SSL=ON ' .
'-DUSE_NGHTTP2=ON ' . // enable nghttp2 '-DUSE_NGHTTP2=ON ' . // enable nghttp2
'-DSHARE_LIB_OBJECT=OFF ' . // disable shared lib object
'-DCURL_USE_LIBSSH2=ON ' . // enable libssh2 '-DCURL_USE_LIBSSH2=ON ' . // enable libssh2
'-DENABLE_IPV6=ON ' . // enable ipv6 '-DENABLE_IPV6=ON ' . // enable ipv6
'-DNGHTTP2_CFLAGS="/DNGHTTP2_STATICLIB" ' .
$alt $alt
) )
->execWithWrapper( ->execWithWrapper(
@@ -53,5 +52,7 @@ class curl extends WindowsLibraryBase
); );
// move libcurl.lib to libcurl_a.lib // move libcurl.lib to libcurl_a.lib
rename(BUILD_LIB_PATH . '\libcurl.lib', BUILD_LIB_PATH . '\libcurl_a.lib'); rename(BUILD_LIB_PATH . '\libcurl.lib', BUILD_LIB_PATH . '\libcurl_a.lib');
FileSystem::replaceFileStr(BUILD_INCLUDE_PATH . '\curl\curl.h', '#ifdef CURL_STATICLIB', '#if 1');
} }
} }

View File

@@ -29,11 +29,16 @@ class nghttp2 extends WindowsLibraryBase
'-DBUILD_SHARED_LIBS=OFF ' . '-DBUILD_SHARED_LIBS=OFF ' .
'-DENABLE_STATIC_CRT=ON ' . '-DENABLE_STATIC_CRT=ON ' .
'-DENABLE_LIB_ONLY=ON ' . '-DENABLE_LIB_ONLY=ON ' .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
'-DENABLE_STATIC_CRT=ON ' .
'-DENABLE_DOC=OFF ' .
'-DBUILD_TESTING=OFF '
) )
->execWithWrapper( ->execWithWrapper(
$this->builder->makeSimpleWrapper('cmake'), $this->builder->makeSimpleWrapper('cmake'),
"--build build --config Release --target install -j{$this->builder->concurrency}" "--build build --config Release --target install -j{$this->builder->concurrency}"
); );
FileSystem::replaceFileStr(BUILD_INCLUDE_PATH . '\nghttp2\nghttp2.h', '#ifdef NGHTTP2_STATICLIB', '#if 1');
} }
} }

View File

@@ -20,9 +20,9 @@ class SwitchPhpVersionCommand extends BaseCommand
$this->addArgument( $this->addArgument(
'php-major-version', 'php-major-version',
InputArgument::REQUIRED, InputArgument::REQUIRED,
'PHP major version (supported: 7.4, 8.0, 8.1, 8.2, 8.3, 8.4)', 'PHP major version (supported: 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5)',
null, null,
fn () => ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] fn () => ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
); );
$this->no_motd = true; $this->no_motd = true;
@@ -32,7 +32,7 @@ class SwitchPhpVersionCommand extends BaseCommand
public function handle(): int public function handle(): int
{ {
$php_ver = $this->input->getArgument('php-major-version'); $php_ver = $this->input->getArgument('php-major-version');
if (!in_array($php_ver, ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'])) { if (!in_array($php_ver, ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'])) {
// match x.y.z // match x.y.z
preg_match('/^\d+\.\d+\.\d+$/', $php_ver, $matches); preg_match('/^\d+\.\d+\.\d+$/', $php_ver, $matches);
if (!$matches) { if (!$matches) {

View File

@@ -22,7 +22,6 @@ class LinuxToolCheckList
'bzip2', 'cmake', 'gcc', 'bzip2', 'cmake', 'gcc',
'g++', 'patch', 'binutils-gold', 'g++', 'patch', 'binutils-gold',
'libtoolize', 'which', 'libtoolize', 'which',
'patchelf',
]; ];
public const TOOLS_DEBIAN = [ public const TOOLS_DEBIAN = [
@@ -31,7 +30,6 @@ class LinuxToolCheckList
'tar', 'unzip', 'gzip', 'gcc', 'g++', 'tar', 'unzip', 'gzip', 'gcc', 'g++',
'bzip2', 'cmake', 'patch', 'bzip2', 'cmake', 'patch',
'xz', 'libtoolize', 'which', 'xz', 'libtoolize', 'which',
'patchelf',
]; ];
public const TOOLS_RHEL = [ public const TOOLS_RHEL = [
@@ -39,8 +37,7 @@ class LinuxToolCheckList
'git', 'autoconf', 'automake', 'git', 'autoconf', 'automake',
'tar', 'unzip', 'gzip', 'gcc', 'g++', 'tar', 'unzip', 'gzip', 'gcc', 'g++',
'bzip2', 'cmake', 'patch', 'which', 'bzip2', 'cmake', 'patch', 'which',
'xz', 'libtool', 'gettext-devel', 'xz', 'libtool', 'gettext-devel', 'file',
'patchelf', 'file',
]; ];
public const TOOLS_ARCH = [ public const TOOLS_ARCH = [

View File

@@ -97,8 +97,9 @@ class Downloader
public static function getLatestGithubTarball(string $name, array $source, string $type = 'releases'): array public static function getLatestGithubTarball(string $name, array $source, string $type = 'releases'): array
{ {
logger()->debug("finding {$name} source from github {$type} tarball"); logger()->debug("finding {$name} source from github {$type} tarball");
$source['query'] ??= '';
$data = json_decode(self::curlExec( $data = json_decode(self::curlExec(
url: "https://api.github.com/repos/{$source['repo']}/{$type}", url: "https://api.github.com/repos/{$source['repo']}/{$type}{$source['query']}",
hooks: [[CurlHook::class, 'setupGithubToken']], hooks: [[CurlHook::class, 'setupGithubToken']],
retries: self::getRetryAttempts() retries: self::getRetryAttempts()
), true, 512, JSON_THROW_ON_ERROR); ), true, 512, JSON_THROW_ON_ERROR);
@@ -108,6 +109,9 @@ class Downloader
if (($rel['prerelease'] ?? false) === true && ($source['prefer-stable'] ?? false)) { if (($rel['prerelease'] ?? false) === true && ($source['prefer-stable'] ?? false)) {
continue; continue;
} }
if (($rel['draft'] ?? false) === true && (($source['prefer-stable'] ?? false) || !$rel['tarball_url'])) {
continue;
}
if (!($source['match'] ?? null)) { if (!($source['match'] ?? null)) {
$url = $rel['tarball_url'] ?? null; $url = $rel['tarball_url'] ?? null;
break; break;

View File

@@ -408,13 +408,13 @@ class FileSystem
continue; continue;
} }
$sub_file = self::convertPath($dir . '/' . $v); $sub_file = self::convertPath($dir . '/' . $v);
if (is_dir($sub_file)) { if (is_link($sub_file) || is_file($sub_file)) {
# 如果是 目录 且 递推 , 则递推添加下级文件 if (!unlink($sub_file)) {
if (!self::removeDir($sub_file)) {
return false; return false;
} }
} elseif (is_link($sub_file) || is_file($sub_file)) { } elseif (is_dir($sub_file)) {
if (!unlink($sub_file)) { # 如果是 目录 且 递推 , 则递推添加下级文件
if (!self::removeDir($sub_file)) {
return false; return false;
} }
} }

View File

@@ -72,8 +72,11 @@ class Zig extends CustomPackage
$latest_version = null; $latest_version = null;
foreach ($index_json as $version => $data) { foreach ($index_json as $version => $data) {
$latest_version = $version; // Skip the master branch, get the latest stable release
break; if ($version !== 'master') {
$latest_version = $version;
break;
}
} }
if (!$latest_version) { if (!$latest_version) {

View File

@@ -67,7 +67,8 @@ class ZigToolchain implements ToolchainInterface
$cflags = getenv('SPC_DEFAULT_C_FLAGS') ?: getenv('CFLAGS') ?: ''; $cflags = getenv('SPC_DEFAULT_C_FLAGS') ?: getenv('CFLAGS') ?: '';
$has_avx512 = str_contains($cflags, '-mavx512') || str_contains($cflags, '-march=x86-64-v4'); $has_avx512 = str_contains($cflags, '-mavx512') || str_contains($cflags, '-march=x86-64-v4');
if (!$has_avx512) { if (!$has_avx512) {
GlobalEnvManager::putenv('SPC_EXTRA_PHP_VARS=php_cv_have_avx512=no php_cv_have_avx512vbmi=no'); $extra_vars = getenv('SPC_EXTRA_PHP_VARS') ?: '';
GlobalEnvManager::putenv("SPC_EXTRA_PHP_VARS=php_cv_have_avx512=no php_cv_have_avx512vbmi=no {$extra_vars}");
} }
} }

View File

@@ -80,7 +80,6 @@ class SPCConfigUtil
$libs = $this->getLibsString($libraries, !$this->absolute_libs); $libs = $this->getLibsString($libraries, !$this->absolute_libs);
// additional OS-specific libraries (e.g. macOS -lresolv) // additional OS-specific libraries (e.g. macOS -lresolv)
// embed
if ($extra_libs = SPCTarget::getRuntimeLibs()) { if ($extra_libs = SPCTarget::getRuntimeLibs()) {
$libs .= " {$extra_libs}"; $libs .= " {$extra_libs}";
} }
@@ -226,9 +225,17 @@ class SPCConfigUtil
// parse pkg-configs // parse pkg-configs
foreach ($libraries as $library) { foreach ($libraries as $library) {
$pc = Config::getLib($library, 'pkg-configs', []); $pc = Config::getLib($library, 'pkg-configs', []);
$pkg_config_path = getenv('PKG_CONFIG_PATH') ?: '';
$search_paths = array_filter(explode(is_unix() ? ':' : ';', $pkg_config_path));
foreach ($pc as $file) { foreach ($pc as $file) {
if (!file_exists(BUILD_LIB_PATH . "/pkgconfig/{$file}.pc")) { $found = false;
throw new WrongUsageException("pkg-config file '{$file}.pc' for lib [{$library}] does not exist in '" . BUILD_LIB_PATH . "/pkgconfig'. Please build it first."); foreach ($search_paths as $path) {
if (file_exists($path . "/{$file}.pc")) {
$found = true;
}
}
if (!$found) {
throw new WrongUsageException("pkg-config file '{$file}.pc' for lib [{$library}] does not exist. Please build it first.");
} }
} }
$pc_cflags = implode(' ', $pc); $pc_cflags = implode(' ', $pc);
@@ -257,9 +264,17 @@ class SPCConfigUtil
foreach ($libraries as $library) { foreach ($libraries as $library) {
// add pkg-configs libs // add pkg-configs libs
$pkg_configs = Config::getLib($library, 'pkg-configs', []); $pkg_configs = Config::getLib($library, 'pkg-configs', []);
foreach ($pkg_configs as $pkg_config) { $pkg_config_path = getenv('PKG_CONFIG_PATH') ?: '';
if (!file_exists(BUILD_LIB_PATH . "/pkgconfig/{$pkg_config}.pc")) { $search_paths = array_filter(explode(is_unix() ? ':' : ';', $pkg_config_path));
throw new WrongUsageException("pkg-config file '{$pkg_config}.pc' for lib [{$library}] does not exist in '" . BUILD_LIB_PATH . "/pkgconfig'. Please build it first."); foreach ($pkg_configs as $file) {
$found = false;
foreach ($search_paths as $path) {
if (file_exists($path . "/{$file}.pc")) {
$found = true;
}
}
if (!$found) {
throw new WrongUsageException("pkg-config file '{$file}.pc' for lib [{$library}] does not exist. Please build it first.");
} }
} }
$pkg_configs = implode(' ', $pkg_configs); $pkg_configs = implode(' ', $pkg_configs);

View File

@@ -27,10 +27,10 @@ class SPCTarget
return true; return true;
} }
if (ToolchainManager::getToolchainClass() === GccNativeToolchain::class) { if (ToolchainManager::getToolchainClass() === GccNativeToolchain::class) {
return PHP_OS_FAMILY === 'Linux' && SystemUtil::isMuslDist(); return PHP_OS_FAMILY === 'Linux' && SystemUtil::isMuslDist() && !getenv('SPC_MUSL_DYNAMIC');
} }
if (ToolchainManager::getToolchainClass() === ClangNativeToolchain::class) { if (ToolchainManager::getToolchainClass() === ClangNativeToolchain::class) {
return PHP_OS_FAMILY === 'Linux' && SystemUtil::isMuslDist(); return PHP_OS_FAMILY === 'Linux' && SystemUtil::isMuslDist() && !getenv('SPC_MUSL_DYNAMIC');
} }
// if SPC_LIBC is set, it means the target is static, remove it when 3.0 is released // if SPC_LIBC is set, it means the target is static, remove it when 3.0 is released
if ($target = getenv('SPC_TARGET')) { if ($target = getenv('SPC_TARGET')) {

View File

@@ -16,19 +16,19 @@ $test_php_version = [
// '8.1', // '8.1',
// '8.2', // '8.2',
// '8.3', // '8.3',
'8.4', // '8.4',
'8.5', '8.5',
// 'git', // 'git',
]; ];
// test os (macos-15-intel, macos-15, ubuntu-latest, windows-latest are available) // test os (macos-15-intel, macos-15, ubuntu-latest, windows-latest are available)
$test_os = [ $test_os = [
'macos-15-intel', // bin/spc for x86_64 // 'macos-15-intel', // bin/spc for x86_64
'macos-15', // bin/spc for arm64 // 'macos-15', // bin/spc for arm64
// 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 // 'ubuntu-latest', // bin/spc-alpine-docker for x86_64
'ubuntu-22.04', // bin/spc-gnu-docker for x86_64 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64
// 'ubuntu-24.04', // bin/spc for x86_64 'ubuntu-24.04', // bin/spc for x86_64
// 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64
'ubuntu-24.04-arm', // bin/spc for arm64 'ubuntu-24.04-arm', // bin/spc for arm64
// 'windows-2022', // .\bin\spc.ps1 // 'windows-2022', // .\bin\spc.ps1
// 'windows-2025', // 'windows-2025',
@@ -50,8 +50,8 @@ $prefer_pre_built = false;
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) { $extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'bcmath,xsl,xml', 'Linux', 'Darwin' => 'pgsql',
'Windows' => 'bcmath', 'Windows' => 'com_dotnet',
}; };
// If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`).