Compare commits

..

868 Commits
2.6.1 ... 2.7.5

Author SHA1 Message Date
Jerry Ma
c5ae719b9c Update src/SPC/builder/unix/library/postgresql.php
Co-authored-by: Marc <m@pyc.ac>
2025-10-14 00:08:40 +08:00
crazywhalecc
7b6e707e24 Remove unnecessary macOS 15 bug CFLAGS from PostgreSQL build configuration 2025-10-14 00:08:40 +08:00
crazywhalecc
0114700dad Fix PostgreSQL build compatibility for aarch64 on glibc 2.17 and update test configurations 2025-10-14 00:08:40 +08:00
Marc
ec9364db69 use latest zip version for building shared (#917) 2025-10-13 11:28:16 +02:00
Marc
033e29985e Merge branch 'main' into feature/shared-exts 2025-10-13 11:20:54 +02:00
Marc
61cba2342d Drop macos-13 from actions runner (#922) 2025-10-13 11:20:37 +02:00
Marc
a3acad4ef3 Update config/source.json 2025-10-13 10:59:31 +02:00
Marc
1e13eb4abe Merge branch 'main' into ci/macos-15-intel 2025-10-13 10:38:48 +02:00
Jerry Ma
1bac06fe3c Remove more macOS 14 case from shared extensions switch
Yeah. Copied by tab.
2025-10-13 08:27:40 +08:00
Marc
762a768969 Merge branch 'main' into feature/shared-exts 2025-10-12 23:23:25 +02:00
Marc
d0a6e3a860 update pgsql version to 18.0, php 8.5 to RC2 (#916) 2025-10-12 22:59:09 +02:00
henderkes
995187d258 extra information for steps 2025-10-12 22:32:27 +02:00
henderkes
5333a04e1c clarification 2025-10-12 22:27:38 +02:00
henderkes
19be5263b5 add error 2025-10-12 22:26:06 +02:00
crazywhalecc
6e79401ab5 Add missing libs for suggested option defined 2025-10-13 00:21:13 +08:00
crazywhalecc
903036f1c0 Bump version 2025-10-13 00:00:31 +08:00
crazywhalecc
6bd3eea0fe Use SPCConfigUtil for postgresql build, refactor patches 2025-10-12 23:54:59 +08:00
crazywhalecc
f28a3cf5a3 Drop macos-13 from actions runner 2025-10-12 22:33:22 +08:00
Marc
c828c2c6e4 Merge branch 'main' into feature/shared-exts 2025-10-12 11:35:57 +02:00
Marc
ae1193ab16 Merge branch 'main' into pgsql-18 2025-10-12 11:28:49 +02:00
Marc
6d6a29368e fix building of shared extensions (grpc, simdjson, soap) (#905) 2025-10-12 11:24:32 +02:00
crazywhalecc
897cb00351 Use failsafe for SPC_EXTRA_PHP_VARS 2025-10-12 16:42:38 +08:00
henderkes
8a1689b79d don't fail build without ldap 2025-10-11 13:20:20 +02:00
henderkes
018dfae15e suggestions 2025-10-11 10:38:51 +02:00
Marc
c83e803c85 Merge branch 'main' into pgsql-18 2025-10-10 18:47:48 +02:00
henderkes
fa4d33671d update to RC2 2025-10-10 18:35:15 +02:00
Marc
e6408b4693 Fix static linux cli -a not working issue (#893) 2025-10-08 11:37:27 +02:00
henderkes
3467c9d291 patch correct file 2025-10-06 22:53:41 +02:00
henderkes
15cd8543f1 arm64 fix 2025-10-06 22:50:37 +02:00
henderkes
864db0ebc5 fix macos finally I hope 2025-10-06 22:49:28 +02:00
henderkes
9ee623112d attempt to fix macOS? 2025-10-06 22:43:03 +02:00
henderkes
d789b1a472 fix musl toolchain (needs LD_LIBRARY_PATH) 2025-10-06 22:31:23 +02:00
henderkes
17a25b44e2 attempt fix for aarch64 #2 2025-10-06 22:26:00 +02:00
henderkes
781260f3fc attempt fix for aarch64 2025-10-06 22:11:17 +02:00
henderkes
6c43fa55b1 don't use -static, shared libraries cannot link against static musl libc and linking isn't done for static libraries yet 2025-10-06 21:37:36 +02:00
henderkes
c4440668bb make sure -DFRONTEND is used 2025-10-06 21:28:57 +02:00
henderkes
e437bf2ffe don't test macos 13 2025-10-06 21:05:05 +02:00
henderkes
0f2d2d5734 test pgsql without macos 13 2025-10-06 21:03:57 +02:00
henderkes
a49ae05599 use latest zip version for building shared 2025-10-06 21:00:45 +02:00
henderkes
8ae2755dbe update php 8.5 to rc1 2025-10-06 20:14:52 +02:00
henderkes
3966bd5f0a update pgsql version to 18.0 2025-10-06 20:06:37 +02:00
Marc
384ba54c79 update extension count (#914) 2025-10-04 08:56:30 +02:00
Marc
26dbc922eb update extension count
we now sit at 101 🎉
2025-10-04 08:39:45 +02:00
henderkes
31a4498056 bring back simdjson tests, extension headers do not properly guard for avx512 symbols 2025-09-30 15:07:22 +02:00
henderkes
044275d909 typo 2025-09-30 14:22:38 +02:00
henderkes
c5316f9231 -v3 doesn't have avx512 yet 2025-09-30 14:21:31 +02:00
henderkes
2d1a61d184 explicitly disable avx512 if zig and march not high enough 2025-09-30 14:00:13 +02:00
henderkes
f7744188f4 fix configutil 2025-09-30 00:34:30 +02:00
henderkes
5b6c923eef snappy is a c++ lib 2025-09-30 00:31:20 +02:00
henderkes
b0b031afb2 add docstring 2025-09-30 00:18:32 +02:00
henderkes
fe09d8c03e add docstring 2025-09-30 00:17:53 +02:00
henderkes
c2813d5736 move hasCpp to SPCConfigUtil 2025-09-30 00:12:59 +02:00
Marc
8b2b658ced Merge branch 'main' into fix/grpc-shared 2025-09-29 23:27:58 +02:00
henderkes
e862bacc8a php 8.5 has beta 3 2025-09-29 21:15:56 +02:00
henderkes
cac57dbf79 php 8.5 has beta 3 2025-09-29 21:15:18 +02:00
crazywhalecc
345fe783cc Add version table in docs 2025-09-24 15:46:54 +08:00
crazywhalecc
55efe6d65b Add gnu-bulk 2025-09-24 15:46:54 +08:00
crazywhalecc
dccbc30972 update README 2025-09-24 15:46:54 +08:00
crazywhalecc
f914a82379 Add PHP version, remove duplicate desc 2025-09-24 15:46:54 +08:00
crazywhalecc
18979d8fb6 Simplify README 2025-09-24 15:46:54 +08:00
henderkes
21149f6807 simdjson needs patch 2025-09-23 12:42:29 +02:00
henderkes
93e6dcab1d cflags and cxxflags separately 2025-09-23 12:01:09 +02:00
henderkes
59dedbea2c simdjson requires +evex512 (for zig-cc) 2025-09-23 12:00:15 +02:00
henderkes
8bda4fd31e simdjson requires +evex512 2025-09-23 11:59:30 +02:00
henderkes
8039ea49f9 soap requires libxml and session 2025-09-23 11:56:12 +02:00
henderkes
fc90b4ae23 allow appending pkg_config_path #910 2025-09-22 13:10:48 +02:00
henderkes
e02be69e40 update grpc from 1.68.x to 1.75.x 2025-09-21 21:01:07 +02:00
henderkes
35a90f2769 skip -mcpu or -march=armv8-... flags because zig doesn't support them (stupid grpc build thirdparty hardcode) 2025-09-21 20:32:47 +02:00
henderkes
fa87149631 shallow submodules as well (grpc download goes from 2.9 gb to 900mb) 2025-09-21 19:59:24 +02:00
Marc
8dfe722e14 Merge branch 'main' into fix/grpc-shared 2025-09-19 15:31:25 +02:00
henderkes
dcbfe1e0ab e-dant/watcher is a c++ library too 2025-09-19 15:29:49 +02:00
Marc
e11946fd10 also install g++ with doctor (not preinstalled on ubuntu, not include… (#904) 2025-09-19 15:22:17 +02:00
henderkes
44399cd185 remove -Wl,--as-needed for imagemagick build 2025-09-19 09:21:17 +02:00
henderkes
927d7f55ba make sure -ldl is not taken as needed, problem on EL8 2025-09-18 22:47:01 +02:00
henderkes
e323d7b155 revert to private 2025-09-18 21:41:35 +02:00
henderkes
d0b253c346 not required 2025-09-18 21:36:38 +02:00
henderkes
81430e6853 also use libstdc++.a for grpc? 2025-09-18 21:29:46 +02:00
henderkes
83696e92b7 remove whitespace 2025-09-18 20:12:41 +02:00
henderkes
b0538c09bf deduplicate those to make it more readable 2025-09-18 20:09:17 +02:00
henderkes
40f89d1dca is shared_libadd enough? 2025-09-18 19:44:48 +02:00
henderkes
fa2e041cc9 test shared grpc, imagick 2025-09-18 19:01:10 +02:00
Marc
3c614663a3 Merge branch 'main' into fix/grpc-shared 2025-09-18 18:22:42 +02:00
henderkes
b5c7185374 add comment for new method 2025-09-18 18:20:26 +02:00
henderkes
d0a9a3a594 fix return of array 2025-09-18 18:17:48 +02:00
henderkes
2e6329bb86 add cpp-library for imagemagick too 2025-09-18 18:16:42 +02:00
henderkes
d3ba04fc5b fix grpc shared build (ignores CXXFLAGS, needs CPPFLAGS) 2025-09-18 18:16:41 +02:00
Marc
7a78ea0185 Merge branch 'main' into fix/g++ 2025-09-18 17:35:44 +02:00
henderkes
36b04f9eba also install g++ with doctor (not preinstalled on ubuntu, not included in gcc package) 2025-09-18 17:24:08 +02:00
Marc
79ab6490fd fix CustomPackage handling (#897) 2025-09-18 13:37:26 +02:00
henderkes
191d345250 update paths to only install once 2025-09-18 12:41:36 +02:00
henderkes
311ee40ae4 update LinuxToolCheckList.php to install perl-Time-Piece to make openssl work 2025-09-18 11:58:58 +02:00
henderkes
808d224b08 build frankenphp before shared extensions again 2025-09-18 09:07:18 +02:00
Marc
4247883664 Merge branch 'main' into fix-zig 2025-09-18 08:06:23 +02:00
Marc
3198cc40c1 Remove icu backend from libxml2 (#903) 2025-09-17 10:46:05 +02:00
Marc Henderkes
8680e83af3 fix dba building shared 2025-09-16 14:43:49 +02:00
Marc
0156f33a20 Merge branch 'main' into remove-icu-backend 2025-09-16 13:35:46 +02:00
Marc Henderkes
df8b2dbf16 better patching for libstdc++ when extensions forget they need it 2025-09-16 13:10:10 +02:00
Marc Henderkes
30e174ac95 use any available english locale instead of requiring en_US.utf-8 2025-09-16 13:10:09 +02:00
Marc Henderkes
b9f8f02d98 don't use libicu backend for libxml2
(it's discouraged from being used, the first path always goes through iconv, icu is only the fallback)
2025-09-16 13:10:09 +02:00
henderkes
0b0ae270da we lost a v somehow 2025-09-10 23:35:17 +07:00
henderkes
893ce31b17 only install pkgs for crafting when necessary 2025-09-10 23:28:20 +07:00
crazywhalecc
e35d6c2651 Oh, we also support windows here 2025-09-09 19:43:08 +08:00
crazywhalecc
8dd0512335 Fix macOS lib-depends 2025-09-09 19:43:08 +08:00
henderkes
5c1194ea92 fix custompackage handling 2025-09-09 12:10:06 +07:00
Marc
953ed83df5 Merge pull request #896 from crazywhalecc/fix-zig
Fix zig -isystem overriding
2025-09-08 11:00:03 +02:00
henderkes
c330d02e78 update pkg paths to not double the $arch-$os 2025-09-08 14:18:03 +07:00
henderkes
af6a23011c fix zig relative directory 2025-09-08 13:33:44 +07:00
Abi أب
882ae07deb libxml2 arg typo 2025-09-07 22:56:41 +08:00
crazywhalecc
be7c002869 Patch only when building cli 2025-09-07 16:10:50 +08:00
crazywhalecc
e621e4a5a1 test 2025-09-07 15:38:38 +08:00
crazywhalecc
bd815d4ea2 Fix static linux cli -a not working issue 2025-09-07 14:10:28 +08:00
crazywhalecc
4bc30b0b6f Add php-src/config.log for SPCException 2025-09-07 11:50:51 +08:00
Marc
8d303348d9 Merge pull request #883 from crazywhalecc/sapi/cgi
Add cgi support for macOS and Linux
2025-09-05 11:52:26 +02:00
Marc
2a2f4120b9 Merge pull request #889 from crazywhalecc/franken
use our toolchain for go mod
2025-09-05 11:47:15 +02:00
Marc
15f8887f14 Update config/lib.json 2025-09-05 16:25:15 +07:00
crazywhalecc
fe945ab3ea Merge branch 'main' into sapi/cgi
# Conflicts:
#	composer.lock
2025-09-05 17:15:28 +08:00
crazywhalecc
e2b6f4cedd Merge branch 'main' into sapi/cgi 2025-09-05 17:14:27 +08:00
Jerry Ma
d82c86cf62 Fix docker doctor fix pkgroot volume overwrite bug (#882)
* Fix docker doctor fix pkgroot volume overwrite bug

* cs fix

* Remove pkgroot-private

* Use arch-specified pkgroot

* Update setup-runtime php version

* Add docker-entrypoint.sh

* Update dependencies

* cs fix

* test
2025-09-05 17:13:40 +08:00
henderkes
9df2867175 just always require libxml2 until we rework sapis to require their own stuff 2025-09-05 15:52:07 +07:00
henderkes
5c803d1553 fix cs 2025-09-05 15:31:30 +07:00
henderkes
d45b1853f8 fix cs 2025-09-05 15:28:51 +07:00
henderkes
1ac621fb9c use our toolchain for go mod 2025-09-05 15:20:24 +07:00
crazywhalecc
4e74ac1937 test 2025-09-05 15:02:45 +08:00
crazywhalecc
959734ac31 cs fix 2025-09-05 11:17:45 +08:00
crazywhalecc
166f3de52f Merge branch 'main' into feat/cgi 2025-09-05 11:17:34 +08:00
crazywhalecc
e3adfff16f Update dependencies 2025-09-05 11:14:56 +08:00
crazywhalecc
7cbc374278 Add docker-entrypoint.sh 2025-09-05 11:04:42 +08:00
crazywhalecc
129041402d Update setup-runtime php version 2025-09-05 11:00:57 +08:00
crazywhalecc
9ac578dfd6 Use arch-specified pkgroot 2025-09-05 11:00:46 +08:00
crazywhalecc
ef709a169b Remove pkgroot-private 2025-09-05 11:00:25 +08:00
Marc
2eeba33f94 Merge pull request #885 from crazywhalecc/dumb_github
switch getting frankenphp version to go mod (bypass rate limits)
2025-09-04 18:15:40 +02:00
henderkes
f4b2b9ae7d fix cs 2025-09-04 17:45:13 +07:00
henderkes
e44efb2a54 use go mod to bypass github rate limiting 2025-09-04 17:42:17 +07:00
henderkes
598f6d55c5 keep retrying more 2025-09-04 16:28:17 +07:00
crazywhalecc
a2c5c7e6e6 Add cgi SAPI 2025-09-04 14:05:00 +08:00
crazywhalecc
4f6e646812 cs fix 2025-09-04 12:13:57 +08:00
crazywhalecc
a79564f685 Fix docker doctor fix pkgroot volume overwrite bug 2025-09-04 12:03:13 +08:00
crazywhalecc
a77e49cbc9 Stubborn phpstan 2025-09-02 00:17:44 +08:00
crazywhalecc
cefb737fd2 Update version to 2.7.3 2025-09-02 00:17:44 +08:00
crazywhalecc
8c8aba2dd5 Fix unixodbc driver config searching path 2025-09-02 00:17:44 +08:00
Marc
97b18e9121 Merge pull request #877 from crazywhalecc/franken-retries
retry fetching frankenphp release info
2025-09-01 15:29:21 +02:00
gemini
ddc9cc2237 Fix cli generator: prefer-pre-built belongs to download-options rather than build-options 2025-09-01 20:44:37 +08:00
DubbleClick
aff803f334 retry fetching frankenphp release info 2025-09-01 19:07:29 +07:00
Marc
38ec03fe30 Merge pull request #871 from crazywhalecc/fix/frankenphp-dynamic-exports
build frankenphp and embed after shared extensions
2025-08-31 15:06:11 +02:00
Marc
55836771c9 Merge pull request #869 from crazywhalecc/pkg-config-pkg
turn pkg-config into a package
2025-08-31 15:04:41 +02:00
crazywhalecc
08a68796bf Call export in dynamic symbol getter 2025-08-31 18:05:09 +08:00
crazywhalecc
3b9efcb2d4 Put it into toolchain manager to skip in unit test 2025-08-31 15:24:29 +08:00
crazywhalecc
022ba3dce4 Merge branch 'main' into pkg-config-pkg
# Conflicts:
#	src/globals/test-extensions.php
2025-08-31 15:20:50 +08:00
crazywhalecc
86973e622d sort config 2025-08-31 15:06:59 +08:00
crazywhalecc
0fa38bad6d Use existing pkg-config builds and pre-built contents for packages 2025-08-31 15:04:34 +08:00
crazywhalecc
465bd3ce85 Use separated functions for exporting symbols 2025-08-31 14:24:28 +08:00
Jerry Ma
0c9130ab6c Update node version in vitepress-deploy.yml 2025-08-31 13:44:37 +08:00
crazywhalecc
6c75ecf0c4 Add docs search 2025-08-31 11:47:41 +08:00
DubbleClick
d533a0591b skip line before preg_replacing 2025-08-30 19:31:22 +07:00
DubbleClick
3f74d58503 fix macos, for real this time 2025-08-30 14:12:13 +07:00
DubbleClick
1ba92ccc99 fix patch version stripping (.\d -> .\d+) 2025-08-30 12:02:15 +07:00
DubbleClick
75db184077 fix macos command to print defined symbols? 2025-08-29 17:50:47 +07:00
DubbleClick
66902d74c4 cs fix 2025-08-29 16:38:48 +07:00
DubbleClick
f6cc6af39c macos? 3 2025-08-29 16:36:43 +07:00
DubbleClick
0da8dcf04a macos? 2 2025-08-29 15:14:54 +07:00
DubbleClick
190be6c7b9 macos? 2025-08-29 14:12:00 +07:00
DubbleClick
2972ab31d7 don't add empty dynamic list x) 2025-08-29 12:15:56 +07:00
DubbleClick
4b4ae9b014 write to a --dynamic-list file
see https://sourceware.org/binutils/docs-2.36/ld/Options.html
2025-08-29 10:53:38 +07:00
DubbleClick
20db00afcc no need to test all static targets, nothing changes for them 2025-08-29 10:26:46 +07:00
DubbleClick
56c90ca4a3 use all symbols from libphp.a, so we don't need to build shared extensions 2025-08-29 10:24:51 +07:00
DubbleClick
fad2314539 found ENABLE_SHARED option in liburing! 2025-08-29 09:25:32 +07:00
DubbleClick
460eb02086 build frankenphp and embed after shared extensions, make sure the linker doesn't drop libphp.a symbols that extensions need 2025-08-29 08:52:55 +07:00
Marc
5a30d509e7 Merge pull request #864 from crazywhalecc/swoolehooks
swoole hooks can be compiled if pgsql/sqlite are not compiled in statically
2025-08-29 03:46:30 +02:00
crazywhalecc
0f0050115c Update cli generator, add frankenphp SAPI, add copy-to-clipboard func 2025-08-28 22:35:51 +08:00
crazywhalecc
bf55db959e Add swoole-hook-odbc notes 2025-08-28 22:35:23 +08:00
DubbleClick
39a9840d49 why is phpstan so stupid about this constant? 2025-08-28 12:14:26 +07:00
DubbleClick
866ca264d9 only disable it for x86_64 2025-08-28 11:35:46 +07:00
DubbleClick
f18725083a disable opcache jit automatically on alpine target (only required for php < 8.5) 2025-08-28 11:32:33 +07:00
crazywhalecc
20fbbb1dbe test 2025-08-28 11:01:58 +08:00
crazywhalecc
1a7bf2d070 test 2025-08-28 10:49:02 +08:00
crazywhalecc
fc7e8ebc53 extension test 2025-08-28 10:29:22 +08:00
crazywhalecc
532360886e Merge branch 'main' into swoolehooks 2025-08-28 10:29:07 +08:00
crazywhalecc
117a54d077 extension test 2025-08-28 10:14:47 +08:00
DubbleClick
f2c131a2cc wno-int-conversion 2025-08-27 17:01:07 +07:00
DubbleClick
6f0310e8f7 cs fix 2025-08-27 16:46:58 +07:00
DubbleClick
c7141003db oops 2025-08-27 16:46:09 +07:00
DubbleClick
d32bdb2825 all env vars 2025-08-27 16:45:47 +07:00
DubbleClick
a66abfa583 test all OS 2025-08-27 16:35:24 +07:00
DubbleClick
2551772de4 use system cc 2025-08-27 16:34:29 +07:00
DubbleClick
25fe794acc trim all items 2025-08-27 14:36:05 +07:00
DubbleClick
694fd2f1e0 turn pkg-config into a package instead of a library 2025-08-27 14:33:39 +07:00
DubbleClick
5a4b920ae2 pkg-config patch 2025-08-27 13:04:08 +07:00
DubbleClick
95f1b65bca fix perl installation by checking for FindBin 2025-08-27 13:03:57 +07:00
DubbleClick
25401e5959 cs fix 2025-08-27 12:43:48 +07:00
DubbleClick
3da58d5c24 filter micro patches to not be '' 2025-08-27 11:48:59 +07:00
DubbleClick
08ab3c17d6 fix perl-IPC-Cmd check so it doesn't try installing it every time 2025-08-27 11:40:06 +07:00
DubbleClick
ecdb94b429 suggestions 2025-08-27 08:31:48 +07:00
DubbleClick
00892c20fa fix odbc libs when iconv is built too 2025-08-26 20:44:30 +07:00
DubbleClick
c433aed521 fix macos? 2025-08-26 19:35:10 +07:00
DubbleClick
1243fb9678 don't test macos as it just fails either way, add odbc test 2025-08-26 18:55:22 +07:00
DubbleClick
d9c2247f99 fix alpine realpath -s issue 2025-08-26 18:16:44 +07:00
DubbleClick
0d4d4283d1 only install library for liburing 2025-08-26 18:04:43 +07:00
DubbleClick
effefd4844 string 2025-08-26 14:51:07 +07:00
DubbleClick
2d409db2f9 we don't need a min glibc version, just don't use --use-libc! 2025-08-26 14:42:34 +07:00
DubbleClick
00f262571c cs fix 2025-08-26 14:08:09 +07:00
DubbleClick
4eac953c71 ensure liburing is only pulled in by suggested libs when glibc >= 2.30 (or musl) 2025-08-26 14:07:49 +07:00
DubbleClick
43352ab986 don't print repeated --ri swoole check 2025-08-26 01:01:45 +07:00
DubbleClick
9803bf6c3f prevent warning message from addons 2025-08-26 00:59:54 +07:00
DubbleClick
ba326973e5 prevent infinite recursion if ext suggests addons that depend on the extension 2025-08-26 00:56:57 +07:00
DubbleClick
a1f2126c00 update comments 2025-08-26 00:38:35 +07:00
DubbleClick
b1da64d46b add swoole-hook-odbc to work the same way as the other hooks 2025-08-26 00:24:40 +07:00
DubbleClick
2694dd9e21 add liburing for swoole 2025-08-25 22:57:04 +07:00
Marc
37e0f1d3f3 Update src/SPC/command/BuildPHPCommand.php 2025-08-25 19:50:41 +07:00
DubbleClick
f80aee5133 get rid of $rt 2025-08-25 19:31:15 +07:00
DubbleClick
65ee7479ac suggestion and clean up frankenphp build 2025-08-25 19:29:10 +07:00
DubbleClick
868f6d408b only feed -lgcov to the go driver 2025-08-25 18:44:03 +07:00
DubbleClick
efdfbf437a use format string 2025-08-25 18:23:04 +07:00
DubbleClick
2b57bca55c remove useless import 2025-08-25 15:30:04 +07:00
DubbleClick
99ccbf8a40 @crazywhalecc please look what's wrong with macos 2025-08-25 15:28:53 +07:00
DubbleClick
9fe322375f use 8.4 for tests only 2025-08-25 14:55:30 +07:00
DubbleClick
d13e369994 test swoole 2025-08-25 13:11:40 +07:00
DubbleClick
a46ad7b81e cs fix 2025-08-25 12:58:12 +07:00
DubbleClick
324ba0d3dc use type=addon and arg-type=none 2025-08-25 12:57:49 +07:00
DubbleClick
1c7fa0132d remove space 2025-08-25 12:44:34 +07:00
DubbleClick
93223a9d44 too much pgo, too little pdo 2025-08-25 12:43:21 +07:00
DubbleClick
b6d4af218b zts -> --enable-swoole-thread 2025-08-25 12:42:36 +07:00
DubbleClick
448941f741 don't request configurearg if it's not used (ease debugging) 2025-08-25 12:36:10 +07:00
DubbleClick
7e0e9091be explicitly enable swoole-mysql too 2025-08-25 12:11:56 +07:00
DubbleClick
8104ff7236 update checks for shared swoole-hook extensions 2025-08-25 12:08:53 +07:00
DubbleClick
75f734daa8 cs fix 2025-08-25 11:22:35 +07:00
DubbleClick
779a724875 go's gcc driver is the dumbest shit to ever exist 2025-08-25 11:21:08 +07:00
DubbleClick
e975e151f9 swoole hooks can be compiled if pgsql/sqlite are not compiled in statically 2025-08-25 11:09:02 +07:00
Marc
a5351e1546 Merge pull request #863 from crazywhalecc/brotli-watcher
fix gcc version detection
2025-08-25 05:32:46 +02:00
DubbleClick
af90b840ee format string 2025-08-25 09:59:27 +07:00
DubbleClick
2558c02470 oopsie 2025-08-25 09:59:06 +07:00
DubbleClick
df60ccff0e also make sure clang version uses dots 2025-08-25 09:52:03 +07:00
DubbleClick
2ed8bbf391 add cflags and ldflags to frankenphp build 2025-08-25 09:29:19 +07:00
DubbleClick
ef3025798d fix gcc compiler version 2025-08-25 09:29:06 +07:00
Marc
bea3bd8392 Merge pull request #861 from crazywhalecc/fix/macos-ar
Add macOS AR and LD
2025-08-22 07:23:49 +02:00
crazywhalecc
99e8900aba Add macOS AR and LD 2025-08-22 13:19:42 +08:00
Marc
1c4a6ca02e Merge pull request #860 from crazywhalecc/brotli-watcher
add brotli and watcher to lib-suggests
2025-08-21 15:31:35 +02:00
DubbleClick
b5fa7be53f add brotli and watcher to lib-suggests 2025-08-20 13:40:54 +07:00
Marc
3804e842bb Merge pull request #858 from crazywhalecc/fix/imagick
imagick needs static libstdc++ on gcc-toolset (successor of devtoolse) too
2025-08-20 07:56:08 +02:00
DubbleClick
e6832ecf61 add msgpack suggestion 2025-08-19 20:15:41 +07:00
DubbleClick
ed3e29bade devtoolset any version 2025-08-19 20:03:16 +07:00
DubbleClick
811aeb58ea imagick needs static libstdc++ on gcc-toolset (successor of devtoolset) too 2025-08-19 20:01:10 +07:00
Marc
6b5aaa38ae Merge pull request #857 from crazywhalecc/fix/lstdcpp
move -lstdc++ to the end of the libraries
2025-08-19 10:51:28 +02:00
DubbleClick
4e9545262d finish the redis thingy from the year long open PR 2025-08-19 10:42:30 +07:00
DubbleClick
d48c84d81b move -lstdc++ to the end of the libraries 2025-08-19 10:27:52 +07:00
Jerry Ma
cbddb2652d Merge pull request #856 from crazywhalecc/fix/windows-cmd
Fix WindowsCmd execution, use popen instead of proc_open
2025-08-18 12:07:09 +08:00
Jerry Ma
5f629253ac Merge pull request #853 from crazywhalecc/fix/exception-reflection
Enhance exception handling by binding builder and extra info to exception handler
2025-08-16 19:33:13 +08:00
crazywhalecc
8d84a95c01 Fix WindowsCmd execution, use popen instead of proc_open 2025-08-16 17:54:24 +08:00
crazywhalecc
2cabaf6402 8.5 extension test 2025-08-15 13:19:14 +08:00
crazywhalecc
ad25ac49b8 Update to beta1, extension test 2025-08-15 12:28:26 +08:00
crazywhalecc
d0412a88df Use PatchException instead of ExecutionException for patchFile 2025-08-15 12:04:06 +08:00
crazywhalecc
a3ae1eb2f0 Remove redundant builer options 2025-08-15 11:54:34 +08:00
crazywhalecc
2e616af836 PHPStan fix 2025-08-11 13:32:59 +08:00
Jerry Ma
4fd8afcee4 Update src/SPC/exception/ExceptionHandler.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:30:10 +08:00
Jerry Ma
e96b4f5541 Update src/SPC/exception/ExceptionHandler.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:30:04 +08:00
Jerry Ma
9978a56b1e Update src/SPC/exception/ExceptionHandler.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:29:59 +08:00
Jerry Ma
d3a5be13ea Update src/SPC/exception/ExceptionHandler.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:29:54 +08:00
Jerry Ma
5ba0de12eb Update src/SPC/exception/ExceptionHandler.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:29:48 +08:00
Jerry Ma
a73c097c94 Update src/SPC/command/BuildPHPCommand.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:29:42 +08:00
Jerry Ma
d3840b19fa Update src/SPC/builder/BuilderProvider.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-11 13:29:36 +08:00
crazywhalecc
b34b6594de Suggestions 2025-08-11 12:05:41 +08:00
crazywhalecc
2fba61e9bd Enhance exception handling by binding builder and extra info to ExceptionHandler 2025-08-11 10:48:48 +08:00
crazywhalecc
1e9434221b Remove spc.env.log due to potential secret leaks 2025-08-07 16:25:01 +08:00
crazywhalecc
afd6791075 Fix phpunit 2025-08-07 13:09:18 +08:00
crazywhalecc
b3b53b6b4d Use latest version of logger 2025-08-07 13:09:18 +08:00
crazywhalecc
b8b8cf6ea9 Update version to 2.7.2 2025-08-07 13:09:18 +08:00
crazywhalecc
9a340e1ad8 Update docs, GitHub issue templates, workflows 2025-08-07 13:09:18 +08:00
crazywhalecc
29dc5e4ea7 Chore 2025-08-07 13:09:18 +08:00
crazywhalecc
08fa49b791 Remove craft.log 2025-08-07 13:09:18 +08:00
crazywhalecc
333b776e77 Refactor all command class exception handling 2025-08-07 13:09:18 +08:00
crazywhalecc
f68f060be2 Refactor all (except command) modules using new exceptions 2025-08-07 13:09:18 +08:00
crazywhalecc
722bb31815 Introduce AttributeMapper for managing extensions and doctor attributes 2025-08-07 13:09:18 +08:00
crazywhalecc
e28580de00 Refactor shell utilities: reorganize namespaces and introduce Shell base class 2025-08-07 13:09:18 +08:00
crazywhalecc
cc447a089a Refactor all exception classes, remove unclear RuntimeException, InvalidArgumentException 2025-08-07 13:09:18 +08:00
crazywhalecc
0c9a30256e Remove all @throws PHPDoc, it's almost useless for SPC anymore 2025-08-07 13:09:18 +08:00
Jerry Ma
fa10142f13 Merge pull request #847 from crazywhalecc/fix/spc-exe
Fix spc build actions version, add spc validation
2025-08-06 01:03:38 +08:00
Jerry Ma
c342741670 Update version to 2.7.1 2025-08-05 23:13:19 +08:00
Jerry Ma
64d49003e0 Update release-build.yml 2025-08-05 21:26:35 +08:00
crazywhalecc
b0c93c7418 Fix spc build actions version, add spc validation 2025-08-05 18:59:30 +08:00
Jerry Ma
085abd635e Merge pull request #819 from crazywhalecc/php-85
Add PHP 8.5 initial support
2025-08-05 12:01:47 +08:00
DubbleClick
3789c7c335 only enable one of password-argon2 or openssl-argon2 2025-08-04 10:14:48 +07:00
crazywhalecc
4fb4e42896 Revert 2025-08-04 01:10:08 +08:00
crazywhalecc
81e7a0c554 Add without argon2 option 2025-08-03 23:01:24 +08:00
crazywhalecc
4cbe4ea82d Revert corrupted revert 2025-08-03 23:01:09 +08:00
crazywhalecc
ea4905cd0d Add argon2 support for PHP-NTS < 8.5 2025-08-03 22:59:40 +08:00
crazywhalecc
3c09ba59d7 Merge remote-tracking branch 'origin/php-85' into php-85 2025-08-03 22:55:17 +08:00
Jerry Ma
430f436b79 Update src/SPC/builder/macos/MacOSBuilder.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-03 22:48:09 +08:00
Jerry Ma
93001dce88 Update src/SPC/builder/macos/MacOSBuilder.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-03 22:47:02 +08:00
Jerry Ma
2d6d25cadf Update src/SPC/builder/linux/LinuxBuilder.php
Co-authored-by: Marc <m@pyc.ac>
2025-08-03 22:46:47 +08:00
crazywhalecc
b644da8210 Remove redundant patches for openssl 2025-08-03 22:45:24 +08:00
crazywhalecc
f1a9a28ed7 Use backup file function to avoid multiple build conflict 2025-08-03 02:06:08 +08:00
crazywhalecc
643926886c Test original 2025-08-03 02:00:19 +08:00
crazywhalecc
9a5a59d876 Test 2025-08-03 01:49:15 +08:00
crazywhalecc
e7fe91faef Fix patch, use pure socket client directly 2025-08-03 01:23:47 +08:00
crazywhalecc
e6cf05ddff Test 2025-08-03 01:12:28 +08:00
crazywhalecc
c3e9a2816b Test 2025-08-03 00:29:13 +08:00
Marc
0bb8e83d68 Merge pull request #844 from crazywhalecc/swoole-v6
change swoole to version 6.x because 5.x is not compatible with php 8.4+
2025-08-02 23:06:35 +07:00
crazywhalecc
d0053534ab tmate 2025-08-02 23:06:16 +08:00
crazywhalecc
38725c2bb4 Update ca certificates 2025-08-02 22:22:09 +08:00
DubbleClick
b8fe70e5ee change swoole to version 6.x because 5.x is not compatible with php 8.4+ 2025-08-02 20:23:26 +07:00
crazywhalecc
3960a21e05 Use full domain test list 2025-08-02 18:40:55 +08:00
crazywhalecc
e14301d991 Symbol workaround for cross toolchain 2025-08-02 18:07:32 +08:00
Jerry Ma
65f74044d8 Update tests.yml 2025-08-02 03:03:20 +08:00
Jerry Ma
f6eba32be5 Update tests.yml 2025-08-02 02:38:24 +08:00
crazywhalecc
af62e55da8 Add missing space 2025-08-02 01:38:32 +08:00
crazywhalecc
22a8191b97 Fix opcache jit option parsing in builder 2025-08-02 01:29:20 +08:00
Jerry Ma
17ff5f63bf Update tests.yml 2025-08-02 00:58:36 +08:00
crazywhalecc
48a7d814f8 Test jit 2025-08-01 17:00:35 +08:00
crazywhalecc
2c5cf07e9c cs fix, fix file name 2025-08-01 15:45:33 +08:00
crazywhalecc
cace504a63 Workaround for windows openssl temporarily 2025-08-01 15:42:34 +08:00
crazywhalecc
efa47af347 Add git source test 2025-08-01 15:17:13 +08:00
crazywhalecc
1c9fbdb032 Use none base combination 2025-08-01 15:01:55 +08:00
crazywhalecc
ac2eb3adae Remove redis test 2025-08-01 14:21:38 +08:00
crazywhalecc
d6081ee10f Support alpha4 2025-08-01 13:00:12 +08:00
crazywhalecc
8b9b72958e Add PHP_BUILD_COMPILER for different toolchain 2025-08-01 12:48:48 +08:00
crazywhalecc
34edb6e329 Add PHP_BUILD_PROVIDER to env.ini 2025-08-01 10:58:31 +08:00
crazywhalecc
9487051796 Add PHP_BUILD_PROVIDER for PHP >= 8.4 2025-08-01 02:25:12 +08:00
crazywhalecc
7d0577460f cs-fix 2025-08-01 02:05:46 +08:00
crazywhalecc
6b23f4b34a Fix PHPUnit test on Windows, ignore calling linux system util for other OS 2025-08-01 01:53:38 +08:00
crazywhalecc
451de4a6f6 Fix ConfigValidator and sort config 2025-08-01 01:50:32 +08:00
crazywhalecc
33d587ee9e Remove redis test (https://github.com/phpredis/phpredis/pull/2676) 2025-08-01 01:32:37 +08:00
crazywhalecc
6b381238fe Remove collision, it's useless at all 2025-08-01 01:29:35 +08:00
crazywhalecc
07d66ade85 Add separated patchedBeforeWindowsConfigure 2025-08-01 01:28:56 +08:00
crazywhalecc
e1c9240698 README update 2025-08-01 00:51:04 +08:00
crazywhalecc
d3e8af23bc Whoops 2025-08-01 00:50:51 +08:00
crazywhalecc
5f9fe2948c Fix missing SPC_EXTRA_LIBS with type error bug 2025-08-01 00:09:05 +08:00
crazywhalecc
4c54d99621 Remove pcntl 2025-07-31 23:49:53 +08:00
crazywhalecc
72beba76c3 Merge remote-tracking branch 'origin/php-85' into php-85 2025-07-31 23:46:43 +08:00
crazywhalecc
1047d471ed Merge branch 'main' into php-85
# Conflicts:
#	src/SPC/builder/linux/LinuxBuilder.php
#	src/SPC/store/source/PhpSource.php
#	src/globals/test-extensions.php
2025-07-31 23:46:34 +08:00
crazywhalecc
0496af47df Fix windows PHP 8.5 build 2025-07-31 23:43:44 +08:00
Jerry Ma
0ae4bcbd6f Merge pull request #806 from crazywhalecc/zig
Add zig toolchain support & shared build improvement
2025-07-31 22:44:48 +08:00
DubbleClick
c58bc038f4 version 2.7.0 2025-07-31 21:11:42 +07:00
DubbleClick
ecaa31f38d no start group for macos 2025-07-31 21:11:15 +07:00
crazywhalecc
96a7aabda0 Don't show shell log 2025-07-31 21:31:48 +08:00
crazywhalecc
be857913cd Add alt for re2c 2025-07-31 01:54:28 +08:00
crazywhalecc
601444d0a5 Add re2c build for spc-gnu-docker 2025-07-31 01:44:44 +08:00
crazywhalecc
3c972ac905 Add re2c build 2025-07-31 00:55:25 +08:00
crazywhalecc
6984c29a3a suggestion 2025-07-31 00:11:49 +08:00
crazywhalecc
cb0ea67a28 Fix x86_64 macOS bison finder path 2025-07-31 00:09:13 +08:00
crazywhalecc
fcdb029b10 Install re2c manually in gnu docker 2025-07-31 00:07:23 +08:00
crazywhalecc
5f33a07f4c Fix windows builds when unix configure does not exist 2025-07-30 23:57:52 +08:00
crazywhalecc
357c04def0 Merge branch 'main' into php-85
# Conflicts:
#	src/SPC/util/PkgConfigUtil.php
2025-07-30 23:25:49 +08:00
crazywhalecc
0dfa6e63bd Fix dev:lib-version command with dependencies 2025-07-30 23:23:27 +08:00
crazywhalecc
af10cacdff Add openssl version getter for Windows, test openssl 2025-07-30 23:23:12 +08:00
crazywhalecc
5f5d934d58 Add openssl argon2 password hash support for PHP 8.5 2025-07-30 23:02:28 +08:00
DubbleClick
fda637bb03 suggestions 2025-07-30 10:24:21 +07:00
DubbleClick
76d17ebef0 -static was too much 2025-07-29 13:34:01 +07:00
crazywhalecc
df76ecb60f Fix PHPUnit test, remove unneeded test (function is dynamic) 2025-07-29 12:14:31 +08:00
DubbleClick
83dae09208 cs fix 2025-07-29 10:49:08 +07:00
DubbleClick
430364aacd quicker tests 2025-07-29 10:40:46 +07:00
DubbleClick
81f359dbcf fix tests 2025-07-29 10:39:21 +07:00
crazywhalecc
9ed3c8b498 phpstan 2025-07-29 11:25:06 +08:00
DubbleClick
72abd63b69 cs fix 2025-07-29 10:24:05 +07:00
crazywhalecc
ed67393d33 Move opcache JIT handling from Linux and MacOS builders to Extension 2025-07-29 11:22:58 +08:00
DubbleClick
e8bc892d8b Merge branch 'main' of https://github.com/crazywhalecc/static-php-cli into zig 2025-07-29 10:20:30 +07:00
Jerry Ma
fafe7d5778 Merge pull request #835 from crazywhalecc/chore/test-and-validate
Chore: PHPUnit test & docs & PHPDoc for vendor mode
2025-07-29 11:08:53 +08:00
DubbleClick
a968b19be0 remove zig stuff from tests for now, since we need to keep gcc default 2025-07-29 10:02:21 +07:00
crazywhalecc
e9dbeb1e34 Refactor opcache JIT handling and version checks in Linux and MacOS builders 2025-07-29 10:59:36 +08:00
DubbleClick
feaff0a08c fix macos 2025-07-29 09:20:33 +07:00
DubbleClick
342192fd67 remove lto related stuff again, not worth using 2025-07-28 19:43:01 +07:00
crazywhalecc
4efb3dfc9a Add check for Bison version in MacOS tool checklist, trigger extension test 2025-07-28 16:47:04 +08:00
crazywhalecc
b9bec5b526 Whoops, extension test 2025-07-28 16:00:32 +08:00
crazywhalecc
1ae0752933 Trigger full extension test 2025-07-28 15:58:07 +08:00
crazywhalecc
0696acb9c5 Add support for re2c in tool checklists and environment setup 2025-07-28 15:54:55 +08:00
DubbleClick
3087dc86f8 https://www.phoronix.com/news/GNU-Binutils-2.44 ld.gold is deprecated
don't deprecate libc usage yet, we don't want people to switch to gcc/clang yet
2025-07-28 14:51:13 +07:00
crazywhalecc
973c8f082f Add php-src git version support 2025-07-28 15:36:53 +08:00
crazywhalecc
85e89e4326 alpha2 2025-07-28 10:17:14 +08:00
crazywhalecc
fb106a3d41 Merge branch 'refs/heads/main' into php-85
# Conflicts:
#	src/globals/test-extensions.php
2025-07-28 10:12:13 +08:00
DubbleClick
fb2d676293 zig doesn't support windows (php doesn't support mingw, zig can only compile mingw) 2025-07-27 01:22:11 +07:00
DubbleClick
944cca709f use $AR in second part of command too 2025-07-27 01:10:21 +07:00
DubbleClick
5b4cbbb669 set permissions 2025-07-27 01:08:34 +07:00
DubbleClick
a8492f06bb use zig's linker too (ends up getting used automatically in most cases, anyway, but better be explicit) 2025-07-27 01:07:54 +07:00
DubbleClick
b6f673cd68 Use $AR instead of ar. Compatibility with -flto(=thin). 2025-07-27 00:59:32 +07:00
DubbleClick
42b4272965 idk 2025-07-26 23:46:36 +07:00
DubbleClick
5beb083c55 no musl check? 2025-07-26 23:39:32 +07:00
DubbleClick
cf529adc79 uh, oh, we forgot to do post init 2025-07-26 23:35:38 +07:00
DubbleClick
5a4da8ed5d install zig before doctor 2025-07-26 23:28:17 +07:00
DubbleClick
bd3092ae90 wtf? 2025-07-26 23:24:59 +07:00
DubbleClick
76094fd305 hello? 2025-07-26 23:20:27 +07:00
DubbleClick
e1edaa24cc "zig-cc" cannot create shared objects according to conftests... 2025-07-26 23:14:29 +07:00
DubbleClick
d0d51ccf82 trigger CI again after clearing cache 2025-07-26 22:23:00 +07:00
DubbleClick
05053b5cd6 cs fix 2025-07-26 21:45:48 +07:00
DubbleClick
978552136c try to make everything -flto=thin compatible (librdkafka fails for some reason) 2025-07-26 21:44:01 +07:00
DubbleClick
fb62a0e338 small adjustments 2025-07-26 20:12:18 +07:00
DubbleClick
630f861c62 move musl check so it doesn't keep prompting for install 2025-07-26 15:18:20 +07:00
DubbleClick
c2b3b78846 switch to libmimalloc.a because go linker is sometimes doing unpredictable things 2025-07-26 13:51:34 +07:00
DubbleClick
6e74dabc1c reduce libphp.a size by stripping .a archives inside it as well 2025-07-26 13:48:22 +07:00
DubbleClick
2cb1a95132 change dependency tracking 2025-07-26 11:13:29 +07:00
DubbleClick
70a9ffe4a2 now test gnu again 2025-07-25 20:00:46 +07:00
DubbleClick
3cbd52c1f9 test with zig-cc instead 2025-07-25 18:44:30 +07:00
DubbleClick
753c720716 remove test, seems like removing musl from paths was successful 2025-07-25 17:56:42 +07:00
DubbleClick
d627363132 please please...? 2025-07-25 17:52:33 +07:00
DubbleClick
da8c38575e please...? 2025-07-25 17:16:35 +07:00
DubbleClick
a355e4d0e7 run macos tests again 2025-07-25 16:55:51 +07:00
DubbleClick
5482f130ba make sure we don't use musl ld 2025-07-25 16:55:16 +07:00
DubbleClick
18a5215da9 cs fix 2025-07-25 16:26:34 +07:00
DubbleClick
a3efe86cac logging 2025-07-25 16:26:07 +07:00
DubbleClick
ed3a78b56d revert macos mistake 2025-07-25 16:26:02 +07:00
DubbleClick
af63723794 revert DYLD_LIBRARY_PATH 2025-07-25 16:24:22 +07:00
DubbleClick
a0edca5e5b docs for function 2025-07-25 16:22:42 +07:00
DubbleClick
a9fab86269 rename getStaticAndSharedLibs 2025-07-25 16:18:04 +07:00
DubbleClick
821411cfd6 only -lstdc++ on linux 2025-07-25 16:17:13 +07:00
DubbleClick
a8be88d771 fix swow 2025-07-25 16:13:48 +07:00
DubbleClick
b4392aded7 always install musl libc (to be able to compile dynamic with zig) 2025-07-25 16:11:11 +07:00
DubbleClick
37a453b3cd of course x) 2025-07-25 12:57:40 +07:00
DubbleClick
51fcc6b231 test musl again (succeeds locally :) 2025-07-25 12:32:49 +07:00
DubbleClick
199b3b5582 Merge branch 'main' of https://github.com/crazywhalecc/static-php-cli into zig 2025-07-25 12:03:37 +07:00
crazywhalecc
6c3ff7da32 Change LDFLAGS_PROGRAM to hard-coded 2025-07-25 12:58:19 +08:00
crazywhalecc
a375ab9780 Fix custom pkg download callable not working bug 2025-07-25 12:58:19 +08:00
crazywhalecc
f47c3a2d20 Fix macOS missing lib when linking 2025-07-25 12:58:19 +08:00
DubbleClick
029f2db620 oh dear god what am I doing 2025-07-25 11:12:49 +07:00
DubbleClick
0acf238c74 suggested are required too 2025-07-25 11:02:47 +07:00
DubbleClick
27a4d5af54 better description of function 2025-07-25 10:04:06 +07:00
DubbleClick
ea56e460d0 zig script 2025-07-25 10:00:49 +07:00
DubbleClick
00e78dd84f fix imagick problem, for some reason it must be in the --start-group --end-group 2025-07-25 09:59:24 +07:00
DubbleClick
7eb5fb4520 l:libstdc++.a 2025-07-25 09:30:15 +07:00
Marc
8ff52e2e36 -lphp shared not static 2025-07-24 23:47:01 +07:00
DubbleClick
8c5dc91895 test gnu (test musl again later, jxl fails with avx shit again) 2025-07-24 22:53:19 +07:00
DubbleClick
155e22a9f9 with_dependencies was removed 2025-07-24 22:01:32 +07:00
DubbleClick
7177afd7f8 phpstan fix 2025-07-24 21:57:56 +07:00
DubbleClick
eca7a43a01 get rid of extra logic for shared and static libraries, rely on SPCConfigUtil 2025-07-24 21:42:31 +07:00
DubbleClick
dd99f258c1 do not pull it symbols from libpq during conftests... 2025-07-24 21:32:14 +07:00
DubbleClick
5c9a3e236b array_reverse again 2025-07-24 21:29:34 +07:00
DubbleClick
7b07137b5b typo 2025-07-24 18:43:10 +07:00
DubbleClick
eb898a8867 add ulimit -n for zigtoolchain 2025-07-24 17:14:20 +07:00
DubbleClick
c86360c9c4 typo 2025-07-24 16:43:36 +07:00
DubbleClick
1d6b2bd002 cs fix 2025-07-24 15:51:50 +07:00
DubbleClick
41bb3e7319 move -Wno-date-time to ZigToolchain instead of env.ini 2025-07-24 15:51:08 +07:00
Jerry Ma
f500945298 Merge pull request #833 from crazywhalecc/feat/install-pkg-options
Add --no-alt and --skip-extract option to install-pkg command
2025-07-24 16:35:15 +08:00
DubbleClick
6da3f78df6 force disable AVX512 for zig 2025-07-24 15:12:11 +07:00
DubbleClick
407f6d4671 remove zig specifics 2025-07-24 15:03:33 +07:00
DubbleClick
6c76187f5d remove old code 2025-07-24 14:59:47 +07:00
DubbleClick
8c8800f156 work around it for -target without version... 2025-07-24 14:32:47 +07:00
DubbleClick
b3f1103143 well shit, zig cannot build libjxl 2025-07-24 14:28:34 +07:00
DubbleClick
84e470d213 Merge branch 'main' of https://github.com/crazywhalecc/static-php-cli into zig 2025-07-24 11:02:11 +07:00
crazywhalecc
52a623f31e Suggestions 2025-07-24 12:00:17 +08:00
crazywhalecc
abd7d3cfb4 Add --no-alt and --skip-extract option to install-pkg command 2025-07-24 00:42:30 +08:00
Jerry Ma
f543b55f19 Merge pull request #826 from crazywhalecc/grpc
fix grpc support (use cmake, openssl)
2025-07-23 22:03:55 +08:00
crazywhalecc
f2a3ae409f Use latest minimal micro.sfx for self-packing 2025-07-23 21:37:38 +08:00
DubbleClick
4e4cf4bbc7 fix weird macos thing?! 2025-07-23 17:33:49 +07:00
DubbleClick
d532b57810 use mbstring extension everywhere 2025-07-23 17:21:32 +07:00
DubbleClick
aa337c0c84 space ._. 2025-07-23 16:51:35 +07:00
DubbleClick
cc1f899948 re2.pc didn't have prefix listed 2025-07-23 16:50:26 +07:00
DubbleClick
848c30547c Merge branch 'main' of https://github.com/crazywhalecc/static-php-cli into grpc 2025-07-23 16:25:12 +07:00
Marc
c8cc0131da Merge pull request #831 from crazywhalecc/fix/varname-placeholder
Change variable name for placeholder
2025-07-23 16:24:56 +07:00
crazywhalecc
b0c0ecb59c Rename to suggestions 2025-07-23 15:33:26 +08:00
crazywhalecc
45f257ef14 Change variable name for placeholder 2025-07-23 15:13:38 +08:00
DubbleClick
fa38fa1410 easier debugging for breakpoints 2025-07-23 14:13:22 +07:00
DubbleClick
ee492dcde1 patch pc files 2025-07-23 14:10:28 +07:00
DubbleClick
22bec873a8 more merge stuff 2025-07-23 13:55:09 +07:00
DubbleClick
958fd0cdcb Merge branch 'main' of https://github.com/crazywhalecc/static-php-cli into grpc 2025-07-23 13:51:33 +07:00
Marc
0d0c789d8b Merge pull request #828 from crazywhalecc/feat/pkg-config-integration
Add real pkg-config integration
2025-07-23 13:49:36 +07:00
crazywhalecc
3d19299d30 Patch both 2025-07-23 14:35:34 +08:00
DubbleClick
4c56c96326 lib-suggests: ldap was missing for curl 2025-07-23 13:16:23 +07:00
crazywhalecc
42e2f6a89d Update composer deps, trigger extension test 2025-07-23 12:49:13 +08:00
Jerry Ma
c715f20fe3 Merge pull request #830 from crazywhalecc/fix/pack-location-independent
Patch pkg-config and la files with placeholder when packing pre-built content
2025-07-23 12:38:29 +08:00
crazywhalecc
e02ce4c151 Fix gnu docker openssl build 2025-07-23 12:15:18 +08:00
crazywhalecc
9f7a7a5703 Add packing placeholder 2025-07-23 11:52:25 +08:00
crazywhalecc
147fd396cf Fix openssl pc file 2025-07-23 11:52:05 +08:00
crazywhalecc
293a95da6d Use absolute path for pc files 2025-07-23 11:51:28 +08:00
DubbleClick
952ecb2eec test all affected operating systems! 2025-07-23 10:50:29 +07:00
DubbleClick
31e7cd31c1 make sure that mimalloc.o is *always* first, no matter if $_ENV['LIBS'] is set 2025-07-23 10:49:23 +07:00
DubbleClick
51ec8199e4 bring back static lib logic 2025-07-23 10:46:30 +07:00
DubbleClick
f75c58b7d2 revert to double array_reverse, because static libs with dependencies are backwards 2025-07-23 10:21:36 +07:00
DubbleClick
f8970a21be fix cs 2025-07-23 09:53:31 +07:00
DubbleClick
b6be20727d fix a few accidental array_reverse calls, pkg-config --static instead of pkg-config --libs 2025-07-23 09:47:35 +07:00
crazywhalecc
9c4a6b46b6 Fix pkg-config missing option 2025-07-23 09:57:09 +08:00
crazywhalecc
779c7cec30 test pgsql 2025-07-23 01:32:42 +08:00
crazywhalecc
154a21fbaf phpstan, extension test 2025-07-23 00:48:37 +08:00
crazywhalecc
a2e0efaed3 extension test 2025-07-23 00:45:06 +08:00
crazywhalecc
0d408e0df1 Allow empty target 2025-07-23 00:38:36 +08:00
crazywhalecc
b5ceda5955 Fix libxslt build again 2025-07-23 00:38:25 +08:00
crazywhalecc
ffa5219d23 trigger extension test 2025-07-22 23:18:19 +08:00
crazywhalecc
099425abc8 Fix c++, check pkg-config exists before calling PkgConfigUtil 2025-07-22 22:46:13 +08:00
crazywhalecc
dea3c4afeb Looks like ngtcp2 does not happy with pkg-config 2025-07-22 22:25:46 +08:00
crazywhalecc
4cdafe2497 Fix unique and reverse order 2025-07-22 22:25:21 +08:00
crazywhalecc
a88f9933d2 Fix unique and reverse order 2025-07-22 22:25:16 +08:00
crazywhalecc
a095d489f3 Fix libwebp static libs order 2025-07-22 22:09:45 +08:00
crazywhalecc
2c81ca2bf8 Replace example.com 2025-07-22 22:00:39 +08:00
crazywhalecc
f2ccabf062 Fix library base, fix brotli and curl libs, trigger extension test 2025-07-22 21:54:27 +08:00
crazywhalecc
6dd4406782 Disable extension test's UPX 2025-07-22 21:19:11 +08:00
crazywhalecc
062cc84d51 Fix phpunit 2025-07-22 21:15:22 +08:00
crazywhalecc
dfbc9a7fff Trigger common extension test 2025-07-22 21:14:25 +08:00
crazywhalecc
1888b735d1 Fix all extension builds 2025-07-22 21:13:35 +08:00
Marc
a44dc0a5f6 cd later 2025-07-22 19:45:58 +07:00
crazywhalecc
6634ade6b4 Fix library build failure not interrupt bug 2025-07-22 20:41:35 +08:00
DubbleClick
6962d24b52 unify CMakeExecutor and AutoConfExecutor 2025-07-22 19:12:17 +07:00
DubbleClick
eb56690684 use escapeshellarg 2025-07-22 19:03:16 +07:00
DubbleClick
4b7020fbbb also escape if it contains a space 2025-07-22 19:01:46 +07:00
DubbleClick
f9a8231820 simpler check 2025-07-22 19:01:07 +07:00
crazywhalecc
7e977414a7 Use spc-config instead of SPC_EXTRA_LIBS, trigger extension test 2025-07-22 19:59:44 +08:00
DubbleClick
c96d503dae fix cs 2025-07-22 18:45:28 +07:00
DubbleClick
8c603d59c6 simplify path 2025-07-22 18:42:34 +07:00
DubbleClick
bdb705e89a only escape path if required 2025-07-22 18:38:17 +07:00
DubbleClick
9172c39a26 change --with-prefix to --with-path, add --enable-path (yes, grpc uses that...) 2025-07-22 18:29:58 +07:00
DubbleClick
3ca7c15208 simplify back to --enable, it actually supports paths :O 2025-07-22 18:21:33 +07:00
DubbleClick
cfda1e93a0 add macos ldflags 2025-07-22 17:17:11 +07:00
DubbleClick
8f8a493b20 trigger deprecation again 2025-07-22 17:04:56 +07:00
DubbleClick
5aa9255909 cs fix 2025-07-22 16:27:05 +07:00
DubbleClick
107fb08e34 simplify patch logic for grpc (--enable-grpc=PATH does not actually pass a path, needs to be --with-grpc=PATH) 2025-07-22 16:26:37 +07:00
crazywhalecc
95a94da66f Add --no-php option to spc-config 2025-07-22 17:26:34 +08:00
crazywhalecc
c8eb62e8f0 Add real pkg-config integration 2025-07-22 17:23:13 +08:00
DubbleClick
4010a84d88 set up tmate 2025-07-22 15:00:22 +07:00
crazywhalecc
c0db3a69d7 Update composer deps 2025-07-22 14:46:51 +08:00
crazywhalecc
5dbf401615 Fix macOS libphp.dylib compatibility 2025-07-22 14:46:41 +08:00
crazywhalecc
c5811ae947 Reduce grpc building things 2025-07-22 14:46:28 +08:00
crazywhalecc
e1595e1091 Remove old workaround code 2025-07-22 14:46:01 +08:00
DubbleClick
aa366d4213 remove linux target os 2025-07-22 13:06:48 +07:00
crazywhalecc
20ab4afb4b Merge branch 'main' into grpc
# Conflicts:
#	src/globals/test-extensions.php
2025-07-22 13:57:31 +08:00
DubbleClick
1300919c44 cs fix 2025-07-22 12:50:04 +07:00
DubbleClick
81b96c2b30 Merge remote-tracking branch 'origin/main' into zig 2025-07-22 12:49:42 +07:00
Marc
a98f72cc32 Merge pull request #824 from crazywhalecc/tiff
add Lerc, JBIG and JXL libraries for use in imagick
2025-07-22 12:46:45 +07:00
DubbleClick
9ba9b87405 makes more sense 2025-07-22 12:44:51 +07:00
DubbleClick
1e42ef042b Merge remote-tracking branch 'origin/zig' into zig 2025-07-22 12:42:54 +07:00
DubbleClick
206bc95ee2 use correct musl lib 2025-07-22 12:42:45 +07:00
crazywhalecc
b746e50233 Make IANA happier than apple 2025-07-22 13:21:18 +08:00
crazywhalecc
a8dcfce99e chore 2025-07-22 13:16:34 +08:00
crazywhalecc
f69f8d1e4a Move zig-toolchain-only things to zig toolchain class 2025-07-22 13:16:26 +08:00
DubbleClick
9c9ffb615f cs fix 2025-07-22 12:07:03 +07:00
DubbleClick
62a58d410f describe centos 7 behaviour better 2025-07-22 11:49:13 +07:00
DubbleClick
9e7e2e30a4 goddamn centos 7 2025-07-22 11:48:12 +07:00
crazywhalecc
3350888af6 Merge remote-tracking branch 'origin/zig' into zig 2025-07-22 12:46:54 +08:00
DubbleClick
22552262b3 add different build dir in again 2025-07-22 11:43:19 +07:00
DubbleClick
a0f474db20 redundant 2025-07-22 11:39:07 +07:00
DubbleClick
d5cd42b0e7 delete cs fixer wrapper 2025-07-22 11:38:42 +07:00
DubbleClick
307d3dda20 join array to string 2025-07-22 11:30:00 +07:00
crazywhalecc
86e3e51b5a Drop legacy phpmicro support 2025-07-22 12:29:41 +08:00
crazywhalecc
4fc081fcc6 Correct chdir to original dir 2025-07-22 12:25:43 +08:00
crazywhalecc
ff30e0f99a Use https instead of http for gnu docker 2025-07-22 12:24:48 +08:00
DubbleClick
6594f6b653 fix remaining errors 2025-07-22 11:23:42 +07:00
DubbleClick
0942637d12 Merge remote-tracking branch 'origin/grpc' into grpc
# Conflicts:
#	src/SPC/builder/extension/grpc.php
#	src/SPC/builder/unix/library/grpc.php
2025-07-22 10:55:48 +07:00
DubbleClick
bb96db4395 rework static lib detection 2025-07-22 10:54:44 +07:00
DubbleClick
f31f0d6168 should be fixed properly 2025-07-22 10:48:14 +07:00
DubbleClick
1f4a3e4b8f oh, it will likely be this instead 2025-07-22 10:48:14 +07:00
DubbleClick
b30f2bc193 for some reason alpine docker fails in CI, but not locally, after I added this? 2025-07-22 10:48:14 +07:00
DubbleClick
b43d0746f4 cs fix 2025-07-22 10:48:14 +07:00
DubbleClick
227210209c -static-libstdc++ and -static-libgcc for static builds (musl toolchain) 2025-07-22 10:48:14 +07:00
DubbleClick
3dd3cf2814 use pkgconfig to determine libs fix cs 2025-07-22 10:48:14 +07:00
DubbleClick
e98e221d93 use pkgconfig to determine libs 2025-07-22 10:48:14 +07:00
DubbleClick
81a59be0c4 use =package 2025-07-22 10:48:14 +07:00
DubbleClick
8eb7723114 enable tests 2025-07-22 10:48:13 +07:00
DubbleClick
45d96734dd grpc can be built shared too 2025-07-22 10:48:13 +07:00
DubbleClick
915ffd84c8 remove grpc_php_ext_src 2025-07-22 10:48:13 +07:00
DubbleClick
161a92aff7 needed --libs --static 2025-07-22 10:48:13 +07:00
DubbleClick
9b207807eb doesn't even work yet, there has to be a better way than to add 2913912309 libraries 2025-07-22 10:48:13 +07:00
DubbleClick
0bdafed92f fix cs 2025-07-22 10:47:35 +07:00
DubbleClick
2ebd230a08 use git instead of patching deps.sh 2025-07-22 10:43:51 +07:00
DubbleClick
6d60000952 Merge branch 'tiff' of https://github.com/crazywhalecc/static-php-cli into tiff 2025-07-22 10:26:25 +07:00
DubbleClick
1b6422eed3 suggestion 2 2025-07-22 10:22:53 +07:00
DubbleClick
a643c44ac6 suggestion 1 2025-07-22 10:22:53 +07:00
DubbleClick
02732036de test shared imagick.so build 2025-07-22 10:22:53 +07:00
DubbleClick
c0483b4b34 don't download libpng, zlib, brotli, as we already build them 2025-07-22 10:22:53 +07:00
DubbleClick
eff6c0666b disable jni instead of sjpeg 2025-07-22 10:22:53 +07:00
DubbleClick
ed97669d9e force usage of already built brotli lib 2025-07-22 10:22:52 +07:00
DubbleClick
ddb14e2db7 install libatomic-devel for devtoolset-10 2025-07-22 10:22:52 +07:00
DubbleClick
c452252a7d add jxl to test 2025-07-22 10:22:52 +07:00
DubbleClick
6fcd301cf5 fix 2025-07-22 10:22:52 +07:00
DubbleClick
52862a3d63 fix libtiff libs being defined after configure 2025-07-22 10:22:52 +07:00
DubbleClick
ff092b4e9d add libjxl #755 2025-07-22 10:22:52 +07:00
DubbleClick
0d6453751d fixes 2025-07-22 10:22:52 +07:00
Marc
082b9a907b Update src/SPC/builder/unix/library/jbig.php
Co-authored-by: Jerry Ma <jesse2061@outlook.com>
2025-07-22 10:22:52 +07:00
DubbleClick
5675a1e2ad Revert "only uncomment that line temporarily"
This reverts commit d07fadde76.
2025-07-22 10:22:52 +07:00
DubbleClick
8601c26f2d only uncomment that line temporarily 2025-07-22 10:22:52 +07:00
DubbleClick
ece7a04437 oops 2025-07-22 10:22:52 +07:00
DubbleClick
9d2d3d2d0a test
# Conflicts:
#	src/globals/test-extensions.php
2025-07-22 10:22:48 +07:00
DubbleClick
cec445eab5 sort 2025-07-22 10:21:09 +07:00
DubbleClick
8116e8898e fix lerc build (needs -lstdc++) 2025-07-22 10:21:09 +07:00
DubbleClick
be0dbcd9eb add jbig 2025-07-22 10:21:09 +07:00
DubbleClick
5c44703f53 add lerc 2025-07-22 10:21:09 +07:00
Marc
c364970e05 Merge pull request #827 from crazywhalecc/feat/git-submodules
Allow specifying submodules for git source
2025-07-22 10:19:30 +07:00
Jerry Ma
b2385cf80c Update src/SPC/store/Downloader.php
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-21 23:33:20 +08:00
Jerry Ma
2b1d03d9d4 Update src/SPC/store/Downloader.php
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-21 23:29:38 +08:00
crazywhalecc
5b6f33a2a1 Allow specifying submodules for git source 2025-07-21 23:21:00 +08:00
Marc
352955d608 absolute dir? 2025-07-21 21:36:33 +07:00
Marc
e07b281577 fix build dir conflict 2025-07-21 21:25:33 +07:00
Marc
71f4e45256 remove workaround 2025-07-21 21:22:41 +07:00
Marc
828f51500d disable ubuntu latest (jit error until php-src fixes it) 2025-07-21 21:01:39 +07:00
DubbleClick
4a0a7e0df3 suggestion 2 2025-07-21 19:34:31 +07:00
DubbleClick
3c8b588312 suggestion 1 2025-07-21 19:32:44 +07:00
DubbleClick
711d61d120 testing frankenphp with php 8.1 makes no sense 2025-07-21 19:00:53 +07:00
Marc
bce363e543 make sure we didn't break any other OS 2025-07-21 18:32:57 +07:00
DubbleClick
d66d7b3a73 should be fixed properly 2025-07-21 16:56:39 +07:00
DubbleClick
024542d361 oh, it will likely be this instead 2025-07-21 16:03:28 +07:00
DubbleClick
7d85aacace for some reason alpine docker fails in CI, but not locally, after I added this? 2025-07-21 16:00:28 +07:00
DubbleClick
31b2e6779d cs fix 2025-07-21 14:29:27 +07:00
DubbleClick
2b39a6d535 -static-libstdc++ and -static-libgcc for static builds (musl toolchain) 2025-07-21 14:29:01 +07:00
DubbleClick
e490a1763a use pkgconfig to determine libs fix cs 2025-07-21 12:12:18 +07:00
DubbleClick
bf4b35aa0a use pkgconfig to determine libs 2025-07-21 12:10:14 +07:00
DubbleClick
1f7d3ec91d use =package 2025-07-21 10:55:21 +07:00
DubbleClick
23412d6bfa enable tests 2025-07-21 09:46:06 +07:00
DubbleClick
bd0042f079 grpc can be built shared too 2025-07-21 09:43:01 +07:00
DubbleClick
0ccf1a1c5d remove grpc_php_ext_src 2025-07-21 09:41:36 +07:00
DubbleClick
76d7002646 needed --libs --static 2025-07-21 09:33:29 +07:00
DubbleClick
38cc4cfe7e doesn't even work yet, there has to be a better way than to add 2913912309 libraries 2025-07-21 00:32:43 +07:00
DubbleClick
d91b476f33 test shared imagick.so build 2025-07-20 10:37:37 +07:00
DubbleClick
f7080c61d5 don't download libpng, zlib, brotli, as we already build them 2025-07-20 02:49:30 +07:00
DubbleClick
26842fba27 disable jni instead of sjpeg 2025-07-20 02:17:00 +07:00
DubbleClick
dce1065af5 force usage of already built brotli lib 2025-07-20 02:06:43 +07:00
DubbleClick
f0af17abe4 install libatomic-devel for devtoolset-10 2025-07-20 01:44:09 +07:00
DubbleClick
fbd56da7ad add jxl to test 2025-07-20 01:21:33 +07:00
DubbleClick
0ef8b8c175 fix 2025-07-20 01:17:58 +07:00
DubbleClick
230879a0db fix libtiff libs being defined after configure 2025-07-20 01:13:51 +07:00
DubbleClick
2ef64e4597 add libjxl #755 2025-07-20 00:11:29 +07:00
DubbleClick
6c18862fd1 fixes 2025-07-19 23:54:38 +07:00
Marc
6c109c52f6 Update src/SPC/builder/unix/library/jbig.php
Co-authored-by: Jerry Ma <jesse2061@outlook.com>
2025-07-19 17:56:54 +07:00
Jerry Ma
f3400b8756 Merge pull request #822 from yoramdelangen/fix/workflow-reuse-upload-license-conflicts
fix: conflict upload names when reusing workflow more then once
2025-07-19 18:37:08 +08:00
DubbleClick
b79b1f5750 cs fix 2025-07-19 15:23:18 +07:00
DubbleClick
9b72f57463 use www.example.com 2025-07-19 15:22:23 +07:00
DubbleClick
6f9a45b54a shared extensions may also need to patch 2025-07-19 15:17:44 +07:00
DubbleClick
683461d918 actually path php makefile 2025-07-19 15:12:15 +07:00
DubbleClick
ada203c00c str_starts_with 2025-07-19 15:11:22 +07:00
DubbleClick
01887d652c add extra runtime objects for shared libraries built directly by php make too 2025-07-19 15:10:42 +07:00
DubbleClick
fff23649cf only comment out that line temporarily 2025-07-18 20:45:46 +07:00
DubbleClick
c7762a5b65 Revert "only uncomment that line temporarily"
This reverts commit d07fadde76.
2025-07-18 20:44:04 +07:00
DubbleClick
d07fadde76 only uncomment that line temporarily 2025-07-18 20:30:51 +07:00
DubbleClick
ac7a09edd1 oops 2025-07-18 14:52:39 +07:00
Marc
f30f095f00 Merge branch 'main' into tiff 2025-07-18 14:47:59 +07:00
DubbleClick
d91a66ee8d test 2025-07-18 14:47:05 +07:00
DubbleClick
7db7ed97ee sort 2025-07-18 14:41:10 +07:00
DubbleClick
6b9d49eb71 fix lerc build (needs -lstdc++) 2025-07-18 14:39:17 +07:00
DubbleClick
7c9e8e3e40 add jbig 2025-07-18 14:04:55 +07:00
DubbleClick
5586f627d3 add lerc 2025-07-18 13:51:33 +07:00
Marc
04f3f0872d Merge branch 'main' into zig 2025-07-18 12:47:58 +07:00
Marc
e4921087d9 Merge pull request #823 from crazywhalecc/fix/curl-patch
Fix curl build for non-windows
2025-07-18 12:37:38 +07:00
crazywhalecc
005b78413c Fix curl build for non-windows 2025-07-18 13:23:46 +08:00
DubbleClick
c752f4d4b5 tidy too 2025-07-18 11:56:29 +07:00
DubbleClick
991e2dee5a stable 2025-07-18 11:53:57 +07:00
DubbleClick
33d974bb3d use stable sources for swoole and swow 2025-07-18 11:53:36 +07:00
Yoram
0a1677af95 add build-meta to use php-version and os for artifacts upload name 2025-07-17 10:19:54 +02:00
Yoram
7ffbb10587 fix: conflict upload names when reusing workflow more then once 2025-07-17 09:48:22 +02:00
Jerry Ma
3d45890a2d Merge pull request #821 from crazywhalecc/fix/windows-curl-sspi
Fix/windows curl sspi
2025-07-17 13:58:31 +08:00
Jerry Ma
bb5eb64b28 Merge pull request #802 from crazywhalecc/feat/safe-pack
Check lib-suggest before packing libs
2025-07-17 13:34:15 +08:00
crazywhalecc
e6a050de82 Use SPC_EXTRA_LIBS instead of SPC_WINDOWS_EXEC_LIBS 2025-07-17 13:14:18 +08:00
crazywhalecc
7e7eb844a7 cs-fix 2025-07-17 12:26:30 +08:00
crazywhalecc
e56c628bec Add windows tests 2025-07-17 12:23:03 +08:00
crazywhalecc
c604f88685 Disallow alt for php-src 2025-07-17 12:21:50 +08:00
crazywhalecc
83db186972 Fix curl static build for Windows 2025-07-17 12:21:13 +08:00
DubbleClick
e675af9a18 use zts of course... 2025-07-16 18:58:08 +07:00
Marc
ca8cd7ff3d Merge branch 'main' into zig 2025-07-16 18:43:48 +07:00
DubbleClick
b05002ee9b manual compilation doesn't respect CFLAGS, so pass them directly 2025-07-16 17:50:39 +07:00
DubbleClick
b3c665907b always dump error when extension sanity test fails 2025-07-16 12:34:30 +07:00
DubbleClick
64776e3868 don't do host shenanigans with libffi 2025-07-16 12:28:22 +07:00
DubbleClick
df4d66ad4b disable jbig for imagemagick 2025-07-15 23:29:33 +07:00
crazywhalecc
f0612591be Test bulk (without amqp, swoole) and spc-max 2025-07-15 23:31:26 +08:00
crazywhalecc
5838c87140 Merge remote-tracking branch 'origin/php-85' into php-85 2025-07-15 22:08:16 +08:00
crazywhalecc
1ce3ba0f30 Update docs and READMEs 2025-07-15 22:08:10 +08:00
Jerry Ma
dc8f7de75a Merge branch 'main' into php-85 2025-07-15 21:59:48 +08:00
crazywhalecc
d3f8e94fe9 Use new branch of micro, extension test 2025-07-15 21:57:49 +08:00
crazywhalecc
88cf0184cc extension test 2025-07-15 21:57:06 +08:00
crazywhalecc
b9e096abfa Download alpha version for 8.5 2025-07-15 21:14:15 +08:00
crazywhalecc
ec959f6239 Add 8.5 patch support for phpmicro 2025-07-15 21:14:02 +08:00
crazywhalecc
5f2459ae43 Avoid useless exception on startup version mismatch 2025-07-15 21:11:38 +08:00
Jerry Ma
9af3b745a2 Merge pull request #792 from crazywhalecc/fix/ext-imap-extraction
Skip re-extract ext-imap source
2025-07-10 21:39:34 +08:00
crazywhalecc
a5cd5fcb31 Fix test and bump docker image version 2025-07-10 20:20:29 +08:00
crazywhalecc
ec153fa6ff Workaround for swoole with alpine 3.21 2025-07-10 20:10:54 +08:00
crazywhalecc
dd72b32559 Merge 2025-07-10 12:59:27 +08:00
DubbleClick
4f4e1ca80d revert 2025-07-09 09:50:58 +07:00
DubbleClick
dd6c1d9607 patch pkgconf prefix to BUILD_ROOT_PATH instead of /../.. 2025-07-08 22:56:36 +07:00
DubbleClick
7b5f4e9dd0 cs fix 2025-07-08 11:25:44 +07:00
DubbleClick
9cd17fca1c make sure that libargon2 is always linked in before libsodium 2025-07-07 22:44:07 +07:00
DubbleClick
385a46b96f update notes for argon2 2025-07-07 21:19:57 +07:00
DubbleClick
04cbba3f4e enable-pie for openssl 2025-07-07 21:09:39 +07:00
DubbleClick
5ab5908ef5 comment it out again 2025-07-06 09:51:12 +07:00
DubbleClick
9bf65ffe83 figure out what libphp it pulls in and why 2025-07-06 08:34:01 +07:00
DubbleClick
10c8fe1f26 make it fail again (so we can later enable tmate) 2025-07-05 22:51:57 +07:00
DubbleClick
01517f82b8 disable tmate 2025-07-05 22:22:51 +07:00
DubbleClick
67277ccc21 explicitly state libphp we built? 2025-07-05 21:54:36 +07:00
DubbleClick
b12cb3350f move tmate session thingy 2025-07-05 20:00:55 +07:00
DubbleClick
3ff8c504f8 cs fix, enable action-tmate 2025-07-05 19:19:17 +07:00
DubbleClick
939b9eb8a8 fix debug flags 2025-07-05 19:13:16 +07:00
Marc
9935eba336 Update test-extensions.php 2025-07-05 15:56:36 +07:00
Marc
4024f9d6dd Update SPCTarget.php 2025-07-05 14:47:27 +07:00
DubbleClick
a097484a51 update isStatic check to ignore SPC_LIBC if using Gcc/Clang/Musl toolchain 2025-07-05 14:26:04 +07:00
DubbleClick
b0cfb4b2c4 don't clog our build CI when cs fix, phpstan or phpunit fail 2025-07-05 14:00:43 +07:00
DubbleClick
05f3abe944 cs fix 2025-07-05 13:53:12 +07:00
DubbleClick
a191c136dc strip all may strip things needed for relocation on musl 2025-07-05 13:52:47 +07:00
DubbleClick
e31e228d10 don't hardcode architecture 2025-07-05 12:19:26 +07:00
DubbleClick
47cbdf555f oops, needs musl 2025-07-05 12:13:02 +07:00
DubbleClick
26aca723cb update php-cs fixer to get rid of PHP_CS_FIXER_IGNORE_ENV variable 2025-07-05 12:11:48 +07:00
DubbleClick
93d6a45a78 *full* shared extension build linked against musl libc dynamically works! 2025-07-05 12:01:52 +07:00
DubbleClick
2ac20cf3af remove unnecessary LDFLAGS_PROGRAM env var 2025-07-05 10:44:40 +07:00
crazywhalecc
112f607d6e Add linux-only for extra runtime objects 2025-07-05 11:42:00 +08:00
crazywhalecc
c9d33bffc8 Chore 2025-07-05 10:49:55 +08:00
crazywhalecc
59f9143a3c Remove redundant postfix in openssl 2025-07-05 10:49:36 +08:00
crazywhalecc
d7f3005b69 Fix missing dash 2025-07-05 10:49:20 +08:00
crazywhalecc
5f8cd972cd Move extra runtime object to zig toolchain 2025-07-05 10:48:56 +08:00
DubbleClick
013a19e25b rename COMPILER_EXTRA to SPC_COMPILER_EXTRA 2025-07-04 14:39:42 +07:00
DubbleClick
94c38df1ba remove superfluous build-frankenphp script 2025-07-04 14:32:47 +07:00
DubbleClick
d65d82ff0a remove extra libraries for php configure/make, since they're the same and only depend on the target libc 2025-07-04 14:27:48 +07:00
DubbleClick
3070376fb6 dont use 32 bit objects 2025-07-03 20:37:50 +07:00
DubbleClick
e019b65ef7 does this break tests again? 2025-07-03 16:40:04 +07:00
DubbleClick
ccdb6a031f test native-linux-gnu again? 2025-07-03 15:42:42 +07:00
DubbleClick
e5c5b77a9a don't run extra logic in zig-cc script if there's no version string in SPC_TARGET 2025-07-03 14:46:07 +07:00
DubbleClick
3444e308fd cs fix 2025-07-03 13:51:54 +07:00
DubbleClick
8b37c64088 don't replace -lc++? 2025-07-03 13:50:06 +07:00
DubbleClick
f6a1065cd7 fix libc detection too 2025-07-03 12:44:49 +07:00
DubbleClick
4a2b28e88c fix isStatic detection for native-native 2025-07-03 12:33:55 +07:00
DubbleClick
6355a97b47 don't pass --build-shared when not using zig toolchain 2025-07-03 12:26:11 +07:00
DubbleClick
20c4056561 test native-native in CI 2025-07-03 12:25:36 +07:00
DubbleClick
a5a87b975b update target declaration to be correct 2025-07-03 12:20:59 +07:00
DubbleClick
456d12fb58 fix error suppression 2025-07-03 11:59:39 +07:00
DubbleClick
c735960ff8 Revert "remote -lutil?"
This reverts commit aff3373b78.
2025-07-03 11:43:05 +07:00
DubbleClick
cebd95b2c7 suggestion 2025-07-03 11:21:24 +07:00
DubbleClick
aff3373b78 remote -lutil? 2025-07-03 11:11:21 +07:00
DubbleClick
420fe497a5 patch correct pc 2025-07-03 09:23:59 +07:00
DubbleClick
f6a292b57b cleaner 2025-07-02 21:38:58 +07:00
DubbleClick
39ffb8d99d why does exec work but output=$(...) doesn't? 2025-07-02 21:32:24 +07:00
DubbleClick
2ac5438f6b libheif and libde265 report dependency on -lc++ instead of -lstdc++ 2025-07-02 16:11:21 +07:00
DubbleClick
76b36cef35 fix macos test 2025-07-02 14:26:15 +07:00
DubbleClick
4b38da76b1 test frankenphp too 2025-07-02 14:01:06 +07:00
DubbleClick
cc285ae8d8 cs fix 2025-07-02 12:57:58 +07:00
DubbleClick
a5a020eef1 Revert "add cache file option to autoconf executor by default (if cflags and ldflags match default)"
This reverts commit abe27598de.
2025-07-02 12:56:11 +07:00
DubbleClick
6f68d7b7f1 Revert "add cache file option to autoconf executor by default (if cflags and ldflags match default)"
This reverts commit 5577cd0fab.
2025-07-02 12:55:59 +07:00
DubbleClick
abe27598de add cache file option to autoconf executor by default (if cflags and ldflags match default) 2025-07-02 11:47:36 +07:00
DubbleClick
5577cd0fab add cache file option to autoconf executor by default (if cflags and ldflags match default) 2025-07-02 11:47:20 +07:00
DubbleClick
0695fb9381 cs fixer 2025-07-02 09:33:33 +07:00
DubbleClick
b5aa7fc213 simplify script a bit 2025-07-02 09:26:11 +07:00
DubbleClick
b16638d813 place -lstdc++ in compiler_extra 2025-07-02 09:23:31 +07:00
DubbleClick
a0564628c4 try removing -lstdc++ (this will likely make a few extensions fail to load with undefined gxx_personality_v0 again, but we can use COMPILER_EXTRA there) 2025-07-01 23:32:55 +07:00
DubbleClick
719bde87b7 allow compilation with empty target 2025-07-01 23:31:54 +07:00
DubbleClick
d8ee308a5f allow explicitly setting toolchain (simplify testing without constantly overriding CC and CXX) 2025-07-01 23:01:53 +07:00
Marc
a5d26d6517 Merge pull request #813 from crazywhalecc/fix-native
fix g++ not found error
2025-07-01 22:12:09 +07:00
DubbleClick
8b3a22cbe4 better error message 2025-07-01 18:23:02 +07:00
DubbleClick
8d47e56010 sanity check after toolset init 2025-07-01 18:22:05 +07:00
DubbleClick
a6d68b9ecf fix ncurses 2025-07-01 18:09:17 +07:00
DubbleClick
d275d6cc69 fix native chain 2025-07-01 18:06:18 +07:00
DubbleClick
e5ea32e9c0 fix in case it's not set 2025-07-01 17:57:36 +07:00
DubbleClick
5bc4504e37 fix g++ not found error 2025-07-01 17:53:35 +07:00
DubbleClick
fd89e83798 musl paths in zig toolchain are hogwash, of course 2025-07-01 17:08:19 +07:00
DubbleClick
88f9172866 bring back opcache jit fix 2025-07-01 16:57:56 +07:00
DubbleClick
27f57cc23a fix zig runtime 2025-07-01 16:40:12 +07:00
DubbleClick
f6c6011061 err, we need to install zig of course 2025-07-01 16:25:08 +07:00
DubbleClick
408b3b4060 try to test with zig? 2025-07-01 16:21:57 +07:00
DubbleClick
55fd7ba8e6 bring back static -lstdc++ for rhel 2.17 2025-07-01 15:58:04 +07:00
DubbleClick
e34eb502db fix tests failing to deprecation 2025-07-01 15:05:44 +07:00
DubbleClick
292df38c10 isInstalled for GoXcaddy 2025-07-01 14:59:34 +07:00
DubbleClick
a483c42893 redis check if static or shared 2025-07-01 14:45:28 +07:00
DubbleClick
bebcb978f6 conflicts with shared tests 2025-07-01 14:41:14 +07:00
DubbleClick
ba7f994a71 simplify zig script 2025-07-01 14:12:51 +07:00
DubbleClick
9c7e2171f6 formatting 2025-07-01 14:07:41 +07:00
DubbleClick
b7e8587608 cs fixes 2025-07-01 14:02:10 +07:00
DubbleClick
0a33fba23e zig toolchain stuff 2025-07-01 14:01:48 +07:00
DubbleClick
5370af4a84 don't zig the tests yet 2025-07-01 13:06:03 +07:00
DubbleClick
df0d5fdbe8 merge fix 2025-07-01 13:02:59 +07:00
DubbleClick
7b33ee79dd make sure that $TARGET splits for -dynamic, otherwise it resolves to "-target 'native-native -dynamic'" 2025-07-01 12:56:51 +07:00
DubbleClick
ad8322b6a6 add zig to libc/static target parsing 2025-07-01 12:55:32 +07:00
DubbleClick
c43a10027b fix 2025-07-01 11:02:20 +07:00
DubbleClick
2ebdc4509c < 2025-07-01 11:00:24 +07:00
Jerry Ma
4cb4c9c6a5 Merge pull request #812 from crazywhalecc/sponsor-badge
Add special sponsors
2025-06-30 22:09:36 +08:00
Jerry Ma
9190335a70 Merge pull request #810 from crazywhalecc/refactor/spc-target
refactor: replace SPC_LIBC with SPC_TARGET and update related logic
2025-06-30 21:49:01 +08:00
crazywhalecc
4e244789a2 Add frankenphp SAPI 2025-06-30 21:45:45 +08:00
crazywhalecc
6de7b8e63b Add special sponsors 2025-06-30 21:41:48 +08:00
Marc
68e500eea0 Merge branch 'main' into refactor/spc-target 2025-06-30 20:16:59 +07:00
Marc
840e09a684 Merge pull request #811 from crazywhalecc/fix/micro-patches
Fix/micro patches
2025-06-30 20:16:19 +07:00
crazywhalecc
d00a5223d3 Add exception for checking patch file exist 2025-06-30 19:45:26 +08:00
crazywhalecc
3965a899c7 Add missing directory separator 2025-06-30 19:41:32 +08:00
DubbleClick
956667bf08 fix alpine doctor saying gettext-dev isn't installed 2025-06-30 13:40:51 +07:00
DubbleClick
51e23d21cd remove w32 patches (other branch isn't merged yet) 2025-06-30 12:56:12 +07:00
crazywhalecc
44c6d6288e Refactor LinuxMuslCheck to use MuslToolchain class for toolchain check 2025-06-30 13:04:49 +08:00
Jerry Ma
e5848086c3 Update bin/spc-gnu-docker
Co-authored-by: Marc <m@pyc.ac>
2025-06-30 12:19:17 +08:00
Jerry Ma
138e5588e9 Update bin/spc-gnu-docker
Co-authored-by: Marc <m@pyc.ac>
2025-06-30 12:18:49 +08:00
crazywhalecc
ab5828a560 Remove redundant path in gnu docker 2025-06-30 09:05:56 +08:00
DubbleClick
1839f13149 thanks, autocomplete, for the useless flag 2025-06-29 22:57:25 +07:00
DubbleClick
320c21d272 -static, not static 2025-06-29 22:26:30 +07:00
crazywhalecc
e1e48922de Use isStatic instead of isStaticTarget 2025-06-29 22:49:48 +08:00
DubbleClick
3940f032af fix tests 2025-06-29 21:09:59 +07:00
crazywhalecc
956688d9f4 Fix CI again 2025-06-29 19:53:22 +08:00
crazywhalecc
7f45f4aeec Fix phpunit, add SPC_SKIP_TOOLCHAIN_CHECK 2025-06-29 19:48:09 +08:00
DubbleClick
78666ff7de support for frankenphp linked dynamically too 2025-06-29 18:28:42 +07:00
DubbleClick
dbdf10c75a support for dynamic linking of musl libc 2025-06-29 18:24:25 +07:00
DubbleClick
2564da2615 Reapply "just strip out the error and return the output instead of executing again without version"
This reverts commit 1d29ac228c.
2025-06-29 16:56:24 +07:00
DubbleClick
bd25de15cc okay this drove me crazy... 2025-06-29 16:50:19 +07:00
crazywhalecc
fcaa7c5f42 Add no-env-check for builder 2025-06-29 16:21:22 +08:00
crazywhalecc
e36800b951 phpunit fix 2025-06-29 16:03:38 +08:00
crazywhalecc
977fbaa8ef Suggestions 2025-06-29 16:00:17 +08:00
DubbleClick
6ed62aa05c use CC=cc to install xcaddy 2025-06-29 13:31:43 +07:00
DubbleClick
1d29ac228c Revert "just strip out the error and return the output instead of executing again without version"
This reverts commit d588e6e4fd.
2025-06-29 10:40:48 +07:00
DubbleClick
a44d90671c fix existing check for Zig::fetch 2025-06-29 00:49:39 +07:00
DubbleClick
d6b0912492 run glibc test with shared extensions against 2.28 this time 2025-06-29 00:40:03 +07:00
DubbleClick
d588e6e4fd just strip out the error and return the output instead of executing again without version 2025-06-29 00:06:40 +07:00
DubbleClick
19ddddf618 self:: instead of SourcePatcher:: 2025-06-28 23:45:02 +07:00
DubbleClick
a7bf1e9676 we need to patch swoole early enough 2025-06-28 23:33:13 +07:00
DubbleClick
02f2837f86 adjust craft command for zig 2025-06-28 22:55:30 +07:00
crazywhalecc
0598eff9c5 Add suffix support for SPC_TARGET 2025-06-28 23:13:40 +08:00
crazywhalecc
a6364389ba Add suffix support for SPC_TARGET 2025-06-28 23:11:26 +08:00
DubbleClick
9e9474a026 extra patch for swoole for CFLAGS too 2025-06-28 22:09:58 +07:00
crazywhalecc
c23c5ae614 Disable openmp for imagemagick 2025-06-28 23:08:17 +08:00
DubbleClick
de3cb2f686 no "" 2025-06-28 21:59:12 +07:00
crazywhalecc
454b5a77ad Add SPC_LIBC mapping to SPC_TARGET 2025-06-28 22:59:02 +08:00
DubbleClick
4a493f3f6d don't set rpath because on musl it'll fall over with static binaries 2025-06-28 21:50:57 +07:00
DubbleClick
61274cb865 use extra COMPILER_EXTRA env variable to make sure it's actually passed to compiler 2025-06-28 21:21:29 +07:00
crazywhalecc
8145a7536b Fix spc-gnu-docker path 2025-06-28 19:05:52 +08:00
crazywhalecc
e41d7899c7 Add comments, re-trigger tests 2025-06-28 18:14:10 +08:00
Jerry Ma
88d99a7dea Update src/SPC/store/SourcePatcher.php
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-28 18:04:45 +08:00
crazywhalecc
90823e3b17 Use explict glibc toolchain target 2025-06-28 17:28:02 +08:00
crazywhalecc
3357f286ab Remove libgomp deps 2025-06-28 17:13:22 +08:00
crazywhalecc
ad080da026 Refactor micro patching logic in SourcePatcher 2025-06-28 17:06:51 +08:00
crazywhalecc
25c2def710 Remove unnecessary SPC_MICRO_PATCHES 2025-06-28 16:47:19 +08:00
crazywhalecc
604131b31d Use own exception 2025-06-28 16:45:20 +08:00
crazywhalecc
924da6ae69 extension test 2025-06-28 16:39:02 +08:00
crazywhalecc
12aadf18cc refactor: replace SPC_LIBC with SPC_TARGET and update related logic 2025-06-28 16:36:05 +08:00
DubbleClick
aa516522aa why isn't this triggered? 2025-06-27 23:35:04 +07:00
DubbleClick
efb1ff5a93 test fix 2? 2025-06-27 22:56:49 +07:00
DubbleClick
aff9ff20e8 test fix? 2025-06-27 22:55:23 +07:00
DubbleClick
4c8a173213 build_lib_path is better 2025-06-27 22:53:18 +07:00
DubbleClick
b6240f16fb clean files before compiling because it may try to link the wrong one 2025-06-27 22:51:53 +07:00
DubbleClick
f5281535d9 strip libphp.so and frankenphp 2025-06-27 22:48:15 +07:00
DubbleClick
96babd0939 crazy test 2025-06-27 22:06:19 +07:00
DubbleClick
464c2dca85 cs fix 2025-06-27 22:01:56 +07:00
DubbleClick
43dc04b4d0 building shared libphp.so on musl is really pointless and should be an error, since static compilations cannot load it 2025-06-27 22:01:37 +07:00
DubbleClick
e92f043cfa really stupid patch for swoole 2025-06-27 21:38:16 +07:00
DubbleClick
ff95b464ce really stupid patch for swoole 2025-06-27 21:26:06 +07:00
DubbleClick
69e1acd5ae really stupid patch 2025-06-27 20:28:59 +07:00
DubbleClick
e162a0ecd6 libaom uses different PIC check 2025-06-27 19:37:10 +07:00
DubbleClick
383045d1c0 cs fix 2025-06-27 19:27:02 +07:00
DubbleClick
e6bec8eb57 fix lib extra cflags 2025-06-27 19:26:08 +07:00
DubbleClick
d2dea83c63 don't check for musl toolkit when running zig, add -static to ncurses 2025-06-27 18:21:22 +07:00
DubbleClick
797aaf1ea8 remove libdir 2025-06-27 14:51:36 +07:00
DubbleClick
5a7fd8c24e we shouldn't need that, need to figure out the cause 2025-06-27 09:26:57 +07:00
DubbleClick
cc4ec4b598 add back debug 2025-06-27 00:17:24 +07:00
DubbleClick
55d78579c8 pgsql x86_64 fix? 2025-06-27 00:11:28 +07:00
Marc
d94542049c Update test-extensions.php
no debug do I can see where it fails
2025-06-26 22:58:48 +07:00
DubbleClick
6dec25b4f4 space 2025-06-26 22:03:08 +07:00
DubbleClick
8c7049913b can build shared extensions on ubuntu 24.04 now 2025-06-26 17:56:33 +07:00
DubbleClick
7edd8e6e19 test glibc of course 2025-06-26 17:39:42 +07:00
DubbleClick
2b4eb7127d what the frick is going on with my phpstorm 2025-06-26 17:39:05 +07:00
DubbleClick
9a3ce775a8 complete test suite 2025-06-26 17:36:50 +07:00
DubbleClick
2ff78e531e cs fix, where did that come from? 2025-06-26 17:25:46 +07:00
DubbleClick
03a33d87ff fix frankenphp build 2025-06-26 17:23:37 +07:00
DubbleClick
176e5627e5 hahaha, musl 2.17 is a little far away 2025-06-26 16:49:26 +07:00
DubbleClick
5801d05047 test musl (I have not tested this yet!) 2025-06-26 16:47:07 +07:00
DubbleClick
815ba75c76 we can build musl with zig cc too, don't need musl toolchain 2025-06-26 16:43:37 +07:00
DubbleClick
fff16b4019 refactor our 2025-06-26 16:03:57 +07:00
DubbleClick
e408a2cf1d suggestion and aarch64 fix 2025-06-26 15:55:41 +07:00
DubbleClick
b535600297 this is insane 2025-06-26 15:44:21 +07:00
DubbleClick
762c554468 test zig 2025-06-26 14:39:49 +07:00
DubbleClick
a8c7057aba fix windows 2025-06-26 14:30:42 +07:00
DubbleClick
935f3fc37c cs fix 2025-06-26 14:29:00 +07:00
DubbleClick
fae2878c41 refactor env var logic out to packages, abomination of a zig-cc script... 2025-06-26 14:24:00 +07:00
DubbleClick
d30ccb810c Merge remote-tracking branch 'origin/main' into zig 2025-06-26 12:30:50 +07:00
DubbleClick
8d75a85d6d ziggy 2025-06-26 12:30:04 +07:00
DubbleClick
625bfd1bec don't escape 2025-06-26 11:18:34 +07:00
DubbleClick
b142610800 move to systemutil 2025-06-25 14:52:50 +07:00
DubbleClick
9a3a536479 runtime object patch for shared extensions 2025-06-25 14:32:00 +07:00
DubbleClick
55f01149e4 prevent warning 2025-06-25 13:56:12 +07:00
DubbleClick
6f5fc43490 remove extra -lunwind patch since we don't only need it in opcache 2025-06-25 11:26:45 +07:00
DubbleClick
cb62ffdfc2 we manage -fno-sanitize in code, only needed for opcache with jit 2025-06-25 11:24:01 +07:00
DubbleClick
40ac705c46 remove openmp support entirely, system packages distribute it disabled, the ini disables it by default and the authors recommend disabling it. WIth a distinction between libgomp, libomp and the non-existent usable static libraries for them, it's just not worth it. 2025-06-25 11:21:58 +07:00
DubbleClick
5334727528 remove -L/usr/lib64 (need to put it in the zig-cc script, stupid to add it in 15 different places instead) 2025-06-24 23:07:17 +07:00
DubbleClick
253206de22 better 2025-06-24 22:57:12 +07:00
DubbleClick
5a60f4c02b another librdkafka patch 2025-06-24 22:56:48 +07:00
DubbleClick
63fcdd9db4 default param 2025-06-24 21:04:08 +07:00
DubbleClick
832c0230e2 getcctype default 2025-06-24 21:03:32 +07:00
DubbleClick
e1028b0348 swoole has date time conversion error in c++ code, clang needs -lunwind 2025-06-24 20:43:38 +07:00
DubbleClick
2433752273 needless default 2025-06-24 13:17:43 +07:00
DubbleClick
1b0b551fc6 handle case where libphp.so is built instead of libphp-release.so 2025-06-24 12:10:01 +07:00
DubbleClick
74849a8d48 -fno-sanitize=undefined is enabled in zig by default, not in gcc and clang 2025-06-24 09:05:44 +07:00
DubbleClick
ee0de6933f deprecated linker option 2025-06-23 19:21:51 +07:00
DubbleClick
bd863dba34 zig is clang 2025-06-23 15:26:39 +07:00
DubbleClick
f9af24e246 dont fail on -lomp 2025-06-23 13:23:13 +07:00
DubbleClick
864c55feaf oops 2025-06-23 13:12:40 +07:00
DubbleClick
7628847a46 suboptimal solutions, but a bit closer to building 2025-06-23 12:57:00 +07:00
DubbleClick
955b586908 fix lz4 2025-06-22 19:51:55 +07:00
DubbleClick
32a1fd45df don't disable warnings 2025-06-22 17:21:28 +07:00
DubbleClick
15fbde29d4 remove duplicate 2025-06-22 17:02:16 +07:00
DubbleClick
2cce02bfa9 liblz4 replacement 2025-06-22 17:01:08 +07:00
DubbleClick
7e35de8a0e CXX for watcher-c 2025-06-22 16:19:01 +07:00
DubbleClick
9a98fd9cff patch things for zig compatibility 2025-06-22 15:52:01 +07:00
crazywhalecc
1409d1b47b Check lib-suggest before packing libs 2025-06-22 13:52:53 +08:00
301 changed files with 10159 additions and 6118 deletions

View File

@@ -10,6 +10,7 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
indent_size = 2
[*.{yml,yaml, vue}]
[*.{yml,yaml,vue,ts}]
indent_size = 2

View File

@@ -3,6 +3,15 @@ name: Bug report
about: Build PHP or library failed, download failed, doesn't seem to work...
title: ''
labels: bug
assignees: crazywhalecc
body:
- type: textarea
id: what-happened
attributes:
label: What happened?
description: |
Please tell us what you do, what you get and what you expected.
Provide with some step-by-step instructions to reproduce the issue.
If possible, attach a screenshot or log files in ./log directory.
validations:
required: true
---

View File

@@ -3,6 +3,6 @@ name: Feature request
about: Suggest an idea for this project
title: ''
labels: new feature
assignees: ''
assignees: crazywhalecc
---

View File

@@ -8,7 +8,7 @@
> If a modification is not involved, please skip it directly.
- If you modified `*.php` or `*.json`, run them locally to ensure your changes are valid:
- [ ] `PHP_CS_FIXER_IGNORE_ENV=1 composer cs-fix`
- [ ] `composer cs-fix`
- [ ] `composer analyse`
- [ ] `composer test`
- [ ] `bin/spc dev:sort-config`

View File

@@ -136,12 +136,12 @@ jobs:
macos-x86_64)
DOWN_CMD="composer update --no-dev --classmap-authoritative && ./bin/spc doctor --auto-fix && ./bin/spc download"
BUILD_CMD="./bin/spc build"
RUNS_ON="macos-13"
RUNS_ON="macos-15-intel"
;;
macos-aarch64)
DOWN_CMD="composer update --no-dev --classmap-authoritative && ./bin/spc doctor --auto-fix && ./bin/spc download"
BUILD_CMD="./bin/spc build"
RUNS_ON="macos-14"
RUNS_ON="macos-15"
;;
esac
DOWN_CMD="$DOWN_CMD --with-php=${{ inputs.php-version }} --for-extensions=${{ inputs.extensions }} --ignore-cache-sources=php-src"
@@ -198,9 +198,9 @@ jobs:
run: ${{ needs.define-build.outputs.download }}
- name: "Build PHP"
run: ${{ needs.define-build.outputs.build }}
#- name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
# Upload cli executable
- if: ${{ inputs.build-cli == true }}
@@ -230,12 +230,12 @@ jobs:
- uses: actions/upload-artifact@v4
name: "Upload License Files"
with:
name: license-files
name: license-files-${{ inputs.php-version }}-${{ inputs.os }}
path: buildroot/license/
- uses: actions/upload-artifact@v4
name: "Upload Build Metadata"
with:
name: build-meta
name: build-meta-${{ inputs.php-version }}-${{ inputs.os }}
path: |
buildroot/build-extensions.json
buildroot/build-libraries.json

View File

@@ -65,7 +65,7 @@ jobs:
- sqlsrv
- ssh2
- swoole
- swoole,swoole-hook-pgsql,swoole-hook-mysql,swoole-hook-sqlite
- swoole,swoole-hook-pgsql,swoole-hook-mysql,swoole-hook-sqlite,swoole-hook-odbc
- swow
- sysvmsg,sysvsem,sysvshm
- tidy
@@ -85,9 +85,9 @@ jobs:
- "8.4"
operating-system:
- "ubuntu-latest"
#- "macos-13"
#- "macos-15-intel"
#- "debian-arm64-self-hosted"
- "macos-14"
- "macos-15"
steps:
- name: "Checkout"
@@ -99,11 +99,11 @@ jobs:
OS=""
if [ "${{ matrix.operating-system }}" = "ubuntu-latest" ]; then
OS="linux-x86_64"
elif [ "${{ matrix.operating-system }}" = "macos-13" ]; then
elif [ "${{ matrix.operating-system }}" = "macos-15-intel" ]; then
OS="macos-x86_64"
elif [ "${{ matrix.operating-system }}" = "debian-arm64-self-hosted" ]; then
OS="linux-aarch64"
elif [ "${{ matrix.operating-system }}" = "macos-14" ]; then
elif [ "${{ matrix.operating-system }}" = "macos-15" ]; then
OS="macos-aarch64"
fi
echo "OS=$OS" >> $GITHUB_ENV
@@ -136,11 +136,4 @@ jobs:
- name: "Build library: ${{ matrix.library }}"
run: |
SPC_USE_SUDO=yes ./bin/spc doctor --auto-fix
if [ "${{ env.OS }}" = "linux-x86_64" ]; then
./bin/spc install-pkg upx
UPX=--with-upx-pack
elif [ "${{ env.OS }}" = "linux-aarch64" ]; then
./bin/spc install-pkg upx
UPX=--with-upx-pack
fi
./bin/spc build --build-cli --build-micro --build-fpm ${{ matrix.extension }} --debug $UPX --with-suggested-libs --with-suggested-exts
./bin/spc build --build-cli --build-micro --build-fpm ${{ matrix.extension }} --debug --with-suggested-libs --with-suggested-exts

View File

@@ -3,6 +3,10 @@ name: Build SPC Binary
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
paths:
- '.github/workflows/release-build.yml'
release:
types:
- published
@@ -10,7 +14,7 @@ on:
env:
PHP_VERSION: 8.4
MICRO_VERSION: 8.4.4
MICRO_VERSION: 8.4.11
jobs:
build-release-artifacts:
@@ -23,7 +27,7 @@ jobs:
os: "ubuntu-latest"
filename: "spc-linux-x86_64.tar.gz"
- name: "macos-x86_64"
os: "macos-13"
os: "macos-15-intel"
filename: "spc-macos-x86_64.tar.gz"
- name: "linux-aarch64"
os: "ubuntu-latest"
@@ -42,12 +46,13 @@ jobs:
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
- name: "Install PHP for official runners"
uses: "shivammathur/setup-php@v2"
uses: shivammathur/setup-php@v2
with:
coverage: none
tools: composer:v2
php-version: "${{ env.PHP_VERSION }}"
ini-values: memory_limit=-1
extensions: curl, openssl, mbstring
- name: "Get Composer Cache Directory"
id: composer-cache
@@ -116,7 +121,8 @@ jobs:
files: dist/${{ matrix.operating-system.filename }}
- name: "Deploy to self-hosted OSS"
if: github.repository == 'crazywhalecc/static-php-cli'
# only run this step if the repository is static-php-cli and the branch is main
if: github.repository == 'crazywhalecc/static-php-cli' && github.ref == 'refs/heads/main'
uses: static-php/upload-s3-action@v1.0.0
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
@@ -131,3 +137,39 @@ jobs:
with:
path: spc${{ env.SUFFIX }}
name: spc-${{ matrix.operating-system.name }}${{ env.SUFFIX }}
test-spc:
name: "Test SPC Binary for ${{ matrix.operating-system.name }}"
runs-on: ${{ matrix.operating-system.os }}
needs: [build-release-artifacts]
strategy:
matrix:
operating-system:
- name: "linux-x86_64"
os: "ubuntu-latest"
- name: "macos-x86_64"
os: "macos-15-intel"
- name: "linux-aarch64"
os: "ubuntu-24.04-arm"
- name: "macos-aarch64"
os: "macos-15"
- name: "windows-x64"
os: "windows-latest"
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Download Artifact"
uses: actions/download-artifact@v4
env:
SUFFIX: ${{ matrix.operating-system.name == 'windows-x64' && '.exe' || '' }}
with:
name: spc-${{ matrix.operating-system.name }}${{ env.SUFFIX }}
- name: "Chmod"
if: matrix.operating-system.name != 'windows-x64'
run: chmod +x spc
- name: "Run SPC Tests"
env:
SUFFIX: ${{ matrix.operating-system.name == 'windows-x64' && '.exe' || '' }}
run: ./spc${{ env.SUFFIX }} dev:extensions

View File

@@ -39,7 +39,7 @@ jobs:
tools: pecl, composer, php-cs-fixer
- name: Run PHP-CS-Fixer fix
run: PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --dry-run --diff --ansi
run: php-cs-fixer fix --dry-run --diff --ansi
phpstan:
runs-on: ubuntu-latest
@@ -55,6 +55,8 @@ jobs:
extensions: curl, openssl, mbstring
ini-values: memory_limit=-1
tools: composer
env:
phpts: zts
- name: "Cache Composer packages"
id: composer-cache
@@ -121,6 +123,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
extensions: curl, openssl, mbstring
- name: Define
id: gendef
@@ -134,7 +137,7 @@ jobs:
build:
name: "Build PHP Test (PHP ${{ matrix.php }} ${{ matrix.os }})"
runs-on: ${{ matrix.os }}
needs: define-matrix
needs: [define-matrix, php-cs-fixer, phpstan, phpunit]
timeout-minutes: 120
strategy:
matrix:
@@ -142,6 +145,10 @@ jobs:
os: ${{ fromJSON(needs.define-matrix.outputs.os) }}
fail-fast: false
steps:
- name: "Update runner packages"
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
run: sudo apt-get update && sudo apt-get install -y ca-certificates
- name: "Checkout"
uses: actions/checkout@v4
@@ -198,3 +205,14 @@ jobs:
- name: "Run Build Tests (build - embed for non-windows)"
if: ${{ !startsWith(matrix.os, 'windows-') }}
run: php src/globals/test-extensions.php build_embed_cmd ${{ matrix.os }} ${{ matrix.php }}
- name: "Upload logs"
if: ${{ always() && hashFiles('log/**') != '' }}
uses: actions/upload-artifact@v4
with:
name: build-logs-${{ matrix.os }}-${{ matrix.php }}
path: log
# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3

View File

@@ -21,7 +21,6 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
- run: yarn install --frozen-lockfile
@@ -32,12 +31,13 @@ jobs:
cp -r config/* docs/.vitepress/config/
- name: "Install PHP for official runners"
uses: "shivammathur/setup-php@v2"
uses: shivammathur/setup-php@v2
with:
coverage: none
tools: composer:v2
php-version: 8.4
ini-values: memory_limit=-1
extensions: curl, openssl, mbstring
- name: "Get Composer Cache Directory"
id: composer-cache

14
.gitignore vendored
View File

@@ -34,9 +34,7 @@ packlib_files.txt
/bin/*
!/bin/spc*
!/bin/setup-runtime*
!/bin/spc-alpine-docker
!/bin/php-cs-fixer-wrapper
!/bin/build-static-frankenphp
!/bin/docker-entrypoint.sh
# exclude windows build tools
/php-sdk-binary-tools/
@@ -51,6 +49,12 @@ packlib_files.txt
package-lock.json
pnpm-lock.yaml
# craft.log
craft.log
# craft
craft.yml
# SPC logs
log/
# spc.phar
spc.phar
spc.exe

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setUnsupportedPhpVersionAllowed(true)
->setRules([
'@PSR12' => true,
'@Symfony' => true,
@@ -69,4 +70,5 @@ return (new PhpCsFixer\Config())
])
->setFinder(
PhpCsFixer\Finder::create()->in([__DIR__ . '/src', __DIR__ . '/tests/SPC'])
);
)
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect());

View File

@@ -5,302 +5,168 @@
[![Releases](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/releases)
[![CI](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml)
[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE)
[![Extensions](https://img.shields.io/badge/Extension%20Counter-75+-yellow.svg?style=flat-square)](https://static-php.dev/zh/guide/extensions.html)
**static-php-cli**是一个用于静态编译、构建 PHP 解释器的工具,支持众多流行扩展。
目前 static-php-cli 支持 `cli``fpm``embed``micro` SAPI。
**static-php-cli**也支持将 PHP 代码和 PHP 运行时打包为一个文件并运行。
**static-php-cli** 是一个用于构建静态、独立 PHP 运行时的强大工具,支持众多流行扩展。
## 特性
static-php-cli简称 `spc`)有许多特性:
- :elephant: **支持多 PHP 版本** - 支持 PHP 8.1, 8.2, 8.3, 8.4, 8.5
- :handbag: **单文件 PHP 可执行文件** - 构建零依赖的独立 PHP
- :hamburger: **phpmicro 集成** - 构建 **[phpmicro](https://github.com/dixyes/phpmicro)** 自解压可执行文件(将 PHP 二进制文件和源代码合并为一个文件)
- :pill: **智能环境检查器** - 自动构建环境检查器,具备自动修复功能
- :zap: **跨平台支持** - 支持 Linux、macOS、FreeBSD 和 Windows
- :wrench: **可配置补丁** - 可自定义的源代码补丁系统
- :books: **智能依赖管理** - 自动处理构建依赖
- 📦 **自包含工具** - 提供使用 [box](https://github.com/box-project/box) 构建的 `spc` 可执行文件
- :fire: **广泛的扩展支持** - 支持 75+ 流行 [扩展](https://static-php.dev/zh/guide/extensions.html)
- :floppy_disk: **UPX 压缩** - 减小二进制文件大小 30-50%(仅 Linux/Windows
- :handbag: 构建独立的单文件 PHP 解释器,无需任何依赖
- :hamburger: 构建 **[phpmicro](https://github.com/dixyes/phpmicro)** 自执行二进制(将 PHP 代码和 PHP 解释器打包为一个文件)
- :pill: 提供一键检查和修复编译环境的 Doctor 模块
- :zap: 支持多个系统:`Linux``macOS``FreeBSD``Windows`
- :wrench: 高度自定义的代码 patch 功能
- :books: 自带编译依赖管理
- 📦 提供由自身编译的独立 `spc` 二进制(使用 spc 和 [box](https://github.com/box-project/box) 构建)
- :fire: 支持大量 [扩展](https://static-php.dev/zh/guide/extensions.html)
- :floppy_disk: 整合 UPX 工具(减小二进制文件体积)
**静态 php-cli:**
**单文件独立 php-cli**
<img width="700" alt="out1" src="https://github.com/crazywhalecc/static-php-cli/assets/20330940/01a2e60f-13b0-4242-a645-f7afa4936396">
**使用 phpmicro 打包 PHP 代码:**
**使用 phpmicro PHP 代码与 PHP 解释器结合:**
<img width="700" alt="out2" src="https://github.com/crazywhalecc/static-php-cli/assets/20330940/46b7128d-fb72-4169-957e-48564c3ff3e2">
## 文档
## 快速开始
目前 README 编写了基本用法。有关 static-php-cli 所有的功能,请点击这里查看文档:<https://static-php.dev>。
## 直接下载
如果你不想自行编译 PHP可以从本项目现有的示例 Action 下载 Artifact也可以从自托管的服务器下载。
| 组合名称 | 组合扩展数 | 系统 | 备注 |
|---------------------------------------------------------------------|----------------------------------------------------------------------------|-------------|--------------|
| [common](https://dl.static-php.dev/static-php-cli/common/) | [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) | Linux/macOS | 体积为 7.5MB 左右 |
| [bulk](https://dl.static-php.dev/static-php-cli/bulk/) | [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) | Linux/macOS | 体积为 25MB 左右 |
| [minimal](https://dl.static-php.dev/static-php-cli/minimal/) | [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) | Linux/macOS | 体积为 3MB 左右 |
| [spc-min](https://dl.static-php.dev/static-php-cli/windows/spc-min) | [5](https://dl.static-php.dev/static-php-cli/windows/spc-min/README.txt) | Windows | 体积为 3MB 左右 |
| [spc-max](https://dl.static-php.dev/static-php-cli/windows/spc-max) | [40+](https://dl.static-php.dev/static-php-cli/windows/spc-max/README.txt) | Windows | 体积为 8.5MB 左右 |
> Linux 和 Windows 默认启用了 UPX 压缩,可减小 30~50% 的 PHP 二进制体积。
> macOS 当前不支持 UPX所以上述预编译的 macOS 版本体积可能较大。
## 使用 static-php-cli 构建 PHP
### 编译环境需求
- PHP >= 8.4(这是 spc 自身需要的版本,不是支持的构建版本)
- 扩展:`mbstring,tokenizer,phar`
- 系统安装了 `curl``git`
是的,本项目采用 PHP 编写,编译前需要一个 PHP 环境,比较滑稽。
但本项目默认可通过自身构建的 micro 和 static-php 二进制运行,其他只需要包含上面提到的扩展和 PHP 版本大于等于 8.1 即可。
下面是架构支持情况,:octocat: 代表支持 GitHub Action 构建,:computer: 代表支持本地构建,空 代表暂不支持。
| | x86_64 | aarch64 |
|---------|----------------------|----------------------|
| macOS | :octocat: :computer: | :octocat: :computer: |
| Linux | :octocat: :computer: | :octocat: :computer: |
| Windows | :octocat: :computer: | |
| FreeBSD | :computer: | :computer: |
当前支持编译的 PHP 版本:
> :warning: 支持,但 static-php-cli 作者可能不再提供补丁修复
>
> :heavy_check_mark: 支持
>
> :x: 不支持
| PHP Version | Status | Comment |
|-------------|--------------------|----------------------------------------------|
| 7.2 | :x: | |
| 7.3 | :x: | phpmicro 和许多扩展不支持 7.3、7.4 版本 |
| 7.4 | :x: | phpmicro 和许多扩展不支持 7.3、7.4 版本 |
| 8.0 | :warning: | PHP 官方已停止 8.0 的维护,我们不再处理 8.0 相关的 backport 支持 |
| 8.1 | :heavy_check_mark: | PHP 官方仅对 8.1 提供安全更新 |
| 8.2 | :heavy_check_mark: | |
| 8.3 | :heavy_check_mark: | |
| 8.4 | :heavy_check_mark: | |
> 这个表格的支持状态是 static-php-cli 对构建对应版本的支持情况,不是 PHP 官方对该版本的支持情况。
### 支持的扩展
请先根据下方扩展列表选择你要编译的扩展。
- [扩展支持列表](https://static-php.dev/zh/guide/extensions.html)
- [编译命令生成器](https://static-php.dev/zh/guide/cli-generator.html)
> 如果这里没有你需要的扩展,可以提交 Issue。
### 在线构建(使用 GitHub Actions
使用 GitHub Action 可以方便地构建一个静态编译的 PHP同时可以自行定义要编译的扩展。
1. Fork 本项目。
2. 进入项目的 Actions选择 CI。
3. 选择 `Run workflow`,填入你要编译的 PHP 版本、目标类型、扩展列表。(扩展列表使用英文逗号分割,例如 `bcmath,curl,mbstring`
4. 等待大约一段时间后,进入对应的任务中,获取 `Artifacts`
如果你选择了 `debug`,则会在构建时输出所有日志,包括编译的日志,以供排查错误。
### 本地构建(使用 spc 二进制,推荐)
该项目提供了 static-php-cli 的二进制文件:`spc`
您可以使用 `spc` 二进制文件,无需安装任何运行时(用起来就像 golang 程序)。
目前,`spc` 二进制文件提供的平台有 Linux 和 macOS。
使用以下命令从自托管服务器下载:
### 1. 下载 spc 二进制文件
```bash
# Download from self-hosted nightly builds (sync with main branch)
# For Linux x86_64
# Linux x86_64
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64
# For Linux aarch64
# Linux aarch64
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-aarch64
# macOS x86_64 (Intel)
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-x86_64
# macOS aarch64 (Apple)
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64
# Windows (x86_64, win10 build 17063 or later)
# Windows (x86_64, win10 build 17063 或更高版本,请先安装 VS2022)
curl.exe -fsSL -o spc.exe https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe
```
# Add execute perm (Linux and macOS only)
对于 macOS 和 Linux请先添加执行权限
```bash
chmod +x ./spc
# Run (Linux and macOS)
./spc --version
# Run (Windows powershell)
.\spc.exe --version
```
自托管 `spc` 由 GitHub Actions 构建,你也可以从 Actions 直接下载:[此处](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml)。
### 2. 构建静态 PHP
### 本地构建(使用 git 源码)
首先,创建一个 `craft.yml` 文件,并从 [扩展列表](https://static-php.dev/zh/guide/extensions.html) 或 [命令生成器](https://static-php.dev/zh/guide/cli-generator.html) 中指定要包含的扩展:
如果你需要修改 static-php-cli 源码,或者使用 spc 二进制构建有问题,你可以使用 git 源码下载 static-php-cli。
```yml
# PHP 版本支持8.1, 8.2, 8.3, 8.4, 8.5
php-version: 8.4
# 在此处放置您的扩展列表
extensions: "apcu,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,gd,iconv,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib"
sapi:
- cli
- micro
- fpm
download-options:
prefer-pre-built: true
```
运行命令:
```bash
# clone 仓库即可
git clone https://github.com/crazywhalecc/static-php-cli.git
./spc craft
# 输出完整控制台日志
./spc craft --debug
```
如果您的系统上尚未安装 php我们建议你使用内置的 setup-runtime 自动安装 PHP 和 Composer。
### 3. 静态 PHP 使用
```bash
cd static-php-cli
chmod +x bin/setup-runtime
# it will download static php (from self-hosted server) and composer (from getcomposer)
bin/setup-runtime
# initialize composer deps
bin/composer install
# chmod
chmod +x bin/spc
bin/spc --version
现在您可以将 static-php-cli 构建的二进制文件复制到另一台机器上,无需依赖即可运行:
```
# php-cli
buildroot/bin/php -v
# phpmicro
echo '<?php echo "Hello world!\n";' > a.php
./spc micro:combine a.php -O my-app
./my-app
# php-fpm
buildroot/bin/php-fpm -v
```
### 开始构建 PHP
## 文档
下面是使用 static-php-cli 的基础用法:
当前 README 包含基本用法。有关 static-php-cli 的所有功能,
请访问 <https://static-php.dev>。
> 如果你使用的是打包好的 `spc` 二进制,你需要将下列命令的 `./bin/spc` 替换为 `./spc`。
## 直接下载
```bash
# 检查环境依赖,并根据尝试自动安装缺失的编译工具
./bin/spc doctor --auto-fix
如果您不想构建或想先测试,可以从 [Actions](https://github.com/static-php/static-php-cli-hosted/actions/workflows/build-php-bulk.yml) 下载示例预编译工件,或从自托管服务器下载。
# 输出目标项目依赖的扩展列表
./bin/spc dump-extensions /path/to/your/project --format=text
以下是几个具有不同扩展组合的预编译静态 PHP 二进制文件,
您可以根据需要直接下载。
# 拉取所有依赖库
./bin/spc download --all
# 只拉取编译指定扩展需要的所有依赖(推荐)
./bin/spc download --for-extensions="openssl,pcntl,mbstring,pdo_sqlite"
# 下载依赖时,优先下载有预编译的库(节省编译依赖的时间)
./bin/spc download --for-extensions="openssl,curl,mbstring,mbregex" --prefer-pre-built
# 下载编译不同版本的 PHP (--with-php=x.y 或 --with-php=x.y.z推荐 8.1 ~ 8.3)
./bin/spc download --for-extensions="openssl,curl,mbstring" --with-php=8.1
| 组合名称 | 扩展数量 | 系统 | 备注 |
|----------------------------------------------------------------------|----------------------------------------------------------------------------|--------------|--------------------|
| [common](https://dl.static-php.dev/static-php-cli/common/) | [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) | Linux, macOS | 二进制文件大小约为 7.5MB |
| [bulk](https://dl.static-php.dev/static-php-cli/bulk/) | [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) | Linux, macOS | 二进制文件大小约为 25MB |
| [gnu-bulk](https://dl.static-php.dev/static-php-cli/gnu-bulk/) | [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) | Linux, macOS | 使用 glibc 的 bulk 组合 |
| [minimal](https://dl.static-php.dev/static-php-cli/minimal/) | [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) | Linux, macOS | 二进制文件大小约为 3MB |
| [spc-min](https://dl.static-php.dev/static-php-cli/windows/spc-min/) | [5](https://dl.static-php.dev/static-php-cli/windows/spc-min/README.txt) | Windows | 二进制文件大小约为 3MB |
| [spc-max](https://dl.static-php.dev/static-php-cli/windows/spc-max/) | [40+](https://dl.static-php.dev/static-php-cli/windows/spc-max/README.txt) | Windows | 二进制文件大小约为 8.5MB |
# 构建包含 bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl 扩展的 php-cli 和 micro.sfx
./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro
# 编译线程安全版本 (--enable-zts)
./bin/spc build "curl,phar" --enable-zts --build-cli
# 编译后使用 UPX 减小可执行文件体积 (仅 Linux、Windows 可用) (至少压缩至原来的 30~50%)
./bin/spc build "curl,phar" --enable-zts --build-cli --with-upx-pack
```
> Linux 和 Windows 支持对二进制文件进行 UPX 压缩,可以将二进制文件大小减少 30% 到 50%。
> macOS 不支持 UPX 压缩,因此 mac 的预构建二进制文件大小较大。
其中,目前支持构建 climicrofpm 和 embed使用以下参数的一个或多个来指定编译的 SAPI
### 在线构建(使用 GitHub Actions
- `--build-cli`:构建 cli 二进制
- `--build-micro`:构建 phpmicro 自执行二进制
- `--build-fpm`:构建 fpm
- `--build-embed`:构建 embedlibphp
- `--build-all`:构建所有
上方直接下载的二进制不能满足需求时,可使用 GitHub Action 可以轻松构建静态编译的 PHP
同时自行定义要编译的扩展。
如果出现了任何错误,可以使用 `--debug` 参数来展示完整的输出日志,以供排查错误:
1. Fork 本项目。
2. 进入项目的 Actions 并选择 `CI`
3. 选择 `Run workflow`,填入您要编译的 PHP 版本、目标类型和扩展列表。(扩展用逗号分隔,例如 `bcmath,curl,mbstring`
4. 等待一段时间后,进入相应的任务并获取 `Artifacts`
```bash
./bin/spc build "openssl,pcntl,mbstring" --debug --build-all
./bin/spc download --all --debug
```
## 不同 SAPI 的使用
### 使用 cli
> php-cli 是一个静态的二进制文件,类似 Go、Rust 语言编译后的单个可移植的二进制文件。
采用参数 `--build-cli``--build-all` 参数时,最后编译结果会输出一个 `./php` 的二进制文件,此文件可分发、可直接使用。
该文件编译后会存放在 `buildroot/bin/` 目录中,名称为 `php`,拷贝出来即可。
```bash
cd buildroot/bin/
./php -v # 检查版本
./php -m # 检查编译的扩展
./php your_code.php # 运行代码
./php your_project.phar # 运行打包为 phar 单文件的项目
```
### 使用 micro
> phpmicro 是一个提供自执行二进制 PHP 的项目,本项目依赖 phpmicro 进行编译自执行二进制。详见 [dixyes/phpmicro](https://github.com/dixyes/phpmicro)。
采用项目参数 `--build-micro``--build-all` 时,最后编译结果会输出一个 `./micro.sfx` 的文件,此文件需要配合你的 PHP 源码使用。
该文件编译后会存放在 `buildroot/bin/` 目录中,拷贝出来即可。
使用时应准备好你的项目源码文件,可以是单个 PHP 文件,也可以是 Phar 文件。
```bash
echo "<?php echo 'Hello world' . PHP_EOL;" > code.php
cat micro.sfx code.php > single-app && chmod +x single-app
./single-app
```
如果打包 PHAR 文件,仅需把 code.php 更换为 phar 文件路径即可。
你可以使用 [box-project/box](https://github.com/box-project/box) 将你的 CLI 项目打包为 Phar
然后将它与 phpmicro 结合,生成独立可执行的二进制文件。
```bash
# 使用 static-php-cli 生成的 micro.sfx 结合,也可以直接使用 cat 命令结合它们
bin/spc micro:combine my-app.phar
cat buildroot/bin/micro.sfx my-app.phar > my-app && chmod +x my-app
# 使用 micro:combine 结合可以将 INI 选项注入到二进制中
bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=system" --output my-app-2
```
> 有些情况下的 phar 文件或 PHP 项目可能无法在 micro 环境下运行。
### 使用 fpm
采用项目参数 `--build-fpm``--build-all` 时,最后编译结果会输出一个 `./php-fpm` 的文件。
该文件存放在 `buildroot/bin/` 目录,拷贝出来即可使用。
在正常的 Linux 发行版和 macOS 系统中,安装 php-fpm 后包管理会自动生成默认的 fpm 配置文件。
因为 php-fpm 必须指定配置文件才可启动,本项目编译的 php-fpm 不会带任何配置文件,所以需自行编写 `php-fpm.conf``pool.conf` 配置文件。
指定 `php-fpm.conf` 可以使用命令参数 `-y`,例如:`./php-fpm -y php-fpm.conf`
### 使用 embed
采用项目参数 `--build-embed``--build-all` 时,最后编译结果会输出一个 `libphp.a``php-config` 以及一系列头文件,存放在 `buildroot/`,你可以在你的其他代码中引入它们。
如果你知道 [embed SAPI](https://github.com/php/php-src/tree/master/sapi/embed),你应该知道如何使用它。对于有可能编译用到引入其他库的问题,你可以使用 `buildroot/bin/php-config` 来获取编译时的配置。
另外,有关如何使用此功能的高级示例,请查看[如何使用它构建 FrankenPHP 的静态版本](https://github.com/php/frankenphp/blob/main/docs/static.md)。
如果您启用 `debug`,构建时将输出所有日志,包括编译日志,以便故障排除。
## 贡献
如果缺少你需要的扩展,可发起 Issue。如果你对本项目较熟悉也欢迎为本项目发起 Pull Request
如果需要的扩展缺失,可以创建 issue
如果您熟悉本项目,也欢迎发起 pull request。
另外,添加新扩展的贡献方式,可以参考下方 `进阶`
如果您想贡献文档,请直接编辑 `docs/` 目录
如果你想贡献文档内容,请直接修改 `docs/` 目录
现在有一个 [static-php](https://github.com/static-php) 组织,用于存储与项目相关的仓库
## 赞助本项目
可以 [我的个人赞助页](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md) 支持我和我的项目。捐赠的一部分将会被用于维护 **static-php.dev** 服务器。
可以 [GitHub Sponsor](https://github.com/crazywhalecc) 赞助我或我的项目。捐赠的一部分将用于维护 **static-php.dev** 服务器。
## 开源协议
**特别感谢以下赞助商**
本项目采用 MIT License 许可开源,下面是类似的项目:
<a href="https://beyondco.de/"><img src="/docs/public/images/beyondcode-seeklogo.png" width="300" alt="Beyond Code Logo" /></a>
<a href="https://nativephp.com/"><img src="/docs/public/images/nativephp-logo.svg" width="300" alt="NativePHP Logo" /></a>
## 开源许可证
本项目本身基于 MIT 许可证,
一些新添加的扩展和依赖可能来自其他项目,
这些代码文件的头部也会给出额外的许可证和作者说明。
这些是类似的项目:
- [dixyes/lwmbs](https://github.com/dixyes/lwmbs)
- [swoole/swoole-cli](https://github.com/swoole/swoole-cli)
项目使用了 [dixyes/lwmbs](https://github.com/dixyes/lwmbs) 的一些代码,例如 Windows 静态构建目标和 libiconv 支持。
lwmbs 使用 [Mulan PSL 2](http://license.coscl.org.cn/MulanPSL2) 许可进行分发。对应文件有关于作者和许可的特殊说明,除此之外,均使用 MIT 授权许可
项目使用了 [dixyes/lwmbs](https://github.com/dixyes/lwmbs) 的一些代码,例如 Windows 静态构建目标和 libiconv 支持。
lwmbs 基于 [Mulan PSL 2](http://license.coscl.org.cn/MulanPSL2) 许可
本项目的特殊性,使用项目编译过程中会使用很多其他开源项目,例如 curl、protobuf 等,它们都有各自的开源协议。
请在编译完成后,使用命令 `bin/spc dump-license` 导出项目使用项目的开源协议,并遵守对应项目的 LICENSE。
由于本项目的特殊性,
项目编译过程中会使用许多其他开源项目,如 curl 和 protobuf
它们都有自己的开源许可证。
请在编译后使用 `bin/spc dump-license` 命令导出项目中使用的开源许可证,
并遵守相应项目的 LICENSE。

333
README.md
View File

@@ -5,29 +5,22 @@
[![Releases](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/releases)
[![CI](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml)
[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE)
[![Extensions](https://img.shields.io/badge/Extension%20Counter-75+-yellow.svg?style=flat-square)](https://static-php.dev/en/guide/extensions.html)
**static-php-cli** is a powerful tool designed for building static, standalone PHP runtime
with popular extensions.
Static PHP built by **static-php-cli** supports `cli`, `fpm`, `embed` and `micro` SAPI.
**static-php-cli** also has the ability to package PHP projects
along with the PHP interpreter into one single executable file.
## Features
static-php-cli (you can call it `spc`) has a lot of features:
- :handbag: Build single-file php executable, without any dependencies
- :hamburger: Build **[phpmicro](https://github.com/dixyes/phpmicro)** self-extracted executable (glue php binary and php source code into one file)
- :pill: Automatic build environment checker (Doctor module)
- :elephant: Support multiple PHP versions - PHP 8.1, 8.2, 8.3, 8.4, 8.5
- :handbag: Build single-file PHP executable with zero dependencies
- :hamburger:Build **[phpmicro](https://github.com/dixyes/phpmicro)** self-extracting executables (combines PHP binary and source code into one file)
- :pill: Automatic build environment checker with auto-fix capabilities
- :zap: `Linux`, `macOS`, `FreeBSD`, `Windows` support
- :wrench: Configurable source code patches
- :books: Build dependency management
- 📦 Provide `spc` own standalone executable (built by spc and [box](https://github.com/box-project/box))
- :fire: Support many popular [extensions](https://static-php.dev/en/guide/extensions.html)
- :floppy_disk: UPX integration (significantly reduces binary size)
- :wrench: Configurable source code patching
- :books: Intelligent dependency management
- 📦 Self-contained `spc` executable (built with [box](https://github.com/box-project/box))
- :fire: Support 100+ popular [extensions](https://static-php.dev/en/guide/extensions.html)
- :floppy_disk: UPX compression support (reduces binary size by 30-50%)
**Single-file standalone php-cli:**
@@ -37,6 +30,72 @@ static-php-cli (you can call it `spc`) has a lot of features:
<img width="700" alt="out2" src="https://github.com/crazywhalecc/static-php-cli/assets/20330940/46b7128d-fb72-4169-957e-48564c3ff3e2">
## Quickstart
### 1. Download spc binary
```bash
# For Linux x86_64
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64
# For Linux aarch64
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-aarch64
# macOS x86_64 (Intel)
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-x86_64
# macOS aarch64 (Apple)
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64
# Windows (x86_64, win10 build 17063 or later, please install VS2022 first)
curl.exe -fsSL -o spc.exe https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe
```
For macOS and Linux, add execute permission first:
```bash
chmod +x ./spc
```
### 2. Build Static PHP
First, create a `craft.yml` file and specify which extensions you want to include from [extension list](https://static-php.dev/en/guide/extensions.html) or [command generator](https://static-php.dev/en/guide/cli-generator.html):
```yml
# PHP version support: 8.1, 8.2, 8.3, 8.4, 8.5
php-version: 8.4
# Put your extension list here
extensions: "apcu,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,gd,iconv,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib"
sapi:
- cli
- micro
- fpm
download-options:
prefer-pre-built: true
```
Run command:
```bash
./spc craft
# Output full console log
./spc craft --debug
```
### 3. Static PHP usage
Now you can copy binaries built by static-php-cli to another machine and run with no dependencies:
```
# php-cli
buildroot/bin/php -v
# phpmicro
echo '<?php echo "Hello world!\n";' > a.php
./spc micro:combine a.php -O my-app
./my-app
# php-fpm
buildroot/bin/php-fpm -v
```
## Documentation
The current README contains basic usage. For all the features of static-php-cli,
@@ -53,6 +112,7 @@ which can be downloaded directly according to your needs.
|----------------------------------------------------------------------|----------------------------------------------------------------------------|--------------|--------------------------------|
| [common](https://dl.static-php.dev/static-php-cli/common/) | [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) | Linux, macOS | The binary size is about 7.5MB |
| [bulk](https://dl.static-php.dev/static-php-cli/bulk/) | [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) | Linux, macOS | The binary size is about 25MB |
| [gnu-bulk](https://dl.static-php.dev/static-php-cli/gnu-bulk/) | [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) | Linux, macOS | Using shared glibc |
| [minimal](https://dl.static-php.dev/static-php-cli/minimal/) | [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) | Linux, macOS | The binary size is about 3MB |
| [spc-min](https://dl.static-php.dev/static-php-cli/windows/spc-min/) | [5](https://dl.static-php.dev/static-php-cli/windows/spc-min/README.txt) | Windows | The binary size is about 3MB |
| [spc-max](https://dl.static-php.dev/static-php-cli/windows/spc-max/) | [40+](https://dl.static-php.dev/static-php-cli/windows/spc-max/README.txt) | Windows | The binary size is about 8.5MB |
@@ -60,63 +120,10 @@ which can be downloaded directly according to your needs.
> Linux and Windows supports UPX compression for binaries, which can reduce the size of the binary by 30% to 50%.
> macOS does not support UPX compression, so the size of the pre-built binaries for mac is larger.
## Build
### Compilation Requirements
You can say I made a PHP builder written in PHP, pretty funny.
But static-php-cli runtime only requires an environment above PHP 8.1 and extensions mentioned below.
- PHP >= 8.4 (This is the version required by spc itself, not the build version)
- Extension: `mbstring,tokenizer,phar`
- Supported OS with `curl` and `git` installed
Here is the supported OS and arch, where :octocat: represents support for GitHub Action builds,
:computer: represents support for local manual builds, and blank represents not currently supported.
| | x86_64 | aarch64 |
|---------|----------------------|----------------------|
| macOS | :octocat: :computer: | :octocat: :computer: |
| Linux | :octocat: :computer: | :octocat: :computer: |
| Windows | :octocat: :computer: | |
| FreeBSD | :computer: | :computer: |
Currently supported PHP versions for compilation:
> :warning: supported but not maintained by static-php-cli authors
>
> :heavy_check_mark: supported
>
> :x: not supported
| PHP Version | Status | Comment |
|-------------|--------------------|----------------------------------------------------------------------------------------------------|
| 7.2 | :x: | |
| 7.3 | :x: | phpmicro and some extensions not supported on 7.x |
| 7.4 | :x: | phpmicro and some extensions not supported on 7.x |
| 8.0 | :warning: | PHP official has stopped maintenance of 8.0, we no longer provide backport support for version 8.0 |
| 8.1 | :heavy_check_mark: | PHP official has security fixes only |
| 8.2 | :heavy_check_mark: | |
| 8.3 | :heavy_check_mark: | |
| 8.4 | :heavy_check_mark: | |
> This table shows the support status for static-php-cli in building the corresponding version,
> not the official PHP support status for that version.
### Supported Extensions
Please first select the extension you want to compile based on the extension list below.
- [Supported Extension List](https://static-php.dev/en/guide/extensions.html)
- [Command Generator](https://static-php.dev/en/guide/cli-generator.html)
> If an extension you need is missing, you can submit an issue.
Here is the current planned roadmap for extension support: [#152](https://github.com/crazywhalecc/static-php-cli/issues/152) .
### Build Online (using GitHub Actions)
Use GitHub Action to easily build a statically compiled PHP,
When the above direct download binaries cannot meet your needs,
you can use GitHub Action to easily build a statically compiled PHP,
and at the same time define the extensions to be compiled by yourself.
1. Fork me.
@@ -126,184 +133,6 @@ and at the same time define the extensions to be compiled by yourself.
If you enable `debug`, all logs will be output at build time, including compiled logs, for troubleshooting.
### Build Locally (using SPC binary, recommended)
This project provides a binary file of static-php-cli: `spc`.
You can use `spc` binary instead of installing any runtime like golang app.
Currently, the platforms supported by `spc` binary are Linux and macOS.
Download from self-hosted nightly builds using commands below:
```bash
# Download from self-hosted nightly builds (sync with main branch)
# For Linux x86_64
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64
# For Linux aarch64
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-aarch64
# macOS x86_64 (Intel)
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-x86_64
# macOS aarch64 (Apple)
curl -fsSL -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64
# Windows (x86_64, win10 build 17063 or later)
curl.exe -fsSL -o spc.exe https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe
# Add execute perm (Linux and macOS only)
chmod +x ./spc
# Run (Linux and macOS)
./spc --version
# Run (Windows powershell)
.\spc.exe --version
```
Self-hosted `spc` is built by GitHub Actions, you can also download from Actions artifacts [here](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml).
### Build Locally (using git source)
If you need to modify the static-php-cli source code, or have problems using the spc binary build,
you can download static-php-cli using the git source code.
```bash
# just clone me!
git clone https://github.com/crazywhalecc/static-php-cli.git
```
If you have not installed php on your system, we recommend that you use the built-in setup-runtime to install PHP and Composer automatically.
```bash
cd static-php-cli
chmod +x bin/setup-runtime
# it will download static php (from self-hosted server) and composer (from getcomposer)
bin/setup-runtime
# initialize composer deps
bin/composer install
# chmod
chmod +x bin/spc
bin/spc --version
```
### Start Building PHP
Basic usage for building php with some extensions:
> If you are using the packaged standalone `spc` binary, you need to replace `bin/spc` with `./spc` or `.\spc.exe` in the following commands.
```bash
# Check system tool dependencies, auto-fix them if possible
./bin/spc doctor --auto-fix
# fetch all libraries
./bin/spc download --all
# dump a list of extensions required by your project
./bin/spc dump-extensions /path/to/your/project --format=text
# only fetch necessary sources by needed extensions (recommended)
./bin/spc download --for-extensions="openssl,pcntl,mbstring,pdo_sqlite"
# download pre-built libraries first (save time for compiling dependencies)
./bin/spc download --for-extensions="openssl,curl,mbstring,mbregex" --prefer-pre-built
# download different PHP version (--with-php=x.y or --with-php=x.y.z, recommend 8.3 ~ 8.4)
./bin/spc download --for-extensions="openssl,curl,mbstring" --with-php=8.1
# with bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl extension, build both CLI and phpmicro SAPI
./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro
# build thread-safe (ZTS) version (--enable-zts)
./bin/spc build "curl,phar" --enable-zts --build-cli
# build, pack executable with UPX (linux and windows only) (reduce binary size for 30~50%)
./bin/spc build "curl,phar" --enable-zts --build-cli --with-upx-pack
```
Now we support `cli`, `micro`, `fpm` and `embed` SAPI. You can use one or more of the following parameters to specify the compiled SAPI:
- `--build-cli`: build static cli executable
- `--build-micro`: build static phpmicro self-extracted executable
- `--build-fpm`: build static fpm binary
- `--build-embed`: build embed (libphp)
- `--build-all`: build all
If anything goes wrong, use `--debug` option to display full terminal output:
```bash
./bin/spc build "openssl,pcntl,mbstring" --debug --build-all
./bin/spc download --all --debug
```
## Different SAPI Usage
### Use cli
> php-cli is a single static binary, you can use it like normal php installed on your system.
When using the parameter `--build-cli` or `--build-all`,
the final compilation result will output a binary file named `./php`,
which can be distributed and used directly.
This file will be located in the directory `buildroot/bin/`, copy it out for use.
```bash
cd buildroot/bin/
./php -v # check version
./php -m # check extensions
./php your_code.php # run your php code
./php your_project.phar # run your phar (project archive)
```
### Use micro
> phpmicro is a SelF-extracted eXecutable SAPI module,
> provided by [phpmicro](https://github.com/dixyes/phpmicro) project.
> But this project is using a [fork](https://github.com/static-php/phpmicro) of phpmicro, because we need to add some features to it.
> It can put php runtime and your source code together.
When using the parameter `--build-all` or `--build-micro`,
the final compilation result will output a file named `./micro.sfx`,
which needs to be used with your PHP source code like `code.php`.
This file will be located in the path `buildroot/bin/micro.sfx`, simply copy it out for use.
Prepare your project source code, which can be a single PHP file or a Phar file, for use.
```bash
echo "<?php echo 'Hello world' . PHP_EOL;" > code.php
cat micro.sfx code.php > single-app && chmod +x single-app
./single-app
```
If you package a PHAR file, just replace `code.php` with the phar file path.
You can use [box-project/box](https://github.com/box-project/box) to package your CLI project as Phar,
It is then combined with phpmicro to produce a standalone executable binary.
```bash
# Use the micro.sfx generated by static-php-cli to combine,
bin/spc micro:combine my-app.phar
# or you can directly use the cat command to combine them.
cat buildroot/bin/micro.sfx my-app.phar > my-app && chmod +x my-app
# Use micro:combine combination to inject INI options into the binary.
bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=system" --output my-app-2
```
> In some cases, PHAR files may not run in a micro environment. Overall, micro is not production ready.
### Use fpm
When using the parameter `--build-all` or `--build-fpm`,
the final compilation result will output a file named `./php-fpm`,
This file will be located in the path `buildroot/bin/`, simply copy it out for use.
In common Linux distributions and macOS systems, the package manager will automatically generate a default fpm configuration file after installing php-fpm.
Because php-fpm must specify a configuration file before running, the php-fpm compiled by this project will not have any configuration files, so you need to write `php-fpm.conf` and `pool.conf` configuration files yourself.
Specifying `php-fpm.conf` can use the command parameter `-y`, for example: `./php-fpm -y php-fpm.conf`.
### Use embed
When using the project parameters `--build-embed` or `--build-all`,
the final compilation result will output a `libphp.a`, `php-config` and a series of header files,
stored in `buildroot/`. You can introduce them in your other projects.
If you know [embed SAPI](https://github.com/php/php-src/tree/master/sapi/embed), you should know how to use it.
You may require the introduction of other libraries during compilation,
you can use `buildroot/bin/php-config` to obtain the compile-time configuration.
For an advanced example of how to use this feature, take a look at [how to use it to build a static version of FrankenPHP](https://github.com/php/frankenphp/blob/main/docs/static.md).
## Contribution
If the extension you need is missing, you can create an issue.
@@ -317,6 +146,12 @@ Now there is a [static-php](https://github.com/static-php) organization, which i
You can sponsor me or my project from [GitHub Sponsor](https://github.com/crazywhalecc). A portion of your donation will be used to maintain the **static-php.dev** server.
**Special thanks to sponsors below**:
<a href="https://beyondco.de/"><img src="/docs/public/images/beyondcode-seeklogo.png" width="300" alt="Beyond Code Logo" /></a>
<a href="https://nativephp.com/"><img src="/docs/public/images/nativephp-logo.svg" width="300" alt="NativePHP Logo" /></a>
## Open-Source License
This project itself is based on MIT License,

View File

@@ -1,158 +0,0 @@
#!/usr/bin/env bash
# This file is using docker to run commands
set -e
# Detect docker can run
if ! which docker >/dev/null; then
echo "Docker is not installed, please install docker first !"
exit 1
fi
DOCKER_EXECUTABLE="docker"
# shellcheck disable=SC2046
if [ $(id -u) -ne 0 ]; then
if ! docker info > /dev/null 2>&1; then
if [ "$SPC_USE_SUDO" != "yes" ]; then
echo "Docker command requires sudo"
# shellcheck disable=SC2039
echo -n 'To use sudo to run docker, run "export SPC_USE_SUDO=yes" and run command again'
exit 1
fi
DOCKER_EXECUTABLE="sudo docker"
fi
fi
# to check if qemu-docker run
if [ "$SPC_USE_ARCH" = "" ]; then
SPC_USE_ARCH=current
fi
case $SPC_USE_ARCH in
current)
BASE_ARCH=$(uname -m)
if [ "$BASE_ARCH" = "arm64" ]; then
BASE_ARCH=aarch64
GO_ARCH=arm64
else
GO_ARCH=amd64
fi
;;
aarch64)
BASE_ARCH=aarch64
GO_ARCH=arm64
# shellcheck disable=SC2039
echo -e "\e[033m* Using different arch needs to setup qemu-static for docker !\e[0m"
$DOCKER_EXECUTABLE run --rm --privileged multiarch/qemu-user-static:register --reset > /dev/null
;;
*)
echo "Current arch is not supported to run in docker: $SPC_USE_ARCH"
exit 1
;;
esac
# Detect docker env is setup
if ! $DOCKER_EXECUTABLE images | grep -q cwcc-frankenphp-gnu-$SPC_USE_ARCH; then
echo "Docker container does not exist. Building docker image ..."
$DOCKER_EXECUTABLE build -t cwcc-frankenphp-gnu-$SPC_USE_ARCH -f- . <<EOF
FROM centos:7
RUN sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo && \
sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo && \
sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo
RUN yum clean all && \
yum makecache && \
yum update -y && \
localedef -c -i en_US -f UTF-8 en_US.UTF-8
RUN yum install -y centos-release-scl
RUN if [ "$BASE_ARCH" = "aarch64" ]; then \
sed -i 's|mirror.centos.org/centos|vault.centos.org/altarch|g' /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo ; \
sed -i 's|mirror.centos.org/centos|vault.centos.org/altarch|g' /etc/yum.repos.d/CentOS-SCLo-scl.repo ; \
else \
sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo ; \
fi
RUN sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo && \
sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo
RUN yum update -y && \
yum install -y devtoolset-10-gcc-*
RUN echo "source scl_source enable devtoolset-10" >> /etc/bashrc
RUN source /etc/bashrc
RUN curl -o cmake.tgz -fsSL https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-$BASE_ARCH.tar.gz && \
mkdir /cmake && \
tar -xzf cmake.tgz -C /cmake --strip-components 1
WORKDIR /app
ADD ./src /app/src
COPY ./composer.* /app/
ADD ./bin/setup-runtime /app/bin/setup-runtime
ADD ./bin/spc /app/bin/spc
RUN /app/bin/setup-runtime
RUN /app/bin/php /app/bin/composer install --no-dev --classmap-authoritative
ENV PATH="/app/bin:/cmake/bin:/usr/local/go/bin:$PATH"
ENV SPC_LIBC=glibc
ADD ./config/env.ini /app/config/env.ini
RUN bin/spc doctor --auto-fix --debug
RUN curl -o make.tgz -fsSL https://ftp.gnu.org/gnu/make/make-4.4.tar.gz && \
tar -zxvf make.tgz && \
cd make-4.4 && \
./configure && \
make && \
make install && \
ln -sf /usr/local/bin/make /usr/bin/make
RUN curl -o automake.tgz -fsSL https://ftp.gnu.org/gnu/automake/automake-1.17.tar.xz && \
tar -xvf automake.tgz && \
cd automake-1.17 && \
./configure && \
make && \
make install && \
ln -sf /usr/local/bin/automake /usr/bin/automake
RUN git clone https://github.com/static-php/gnu-frankenphp --depth=1 /frankenphp
WORKDIR /frankenphp
RUN curl -o go.tgz -fsSL https://go.dev/dl/go1.24.1.linux-$GO_ARCH.tar.gz && \
rm -rf /usr/local/go && tar -C /usr/local -xzf go.tgz
EOF
fi
# Check if in ci (local terminal can execute with -it)
if [ -t 0 ]; then
INTERACT=-it
else
INTERACT=''
fi
# Mounting volumes
MOUNT_LIST=""
# shellcheck disable=SC2089
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/config:/app/config"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/src:/app/src"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/buildroot:/app/buildroot"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/source:/app/source"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/dist:/app/dist"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/downloads:/app/downloads"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/pkgroot:/app/pkgroot"
MOUNT_LIST="$MOUNT_LIST -v ""$(pwd)""/frankenphp-dist:/frankenphp/dist"
# Apply env in temp env file
echo 'CC=/opt/rh/devtoolset-10/root/usr/bin/gcc' > /tmp/spc-gnu-docker.env
echo 'CXX=/opt/rh/devtoolset-10/root/usr/bin/g++' >> /tmp/spc-gnu-docker.env
echo 'AR=/opt/rh/devtoolset-10/root/usr/bin/ar' >> /tmp/spc-gnu-docker.env
echo 'LD=/opt/rh/devtoolset-10/root/usr/bin/ld' >> /tmp/spc-gnu-docker.env
echo 'SPC_DEFAULT_C_FLAGS=-fPIE -fPIC' >> /tmp/spc-gnu-docker.env
echo 'SPC_LIBC=glibc' >> /tmp/spc-gnu-docker.env
echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-Wl,-O1 -pie"' >> /tmp/spc-gnu-docker.env
echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm -lresolv -lutil -lrt"' >> /tmp/spc-gnu-docker.env
# Run docker
# shellcheck disable=SC2068
# shellcheck disable=SC2086
# shellcheck disable=SC2090
$DOCKER_EXECUTABLE run --rm $INTERACT -e SPC_FIX_DEPLOY_ROOT="$(pwd)" --env-file /tmp/spc-gnu-docker.env $MOUNT_LIST cwcc-frankenphp-gnu-$SPC_USE_ARCH ./build-static.sh

11
bin/docker-entrypoint.sh Normal file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -e
TARGET_DIR="/app/pkgroot/$(uname -m)-linux"
BACKUP_DIR="/app/pkgroot-private"
# copy private pkgroot to pkgroot if pkgroot is empty
if [ ! -d "$TARGET_DIR" ] || [ -z "$(ls -A "$TARGET_DIR")" ]; then
echo "* Copying private pkgroot to pkgroot ..."
rm -rf "$TARGET_DIR"
cp -r "$BACKUP_DIR" "$TARGET_DIR"
fi
exec "$@"

View File

@@ -1,4 +0,0 @@
#!/usr/bin/env bash
# get parent dir, and run the php-cs-fixer
PHP_CS_FIXER_IGNORE_ENV=1 "$(dirname "$0")/../vendor/bin/php-cs-fixer" "$@"

View File

@@ -25,7 +25,7 @@ __DIR__=$(cd "$(dirname "$0")" && pwd)
__PROJECT__=$(cd "${__DIR__}"/../ && pwd)
# set download dir
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.4.4-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.4.12-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
__COMPOSER_URL__="https://getcomposer.org/download/latest-stable/composer.phar"
# use china mirror
@@ -45,7 +45,7 @@ done
case "$mirror" in
china)
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.4.4-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.4.12-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
__COMPOSER_URL__="https://mirrors.tencent.com/composer/composer.phar"
;;

View File

@@ -3,7 +3,7 @@
set -e
# This file is using docker to run commands
SPC_DOCKER_VERSION=v4
SPC_DOCKER_VERSION=v6
# Detect docker can run
if ! which docker >/dev/null; then
@@ -53,9 +53,9 @@ aarch64|arm64)
exit 1
;;
esac
# if ALPINE_FROM is not set, use alpine:edge
# if ALPINE_FROM is not set, use alpine:3.21
if [ -z "$ALPINE_FROM" ]; then
ALPINE_FROM=alpine:edge
ALPINE_FROM=alpine:3.21
fi
if [ "$SPC_USE_ARCH" != "$CURRENT_ARCH" ]; then
echo "* Using different arch needs to setup qemu-static for docker !"
@@ -64,7 +64,7 @@ if [ "$SPC_USE_ARCH" != "$CURRENT_ARCH" ]; then
$DOCKER_EXECUTABLE run --rm --privileged multiarch/qemu-user-static:register --reset > /dev/null
fi
else
ALPINE_FROM=alpine:edge
ALPINE_FROM=alpine:3.21
fi
if [ "$SPC_USE_MIRROR" = "yes" ]; then
@@ -104,6 +104,7 @@ RUN apk update; \
m4 \
make \
pkgconfig \
re2c \
wget \
xz \
gettext-dev \
@@ -121,6 +122,14 @@ ADD ./src /app/src
COPY ./composer.* /app/
ADD ./bin /app/bin
RUN composer install --no-dev
ADD ./config /app/config
RUN bin/spc doctor --auto-fix
RUN bin/spc install-pkg upx
RUN mv /app/pkgroot/\$(uname -m)-linux /app/pkgroot-private
ADD bin/docker-entrypoint.sh /bin/docker-entrypoint.sh
RUN chmod +x /bin/docker-entrypoint.sh
ENTRYPOINT ["/bin/docker-entrypoint.sh"]
EOF
fi

View File

@@ -3,7 +3,7 @@
set -e
# This file is using docker to run commands
SPC_DOCKER_VERSION=v4
SPC_DOCKER_VERSION=v6
# Detect docker can run
if ! which docker >/dev/null; then
@@ -64,7 +64,7 @@ fi
# Detect docker env is setup
if ! $DOCKER_EXECUTABLE images | grep -q cwcc-spc-gnu-$SPC_USE_ARCH-$SPC_DOCKER_VERSION; then
echo "Docker container does not exist. Building docker image ..."
$DOCKER_EXECUTABLE buildx build $PLATFORM_ARG --no-cache -t cwcc-spc-gnu-$SPC_USE_ARCH-$SPC_DOCKER_VERSION -f- . <<EOF
$DOCKER_EXECUTABLE buildx build $PLATFORM_ARG -t cwcc-spc-gnu-$SPC_USE_ARCH-$SPC_DOCKER_VERSION -f- . <<EOF
FROM centos:7
RUN sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo && \
sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo && \
@@ -83,10 +83,11 @@ RUN if [ "$SPC_USE_ARCH" = "aarch64" ]; then \
sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo ; \
fi
RUN sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo && \
sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo
sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo && \
sed -i 's|http://|https://|g' /etc/yum.repos.d/*.repo
RUN yum update -y && \
yum install -y devtoolset-10-gcc-*
yum install -y devtoolset-10-gcc-* devtoolset-10-libatomic-devel
RUN echo "source scl_source enable devtoolset-10" >> /etc/bashrc
RUN source /etc/bashrc
RUN yum install -y which
@@ -96,22 +97,26 @@ RUN curl -fsSL -o patchelf.tgz https://github.com/NixOS/patchelf/releases/downlo
tar -xzf patchelf.tgz -C /patchelf --strip-components=1 && \
cp /patchelf/bin/patchelf /usr/bin/
RUN curl -o cmake.tgz -fsSL 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 && \
tar -xzf cmake.tgz -C /cmake --strip-components 1
WORKDIR /app
ADD ./src /app/src
COPY ./composer.* /app/
ADD ./bin/setup-runtime /app/bin/setup-runtime
ADD ./bin/spc /app/bin/spc
RUN /app/bin/setup-runtime
ADD ./src /app/src
RUN /app/bin/php /app/bin/composer install --no-dev
ENV PATH="/app/bin:/cmake/bin:$PATH"
ENV SPC_LIBC=glibc
ENV PATH="/app/bin:/cmake/bin:/opt/rh/devtoolset-10/root/usr/bin:\$PATH"
ADD ./config/env.ini /app/config/env.ini
ADD ./config /app/config
RUN CC=gcc bin/spc doctor --auto-fix --debug
RUN bin/spc install-pkg upx
RUN if [ -f /app/buildroot/bin/re2c ]; then \
cp /app/buildroot/bin/re2c /usr/local/bin/re2c ;\
fi
RUN curl -o make.tgz -fsSL https://ftp.gnu.org/gnu/make/make-4.4.tar.gz && \
tar -zxvf make.tgz && \
@@ -129,6 +134,10 @@ RUN curl -o automake.tgz -fsSL https://ftp.gnu.org/gnu/automake/automake-1.17.ta
make install && \
ln -sf /usr/local/bin/automake /usr/bin/automake
RUN mv /app/pkgroot/\$(uname -m)-linux /app/pkgroot-private
ADD bin/docker-entrypoint.sh /bin/docker-entrypoint.sh
RUN chmod +x /bin/docker-entrypoint.sh
ENTRYPOINT ["/bin/docker-entrypoint.sh"]
EOF
fi
@@ -154,14 +163,8 @@ if [ -f "$(pwd)/craft.yml" ]; then
fi
# Apply env in temp env file
echo 'CC=/opt/rh/devtoolset-10/root/usr/bin/gcc' > /tmp/spc-gnu-docker.env
echo 'CXX=/opt/rh/devtoolset-10/root/usr/bin/g++' >> /tmp/spc-gnu-docker.env
echo 'AR=/opt/rh/devtoolset-10/root/usr/bin/ar' >> /tmp/spc-gnu-docker.env
echo 'LD=/opt/rh/devtoolset-10/root/usr/bin/ld' >> /tmp/spc-gnu-docker.env
echo 'SPC_DEFAULT_C_FLAGS=-fPIC' >> /tmp/spc-gnu-docker.env
echo 'SPC_DEFAULT_C_FLAGS=-fPIC' > /tmp/spc-gnu-docker.env
echo 'SPC_LIBC=glibc' >> /tmp/spc-gnu-docker.env
echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-Wl,-O1 -pie"' >> /tmp/spc-gnu-docker.env
echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm -lresolv -lutil -lrt"' >> /tmp/spc-gnu-docker.env
# Environment variable passthrough
ENV_LIST=""

View File

@@ -16,14 +16,13 @@
"symfony/console": "^5.4 || ^6 || ^7",
"symfony/process": "^7.2",
"symfony/yaml": "^7.2",
"zhamao/logger": "^1.0"
"zhamao/logger": "^1.1.3"
},
"require-dev": {
"captainhook/captainhook-phar": "^5.23",
"captainhook/hook-installer": "^1.0",
"friendsofphp/php-cs-fixer": "^3.60",
"humbug/box": "^4.5.0 || ^4.6.0",
"nunomaduro/collision": "^7.8",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.3 || ^9.5"
},

856
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -10,6 +10,7 @@
;
; Here's a list of env vars, these value cannot be changed anywhere:
;
; SPC_VERSION: the version of static-php-cli.
; WORKING_DIR: the working directory of the build process. (default: `$(pwd)`)
; ROOT_DIR: the root directory of static-php-cli. (default: `/path/to/static-php-cli`, when running in phar or micro mode: `phar://path/to/spc.phar`)
; BUILD_ROOT_PATH: the root path of the build process. (default: `$(pwd)/buildroot`)
@@ -33,7 +34,7 @@
; SPC_LINUX_DEFAULT_CC: the default compiler for linux. (For alpine linux: `gcc`, default: `$GNU_ARCH-linux-musl-gcc`)
; SPC_LINUX_DEFAULT_CXX: the default c++ compiler for linux. (For alpine linux: `g++`, default: `$GNU_ARCH-linux-musl-g++`)
; SPC_LINUX_DEFAULT_AR: the default archiver for linux. (For alpine linux: `ar`, default: `$GNU_ARCH-linux-musl-ar`)
; SPC_EXTRA_PHP_VARS: the extra vars for building php, used in `configure` and `make` command.
[global]
; Build concurrency for make -jN, default is CPU_COUNT, this value are used in every libs.
@@ -44,6 +45,8 @@ SPC_SKIP_PHP_VERSION_CHECK="no"
SPC_SKIP_DOCTOR_CHECK_ITEMS=""
; extra modules that xcaddy will include in the FrankenPHP build
SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES="--with github.com/dunglas/frankenphp/caddy --with github.com/dunglas/mercure/caddy --with github.com/dunglas/vulcain/caddy --with github.com/dunglas/caddy-cbrotli"
; The display message for php version output (PHP >= 8.4 available)
PHP_BUILD_PROVIDER="static-php-cli ${SPC_VERSION}"
; EXTENSION_DIR where the built php will look for extension when a .ini instructs to load them
; only useful for builds targeting not pure-static linking
@@ -55,6 +58,8 @@ SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES="--with github.com/dunglas/frankenphp/cadd
; EXTENSION_DIR=
[windows]
; build target: win7-static
SPC_TARGET=native-windows
; php-sdk-binary-tools path
PHP_SDK_PATH="${WORKING_DIR}\php-sdk-binary-tools"
; upx executable path
@@ -63,8 +68,24 @@ UPX_EXEC="${PKG_ROOT_PATH}\bin\upx.exe"
SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,cli_static
[linux]
; include PATH for musl libc.
; Linux can use different build toolchains.
; - musl (default, when SPC_LIBC=musl): used for general linux distros, can build `musl` (statically linked) only.
; - zig (will become default): usable on all Linux distros, can build `-musl`, `arch-linux-musl -dynamic` and `arch-linux-gnu` targets. Can specify version such as `x86_64-linux-gnu.2.17`.
; - 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.
; LEGACY option to specify the target
SPC_LIBC=musl
; Recommended: specify your target here. Zig toolchain will be used.
; examples:
; `native-native-gnu` - links against glibc, current OS version
; `native-native-gnu.2.17` - links against glibc, version 2.17
; `native-native` - links against system libc dynamically
; `native-native-musl` - links against musl libc statically
; `native-native-musl -dynamic` - links against musl libc dynamically
; SPC_TARGET=
; compiler environments
CC=${SPC_LINUX_DEFAULT_CC}
CXX=${SPC_LINUX_DEFAULT_CXX}
@@ -73,74 +94,61 @@ LD=${SPC_LINUX_DEFAULT_LD}
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
SPC_DEFAULT_C_FLAGS="-fPIC -Os"
SPC_DEFAULT_CXX_FLAGS="-fPIC -Os"
; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated)
SPC_EXTRA_LIBS=
SPC_DEFAULT_LD_FLAGS=""
; upx executable path
UPX_EXEC=${PKG_ROOT_PATH}/bin/upx
; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches
SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream
SPC_MICRO_PATCHES=cli_checks,disable_huge_page
; *** default build command for building php ***
; buildconf command
SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
; configure command
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --disable-shared --enable-static --disable-all --disable-cgi --disable-phpdbg --with-pic"
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --disable-shared --enable-static --disable-all --disable-phpdbg --with-pic"
; make command
SPC_CMD_PREFIX_PHP_MAKE="make -j${CPU_COUNT}"
; embed type for php, static (libphp.a) or shared (libphp.so)
SPC_CMD_VAR_PHP_EMBED_TYPE="static"
SPC_CMD_PREFIX_PHP_MAKE="make -j${SPC_CONCURRENCY}"
; *** default build vars for building php ***
; embed type for php, static (libphp.a) or shared (libphp.so)
SPC_CMD_VAR_PHP_EMBED_TYPE="static"
; CFLAGS for configuring php
SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -fPIE"
; CPPFLAGS for configuring php
SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}"
; LDFLAGS for configuring php
SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}"
; LIBS for configuring php
SPC_CMD_VAR_PHP_CONFIGURE_LIBS="-ldl -lpthread -lm"
; EXTRA_CFLAGS for `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fno-ident -fPIE ${SPC_DEFAULT_C_FLAGS}"
; EXTRA_LIBS for `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm"
; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS=""
; EXTRA_LDFLAGS_PROGRAM for `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-all-static -Wl,-O1 -pie"
[macos]
; 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.
SPC_TARGET=native-macos
; compiler environments
CC=clang
CXX=clang++
AR=ar
LD=ld
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
SPC_DEFAULT_C_FLAGS="--target=${MAC_ARCH}-apple-darwin -Os"
SPC_DEFAULT_CXX_FLAGS="--target=${MAC_ARCH}-apple-darwin -Os"
; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated)
SPC_EXTRA_LIBS=
SPC_DEFAULT_LD_FLAGS=""
; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches
SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,macos_iconv
SPC_MICRO_PATCHES=cli_checks,macos_iconv
; *** default build command for building php ***
; buildconf command
SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
; configure command
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg"
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-phpdbg"
; make command
SPC_CMD_PREFIX_PHP_MAKE="make -j${CPU_COUNT}"
SPC_CMD_PREFIX_PHP_MAKE="make -j${SPC_CONCURRENCY}"
; *** default build vars for building php ***
; CFLAGS for configuring php
SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -Werror=unknown-warning-option"
; CPPFLAGS for configuring php
SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}"
; LDFLAGS for configuring php
SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}"
; EXTRA_CFLAGS for `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie ${SPC_DEFAULT_C_FLAGS}"
; EXTRA_LIBS for `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-lresolv"
; embed type for php, static (libphp.a) or shared (libphp.dylib)
SPC_CMD_VAR_PHP_EMBED_TYPE="static"
; CFLAGS for configuring php
SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -Werror=unknown-warning-option"
; EXTRA_CFLAGS for `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie ${SPC_DEFAULT_C_FLAGS}"
[freebsd]
; compiler environments

View File

@@ -34,7 +34,7 @@
},
"bz2": {
"type": "builtin",
"arg-type-unix": "with-prefix",
"arg-type-unix": "with-path",
"arg-type-windows": "with",
"lib-depends": [
"bzip2"
@@ -185,7 +185,7 @@
"BSD": "wip"
},
"type": "builtin",
"arg-type": "with-prefix",
"arg-type": "with-path",
"lib-depends": [
"gettext"
]
@@ -211,7 +211,7 @@
"BSD": "wip"
},
"type": "builtin",
"arg-type": "with-prefix",
"arg-type": "with-path",
"lib-depends": [
"gmp"
]
@@ -233,7 +233,7 @@
},
"type": "external",
"source": "grpc",
"arg-type-unix": "custom",
"arg-type-unix": "enable-path",
"cpp-extension": true,
"lib-depends": [
"grpc"
@@ -244,7 +244,7 @@
"BSD": "wip"
},
"type": "builtin",
"arg-type": "with-prefix",
"arg-type": "with-path",
"arg-type-windows": "with",
"lib-depends-unix": [
"libiconv"
@@ -320,7 +320,7 @@
"BSD": "wip"
},
"type": "builtin",
"arg-type": "with-prefix",
"arg-type": "with-path",
"lib-depends": [
"ldap"
],
@@ -414,9 +414,17 @@
"libmemcached",
"fastlz"
],
"lib-suggests": [
"zstd"
],
"ext-depends": [
"session",
"zlib"
],
"ext-suggests": [
"igbinary",
"msgpack",
"session"
]
},
"mongodb": {
@@ -488,6 +496,7 @@
"opcache": {
"type": "builtin",
"arg-type-unix": "custom",
"arg-type-windows": "enable",
"zend-extension": true
},
"openssl": {
@@ -495,6 +504,7 @@
"type": "builtin",
"arg-type": "custom",
"arg-type-windows": "with",
"build-with-php": true,
"lib-depends": [
"openssl",
"zlib"
@@ -529,9 +539,10 @@
},
"notes": true,
"type": "builtin",
"arg-type": "with-prefix",
"arg-type": "custom",
"lib-depends": [
"libargon2"
"libargon2",
"openssl"
]
},
"pcntl": {
@@ -571,7 +582,7 @@
"BSD": "wip"
},
"type": "builtin",
"arg-type": "with-prefix",
"arg-type": "with-path",
"arg-type-windows": "custom",
"ext-depends": [
"pdo",
@@ -674,7 +685,7 @@
"BSD": "wip"
},
"type": "builtin",
"arg-type": "with-prefix",
"arg-type": "with-path",
"lib-depends": [
"readline"
],
@@ -691,7 +702,8 @@
"arg-type": "custom",
"ext-suggests": [
"session",
"igbinary"
"igbinary",
"msgpack"
],
"lib-suggests-unix": [
"zstd",
@@ -747,11 +759,9 @@
},
"type": "builtin",
"arg-type": "custom",
"lib-depends": [
"libxml2"
],
"ext-depends-windows": [
"xml"
"ext-depends": [
"libxml",
"session"
]
},
"sockets": {
@@ -785,7 +795,7 @@
"BSD": "wip"
},
"type": "builtin",
"arg-type": "with-prefix",
"arg-type": "with-path",
"arg-type-windows": "with",
"lib-depends": [
"sqlite"
@@ -811,7 +821,7 @@
},
"type": "external",
"source": "ext-ssh2",
"arg-type": "with-prefix",
"arg-type": "with-path",
"arg-type-windows": "with",
"lib-depends": [
"libssh2"
@@ -838,14 +848,23 @@
"nghttp2",
"zlib"
],
"lib-suggests": [
"zstd"
],
"lib-suggests-linux": [
"zstd",
"liburing"
],
"ext-depends": [
"openssl",
"curl"
],
"ext-suggests": [
"sockets",
"swoole-hook-pgsql",
"swoole-hook-mysql",
"swoole-hook-sqlite"
"swoole-hook-sqlite",
"swoole-hook-odbc"
]
},
"swoole-hook-mysql": {
@@ -855,11 +874,12 @@
},
"notes": true,
"type": "addon",
"arg-type": "custom",
"arg-type": "none",
"ext-depends": [
"mysqlnd",
"pdo",
"pdo_mysql"
"pdo_mysql",
"swoole"
],
"ext-suggests": [
"mysqli"
@@ -873,10 +893,11 @@
},
"notes": true,
"type": "addon",
"arg-type": "custom",
"arg-type": "none",
"ext-depends": [
"pgsql",
"pdo"
"pdo",
"swoole"
]
},
"swoole-hook-sqlite": {
@@ -886,10 +907,27 @@
},
"notes": true,
"type": "addon",
"arg-type": "custom",
"arg-type": "none",
"ext-depends": [
"sqlite3",
"pdo"
"pdo",
"swoole"
]
},
"swoole-hook-odbc": {
"support": {
"Windows": "no",
"BSD": "wip"
},
"notes": true,
"type": "addon",
"arg-type": "none",
"ext-depends": [
"pdo",
"swoole"
],
"lib-depends": [
"unixodbc"
]
},
"swow": {
@@ -937,7 +975,7 @@
"BSD": "wip"
},
"type": "builtin",
"arg-type": "with-prefix",
"arg-type": "with-path",
"lib-depends": [
"tidy"
]
@@ -953,7 +991,7 @@
},
"type": "external",
"source": "ext-uuid",
"arg-type": "with-prefix",
"arg-type": "with-path",
"lib-depends": [
"libuuid"
]
@@ -965,7 +1003,7 @@
},
"type": "external",
"source": "ext-uv",
"arg-type": "with-prefix",
"arg-type": "with-path",
"lib-depends": [
"libuv"
],
@@ -1067,7 +1105,7 @@
"BSD": "wip"
},
"type": "builtin",
"arg-type": "with-prefix",
"arg-type": "with-path",
"lib-depends": [
"libxslt"
],
@@ -1104,7 +1142,7 @@
},
"type": "external",
"source": "yaml",
"arg-type-unix": "with-prefix",
"arg-type-unix": "with-path",
"arg-type-windows": "with",
"lib-depends": [
"libyaml"
@@ -1114,8 +1152,9 @@
"support": {
"BSD": "wip"
},
"type": "builtin",
"arg-type": "with-prefix",
"type": "external",
"source": "ext-zip",
"arg-type": "custom",
"arg-type-windows": "enable",
"lib-depends-unix": [
"libzip"

View File

@@ -1,9 +1,6 @@
{
"lib-base": {
"type": "root",
"lib-depends-unix": [
"pkg-config"
]
"type": "root"
},
"php": {
"type": "root",
@@ -12,8 +9,19 @@
"lib-base",
"micro"
],
"lib-depends-macos": [
"lib-base",
"micro",
"libxml2"
],
"lib-suggests-linux": [
"libacl"
"libacl",
"brotli",
"watcher"
],
"lib-suggests-macos": [
"brotli",
"watcher"
]
},
"micro": {
@@ -35,10 +43,10 @@
},
"brotli": {
"source": "brotli",
"static-libs-unix": [
"libbrotlidec.a",
"libbrotlienc.a",
"libbrotlicommon.a"
"pkg-configs": [
"libbrotlicommon",
"libbrotlidec",
"libbrotlienc"
],
"static-libs-windows": [
"brotlicommon.lib",
@@ -89,7 +97,8 @@
"nghttp3",
"ngtcp2",
"zstd",
"libcares"
"libcares",
"ldap"
],
"lib-suggests-windows": [
"brotli",
@@ -185,14 +194,16 @@
},
"grpc": {
"source": "grpc",
"static-libs-unix": [
"libgrpc.a",
"libcares.a"
"pkg-configs": [
"grpc"
],
"lib-depends": [
"zlib",
"openssl"
"openssl",
"libcares"
],
"cpp-library": true,
"provide-pre-built": true,
"frameworks": [
"CoreFoundation"
]
@@ -200,11 +211,10 @@
"icu": {
"source": "icu",
"cpp-library": true,
"static-libs-unix": [
"libicui18n.a",
"libicuio.a",
"libicuuc.a",
"libicudata.a"
"pkg-configs": [
"icu-uc",
"icu-i18n",
"icu-io"
]
},
"icu-static-win": {
@@ -221,15 +231,17 @@
},
"imagemagick": {
"source": "imagemagick",
"static-libs-unix": [
"libMagick++-7.Q16HDRI.a",
"libMagickWand-7.Q16HDRI.a",
"libMagickCore-7.Q16HDRI.a"
"cpp-library": true,
"pkg-configs": [
"Magick++-7.Q16HDRI",
"MagickCore-7.Q16HDRI",
"MagickWand-7.Q16HDRI"
],
"lib-depends": [
"zlib",
"libpng",
"libjpeg",
"libjxl",
"libpng",
"libwebp",
"freetype",
"libtiff",
@@ -252,11 +264,23 @@
"openssl"
]
},
"jbig": {
"source": "jbig",
"static-libs-unix": [
"libjbig.a",
"libjbig85.a"
],
"headers": [
"jbig.h",
"jbig85.h",
"jbig_ar.h"
]
},
"ldap": {
"source": "ldap",
"static-libs-unix": [
"libldap.a",
"liblber.a"
"pkg-configs": [
"ldap",
"lber"
],
"lib-depends": [
"openssl",
@@ -265,6 +289,13 @@
"libsodium"
]
},
"lerc": {
"source": "lerc",
"static-libs-unix": [
"libLerc.a"
],
"cpp-library": true
},
"libacl": {
"source": "libacl",
"static-libs-unix": [
@@ -400,6 +431,21 @@
"zlib"
]
},
"libjxl": {
"source": "libjxl",
"pkg-configs": [
"libjxl",
"libjxl_cms",
"libjxl_threads",
"libhwy"
],
"lib-depends": [
"brotli",
"libjpeg",
"libpng",
"libwebp"
]
},
"liblz4": {
"source": "liblz4",
"static-libs-unix": [
@@ -408,6 +454,7 @@
},
"libmemcached": {
"source": "libmemcached",
"cpp-library": true,
"static-libs-unix": [
"libmemcached.a",
"libmemcachedprotocol.a",
@@ -485,9 +532,6 @@
],
"lib-depends": [
"openssl"
],
"lib-suggests": [
"zlib"
]
},
"libtiff": {
@@ -498,6 +542,13 @@
"lib-depends": [
"zlib",
"libjpeg"
],
"lib-suggests-unix": [
"lerc",
"libwebp",
"jbig",
"xz",
"zstd"
]
},
"libuuid": {
@@ -517,12 +568,12 @@
},
"libwebp": {
"source": "libwebp",
"static-libs-unix": [
"libwebp.a",
"libwebpdecoder.a",
"libwebpdemux.a",
"libwebpmux.a",
"libsharpyuv.a"
"pkg-configs": [
"libwebp",
"libwebpdecoder",
"libwebpdemux",
"libwebpmux",
"libsharpyuv"
],
"static-libs-windows": [
"libwebp.lib",
@@ -548,7 +599,6 @@
],
"lib-suggests-unix": [
"xz",
"icu",
"zlib"
],
"lib-depends-windows": [
@@ -615,7 +665,7 @@
"mimalloc": {
"source": "mimalloc",
"static-libs-unix": [
"mimalloc.o"
"libmimalloc.a"
]
},
"ncurses": {
@@ -714,10 +764,8 @@
},
"postgresql": {
"source": "postgresql",
"static-libs-unix": [
"libpq.a",
"libpgport.a",
"libpgcommon.a"
"pkg-configs": [
"libpq"
],
"lib-depends": [
"libiconv",
@@ -759,6 +807,12 @@
"depot.h"
]
},
"re2c": {
"source": "re2c",
"bin-unix": [
"re2c"
]
},
"readline": {
"source": "readline",
"static-libs-unix": [
@@ -770,6 +824,7 @@
},
"snappy": {
"source": "snappy",
"cpp-library": true,
"static-libs-unix": [
"libsnappy.a"
],
@@ -813,6 +868,16 @@
"libiconv"
]
},
"watcher": {
"source": "watcher",
"cpp-library": true,
"static-libs-unix": [
"libwatcher-c.a"
],
"headers": [
"wtr/watcher-c.h"
]
},
"xz": {
"source": "xz",
"static-libs-unix": [
@@ -867,13 +932,19 @@
"zstd_errors.h"
]
},
"watcher": {
"source": "watcher",
"static-libs-unix": [
"libwatcher-c.a"
"liburing": {
"source": "liburing",
"pkg-configs": [
"liburing",
"liburing-ffi"
],
"headers": [
"wtr/watcher-c.h"
"static-libs-linux": [
"liburing.a",
"liburing-ffi.a"
],
"headers-linux": [
"liburing/",
"liburing.h"
]
}
}

View File

@@ -1,4 +1,16 @@
{
"go-xcaddy-aarch64-linux": {
"type": "custom"
},
"go-xcaddy-aarch64-macos": {
"type": "custom"
},
"go-xcaddy-x86_64-linux": {
"type": "custom"
},
"go-xcaddy-x86_64-macos": {
"type": "custom"
},
"musl-toolchain-aarch64-linux": {
"type": "url",
"url": "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/aarch64-musl-toolchain.tgz"
@@ -15,6 +27,38 @@
"nasm-2.16.01/ndisasm.exe": "{php_sdk_path}/bin/ndisasm.exe"
}
},
"pkg-config-aarch64-linux": {
"type": "ghrel",
"repo": "static-php/static-php-cli-hosted",
"match": "pkg-config-aarch64-linux-musl-1.2.5.txz",
"extract-files": {
"bin/pkg-config": "{pkg_root_path}/bin/pkg-config"
}
},
"pkg-config-aarch64-macos": {
"type": "ghrel",
"repo": "static-php/static-php-cli-hosted",
"match": "pkg-config-aarch64-darwin.txz",
"extract-files": {
"bin/pkg-config": "{pkg_root_path}/bin/pkg-config"
}
},
"pkg-config-x86_64-linux": {
"type": "ghrel",
"repo": "static-php/static-php-cli-hosted",
"match": "pkg-config-x86_64-linux-musl-1.2.5.txz",
"extract-files": {
"bin/pkg-config": "{pkg_root_path}/bin/pkg-config"
}
},
"pkg-config-x86_64-macos": {
"type": "ghrel",
"repo": "static-php/static-php-cli-hosted",
"match": "pkg-config-x86_64-darwin.txz",
"extract-files": {
"bin/pkg-config": "{pkg_root_path}/bin/pkg-config"
}
},
"strawberry-perl-x86_64-win": {
"type": "url",
"url": "https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip"
@@ -43,16 +87,19 @@
"upx-*-win64/upx.exe": "{pkg_root_path}/bin/upx.exe"
}
},
"go-xcaddy-x86_64-linux": {
"zig-aarch64-linux": {
"type": "custom"
},
"go-xcaddy-aarch64-linux": {
"zig-aarch64-macos": {
"type": "custom"
},
"go-xcaddy-x86_64-macos": {
"zig-x86_64-linux": {
"type": "custom"
},
"go-xcaddy-aarch64-macos": {
"zig-x86_64-macos": {
"type": "custom"
},
"zig-x86_64-win": {
"type": "custom"
}
}

View File

@@ -4,7 +4,8 @@
"license": {
"type": "file",
"path": "LICENSE"
}
},
"alt": false
},
"amqp": {
"type": "url",
@@ -262,6 +263,15 @@
"path": "LICENSE"
}
},
"ext-zip": {
"type": "url",
"url": "https://pecl.php.net/get/zip",
"filename": "ext-zip.tgz",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-zstd": {
"type": "git",
"path": "php-src/ext/zstd",
@@ -323,7 +333,7 @@
},
"grpc": {
"type": "git",
"rev": "v1.68.x",
"rev": "v1.75.x",
"url": "https://github.com/grpc/grpc.git",
"provide-pre-built": true,
"license": {
@@ -387,6 +397,19 @@
"path": "LICENSE"
}
},
"jbig": {
"type": "url",
"url": "https://dl.static-php.dev/static-php-cli/deps/jbig/jbigkit-2.1.tar.gz",
"provide-pre-built": true,
"alt": {
"type": "url",
"url": "https://www.cl.cam.ac.uk/~mgk25/jbigkit/download/jbigkit-2.1.tar.gz"
},
"license": {
"type": "file",
"path": "COPYING"
}
},
"ldap": {
"type": "filelist",
"url": "https://www.openldap.org/software/download/OpenLDAP/openldap-release/",
@@ -396,6 +419,16 @@
"path": "LICENSE"
}
},
"lerc": {
"type": "ghtar",
"repo": "Esri/lerc",
"prefer-stable": true,
"provide-pre-built": true,
"license": {
"type": "file",
"path": "LICENSE"
}
},
"libacl": {
"alt": {
"type": "url",
@@ -533,6 +566,21 @@
"path": "LICENSE.md"
}
},
"libjxl": {
"type": "git",
"url": "https://github.com/libjxl/libjxl",
"rev": "main",
"submodules": [
"third_party/highway",
"third_party/libjpeg-turbo",
"third_party/sjpeg",
"third_party/skcms"
],
"license": {
"type": "file",
"path": "LICENSE"
}
},
"liblz4": {
"type": "ghrel",
"repo": "lz4/lz4",
@@ -596,6 +644,7 @@
"repo": "libssh2/libssh2",
"match": "libssh2.+\\.tar\\.gz",
"prefer-stable": true,
"provide-pre-built": true,
"license": {
"type": "file",
"path": "COPYING"
@@ -605,7 +654,6 @@
"type": "filelist",
"url": "https://download.osgeo.org/libtiff/",
"regex": "/href=\"(?<file>tiff-(?<version>[^\"]+)\\.tar\\.xz)\"/",
"provide-pre-built": true,
"license": {
"type": "file",
"path": "LICENSE.md"
@@ -694,7 +742,7 @@
"micro": {
"type": "git",
"path": "php-src/sapi/micro",
"rev": "84beta",
"rev": "php-85-win",
"url": "https://github.com/static-php/phpmicro",
"license": {
"type": "file",
@@ -841,7 +889,7 @@
"postgresql": {
"type": "ghtagtar",
"repo": "postgres/postgres",
"match": "REL_16_\\d+",
"match": "REL_18_\\d+",
"license": {
"type": "file",
"path": "COPYRIGHT"
@@ -893,6 +941,20 @@
"path": "LICENSE"
}
},
"re2c": {
"type": "ghrel",
"repo": "skvadrik/re2c",
"match": "re2c.+\\.tar\\.xz",
"prefer-stable": true,
"alt": {
"type": "url",
"url": "https://dl.static-php.dev/static-php-cli/deps/re2c/re2c-4.3.tar.xz"
},
"license": {
"type": "file",
"path": "LICENSE"
}
},
"readline": {
"type": "filelist",
"url": "https://ftp.gnu.org/pub/gnu/readline/",
@@ -957,33 +1019,29 @@
},
"swoole": {
"path": "php-src/ext/swoole",
"type": "git",
"rev": "master",
"url": "https://github.com/swoole/swoole-src.git",
"type": "ghtar",
"repo": "swoole/swoole-src",
"match": "v6\\.+",
"prefer-stable": true,
"license": {
"type": "file",
"path": "LICENSE"
},
"alt": {
"type": "ghtar",
"repo": "swoole/swoole-src",
"prefer-stable": true
}
},
"swow": {
"type": "git",
"path": "php-src/ext/swow-src",
"rev": "ci",
"url": "https://github.com/swow/swow",
"type": "ghtar",
"repo": "swow/swow",
"prefer-stable": true,
"license": {
"type": "file",
"path": "LICENSE"
}
},
"tidy": {
"type": "url",
"url": "https://github.com/htacg/tidy-html5/archive/refs/tags/5.8.0.tar.gz",
"filename": "tidy-html5.tgz",
"type": "ghtar",
"repo": "htacg/tidy-html5",
"prefer-stable": true,
"license": {
"type": "file",
"path": "README/LICENSE.md"
@@ -998,6 +1056,15 @@
"path": "COPYING"
}
},
"watcher": {
"type": "ghtar",
"repo": "e-dant/watcher",
"prefer-stable": true,
"license": {
"type": "file",
"path": "license"
}
},
"xdebug": {
"type": "url",
"url": "https://pecl.php.net/get/xdebug",
@@ -1079,13 +1146,13 @@
"path": "LICENSE"
}
},
"watcher": {
"liburing": {
"type": "ghtar",
"repo": "e-dant/watcher",
"repo": "axboe/liburing",
"prefer-stable": true,
"license": {
"type": "file",
"path": "license"
"path": "COPYING"
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -47,6 +47,18 @@ export default {
nav: [],
socialLinks: [
{icon: 'github', link: 'https://github.com/crazywhalecc/static-php-cli'}
]
],
footer: {
message: 'Released under the MIT License.',
copyright: 'Copyright © 2023-present crazywhalecc'
},
search: {
provider: 'algolia',
options: {
appId: 'IHJHUB1SF1',
apiKey: '8266d31cc2ffbd0e059f1c6e5bdaf8fc',
indexName: 'static-php docs',
},
},
}
}

View File

@@ -2,6 +2,7 @@
import DefaultTheme from 'vitepress/theme'
import {inBrowser, useData} from "vitepress";
import {watchEffect} from "vue";
import './style.css';
export default {
...DefaultTheme,
@@ -13,4 +14,4 @@ export default {
}
})
}
}
}

View File

@@ -0,0 +1,6 @@
/** override default styles */
.vp-sponsor-grid-image {
max-height:36px !important;
max-width: 1000px !important;
}

View File

@@ -46,19 +46,27 @@ If you use `swoole,swoole-hook-sqlite`, you will enable the coroutine mode of Sw
swoole-hook-sqlite conflicts with the `pdo_sqlite` extension. If you want to use Swoole and `pdo_sqlite`, please delete the pdo_sqlite extension and enable `swoole` and `swoole-hook-sqlite`.
This extension contains an implementation of the coroutine environment for `pdo_sqlite`.
## swoole-hook-odbc
swoole-hook-odbc is not an extension, it's a Hook feature of Swoole.
If you use `swoole,swoole-hook-odbc`, you will enable the coroutine mode of Swoole's `odbc` extension.
swoole-hook-odbc conflicts with the `pdo_odbc` extension. If you want to use Swoole and `pdo_odbc`, please delete the `pdo_odbc` extension and enable `swoole` and `swoole-hook-odbc`.
This extension contains an implementation of the coroutine environment for `pdo_odbc`.
## swow
1. Only PHP 8.0 ~ 8.4 is supported.
1. Only PHP 8.0+ is supported.
## imagick
1. The imagick extension currently only has openmp support on musl libc. This means that multithreading is disabled on glibc or other operating systems. The extension is still fully functional.
1. OpenMP support is disabled, this is recommended by the maintainers and also the case system packages.
## imap
1. Kerberos is not supported
2. ext-imap is not thread safe due to the underlying c-client. It's not possible to use it in --enable-zts builds.
3. Because the extension may be dropped from php, we recommend you look for an alternative implementation, such as [Webklex/php-imap](https://github.com/Webklex/php-imap)
2. ext-imap is not thread safe due to the underlying c-client. It's not possible to use it in `--enable-zts` builds.
3. The extension was dropped from php 8.4, we recommend you look for an alternative implementation, such as [Webklex/php-imap](https://github.com/Webklex/php-imap)
## gd
@@ -82,7 +90,7 @@ and this extension cannot be compiled into php by static linking, so it cannot b
## xdebug
1. Xdebug is only buildable as a shared extension. On Linux, you need to use static-php-cli with SPC_LIBC=glibc.
1. Xdebug is only buildable as a shared extension. On Linux, you'll need to use a SPC_TARGET like `native-native -dynamic` or `native-native-gnu`.
2. When using Linux/glibc or macOS, you can compile Xdebug as a shared extension using --build-shared="xdebug".
The compiled `./php` binary can be configured and run by specifying the INI, eg `./php -d 'zend_extension=/path/to/xdebug.so' your-code.php`.
@@ -122,8 +130,8 @@ For details on the solution, see [FAQ - Unable to use ssl](../faq/#unable-to-use
## password-argon2
1. password-argon2 is not a standard extension, it is an additional algorithm for the `password_hash` function.
2. On Linux systems, `password-argon2` dependency `libargon2` conflicts with the `libsodium` library.
1. password-argon2 is not a standard extension. The algorithm `PASSWORD_ARGON2ID` for the `password_hash` function needs libsodium or libargon2 to work.
2. using password-argon2 enables multithread support for this.
## ffi

View File

@@ -21,19 +21,30 @@ The following is the architecture support situation, where :gear: represents sup
| Windows | :gear: :computer: | |
| FreeBSD | :computer: | :computer: |
Among them, Linux is currently only tested on Ubuntu, Debian, and Alpine distributions,
and other distributions have not been tested, which cannot guarantee successful compilation.
For untested distributions, local compilation can be done using methods such as Docker to avoid environmental issues.
Current supported PHP versions for compilation:
There are two architectures for macOS: `x86_64` and `Arm`, but binaries compiled on one architecture cannot be directly used on the other architecture.
Rosetta 2 cannot guarantee that programs compiled with `Arm` architecture can fully run on `x86_64` environment.
> :warning: Partial support, there may be issues with new beta versions and old versions.
>
> :heavy_check_mark: Supported
>
> :x: Not supported
Windows currently only supports the x86_64 architecture, and does not support 32-bit x86 or arm64 architecture.
| PHP Version | Status | Comment |
|-------------|--------------------|-------------------------------------------------------------------------------------------------------------------------|
| 7.2 | :x: | |
| 7.3 | :x: | phpmicro and many extensions do not support 7.3, 7.4 versions |
| 7.4 | :x: | phpmicro and many extensions do not support 7.3, 7.4 versions |
| 8.0 | :warning: | PHP official has stopped maintaining 8.0, we no longer handle 8.0 related backport support |
| 8.1 | :warning: | PHP official only provides security updates for 8.1, we no longer handle 8.1 related backport support after 8.5 release |
| 8.2 | :heavy_check_mark: | |
| 8.3 | :heavy_check_mark: | |
| 8.4 | :heavy_check_mark: | |
| 8.5 (beta) | :warning: | PHP 8.5 is currently in beta stage |
## Supported PHP Version
> This table shows the support status of static-php-cli for building corresponding versions, not the PHP official support status for that version.
Currently, static php cli supports PHP versions 8.1 to 8.4, and theoretically supports PHP 8.0 and earlier versions.
Simply select the earlier version when downloading.
However, due to some extensions and special components that have stopped supporting earlier versions of PHP,
static-php-cli will not explicitly support earlier versions.
## PHP Support Versions
Currently, static-php-cli supports PHP versions 8.2 ~ 8.5, and theoretically supports PHP 8.1 and earlier versions, just select the earlier version when downloading.
However, due to some extensions and special components that have stopped supporting earlier versions of PHP, static-php-cli will not explicitly support earlier versions.
We recommend that you compile the latest PHP version possible for a better experience.

View File

@@ -172,7 +172,7 @@ If the build is successful, you will see the `buildroot/bin` directory in the cu
If the build fails, you can use the `--debug` parameter to view detailed error information,
or use the `--with-clean` to clear the old compilation results and recompile.
If the build still fails to use the above method, please submit an issue and attach your `craft.yml` and `craft.log`.
If the build still fails to use the above method, please submit an issue and attach your `craft.yml` and `./log` archive.
## Step-by-step build command
@@ -242,8 +242,8 @@ Also, it is available when downloading with the `--for-extensions` option.
```bash
# Specifying to download a beta version of PHP8.3
bin/spc download --all -U "php-src:https://downloads.php.net/~eric/php-8.3.0beta1.tar.gz"
# Specifying to download a alpha version of PHP 8.5
bin/spc download --all -U "php-src:https://downloads.php.net/~edorian/php-8.5.0alpha2.tar.xz"
# Specifying to download an older version of the curl library
bin/spc download --all -U "curl:https://curl.se/download/curl-7.88.1.tar.gz"
@@ -289,6 +289,7 @@ You need to specify a compilation target, choose from the following parameters:
- `--build-cli`: Build a cli sapi (command line interface, which can execute PHP code on the command line)
- `--build-fpm`: Build a fpm sapi (php-fpm, used in conjunction with other traditional fpm architecture software such as nginx)
- `--build-cgi`: Build a cgi sapi (cgi, rarely used)
- `--build-micro`: Build a micro sapi (used to build a standalone executable binary containing PHP code)
- `--build-embed`: Build an embed sapi (used to embed into other C language programs)
- `--build-frankenphp`: Build a [FrankenPHP](https://github.com/php/frankenphp) executable

View File

@@ -21,3 +21,16 @@ features:
- title: Dependency Management
details: static-php-cli comes with dependency management and supports installation of different types of PHP extensions.
---
<script setup>
import {VPSponsors} from "vitepress/theme";
const sponsors = [
{ name: 'Beyond Code', img: '/images/beyondcode-seeklogo.png', url: 'https://beyondco.de/' },
{ name: 'NativePHP', img: '/images/nativephp-logo.svg', url: 'https://nativephp.com/' },
];
</script>
## Special Sponsors
<VPSponsors :data="sponsors"/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 764 100">
<path fill="#505b93" d="M29.5,98.4H0V1.2h29.5V98.4z"/>
<path fill="#00aaa6" d="M96.7,98.4H67.2V1.2h29.5V98.4z"/>
<path fill="#272d48" d="M96.7,98.4H29.5V1.2L96.7,98.4z"/>
<path fill="#272d48" d="M102.6,54.5c0-6.2,1.3-11.8,4.1-16.7c2.7-5,6.7-8.8,11.9-11.6c5.2-2.8,11.4-4.2,18.6-4.2c1.1,0,2.8,0.1,5.2,0.3 c4.9,0.4,9.1,1.3,12.5,2.8c3.4,1.5,6.4,3.4,9.1,5.9v-7.2h25.8v74.7h-25.8v-7.2c-2.5,2.6-5.6,4.6-9.4,6.1c-3.8,1.5-7.9,2.4-12.1,2.6 c-0.9,0.1-2.3,0.1-4.1,0.1c-7.2,0-13.4-1.4-18.8-4.1c-5.4-2.7-9.5-6.6-12.4-11.5c-2.9-4.9-4.3-10.5-4.3-16.6V54.5z M128.4,63.9 c0,9.2,5.9,13.8,17.7,13.8c11.8,0,17.7-4.6,17.7-13.8v-5.6c0-9.3-5.9-14-17.7-14c-11.8,0-17.7,4.7-17.7,14V63.9z M208.3,98.4V47h-12.8V23.7l12.8-0.2V1.2h25.9l0.1,22.4h18.3V47h-18.4v51.4 M287.3,98.4h-25.9V23.6h25.9V98.4z M351,98.4H325l-31-74.8H320L338,68l18-44.5h25.9L351,98.4z M454.9,87.6c-4.1,4.2-8.8,7.3-14.1,9.3c-5.3,2-11.8,2.9-19.5,2.9c-8,0-15.1-1.4-21.3-4.2 c-6.2-2.8-11.1-6.7-14.7-11.6c-3.5-5-5.3-10.6-5.3-17V54.6c0-6.5,1.7-12.2,5.2-17.1c3.4-4.9,8.2-8.7,14.2-11.3c6-2.7,12.7-4,20-4 c8,0,15,1.5,21.2,4.3c6.1,2.9,10.9,7,14.4,12.4c3.4,5.4,5.2,11.6,5.2,18.7c0,1.7-0.2,4.2-0.7,7.7l-54.2,0.1v2.1 c0,4.1,1.5,7.3,4.4,9.4c2.9,2.2,6.9,3.2,11.8,3.2c4.6,0,8.5-0.6,11.8-1.8c3.2-1.2,6.4-3.5,9.4-6.8L454.9,87.6z M434.4,51.4 c0-3.1-1.4-5.5-4.2-7.1c-2.8-1.6-6.4-2.4-10.8-2.4s-7.9,0.8-10.5,2.4c-2.6,1.6-3.8,4-3.8,7.1H434.4z M466,98.4V1.2h56c9.9,0,17.8,1.9,23.7,5.6c5.9,3.7,10,8.2,12.2,13.3c2.3,5.1,3.4,10.1,3.4,15 c0,4.8-1.2,9.7-3.5,14.7c-2.3,5-6.4,9.2-12.2,12.8c-5.8,3.6-13.7,5.4-23.7,5.4h-30.2v30.5H466z M522,44.6c9,0,13.6-3.3,13.6-9.9 c0-6.9-4.6-10.3-13.7-10.3h-30.1v20.2H522z M593,98.4h-25.8V1.2H593v38h43.9v-38h25.8v97.2h-25.8V59.9H593V98.4z M668.6,98.4V1.2h56c9.9,0,17.8,1.9,23.7,5.6c5.9,3.7,10,8.2,12.2,13.3c2.3,5.1,3.4,10.1,3.4,15 c0,4.8-1.2,9.7-3.5,14.7c-2.3,5-6.4,9.2-12.2,12.8c-5.8,3.6-13.7,5.4-23.7,5.4h-30.2v30.5H668.6z M724.6,44.6c9,0,13.6-3.3,13.6-9.9 c0-6.9-4.6-10.3-13.7-10.3h-30.1v20.2H724.6z M291.1,20.2h-33.5V0h33.5V20.2z"/>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -4,45 +4,48 @@
## 贡献方法
如果你有代码或文档要贡献,需要先了解以下内容。
如果你有代码或文档要贡献,以下是你需要先了解内容。
1. 你要贡献什么类型的代码?(新扩展、修复 Bug、安全问题、项目框架优化、文档
2. 如果你贡献了新文件或新片段,你的代码是否经过 `php-cs-fixer``phpstan` 的检查?
3. 在贡献代码前是否充分阅读了 [开发指南](../develop/)
如果你可以回答以上问题,并已经对代码做出了修改,可以及时在项目 GitHub 仓库发起 Pull Request。待代码审查完毕后,可根据建议修改代码,或直接合并到主分支。
如果你能回答上述问题并对代码进行了修改,可以及时在项目 GitHub 仓库发起 Pull Request。
代码审查完成后,可以根据建议修改代码,或直接合并到主分支。
## 贡献类型
本项目主要用途是编译静态链接的 PHP 二进制基于 `symfony/console` 编写了命令行处理功能。在开发之前,如果你对它不够熟悉,
可以先查看 [symfony/console 文档](https://symfony.com/doc/current/components/console.html)。
本项目主要目的是编译静态链接的 PHP 二进制文件,命令行处理功能基于 `symfony/console` 编写
在开发之前,如果你对它不够熟悉,请先查看 [symfony/console 文档](https://symfony.com/doc/current/components/console.html)。
### 安全问题
### 安全更新
因为本项目基本上是属于本地运行的 PHP 项目,一般来说不会存在远程攻击行为。但如果你发现了此类问题,请**不要**在 GitHub 仓库提交 PR 或 Issue
你需要通过 [邮件](mailto:admin@zhamao.me) 的方式联系项目维护者crazywhalecc
因为本项目基本上是一个本地运行的 PHP 项目,一般来说不会远程攻击
但如果你发现此类问题,请**不要**在 GitHub 仓库提交 PR 或 Issue
你需要通过 [邮件](mailto:admin@zhamao.me) 联系项目维护者crazywhalecc
### 修复 Bug
修复 Bug 一般不涉及项目结构和框架的修改,所以如果你可以定位到错误代码并直接修复它,请直接提交 PR。
修复 Bug 一般不涉及项目结构和框架的修改,所以如果你定位到错误代码并直接修复它,请直接提交 PR。
### 新扩展
对于添加一个新扩展来说,你需要了解一些本项目的基本结构以及如何根据现有逻辑添加新扩展。在本页的下一章节将会详细介绍。
对于添加新扩展,你需要了解项目的一些基本结构以及如何根据现有逻辑添加新扩展。
这将在本页的下一节中详细介绍。
总的来说,你需要:
1. 评估扩展是否可以内联编译到 PHP 中。
2. 评估扩展的依赖库(如果有)是否可以静态编译。
3.出扩展的依赖库在不同平台编译命令。
4. 验证扩展及其依赖库能否与现有扩展和依赖兼容。
5. 验证扩展在 `cli``micro``fpm``embed` 几种 SAPI 中正常工作。
6. 编写文档,加入你的扩展。
3. 写不同平台的库编译命令。
4. 验证扩展及其依赖与现有扩展和依赖兼容。
5. 验证扩展在 `cli``micro``fpm``embed` SAPIs 中正常工作。
6. 编写文档并添加你的扩展。
### 项目框架优化
如果你已经熟悉 `symfony/console` 的工作原理,并同时要对项目的框架进行一些修改或优化,请先了解以下事情:
1.扩展不属于项目框架优化,但如果你在加入新的扩展时发现不得不优化框架,则需先对框架本身进行修改,然后再加扩展。
2. 对于一些大规模逻辑修改(例如涉及 LibraryBase、Extension 对象等的修改),建议先提交 Issue 或 Draft PR 进行讨论方案
3. 项目早期为纯中文开发项目,代码中存在一部分中文注释。国际化项目后你可以提交 PR 将这些注释翻译为英语。
4. 请不要在代码中提交包含较多无用的代码片段,例如大量未使用的变量、方法、类、重复写了很多次的代码。
1. 加扩展不属于项目框架优化,但如果你在添加新扩展时发现必须优化框架,则需要先修改框架本身,然后再加扩展。
2. 对于一些大规模逻辑修改(例如涉及 LibraryBase、Extension 对象等的修改),建议先提交 Issue 或 Draft PR 进行讨论。
3. 项目早期,它是一个纯私有开发项目,代码中有一些中文注释。项目国际化后你可以提交 PR 将这些注释翻译为英语。
4. 请不要在代码中提交多无用的代码片段,例如大量未使用的变量、方法、类以及多次重写的代码。

View File

@@ -2,7 +2,7 @@
开发本项目需要安装部署 PHP 环境,以及一些 PHP 项目常用的扩展和 Composer。
项目的开发环境和运行环境几乎完全一致你可以参照 **指南-本地构建** 部分安装系统 PHP 或使用本项目预构建的静态 PHP 作为环境这里不再赘述。
项目的开发环境和运行环境几乎完全一致你可以参照 **手动构建** 部分安装系统 PHP 或使用本项目预构建的静态 PHP 作为环境这里不再赘述。
抛开用途,本项目本身其实就是一个 `php-cli` 程序,你可以将它当作一个正常的 PHP 项目进行编辑和开发,同时你需要了解不同系统的 Shell 命令行。
@@ -18,10 +18,10 @@
curl,dom,filter,mbstring,openssl,pcntl,phar,posix,sodium,tokenizer,xml,xmlwriter
```
static-php-cli 项目本身不需要这么多扩展,但在开发过程中,你会用到 ComposerPHPUnit 等工具,它们需要这些扩展。
static-php-cli 项目本身不需要这么多扩展,但在开发过程中,你会用到 ComposerPHPUnit 等工具,它们需要这些扩展。
> 对于 static-php-cli 自身构建的 micro 自执行二进制,仅需要 `pcntl,posix,mbstring,tokenizer,phar`。
## 开始开发
继续向下查看项目结构文档,你可以从中了解 `static-php-cli` 是如何作的。
继续向下查看项目结构文档,你可以学习 `static-php-cli` 是如何作的。

View File

@@ -4,28 +4,28 @@
## php.ini 的路径是什么?
在 Linux、macOS 和 FreeBSD 上,`php.ini`默认路径是 `/usr/local/etc/php/php.ini`
在 Linux、macOS 和 FreeBSD 上,`php.ini` 的路径是 `/usr/local/etc/php/php.ini`
在 Windows 中,路径是 `C:\windows\php.ini``php.exe` 所在的当前目录。
可以在 *nix 系统中使用手动构建选项 `--with-config-file-path` 来更改查找 `php.ini` 的目录。
此外,在 Linux、macOS 和 FreeBSD 上,`/usr/local/etc/php/conf.d` 目录中的 `*.ini` 文件也会被加载。
此外,在 Linux、macOS 和 FreeBSD 上,`/usr/local/etc/php/conf.d` 目录中的 `.ini` 文件也会被加载。
在 Windows 中,该路径默认为空。
可以使用手动构建选项 `--with-config-file-scan-dir` 更改该目录。
PHP 默认也会从 [其他标准位置](https://www.php.net/manual/zh/configuration.file.php) 中搜索 `php.ini`
## 静态编译的 PHP 可以安装扩展吗
## 静态编译的 PHP 可以安装扩展吗
因为传统架构下的 PHP 安装扩展的原理是使用 `.so` 类型的动态链接的库方式安装新扩展,而使用本项目编译的静态链接的 PHP。但是静态链接在不同操作系统有不同的定义。
首先对于 Linux 系统来说,静态链接的二进制文件不会链接系统的动态链接库的,纯静态链接的二进制无法加载动态库,所以无法添加新扩展。
同时,在纯静态模式下你也不能使用 `ffi` 等扩展加载外部 `.so` 模块。
首先对于 Linux 系统,静态链接的二进制文件不会链接系统的动态链接库纯静态链接的二进制文件(`-all-static`无法加载动态库,因此无法添加新扩展。
同时,在纯静态模式下你也不能使用 `ffi` 等扩展加载外部 `.so` 模块。
你可以通过命令 `ldd buildroot/bin/php` 来查你在 Linux 下构建的二进制是否为纯静态链接
你可以使用命令 `ldd buildroot/bin/php`查你在 Linux 下构建的二进制文件是否为纯静态链接。
如果你 [构建 GNU libc 兼容的 PHP](../guide/build-with-glibc),你可以使用 `ffi` 扩展加载外部 `.so` 模块,并加载具有相同 ABI 的 `.so` 扩展。
如果你 [构建基于 GNU libc 的 PHP](../guide/build-with-glibc),你可以使用 `ffi` 扩展加载外部 `.so` 模块,并加载具有相同 ABI 的 `.so` 扩展。
例如,你可以使用以下命令构建一个 glibc 动态链接的静态 PHP 二进制,同时支持 FFI 扩展加载相同 PHP 版本和相同 TS 类型的 `xdebug.so` 扩展:
例如,你可以使用以下命令构建一个 glibc 动态链接的静态 PHP 二进制文件,支持 FFI 扩展加载相同 PHP 版本和相同 TS 类型的 `xdebug.so` 扩展:
```bash
bin/spc-gnu-docker download --for-extensions=ffi,xml --with-php=8.4
@@ -34,14 +34,14 @@ bin/spc-gnu-docker build ffi,xml --build-cli --debug
buildroot/bin/php -d "zend_extension=/path/to/php{PHP_VER}-{ts/nts}/xdebug.so" --ri xdebug
```
对于 macOS 平台来说macOS 下的几乎所有二进制文件都无法真正纯静态链接,几乎所有二进制文件都会链接 macOS 系统库:`/usr/lib/libresolv.9.dylib``/usr/lib/libSystem.B.dylib`
因此,在 macOS 上,可以直接构建出使用静态编译 PHP 二进制文件和动态链接的扩展
对于 macOS 平台macOS 下的几乎所有二进制文件都无法真正纯静态链接,几乎所有二进制文件都会链接 macOS 系统库:`/usr/lib/libresolv.9.dylib``/usr/lib/libSystem.B.dylib`
因此,在 macOS 上,可以**直接**使用 SPC 构建具有动态链接扩展的静态编译 PHP 二进制文件:
1. 使用 `--build-shared=XXX` 选项构建共享扩展 `xxx.so`。例如:`bin/spc build bcmath,zlib --build-shared=xdebug --build-cli`
2. 将获得 `buildroot/modules/xdebug.so``buildroot/bin/php`
2. 将获得 `buildroot/modules/xdebug.so``buildroot/bin/php`
3. `xdebug.so` 文件可用于版本和线程安全相同的 php。
## 可以支持 Oracle 数据库扩展吗
## 可以支持 Oracle 数据库扩展吗
部分依赖库闭源的扩展,如 `oci8``sourceguardian` 等,它们没有提供纯静态编译的依赖库文件(`.a`),仅提供了动态依赖库文件(`.so`
这些扩展无法使用源码的形式编译到 static-php-cli 中,所以本项目可能永远也不会支持这些扩展。不过,理论上你可以根据上面的问题在 macOS 和 Linux 下接入和使用这类扩展。
@@ -49,41 +49,43 @@ buildroot/bin/php -d "zend_extension=/path/to/php{PHP_VER}-{ts/nts}/xdebug.so" -
如果你对此类扩展有需求,或者大部分人都对这些闭源扩展使用有需求,
可以看看有关 [standalone-php-cli](https://github.com/crazywhalecc/static-php-cli/discussions/58) 的讨论。欢迎留言。
## 支持 Windows 吗
## 支持 Windows 吗
该项目目前支持 Windows但支持的扩展数量较少Windows 支持并不完美主要有以下几个问题:
该项目目前支持 Windows但支持的扩展数量较少Windows 支持并不完美主要有以下问题:
1. Windows 的编译程与 *nix 不同,使用的工具链也不同编译个扩展依赖库使用的编译工具也几乎完全不同。
2. Windows 版本的需求也会根据所有使用本项目的人的需求推进如果很多人需要,我会尽快支持相关扩展。
1. Windows 的编译程与 *nix 不同,使用的工具链也不同。用于编译个扩展依赖库的编译工具也几乎完全不同。
2. Windows 版本的需求也会根据所有使用本项目的人的需求推进如果很多人需要,我会尽快支持相关扩展。
## 使用 micro 可以保护我的源码吗
## 我可以使用 micro 保护我的源码吗
不可以。micro.sfx 本质上是将 php 和 php 代码合为一个文件,没有 PHP 代码编译或加密的过程。
首先 php-src 是 PHP 代码的官方解释器,而且现在市面上还没有一个能兼容主流分支的 PHP 编译器。
之前我在网上看到有一个项目是 BPCBinary PHP Compiler可以把 PHP 编译为二进制,但是限制也是很多很多。
不可以。micro.sfx 本质上是将 php 和 php 代码合为一个文件,没有编译或加密 PHP 代码的过程。
加密保护代码的方向和编译也不是一回事,编译过后也可以通过逆向工程等方式拿到代码,真正保护还是通过加壳、加密代码等手段进行
首先php-src 是 PHP 代码的官方解释器,市场上没有与主流分支兼容的 PHP 编译器
我在网上看到一个名为 BPCBinary PHP Compiler的项目可以将 PHP 编译为二进制,但有很多限制。
所以本项目static-php-cli、相关项目lwmbs、swoole-cli都是提供一个对 php-src 源码的便捷编译工具,
本项目和相关项目引用的 phpmicro 也仅仅是 PHP 的 sapi 接口封装,而不是 PHP 代码的编译工具。
PHP 代码的编译器是完全不同的项目,因此不会考虑额外的情况。如果你对加密感兴趣,可以考虑使用现有的加密技术,如 Swoole Compiler、Source Guardian 等
加密和保护代码的方向与编译不同。编译后,也可以通过逆向工程等方法获得代码。真正的保护仍然通过打包和加密代码等手段进行。
因此本项目static-php-cli和相关项目lwmbs、swoole-cli都提供了 php-src 源代码的便捷编译工具
本项目和相关项目引用的 phpmicro 只是 PHP 的 sapi 接口封装,而不是 PHP 代码的编译工具。
PHP 代码的编译器是一个完全不同的项目,因此不考虑额外的情况。
如果你对加密感兴趣,可以考虑使用现有的加密技术,如 Swoole Compiler、Source Guardian 等。
## 无法使用 ssl
**更新:该问题已在最新版本的 static-php-cli 中修复,现在默认读取系统的证书文件。如果你仍然遇到问题,尝试下的解决方案。**
**更新:该问题已在最新版本的 static-php-cli 中修复,现在默认读取系统的证书文件。如果你仍然遇到问题,尝试下的解决方案。**
使用 curl、pgsql 等 请求 HTTPS 网站或建立 SSL 连接时,可能存在 `error:80000002:system library::No such file or directory` 错误
这个错误是由于静态编译的 PHP 未通过 `php.ini` 指定 `openssl.cafile` 导致的。
使用 curl、pgsql 等请求 HTTPS 网站或建立 SSL 连接时,可能会出现 `error:80000002:system library::No such file or directory` 错误
错误是由于静态编译的 PHP 未通过 `php.ini` 指定 `openssl.cafile` 导致的。
你可以在使用 PHP 前指定 `php.ini`并在 INI 添加 `openssl.cafile=/path/to/your-cert.pem` 来解决这个问题。
你可以通过在使用 PHP 前指定 `php.ini` 并在 INI 添加 `openssl.cafile=/path/to/your-cert.pem` 来解决问题。
对于 Linux 系统,你可以从 curl 官方网站下载 [cacert.pem](https://curl.se/docs/caextract.html) 文件,也可以使用系统自带的证书文件。
有关不同发行版的证书位置,参考 [Go 标准库](https://go.dev/src/crypto/x509/root_linux.go)。
有关不同发行版的证书位置,参考 [Golang 文档](https://go.dev/src/crypto/x509/root_linux.go)。
> INI 配置 `openssl.cafile` 不可以使用 `ini_set()` 函数动态设置,因为 `openssl.cafile` 是一个 `PHP_INI_SYSTEM` 类型的配置,只能在 `php.ini` 文件中设置。
> INI 配置 `openssl.cafile` 不使用 `ini_set()` 函数动态设置,因为 `openssl.cafile` 是 `PHP_INI_SYSTEM` 类型的配置,只能在 `php.ini` 文件中设置。
## 为什么不支持旧版本 PHP
## 为什么不支持旧版本 PHP
因为旧版本的 PHP 有很多问题,如安全问题、性能问题功能问题。此外,旧版本的 PHP 很多都无法与最新的依赖库兼容,这也是不支持旧版本 PHP 的原因之一。
因为旧版本的 PHP 有很多问题,如安全问题、性能问题功能问题。此外,许多旧版本的 PHP 与最新的依赖库兼容,这也是不支持旧版本 PHP 的原因之一。
你可以使用 static-php-cli 早期编译的旧版本,如 PHP 8.0,但不会明确支持早期版本。
你可以使用 static-php-cli 早期编译的旧版本,如 PHP 8.0,但不会明确支持早期版本。

View File

@@ -5,6 +5,7 @@ Action 构建指的是直接使用 GitHub Action 进行编译。
如果你不想自行编译,可以从本项目现有的 Action 下载 Artifact也可以从自托管的服务器下载[进入](https://dl.static-php.dev/static-php-cli/common/)
> 自托管的二进制也是由 Action 构建而来,[项目仓库地址](https://github.com/static-php/static-php-cli-hosted)。
> 包含的扩展有bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip
## 构建方法

View File

@@ -43,19 +43,27 @@ swoole-hook-sqlite 不是一个扩展,而是 Swoole 的 Hook 特性。
swoole-hook-sqlite 与 `pdo_sqlite` 扩展冲突。如需使用 Swoole 和 `pdo_sqlite`,请删除 pdo_sqlite 扩展,启用 `swoole``swoole-hook-sqlite` 即可。
该扩展包含了 `pdo_sqlite` 的协程环境的实现。
## swoole-hook-odbc
swoole-hook-odbc 不是一个扩展,而是 Swoole 的 Hook 特性。
如果你在编译时添加了 `swoole,swoole-hook-odbc`,你将启用 Swoole 的 `odbc` 扩展的协程模式。
swoole-hook-odbc 与 `pdo_odbc` 扩展冲突。如需使用 Swoole 和 `pdo_odbc`,请删除 `pdo_odbc` 扩展,启用 `swoole``swoole-hook-odbc` 即可。
该扩展包含了 `pdo_odbc` 的协程环境的实现。
## swow
1. swow 仅支持 PHP 8.0 ~ 8.4 版本。
1. swow 仅支持 PHP 8.0+ 版本。
## imagick
imagick 扩展目前仅在 musl libc 上支持 OpenMPlibgomp。使用 glibc 方式构建的 imagick 扩展无法支持多线程特性
1. OpenMP 支持已被禁用,这是维护者推荐的做法,系统软件包也是如此配置
## imap
1. 该扩展目前不支持 Kerberos。
2. 由于底层的 c-client、ext-imap 不是线程安全的。 无法在 `--enable-zts` 构建中使用它。
3. 由于该扩展可能会从未来的 PHP 中删除,因此我们建议您寻找替代实现,例如 [Webklex/php-imap](https://github.com/Webklex/php-imap)。
3. 该扩展已在 PHP 8.4 中被移除,因此我们建议您寻找替代实现,例如 [Webklex/php-imap](https://github.com/Webklex/php-imap)。
## gd
@@ -76,7 +84,7 @@ bin/spc build gd --with-libs=freetype,libjpeg,libavif,libwebp --build-cli
## xdebug
1. Xdebug 只能作为共享扩展进行构建。在 Linux 上,您需要使用 static-php-cli 并设置 SPC_LIBC=glibc
1. Xdebug 只能作为共享扩展进行构建。您需要使用除了 `musl-static` 外的其他 `SPC_TARGET` 构建目标
2. 使用 Linux/glibc 或 macOS 时,您可以使用 `--build-shared=xdebug` 将 Xdebug 编译为共享扩展。
编译后的 `./php` 二进制文件可以通过指定 INI 文件进行配置和运行,例如 `./php -d 'zend_extension=/path/to/xdebug.so' your-code.php`
@@ -114,8 +122,8 @@ pgsql 16.2 修复了这个 Bug现在正常工作了。
## password-argon2
1. password-argon2不是一个标准的扩展,它是 `password_hash` 函数的额外算法
2. 在Linux系统password-argon2 的依赖库 `libargon2``libsodium` 库冲突
1. password-argon2不是一个标准的扩展`password_hash` 函数的 `PASSWORD_ARGON2ID` 算法需要 libsodium 或 libargon2 才能工作
2. 使用 password-argon2 可以为此启用多线程支持
## ffi

View File

@@ -4,8 +4,8 @@ static-php-cli 是一个用于构建静态编译的 PHP 二进制的工具,目
在指南章节中,你将了解到如何使用 static-php-cli 构建独立的 php 程序。
- [Action 构建](./action-build)
- [本地构建](./manual-build)
- [Action 构建](./action-build)
- [扩展列表](./extensions)
## 编译环境
@@ -19,16 +19,30 @@ static-php-cli 是一个用于构建静态编译的 PHP 二进制的工具,目
| Windows | :gear: :computer: | |
| FreeBSD | :computer: | :computer: |
其中Linux 目前仅在 Ubuntu、Debian、Alpine 发行版测试通过,其他发行版未进行测试,不能保证编译成功。
对于未经过测试的发行版,可以使用 Docker 等方式本地编译,避免环境导致的问题。
当前支持编译的 PHP 版本:
macOS 下支持 x86_64 和 Arm 两种架构,但在其中一个架构上编译的二进制无法直接在另一个架构上使用
Rosetta 2 不能保证 Arm 架构编译的程序可以完全运行在 x86_64 环境下。
> :warning: 部分支持,对于新的测试版和旧版本可能存在问题
>
> :heavy_check_mark: 支持
>
> :x: 不支持
Windows 目前只支持 x86_64 架构,不支持 32 位 x86、不支持 arm64 架构。
| PHP Version | Status | Comment |
|-------------|--------------------|---------------------------------------------------------|
| 7.2 | :x: | |
| 7.3 | :x: | phpmicro 和许多扩展不支持 7.3、7.4 版本 |
| 7.4 | :x: | phpmicro 和许多扩展不支持 7.3、7.4 版本 |
| 8.0 | :warning: | PHP 官方已停止 8.0 的维护,我们不再处理 8.0 相关的 backport 支持 |
| 8.1 | :warning: | PHP 官方仅对 8.1 提供安全更新,在 8.5 发布后我们不再处理 8.1 相关的 backport 支持 |
| 8.2 | :heavy_check_mark: | |
| 8.3 | :heavy_check_mark: | |
| 8.4 | :heavy_check_mark: | |
| 8.5 (beta) | :warning: | PHP 8.5 目前处于 beta 阶段 |
> 这个表格的支持状态是 static-php-cli 对构建对应版本的支持情况,不是 PHP 官方对该版本的支持情况。
## PHP 支持版本
目前static-php-cli 对 PHP 8.1 ~ 8.4 版本是支持的,对于 PHP 8.0 及更早版本理论上支持,只需下载时选择早期版本即可。
目前static-php-cli 对 PHP 8.2 ~ 8.5 版本是支持的,对于 PHP 8.1 及更早版本理论上支持,只需下载时选择早期版本即可。
但由于部分扩展和特殊组件已对早期版本的 PHP 停止了支持,所以 static-php-cli 不会明确支持早期版本。
我们推荐你编译尽可能新的 PHP 版本,以获得更好的体验。

View File

@@ -149,7 +149,7 @@ bin/spc craft --debug
如果中途构建出错,你可以使用 `--debug` 参数查看详细的错误信息,或者使用 `--with-clean` 参数清除旧的编译结果,重新编译。
如使用以上方式仍构建失败,请提交一个 issue附上你的 `craft.yml``craft.log`
如使用以上方式仍构建失败,请提交一个 issue附上你的 `craft.yml` 文件`log/` 目录的压缩包
## 分步构建命令
@@ -209,8 +209,8 @@ bin/spc download --from-zip=/path/to/your/download.zip
让下载器强制使用你指定的链接下载此 source 的包。使用方法为 `{source-name}:{url}` 即可,可同时重写多个库的下载地址。在使用 `--for-extensions` 选项下载时同样可用。
```bash
# 例如:指定下载测试版的 PHP8.3
bin/spc download --all -U "php-src:https://downloads.php.net/~eric/php-8.3.0beta1.tar.gz"
# 例如:指定下载 Alpha 版的 PHP8.5
bin/spc download --all -U "php-src:https://downloads.php.net/~edorian/php-8.5.0alpha2.tar.xz"
# 指定下载旧版本的 curl 库
bin/spc download --all -U "curl:https://curl.se/download/curl-7.88.1.tar.gz"
@@ -249,6 +249,7 @@ bin/spc doctor --auto-fix
- `--build-cli`: 构建一个 cli sapi命令行界面可在命令行执行 PHP 代码)
- `--build-fpm`: 构建一个 fpm sapiphp-fpm用于和其他传统的 fpm 架构的软件如 nginx 配合使用)
- `--build-cgi`: 构建一个 cgi sapicgi可用于传统的 cgi 架构的软件如 apache 配合使用)
- `--build-micro`: 构建一个 micro sapi用于构建一个包含 PHP 代码的独立可执行二进制)
- `--build-embed`: 构建一个 embed sapi用于嵌入到其他 C 语言程序中)
- `--build-frankenphp`: 构建一个 [frankenphp](https://github.com/php/frankenphp) 二进制

View File

@@ -10,20 +10,22 @@
当下载资源时,你可能最终会看到类似 `curl: (56) The requested URL returned error: 403` 的错误,这通常是由于 GitHub 限制导致的。
你可以通过在命令中添加 `--debug` 来验证,会看到类似 `[DEBU] Running command (no output) : curl -sfSL "https://api.github.com/repos/openssl/openssl/releases"` 的输出。
要解决这个问题,可以在 GitHub 上 [创建](https://github.com/settings/token) 一个个人访问令牌,并将其设置为环境变量 `GITHUB_TOKEN=<XXX>`
要解决这个问题,可以在 GitHub 上 [创建](https://github.com/settings/tokens) 一个个人访问令牌,并将其设置为环境变量 `GITHUB_TOKEN=<XXX>`
如果确认地址确实无法正常访问,可以提交 Issue 或 PR 更新地址。
如果确认地址确实无法正常访问,可以提交 Issue 或 PR 更新地址或下载类型
## doctor 无法修复
## Doctor 无法修复某些问题
在绝大部分情况下doctor 模块都可以对缺失的系统环境进行自动修复和安装,但也存在特殊的环境无法正常使用自动修复功能。
部分项目由于系统局限(如 Windows 下无法自动安装 Visual Studio 等软件),无法使用自动修复功能。
在遇到无法自动修复功能时,如果遇到 `Some check items can not be fixed` 字样,则表明无法自动修复,请根据终端显示的方法提交 Issue 或自行修复环境
由于系统限制(例如,Windows 下无法自动安装 Visual Studio 等软件),自动修复功能无法用于某些项目
在遇到无法自动修复功能时,如果遇到 `Some check items can not be fixed` 字样,则表明无法自动修复。
请根据终端显示的方法提交 Issue 或自行修复环境。
## 编译错误
遇到编译错误时,如果没有开启 `--debug` 日志,请先开启调试日志,然后确定报错的命令。
报错的终端输出对于修复编译错误非常重要,请在提交 Issue 时一并将终端日志的最后报错片段(或整个终端日志输出)上传,并且包含使用的 `spc` 命令和参数
报错的终端输出对于修复编译错误非常重要。
在提交 Issue 时,请上传终端日志的最后报错片段(或整个终端日志输出),并且包含使用的 `spc` 命令和参数。
如果你是重复构建,请参考 [本地构建 - 多次构建](./manual-build#多次构建) 章节,清理构建缓存后再次构建
如果你是重复构建,请参考 [本地构建 - 多次构建](./manual-build#多次构建) 章节。

View File

@@ -8,6 +8,8 @@ parameters:
- '#class Fiber#'
- '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist#'
- '#Function Swoole\\Coroutine\\run not found.#'
- '#Static call to instance method ZM\\Logger\\ConsoleColor#'
- '#Constant GNU_ARCH not found#'
dynamicConstantNames:
- PHP_OS_FAMILY
excludePaths:

View File

@@ -4,5 +4,6 @@
>
<php>
<env name="SPC_IGNORE_BAD_HASH" value="yes" force="true" />
<env name="SPC_SKIP_TOOLCHAIN_CHECK" value="yes" force="true" />
</php>
</phpunit>

View File

@@ -9,6 +9,7 @@ use SPC\command\BuildPHPCommand;
use SPC\command\CraftCommand;
use SPC\command\DeleteDownloadCommand;
use SPC\command\dev\AllExtCommand;
use SPC\command\dev\EnvCommand;
use SPC\command\dev\ExtVerCommand;
use SPC\command\dev\GenerateExtDepDocsCommand;
use SPC\command\dev\GenerateExtDocCommand;
@@ -33,7 +34,7 @@ use Symfony\Component\Console\Application;
*/
final class ConsoleApplication extends Application
{
public const VERSION = '2.6.1';
public const string VERSION = '2.7.5';
public function __construct()
{
@@ -70,6 +71,7 @@ final class ConsoleApplication extends Application
new GenerateExtDepDocsCommand(),
new GenerateLibDepDocsCommand(),
new PackLibCommand(),
new EnvCommand(),
]
);
}

View File

@@ -4,17 +4,16 @@ declare(strict_types=1);
namespace SPC\builder;
use PharIo\FileSystem\File;
use SPC\exception\ExceptionHandler;
use SPC\exception\FileSystemException;
use SPC\exception\BuildFailureException;
use SPC\exception\InterruptException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\Config;
use SPC\store\FileSystem;
use SPC\store\LockFile;
use SPC\store\pkg\GoXcaddy;
use SPC\store\SourceManager;
use SPC\util\CustomExt;
use SPC\store\SourcePatcher;
use SPC\util\AttributeMapper;
abstract class BuilderBase
{
@@ -45,33 +44,30 @@ abstract class BuilderBase
/**
* Convert libraries to class
*
* @param array<string> $sorted_libraries Libraries to build (if not empty, must sort first)
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
* @param array<string> $sorted_libraries Libraries to build (if not empty, must sort first)
*
* @internal
*/
abstract public function proveLibs(array $sorted_libraries);
/**
* Set-Up libraries
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function setupLibs(): void
{
// build all libs
foreach ($this->libs as $lib) {
$starttime = microtime(true);
match ($lib->setup($this->getOption('rebuild', false))) {
$status = $lib->setup($this->getOption('rebuild', false));
match ($status) {
LIB_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] setup success, took ' . round(microtime(true) - $starttime, 2) . ' s'),
LIB_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'),
LIB_STATUS_BUILD_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'),
LIB_STATUS_INSTALL_FAILED => logger()->error('lib [' . $lib::NAME . '] install failed'),
default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'),
};
if (in_array($status, [LIB_STATUS_BUILD_FAILED, LIB_STATUS_INSTALL_FAILED])) {
throw new BuildFailureException('Library [' . $lib::NAME . '] setup failed.');
}
}
}
@@ -132,30 +128,6 @@ abstract class BuilderBase
return array_filter($this->exts, fn ($ext) => $ext->isBuildStatic());
}
/**
* Check if there is a cpp extensions or libraries.
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function hasCpp(): bool
{
// judge cpp-extension
$exts = array_keys($this->getExts(false));
foreach ($exts as $ext) {
if (Config::getExt($ext, 'cpp-extension', false) === true) {
return true;
}
}
$libs = array_keys($this->getLibs());
foreach ($libs as $lib) {
if (Config::getLib($lib, 'cpp-library', false) === true) {
return true;
}
}
return false;
}
/**
* Set libs only mode.
*
@@ -169,15 +141,10 @@ abstract class BuilderBase
/**
* Verify the list of "ext" extensions for validity and declare an Extension object to check the dependencies of the extensions.
*
* @throws FileSystemException
* @throws RuntimeException
* @throws \ReflectionException
* @throws \Throwable|WrongUsageException
* @internal
*/
public function proveExts(array $static_extensions, array $shared_extensions = [], bool $skip_check_deps = false, bool $skip_extract = false): void
{
CustomExt::loadCustomExt();
// judge ext
foreach ($static_extensions as $ext) {
// if extension does not support static build, throw exception
@@ -203,10 +170,12 @@ abstract class BuilderBase
$this->emitPatchPoint('before-exts-extract');
SourceManager::initSource(exts: [...$static_extensions, ...$shared_extensions]);
$this->emitPatchPoint('after-exts-extract');
// patch micro
SourcePatcher::patchMicro();
}
foreach ([...$static_extensions, ...$shared_extensions] as $extension) {
$class = CustomExt::getExtClass($extension);
$class = AttributeMapper::getExtensionClassByName($extension) ?? Extension::class;
/** @var Extension $ext */
$ext = new $class($extension, $this);
if (in_array($extension, $static_extensions)) {
@@ -241,9 +210,7 @@ abstract class BuilderBase
abstract public function testPHP(int $build_target = BUILD_TARGET_NONE);
/**
* @throws WrongUsageException
* @throws RuntimeException
* @throws FileSystemException
* Build shared extensions.
*/
public function buildSharedExts(): void
{
@@ -257,6 +224,7 @@ abstract class BuilderBase
}
}
file_put_contents(BUILD_BIN_PATH . '/php-config', implode('', $lines));
FileSystem::replaceFileStr(BUILD_LIB_PATH . '/php/build/phpize.m4', 'test "[$]$1" = "no" && $1=yes', '# test "[$]$1" = "no" && $1=yes');
FileSystem::createDir(BUILD_MODULES_PATH);
try {
foreach ($this->getExts() as $ext) {
@@ -265,29 +233,26 @@ abstract class BuilderBase
}
$ext->buildShared();
}
} catch (RuntimeException $e) {
} finally {
FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir=', $extension_dir_line);
throw $e;
}
FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir=', $extension_dir_line);
FileSystem::replaceFileStr(BUILD_LIB_PATH . '/php/build/phpize.m4', '# test "[$]$1" = "no" && $1=yes', 'test "[$]$1" = "no" && $1=yes');
}
/**
* Generate extension enable arguments for configure.
* e.g. --enable-mbstring
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function makeStaticExtensionArgs(): string
{
$ret = [];
foreach ($this->getExts() as $ext) {
$arg = $ext->getConfigureArg();
$arg = null;
if ($ext->isBuildShared() && !$ext->isBuildStatic()) {
if (
(Config::getExt($ext->getName(), 'type') === 'builtin' &&
!file_exists(SOURCE_PATH . '/php-src/ext/' . $ext->getName() . '/config.m4')) ||
!file_exists(SOURCE_PATH . '/php-src/ext/' . $ext->getName() . '/config.m4')) ||
Config::getExt($ext->getName(), 'build-with-php') === true
) {
$arg = $ext->getConfigureArg(true);
@@ -295,6 +260,7 @@ abstract class BuilderBase
continue;
}
}
$arg ??= $ext->getConfigureArg();
logger()->info($ext->getName() . ' is using ' . $arg);
$ret[] = trim($arg);
}
@@ -312,9 +278,6 @@ abstract class BuilderBase
/**
* Get PHP Version ID from php-src/main/php_version.h
*
* @throws RuntimeException
* @throws WrongUsageException
*/
public function getPHPVersionID(): int
{
@@ -327,20 +290,25 @@ abstract class BuilderBase
return intval($match[1]);
}
throw new RuntimeException('PHP version file format is malformed, please remove it and download again');
throw new WrongUsageException('PHP version file format is malformed, please remove "./source/php-src" dir and download/extract again');
}
public function getPHPVersion(): string
public function getPHPVersion(bool $exception_on_failure = true): string
{
if (!file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) {
if (!$exception_on_failure) {
return 'unknown';
}
throw new WrongUsageException('PHP source files are not available, you need to download them first');
}
$file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h');
if (preg_match('/PHP_VERSION "(.*)"/', $file, $match) !== 0) {
return $match[1];
}
throw new RuntimeException('PHP version file format is malformed, please remove it and download again');
if (!$exception_on_failure) {
return 'unknown';
}
throw new WrongUsageException('PHP version file format is malformed, please remove it and download again');
}
/**
@@ -357,7 +325,7 @@ abstract class BuilderBase
}
$file = LockFile::getLockFullPath($lock);
}
if (preg_match('/php-(\d+\.\d+\.\d+(?:RC\d+)?)\.tar\.(?:gz|bz2|xz)/', $file, $match)) {
if (preg_match('/php-(\d+\.\d+\.\d+(?:RC\d+|alpha\d+|beta\d+)?)\.tar\.(?:gz|bz2|xz)/', $file, $match)) {
return $match[1];
}
return false;
@@ -404,6 +372,9 @@ abstract class BuilderBase
if (($type & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP) {
$ls[] = 'frankenphp';
}
if (($type & BUILD_TARGET_CGI) === BUILD_TARGET_CGI) {
$ls[] = 'cgi';
}
return implode(', ', $ls);
}
@@ -487,7 +458,7 @@ abstract class BuilderBase
foreach ($patches as $patch) {
try {
if (!file_exists($patch)) {
throw new RuntimeException("Additional patch script file {$patch} not found!");
throw new WrongUsageException("Additional patch script file {$patch} not found!");
}
logger()->debug('Running additional patch script: ' . $patch);
require $patch;
@@ -500,11 +471,6 @@ abstract class BuilderBase
exit($e->getCode());
} catch (\Throwable $e) {
logger()->critical('Patch script ' . $patch . ' failed to run.');
if ($this->getOption('debug')) {
ExceptionHandler::getInstance()->handle($e);
} else {
logger()->critical('Please check with --debug option to see more details.');
}
throw $e;
}
}
@@ -521,8 +487,7 @@ abstract class BuilderBase
throw new WrongUsageException('FrankenPHP SAPI is only available on Linux and macOS!');
}
// frankenphp needs package go-xcaddy installed
$pkg_dir = PKG_ROOT_PATH . '/go-xcaddy-' . arch2gnu(php_uname('m')) . '-' . osfamily2shortname();
if (!file_exists("{$pkg_dir}/bin/go") || !file_exists("{$pkg_dir}/bin/xcaddy")) {
if (!GoXcaddy::isInstalled()) {
global $argv;
throw new WrongUsageException("FrankenPHP SAPI requires the go-xcaddy package, please install it first: {$argv[0]} install-pkg go-xcaddy");
}

View File

@@ -8,8 +8,7 @@ use SPC\builder\freebsd\BSDBuilder;
use SPC\builder\linux\LinuxBuilder;
use SPC\builder\macos\MacOSBuilder;
use SPC\builder\windows\WindowsBuilder;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\ExceptionHandler;
use SPC\exception\WrongUsageException;
use Symfony\Component\Console\Input\InputInterface;
@@ -20,11 +19,6 @@ class BuilderProvider
{
private static ?BuilderBase $builder = null;
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public static function makeBuilderByInput(InputInterface $input): BuilderBase
{
ini_set('memory_limit', '4G');
@@ -36,12 +30,13 @@ class BuilderProvider
'BSD' => new BSDBuilder($input->getOptions()),
default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'),
};
// bind the builder to ExceptionHandler
ExceptionHandler::bindBuilder(self::$builder);
return self::$builder;
}
/**
* @throws WrongUsageException
*/
public static function getBuilder(): BuilderBase
{
if (self::$builder === null) {

View File

@@ -4,12 +4,14 @@ declare(strict_types=1);
namespace SPC\builder;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\EnvironmentException;
use SPC\exception\SPCException;
use SPC\exception\ValidationException;
use SPC\exception\WrongUsageException;
use SPC\store\Config;
use SPC\store\FileSystem;
use SPC\util\SPCConfigUtil;
use SPC\util\SPCTarget;
class Extension
{
@@ -21,21 +23,16 @@ class Extension
protected string $source_dir;
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function __construct(protected string $name, protected BuilderBase $builder)
{
$ext_type = Config::getExt($this->name, 'type');
$unix_only = Config::getExt($this->name, 'unix-only', false);
$windows_only = Config::getExt($this->name, 'windows-only', false);
if (PHP_OS_FAMILY !== 'Windows' && $windows_only) {
throw new RuntimeException("{$ext_type} extension {$name} is not supported on Linux and macOS platform");
throw new EnvironmentException("{$ext_type} extension {$name} is not supported on Linux and macOS platform");
}
if (PHP_OS_FAMILY === 'Windows' && $unix_only) {
throw new RuntimeException("{$ext_type} extension {$name} is not supported on Windows platform");
throw new EnvironmentException("{$ext_type} extension {$name} is not supported on Windows platform");
}
// set source_dir for builtin
if ($ext_type === 'builtin') {
@@ -43,7 +40,7 @@ class Extension
} elseif ($ext_type === 'external') {
$source = Config::getExt($this->name, 'source');
if ($source === null) {
throw new RuntimeException("{$ext_type} extension {$name} source not found");
throw new ValidationException("{$ext_type} extension {$name} source not found", validation_module: "Extension [{$name}] loader");
}
$source_path = Config::getSource($source)['path'] ?? null;
$source_path = $source_path === null ? SOURCE_PATH . '/' . $source : SOURCE_PATH . '/' . $source_path;
@@ -60,9 +57,6 @@ class Extension
/**
* 获取开启该扩展的 PHP 编译添加的参数
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getConfigureArg(bool $shared = false): string
{
@@ -77,19 +71,18 @@ class Extension
/**
* 根据 ext 的 arg-type 获取对应开启的参数,一般都是 --enable-xxx 和 --with-xxx
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getEnableArg(bool $shared = false): string
{
$escapedPath = str_replace("'", '', escapeshellarg(BUILD_ROOT_PATH)) !== BUILD_ROOT_PATH || str_contains(BUILD_ROOT_PATH, ' ') ? escapeshellarg(BUILD_ROOT_PATH) : BUILD_ROOT_PATH;
$_name = str_replace('_', '-', $this->name);
return match ($arg_type = Config::getExt($this->name, 'arg-type', 'enable')) {
'enable' => '--enable-' . $_name . ($shared ? '=shared' : '') . ' ',
'enable-path' => '--enable-' . $_name . '=' . ($shared ? 'shared,' : '') . $escapedPath . ' ',
'with' => '--with-' . $_name . ($shared ? '=shared' : '') . ' ',
'with-prefix' => '--with-' . $_name . '=' . ($shared ? 'shared,' : '') . '"' . BUILD_ROOT_PATH . '" ',
'with-path' => '--with-' . $_name . '=' . ($shared ? 'shared,' : '') . $escapedPath . ' ',
'none', 'custom' => '',
default => throw new WrongUsageException("argType does not accept {$arg_type}, use [enable/with/with-prefix] ."),
default => throw new WrongUsageException("argType does not accept {$arg_type}, use [enable/with/with-path] ."),
};
}
@@ -107,10 +100,6 @@ class Extension
/**
* 检查下依赖就行了,作用是导入依赖给 Extension 对象,今后可以对库依赖进行选择性处理
*
* @throws RuntimeException
* @throws FileSystemException
* @throws WrongUsageException
*/
public function checkDependency(): static
{
@@ -178,6 +167,14 @@ class Extension
return false;
}
/**
* Patch code before ./configure.bat for Windows
*/
public function patchBeforeWindowsConfigure(): bool
{
return false;
}
/**
* Patch code before make
* If you need to patch some code, overwrite this
@@ -185,6 +182,14 @@ class Extension
*/
public function patchBeforeMake(): bool
{
if (SPCTarget::getTargetOS() === 'Linux' && $this->isBuildShared() && ($objs = getenv('SPC_EXTRA_RUNTIME_OBJECTS'))) {
FileSystem::replaceFileRegex(
SOURCE_PATH . '/php-src/Makefile',
"/^(shared_objects_{$this->getName()}\\s*=.*)$/m",
"$1 {$objs}",
);
return true;
}
return false;
}
@@ -215,7 +220,33 @@ class Extension
*/
public function patchBeforeSharedMake(): bool
{
return false;
$config = (new SPCConfigUtil($this->builder))->config([$this->getName()], array_map(fn ($l) => $l->getName(), $this->builder->getLibs()));
[$staticLibs, $sharedLibs] = $this->splitLibsIntoStaticAndShared($config['libs']);
$lstdcpp = str_contains($sharedLibs, '-l:libstdc++.a') ? '-l:libstdc++.a' : null;
$lstdcpp ??= str_contains($sharedLibs, '-lstdc++') ? '-lstdc++' : '';
$makefileContent = file_get_contents($this->source_dir . '/Makefile');
if (preg_match('/^(.*_SHARED_LIBADD\s*=\s*)(.*)$/m', $makefileContent, $matches)) {
$prefix = $matches[1];
$currentLibs = trim($matches[2]);
$newLibs = trim("{$currentLibs} {$staticLibs} {$lstdcpp}");
$deduplicatedLibs = deduplicate_flags($newLibs);
FileSystem::replaceFileRegex(
$this->source_dir . '/Makefile',
'/^(.*_SHARED_LIBADD\s*=.*)$/m',
$prefix . $deduplicatedLibs
);
}
if ($objs = getenv('SPC_EXTRA_RUNTIME_OBJECTS')) {
FileSystem::replaceFileRegex(
$this->source_dir . '/Makefile',
"/^(shared_objects_{$this->getName()}\\s*=.*)$/m",
"$1 {$objs}",
);
}
return true;
}
/**
@@ -224,8 +255,6 @@ class Extension
* i.e.; pdo_pgsql would return:
*
* `-d "extension=pgsql" -d "extension=pdo_pgsql"`
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getSharedExtensionLoadString(): string
{
@@ -233,12 +262,15 @@ class Extension
$order = [];
$resolve = function ($extension) use (&$resolve, &$loaded, &$order) {
if (!$extension instanceof Extension) {
return;
}
if (isset($loaded[$extension->getName()])) {
return;
}
$loaded[$extension->getName()] = true;
foreach ($this->dependencies as $dependency) {
foreach ($extension->dependencies as $dependency) {
$resolve($dependency);
}
@@ -249,7 +281,10 @@ class Extension
$ret = '';
foreach ($order as $ext) {
if ($ext instanceof Extension && $ext->isBuildShared()) {
if ($ext instanceof self && $ext->isBuildShared()) {
if (Config::getExt($ext->getName(), 'type', false) === 'addon') {
continue;
}
if (Config::getExt($ext->getName(), 'zend-extension', false) === true) {
$ret .= " -d \"zend_extension={$ext->getName()}\"";
} else {
@@ -265,20 +300,16 @@ class Extension
return $ret;
}
/**
* @throws RuntimeException
*/
public function runCliCheckUnix(): void
{
// Run compile check if build target is cli
// If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php
// If check failed, throw RuntimeException
$sharedExtensions = $this->getSharedExtensionLoadString();
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
if ($ret !== 0) {
throw new RuntimeException(
'extension ' . $this->getName() . ' failed runtime check: php-cli returned ' . $ret . "\n" .
join("\n", $out)
throw new ValidationException(
"extension {$this->getName()} failed compile check: php-cli returned {$ret}",
validation_module: 'Extension ' . $this->getName() . ' sanity check'
);
}
@@ -292,25 +323,21 @@ class Extension
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' -r "' . trim($test) . '"');
if ($ret !== 0) {
if ($this->builder->getOption('debug')) {
var_dump($out);
}
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
throw new ValidationException(
"extension {$this->getName()} failed sanity check. Code: {$ret}, output: " . implode("\n", $out),
validation_module: 'Extension ' . $this->getName() . ' function check'
);
}
}
}
/**
* @throws RuntimeException
*/
public function runCliCheckWindows(): void
{
// Run compile check if build target is cli
// If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php
// If check failed, throw RuntimeException
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -n --ri "' . $this->getDistName() . '"', false);
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: "Extension {$this->getName()} sanity check");
}
if (file_exists(FileSystem::convertPath(ROOT_DIR . '/src/globals/ext-tests/' . $this->getName() . '.php'))) {
@@ -323,7 +350,10 @@ class Extension
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -n -r "' . trim($test) . '"');
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
throw new ValidationException(
"extension {$this->getName()} failed function check",
validation_module: "Extension {$this->getName()} function check"
);
}
}
}
@@ -335,68 +365,54 @@ class Extension
/**
* Build shared extension
*
* @throws WrongUsageException
* @throws RuntimeException
*/
public function buildShared(): void
public function buildShared(array $visited = []): void
{
if (Config::getExt($this->getName(), 'type') === 'builtin' || Config::getExt($this->getName(), 'build-with-php') === true) {
try {
if (Config::getExt($this->getName(), 'type') === 'builtin' || Config::getExt($this->getName(), 'build-with-php') === true) {
if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) {
logger()->info('Shared extension [' . $this->getName() . '] was already built by php-src/configure (' . $this->getName() . '.so)');
return;
}
if (Config::getExt($this->getName(), 'build-with-php') === true) {
logger()->warning('Shared extension [' . $this->getName() . '] did not build with php-src/configure (' . $this->getName() . '.so)');
logger()->warning('Try deleting your build and source folders and running `spc build`` again.');
return;
}
}
if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) {
logger()->info('Shared extension [' . $this->getName() . '] was already built by php-src/configure (' . $this->getName() . '.so)');
logger()->info('Shared extension [' . $this->getName() . '] was already built, skipping (' . $this->getName() . '.so)');
return;
}
if (Config::getExt($this->getName(), 'build-with-php') === true) {
logger()->warning('Shared extension [' . $this->getName() . '] did not build with php-src/configure (' . $this->getName() . '.so)');
logger()->warning('Try deleting your build and source folders and running `spc build`` again.');
logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)');
foreach ($this->dependencies as $dependency) {
if (!$dependency instanceof Extension) {
continue;
}
if (!$dependency->isBuildStatic() && !in_array($dependency->getName(), $visited)) {
logger()->info('extension ' . $this->getName() . ' requires extension ' . $dependency->getName());
$dependency->buildShared([...$visited, $this->getName()]);
}
}
if (Config::getExt($this->getName(), 'type') === 'addon') {
return;
}
match (PHP_OS_FAMILY) {
'Darwin', 'Linux' => $this->buildUnixShared(),
default => throw new WrongUsageException(PHP_OS_FAMILY . ' build shared extensions is not supported yet'),
};
} catch (SPCException $e) {
$e->bindExtensionInfo(['extension_name' => $this->getName()]);
throw $e;
}
if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) {
logger()->info('Shared extension [' . $this->getName() . '] was already built, skipping (' . $this->getName() . '.so)');
}
logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)');
foreach ($this->dependencies as $dependency) {
if (!$dependency instanceof Extension) {
continue;
}
if (!$dependency->isBuildStatic()) {
logger()->info('extension ' . $this->getName() . ' requires extension ' . $dependency->getName());
$dependency->buildShared();
}
}
match (PHP_OS_FAMILY) {
'Darwin', 'Linux' => $this->buildUnixShared(),
default => throw new WrongUsageException(PHP_OS_FAMILY . ' build shared extensions is not supported yet'),
};
}
/**
* Build shared extension for Unix
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
* @throws \ReflectionException
* @throws \Throwable
*/
public function buildUnixShared(): void
{
$config = (new SPCConfigUtil($this->builder))->config([$this->getName()], with_dependencies: true);
[$staticLibString, $sharedLibString] = $this->getStaticAndSharedLibs();
// macOS ld64 doesn't understand these, while Linux and BSD do
// use them to make sure that all symbols are picked up, even if a library has already been visited before
$preStatic = PHP_OS_FAMILY !== 'Darwin' ? '-Wl,-Bstatic -Wl,--start-group ' : '';
$postStatic = PHP_OS_FAMILY !== 'Darwin' ? ' -Wl,--end-group -Wl,-Bdynamic ' : ' ';
$env = [
'CFLAGS' => $config['cflags'],
'CXXFLAGS' => $config['cflags'],
'LDFLAGS' => $config['ldflags'],
'LIBS' => $preStatic . $staticLibString . $postStatic . $sharedLibString,
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
];
$env = $this->getSharedExtensionEnv();
if ($this->patchBeforeSharedPhpize()) {
logger()->info("Extension [{$this->getName()}] patched before shared phpize");
}
@@ -404,33 +420,31 @@ class Extension
// prepare configure args
shell()->cd($this->source_dir)
->setEnv($env)
->appendEnv($this->getExtraEnv())
->exec(BUILD_BIN_PATH . '/phpize');
if ($this->patchBeforeSharedConfigure()) {
logger()->info("Extension [{$this->getName()}] patched before shared configure");
}
$phpvars = getenv('SPC_EXTRA_PHP_VARS') ?: '';
shell()->cd($this->source_dir)
->setEnv($env)
->appendEnv($this->getExtraEnv())
->exec(
'./configure ' . $this->getUnixConfigureArg(true) .
' --with-php-config=' . BUILD_BIN_PATH . '/php-config ' .
'--enable-shared --disable-static'
"--enable-shared --disable-static {$phpvars}"
);
// some extensions don't define their dependencies well, this patch is only needed for a few
FileSystem::replaceFileRegex(
$this->source_dir . '/Makefile',
'/^(.*_SHARED_LIBADD\s*=.*)$/m',
'$1 ' . $staticLibString
);
if ($this->patchBeforeSharedMake()) {
logger()->info("Extension [{$this->getName()}] patched before shared make");
}
shell()->cd($this->source_dir)
->setEnv($env)
->appendEnv($this->getExtraEnv())
->exec('make clean')
->exec('make -j' . $this->builder->concurrency)
->exec('make install');
@@ -473,14 +487,35 @@ class Extension
}
/**
* @throws RuntimeException
* Returns the environment variables a shared extension needs to be built.
* CFLAGS, CXXFLAGS, LDFLAGS and so on.
*/
protected function getSharedExtensionEnv(): array
{
$config = (new SPCConfigUtil($this->builder))->config(
[$this->getName()],
array_map(fn ($l) => $l->getName(), $this->getLibraryDependencies(recursive: true)),
$this->builder->getOption('with-suggested-exts'),
$this->builder->getOption('with-suggested-libs'),
);
[$staticLibs, $sharedLibs] = $this->splitLibsIntoStaticAndShared($config['libs']);
$preStatic = PHP_OS_FAMILY === 'Darwin' ? '' : '-Wl,--start-group ';
$postStatic = PHP_OS_FAMILY === 'Darwin' ? '' : ' -Wl,--end-group ';
return [
'CFLAGS' => $config['cflags'],
'CXXFLAGS' => $config['cflags'],
'LDFLAGS' => $config['ldflags'],
'LIBS' => clean_spaces("{$preStatic} {$staticLibs} {$postStatic} {$sharedLibs}"),
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
];
}
protected function addLibraryDependency(string $name, bool $optional = false): void
{
$depLib = $this->builder->getLib($name);
if (!$depLib) {
if (!$optional) {
throw new RuntimeException("extension {$this->name} requires library {$name}");
throw new WrongUsageException("extension {$this->name} requires library {$name}");
}
logger()->info("enabling {$this->name} without library {$name}");
} else {
@@ -488,15 +523,12 @@ class Extension
}
}
/**
* @throws RuntimeException
*/
protected function addExtensionDependency(string $name, bool $optional = false): void
{
$depExt = $this->builder->getExt($name);
if (!$depExt) {
if (!$optional) {
throw new RuntimeException("{$this->name} requires extension {$name}");
throw new WrongUsageException("{$this->name} requires extension {$name} which is not included");
}
logger()->info("enabling {$this->name} without extension {$name}");
} else {
@@ -504,32 +536,33 @@ class Extension
}
}
protected function getExtraEnv(): array
{
return [];
}
/**
* Get required static and shared libraries as a pair of strings in format -l{libname} -l{libname2}
* Splits a given string of library flags into static and shared libraries.
*
* @return array [staticLibString, sharedLibString]
* @param string $allLibs A space-separated string of library flags (e.g., -lxyz).
* @return array an array containing two elements: the first is a space-separated string
* of static library flags, and the second is a space-separated string
* of shared library flags
*/
protected function getStaticAndSharedLibs(): array
protected function splitLibsIntoStaticAndShared(string $allLibs): array
{
$config = (new SPCConfigUtil($this->builder))->config([$this->getName()], with_dependencies: true);
$sharedLibString = '';
$staticLibString = '';
$staticLibs = $this->getLibFilesString();
$staticLibs = str_replace(BUILD_LIB_PATH . '/lib', '-l', $staticLibs);
$staticLibs = str_replace('.a', '', $staticLibs);
$staticLibs = explode('-l', $staticLibs . ' ' . $config['libs']);
foreach ($staticLibs as $lib) {
$lib = trim($lib);
if ($lib === '') {
continue;
$sharedLibString = '';
$libs = explode(' ', $allLibs);
foreach ($libs as $lib) {
$staticLib = BUILD_LIB_PATH . '/lib' . str_replace('-l', '', $lib) . '.a';
if (str_starts_with($lib, BUILD_LIB_PATH . '/lib') && str_ends_with($lib, '.a')) {
$staticLib = $lib;
}
$static_lib = 'lib' . $lib . '.a';
if (file_exists(BUILD_LIB_PATH . '/' . $static_lib) && !str_contains($static_lib, 'libphp')) {
if (!str_contains($staticLibString, '-l' . $lib . ' ')) {
$staticLibString .= '-l' . $lib . ' ';
}
} elseif (!str_contains($sharedLibString, '-l' . $lib . ' ')) {
$sharedLibString .= '-l' . $lib . ' ';
if ($lib === '-lphp' || !file_exists($staticLib)) {
$sharedLibString .= " {$lib}";
} else {
$staticLibString .= " {$lib}";
}
}
return [trim($staticLibString), trim($sharedLibString)];
@@ -549,12 +582,12 @@ class Extension
$added = 0;
foreach ($ret as $depName => $dep) {
foreach ($dep->getDependencies(true) as $depdepName => $depdep) {
if (!in_array($depdepName, array_keys($deps), true)) {
if (!array_key_exists($depdepName, $deps)) {
$deps[$depdepName] = $depdep;
++$added;
}
}
if (!in_array($depName, array_keys($deps), true)) {
if (!array_key_exists($depName, $deps)) {
$deps[$depName] = $dep;
}
}

View File

@@ -4,8 +4,8 @@ declare(strict_types=1);
namespace SPC\builder;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\SPCException;
use SPC\exception\SPCInternalException;
use SPC\exception\WrongUsageException;
use SPC\store\Config;
use SPC\store\Downloader;
@@ -27,23 +27,17 @@ abstract class LibraryBase
protected bool $patched = false;
/**
* @throws RuntimeException
*/
public function __construct(?string $source_dir = null)
{
if (static::NAME === 'unknown') {
throw new RuntimeException('no unknown!!!!!');
throw new SPCInternalException('Please set the NAME constant in ' . static::class);
}
$this->source_dir = $source_dir ?? (SOURCE_PATH . '/' . Config::getLib(static::NAME, 'source'));
$this->source_dir = $source_dir ?? (SOURCE_PATH . DIRECTORY_SEPARATOR . Config::getLib(static::NAME, 'source'));
}
/**
* Try to install or build this library.
* @param bool $force If true, force install or build
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
* @param bool $force If true, force install or build
*/
public function setup(bool $force = false): int
{
@@ -107,10 +101,6 @@ abstract class LibraryBase
/**
* Calculate dependencies for current library.
*
* @throws RuntimeException
* @throws FileSystemException
* @throws WrongUsageException
*/
public function calcDependency(): void
{
@@ -131,9 +121,6 @@ abstract class LibraryBase
/**
* Get config static libs.
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getStaticLibs(): array
{
@@ -142,9 +129,6 @@ abstract class LibraryBase
/**
* Get config headers.
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getHeaders(): array
{
@@ -153,19 +137,12 @@ abstract class LibraryBase
/**
* Get binary files.
*
* @throws FileSystemException
* @throws WrongUsageException
*/
public function getBinaryFiles(): array
{
return Config::getLib(static::NAME, 'bin', []);
}
/**
* @throws WrongUsageException
* @throws FileSystemException
*/
public function tryInstall(array $lock, bool $force_install = false): int
{
$install_file = $lock['filename'];
@@ -177,27 +154,13 @@ abstract class LibraryBase
FileSystem::extractPackage($install_file, $lock['source_type'], DOWNLOAD_PATH . '/' . $install_file, BUILD_ROOT_PATH);
$this->install();
return LIB_STATUS_OK;
} catch (FileSystemException|RuntimeException $e) {
} catch (SPCException $e) {
logger()->error('Failed to extract pre-built library [' . static::NAME . ']: ' . $e->getMessage());
return LIB_STATUS_INSTALL_FAILED;
}
}
foreach ($this->getStaticLibs() as $name) {
if (!file_exists(BUILD_LIB_PATH . "/{$name}")) {
$this->tryInstall($lock, true);
return LIB_STATUS_OK;
}
}
foreach ($this->getHeaders() as $name) {
if (!file_exists(BUILD_INCLUDE_PATH . "/{$name}")) {
$this->tryInstall($lock, true);
return LIB_STATUS_OK;
}
}
// pkg-config is treated specially. If it is pkg-config, check if the pkg-config binary exists
if (static::NAME === 'pkg-config' && !file_exists(BUILD_ROOT_PATH . '/bin/pkg-config')) {
$this->tryInstall($lock, true);
return LIB_STATUS_OK;
if (!$this->isLibraryInstalled()) {
return $this->tryInstall($lock, true);
}
return LIB_STATUS_ALREADY;
}
@@ -208,10 +171,6 @@ abstract class LibraryBase
* BUILD_STATUS_OK if build success
* BUILD_STATUS_ALREADY if already built
* BUILD_STATUS_FAILED if build failed
*
* @throws RuntimeException
* @throws FileSystemException
* @throws WrongUsageException
*/
public function tryBuild(bool $force_build = false): int
{
@@ -240,28 +199,8 @@ abstract class LibraryBase
return LIB_STATUS_OK;
}
// check if these libraries exist, if not, invoke compilation and return the result status
foreach ($this->getStaticLibs() as $name) {
if (!file_exists(BUILD_LIB_PATH . "/{$name}")) {
$this->tryBuild(true);
return LIB_STATUS_OK;
}
}
// header files the same
foreach ($this->getHeaders() as $name) {
if (!file_exists(BUILD_INCLUDE_PATH . "/{$name}")) {
$this->tryBuild(true);
return LIB_STATUS_OK;
}
}
// current library is package and binary file is not exists
if (Config::getLib(static::NAME, 'type', 'lib') === 'package') {
foreach ($this->getBinaryFiles() as $name) {
if (!file_exists(BUILD_BIN_PATH . "/{$name}")) {
$this->tryBuild(true);
return LIB_STATUS_OK;
}
}
if (!$this->isLibraryInstalled()) {
return $this->tryBuild(true);
}
// if all the files exist at this point, skip the compilation process
return LIB_STATUS_ALREADY;
@@ -322,6 +261,16 @@ abstract class LibraryBase
return false;
}
/**
* Patch code before windows configure.bat
* If you need to patch some code, overwrite this
* return true if you patched something, false if not
*/
public function patchBeforeWindowsConfigure(): bool
{
return false;
}
/**
* Patch code before make
* If you need to patch some code, overwrite this
@@ -332,22 +281,47 @@ abstract class LibraryBase
return false;
}
/**
* Patch php-config after embed was built
* Example: imap requires -lcrypt
*/
public function patchPhpConfig(): bool
{
return false;
}
/**
* Build this library.
*
* @throws RuntimeException
*/
abstract protected function build();
protected function install(): void
{
// do something after extracting pre-built files, default do nothing. overwrite this method to do something
// replace placeholders if BUILD_ROOT_PATH/.spc-extract-placeholder.json exists
$replace_item_file = BUILD_ROOT_PATH . '/.spc-extract-placeholder.json';
if (!file_exists($replace_item_file)) {
return;
}
$replace_items = json_decode(file_get_contents($replace_item_file), true);
if (!is_array($replace_items)) {
throw new SPCInternalException("Invalid placeholder file: {$replace_item_file}");
}
$placeholders = get_pack_replace();
// replace placeholders in BUILD_ROOT_PATH
foreach ($replace_items as $item) {
$filepath = BUILD_ROOT_PATH . "/{$item}";
FileSystem::replaceFileStr(
$filepath,
array_values($placeholders),
array_keys($placeholders),
);
}
// remove placeholder file
unlink($replace_item_file);
}
/**
* Add lib dependency
*
* @throws RuntimeException
*/
protected function addLibraryDependency(string $name, bool $optional = false): void
{
@@ -357,7 +331,7 @@ abstract class LibraryBase
return;
}
if (!$optional) {
throw new RuntimeException(static::NAME . " requires library {$name}");
throw new WrongUsageException(static::NAME . " requires library {$name} but it is not included");
}
logger()->debug('enabling ' . static::NAME . " without {$name}");
}
@@ -388,4 +362,29 @@ abstract class LibraryBase
}
}
}
protected function isLibraryInstalled(): bool
{
foreach (Config::getLib(static::NAME, 'static-libs', []) as $name) {
if (!file_exists(BUILD_LIB_PATH . "/{$name}")) {
return false;
}
}
foreach (Config::getLib(static::NAME, 'headers', []) as $name) {
if (!file_exists(BUILD_INCLUDE_PATH . "/{$name}")) {
return false;
}
}
foreach (Config::getLib(static::NAME, 'pkg-configs', []) as $name) {
if (!file_exists(BUILD_LIB_PATH . "/pkgconfig/{$name}.pc")) {
return false;
}
}
foreach (Config::getLib(static::NAME, 'bin', []) as $name) {
if (!file_exists(BUILD_BIN_PATH . "/{$name}")) {
return false;
}
}
return true;
}
}

View File

@@ -4,7 +4,18 @@ declare(strict_types=1);
namespace SPC\builder;
/**
* Interface for library implementations
*
* This interface defines the basic contract that all library classes must implement.
* It provides a common way to identify and work with different library types.
*/
interface LibraryInterface
{
/**
* Get the name of the library
*
* @return string The library name
*/
public function getName(): string;
}

View File

@@ -13,6 +13,7 @@ class amqp extends Extension
{
public function patchBeforeMake(): bool
{
$patched = parent::patchBeforeMake();
if (PHP_OS_FAMILY === 'Windows') {
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp.h', '/^#warning.*/m', '');
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_framing.h', '/^#warning.*/m', '');
@@ -20,7 +21,7 @@ class amqp extends Extension
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_tcp_socket.h', '/^#warning.*/m', '');
return true;
}
return false;
return $patched;
}
public function getUnixConfigureArg(bool $shared = false): string

View File

@@ -6,18 +6,12 @@ namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('bz2')]
class bz2 extends Extension
{
/**
* @throws FileSystemException
* @throws WrongUsageException
*/
public function patchBeforeConfigure(): bool
{
$frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : '';

View File

@@ -7,17 +7,14 @@ namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\linux\LinuxBuilder;
use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
use SPC\exception\WrongUsageException;
use SPC\builder\windows\WindowsBuilder;
use SPC\exception\PatchException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('curl')]
class curl extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeBuildconf(): bool
{
logger()->info('patching before-configure for curl checks');
@@ -45,10 +42,6 @@ class curl extends Extension
return true;
}
/**
* @throws FileSystemException
* @throws WrongUsageException
*/
public function patchBeforeConfigure(): bool
{
$frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : '';
@@ -57,6 +50,18 @@ class curl extends Extension
return true;
}
public function patchBeforeMake(): bool
{
$patched = parent::patchBeforeMake();
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
if ($this->builder instanceof WindowsBuilder && !str_contains($extra_libs, 'secur32.lib')) {
$extra_libs .= ' secur32.lib';
putenv('SPC_EXTRA_LIBS=' . trim($extra_libs));
return true;
}
return $patched;
}
public function patchBeforeSharedConfigure(): bool
{
$file = $this->source_dir . '/config.m4';
@@ -92,7 +97,7 @@ class curl extends Extension
);
if ($patched === null) {
throw new \RuntimeException('Failed to patch config.m4 due to a regex error');
throw new PatchException('shared extension curl patcher', 'Failed to patch config.m4 due to a regex error');
}
FileSystem::writeFile($file, $patched);

View File

@@ -12,7 +12,7 @@ class dba extends Extension
{
public function getUnixConfigureArg(bool $shared = false): string
{
$qdbm = $this->builder->getLib('qdbm') ? (' --with-qdbm=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH) : '';
$qdbm = $this->builder->getLib('qdbm') ? (' --with-qdbm=' . BUILD_ROOT_PATH) : '';
return '--enable-dba' . ($shared ? '=shared' : '') . $qdbm;
}

View File

@@ -5,16 +5,12 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('dom')]
class dom extends Extension
{
/**
* @throws RuntimeException
*/
public function getUnixConfigureArg(bool $shared = false): string
{
$arg = '--enable-dom' . ($shared ? '=shared' : '');

View File

@@ -5,16 +5,12 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('ev')]
class ev extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeBuildconf(): bool
{
/*

View File

@@ -6,7 +6,6 @@ namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
@@ -27,24 +26,20 @@ class event extends Extension
return $arg;
}
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-levent_openssl/', $this->getLibFilesString());
return true;
}
/**
* @throws FileSystemException
*/
public function patchBeforeMake(): bool
{
$patched = parent::patchBeforeMake();
// Prevent event extension compile error on macOS
if ($this->builder instanceof MacOSBuilder) {
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_OPENPTY 1$/m', '');
return true;
}
return true;
return $patched;
}
}

View File

@@ -6,17 +6,12 @@ namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('gettext')]
class gettext extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeBuildconf(): bool
{
if ($this->builder instanceof MacOSBuilder) {
@@ -25,10 +20,6 @@ class gettext extends Extension
return true;
}
/**
* @throws WrongUsageException
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
if ($this->builder instanceof MacOSBuilder) {

View File

@@ -5,16 +5,12 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('glfw')]
class glfw extends Extension
{
/**
* @throws RuntimeException
*/
public function patchBeforeBuildconf(): bool
{
if (file_exists(SOURCE_PATH . '/php-src/ext/glfw')) {

View File

@@ -5,47 +5,62 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder;
use SPC\builder\windows\WindowsBuilder;
use SPC\exception\ValidationException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
use SPC\util\GlobalEnvManager;
use SPC\util\SPCConfigUtil;
use SPC\util\SPCTarget;
#[CustomExt('grpc')]
class grpc extends Extension
{
public function patchBeforeBuildconf(): bool
{
// soft link to the grpc source code
if ($this->builder instanceof WindowsBuilder) {
// not support windows yet
throw new \RuntimeException('grpc extension does not support windows yet');
throw new ValidationException('grpc extension does not support windows yet');
}
if (!is_link(SOURCE_PATH . '/php-src/ext/grpc')) {
if (is_dir($this->builder->getLib('grpc')->getSourceDir() . '/src/php/ext/grpc')) {
shell()->exec('ln -s ' . $this->builder->getLib('grpc')->getSourceDir() . '/src/php/ext/grpc ' . SOURCE_PATH . '/php-src/ext/grpc');
} elseif (is_dir(BUILD_ROOT_PATH . '/grpc_php_ext_src')) {
shell()->exec('ln -s ' . BUILD_ROOT_PATH . '/grpc_php_ext_src ' . SOURCE_PATH . '/php-src/ext/grpc');
} else {
throw new \RuntimeException('Cannot find grpc source code');
}
$macos = $this->builder instanceof MacOSBuilder ? "\n" . ' LDFLAGS="$LDFLAGS -framework CoreFoundation"' : '';
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/ext/grpc/config.m4', '/GRPC_LIBDIR=.*$/m', 'GRPC_LIBDIR=' . BUILD_LIB_PATH . $macos);
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/ext/grpc/config.m4', '/SEARCH_PATH=.*$/m', 'SEARCH_PATH="' . BUILD_ROOT_PATH . '"');
return true;
if (file_exists(SOURCE_PATH . '/php-src/ext/grpc')) {
return false;
}
return false;
// soft link to the grpc source code
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') {
FileSystem::replaceFileRegex(
SOURCE_PATH . '/php-src/ext/grpc/config.m4',
'/GRPC_LIBDIR=.*$/m',
'GRPC_LIBDIR=' . BUILD_LIB_PATH . "\n" . 'LDFLAGS="$LDFLAGS -framework CoreFoundation"'
);
}
return true;
}
public function patchBeforeConfigure(): bool
{
$util = new SPCConfigUtil($this->builder, ['libs_only_deps' => true]);
$config = $util->config(['grpc']);
$libs = $config['libs'];
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lgrpc', $libs);
return true;
}
public function patchBeforeMake(): bool
{
parent::patchBeforeMake();
// add -Wno-strict-prototypes
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -Wno-strict-prototypes');
return true;
}
public function getUnixConfigureArg(bool $shared = false): string
protected function getSharedExtensionEnv(): array
{
return '--enable-grpc=' . BUILD_ROOT_PATH . '/grpc GRPC_LIB_SUBDIR=' . BUILD_LIB_PATH;
$env = parent::getSharedExtensionEnv();
$env['CPPFLAGS'] = $env['CXXFLAGS'] . ' -Wno-attributes';
return $env;
}
}

View File

@@ -10,34 +10,19 @@ use SPC\util\CustomExt;
#[CustomExt('imagick')]
class imagick extends Extension
{
public function patchBeforeMake(): bool
{
if (PHP_OS_FAMILY !== 'Linux') {
return false;
}
if (getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10')) {
return false;
}
// imagick with calls omp_pause_all, which requires openmp, on non-musl we build imagick without openmp
$extra_libs = trim(getenv('SPC_EXTRA_LIBS') . ' -lgomp');
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
return true;
}
public function getUnixConfigureArg(bool $shared = false): string
{
$disable_omp = !(getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10')) ? '' : ' ac_cv_func_omp_pause_resource_all=no';
$disable_omp = ' ac_cv_func_omp_pause_resource_all=no';
return '--with-imagick=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $disable_omp;
}
protected function getStaticAndSharedLibs(): array
protected function splitLibsIntoStaticAndShared(string $allLibs): array
{
// on centos 7, it will use the symbol _ZTINSt6thread6_StateE, which is not defined in system libstdc++.so.6
[$static, $shared] = parent::getStaticAndSharedLibs();
if (getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10')) {
$static .= ' -lstdc++';
[$static, $shared] = parent::splitLibsIntoStaticAndShared($allLibs);
if (str_contains(getenv('PATH'), 'rh/devtoolset') || str_contains(getenv('PATH'), 'rh/gcc-toolset')) {
$static .= ' -l:libstdc++.a';
$shared = str_replace('-lstdc++', '', $shared);
}
return [$static, $shared];
return [clean_spaces($static), clean_spaces($shared)];
}
}

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\linux\SystemUtil;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
@@ -23,9 +24,6 @@ class imap extends Extension
return false;
}
/**
* @throws WrongUsageException
*/
public function validate(): void
{
if ($this->builder->getOption('enable-zts')) {
@@ -41,4 +39,15 @@ class imap extends Extension
}
return $arg;
}
public function patchBeforeMake(): bool
{
$patched = parent::patchBeforeMake();
if (PHP_OS_FAMILY !== 'Linux' || SystemUtil::isMuslDist()) {
return $patched;
}
$extra_libs = trim((getenv('SPC_EXTRA_LIBS') ?: '') . ' -lcrypt');
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
return true;
}
}

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\ValidationException;
use SPC\util\CustomExt;
#[CustomExt('mbregex')]
@@ -16,11 +16,6 @@ class mbregex extends Extension
return 'mbstring';
}
public function getConfigureArg(bool $shared = false): string
{
return '';
}
/**
* mbregex is not an extension, we need to overwrite the default check.
*/
@@ -29,7 +24,7 @@ class mbregex extends Extension
$sharedext = $this->builder->getExt('mbstring')->isBuildShared() ? '-d "extension_dir=' . BUILD_MODULES_PATH . '" -d "extension=mbstring"' : '';
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $sharedext . ' --ri "mbstring" | grep regex', false);
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !');
throw new ValidationException("Extension {$this->getName()} failed compile check: compiled php-cli mbstring extension does not contain regex !");
}
}
@@ -37,11 +32,11 @@ class mbregex extends Extension
{
[$ret, $out] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n --ri "mbstring"', false);
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli does not contain mbstring !');
throw new ValidationException("extension {$this->getName()} failed compile check: compiled php-cli does not contain mbstring !");
}
$out = implode("\n", $out);
if (!str_contains($out, 'regex')) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !');
throw new ValidationException("extension {$this->getName()} failed compile check: compiled php-cli mbstring extension does not contain regex !");
}
}
}

View File

@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
@@ -17,9 +16,6 @@ class memcache extends Extension
return '--enable-memcache' . ($shared ? '=shared' : '') . ' --with-zlib-dir=' . BUILD_ROOT_PATH;
}
/**
* @throws FileSystemException
*/
public function patchBeforeBuildconf(): bool
{
FileSystem::replaceFileStr(

View File

@@ -17,6 +17,10 @@ class memcached extends Extension
'--with-libmemcached-dir=' . BUILD_ROOT_PATH . ' ' .
'--disable-memcached-sasl ' .
'--enable-memcached-json ' .
($this->builder->getLib('zstd') ? '--with-zstd ' : '') .
($this->builder->getExt('igbinary') ? '--enable-memcached-igbinary ' : '') .
($this->builder->getExt('session') ? '--enable-memcached-session ' : '') .
($this->builder->getExt('msgpack') ? '--enable-memcached-msgpack ' : '') .
'--with-system-fastlz';
}
}

View File

@@ -12,9 +12,9 @@ class mongodb extends Extension
{
public function getUnixConfigureArg(bool $shared = false): string
{
$arg = ' --enable-mongodb ';
$arg = ' --enable-mongodb' . ($shared ? '=shared' : '') . ' ';
$arg .= ' --with-mongodb-system-libs=no --with-mongodb-client-side-encryption=no ';
$arg .= ' --with-mongodb-sasl=no ';
$arg .= ' --with-mongodb-sasl=no ';
if ($this->builder->getLib('openssl')) {
$arg .= '--with-mongodb-ssl=openssl';
}
@@ -22,6 +22,6 @@ class mongodb extends Extension
$arg .= $this->builder->getLib('zstd') ? ' --with-mongodb-zstd=yes ' : ' --with-mongodb-zstd=no ';
// $arg .= $this->builder->getLib('snappy') ? ' --with-mongodb-snappy=yes ' : ' --with-mongodb-snappy=no ';
$arg .= $this->builder->getLib('zlib') ? ' --with-mongodb-zlib=yes ' : ' --with-mongodb-zlib=bundled ';
return $arg;
return clean_spaces($arg);
}
}

View File

@@ -5,18 +5,14 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\SourcePatcher;
use SPC\util\CustomExt;
use SPC\util\SPCTarget;
#[CustomExt('opcache')]
class opcache extends Extension
{
/**
* @throws WrongUsageException
* @throws RuntimeException
*/
public function validate(): void
{
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
@@ -26,25 +22,43 @@ class opcache extends Extension
public function patchBeforeBuildconf(): bool
{
$version = $this->builder->getPHPVersion();
if (file_exists(SOURCE_PATH . '/php-src/.opcache_patched')) {
return false;
}
// if 8.2.0 <= PHP_VERSION < 8.2.23, we need to patch from legacy patch file
if (version_compare($this->builder->getPHPVersion(), '8.2.0', '>=') && version_compare($this->builder->getPHPVersion(), '8.2.23', '<')) {
if (version_compare($version, '8.2.0', '>=') && version_compare($version, '8.2.23', '<')) {
SourcePatcher::patchFile('spc_fix_static_opcache_before_80222.patch', SOURCE_PATH . '/php-src');
}
// if 8.3.0 <= PHP_VERSION < 8.3.11, we need to patch from legacy patch file
elseif (version_compare($this->builder->getPHPVersion(), '8.3.0', '>=') && version_compare($this->builder->getPHPVersion(), '8.3.11', '<')) {
elseif (version_compare($version, '8.3.0', '>=') && version_compare($version, '8.3.11', '<')) {
SourcePatcher::patchFile('spc_fix_static_opcache_before_80310.patch', SOURCE_PATH . '/php-src');
} else {
}
// if 8.3.12 <= PHP_VERSION < 8.5.0-dev, we need to patch from legacy patch file
elseif (version_compare($version, '8.5.0-dev', '<')) {
SourcePatcher::patchMicro(items: ['static_opcache']);
}
// PHP 8.5.0-dev and later supports static opcache without patching
else {
return false;
}
return file_put_contents(SOURCE_PATH . '/php-src/.opcache_patched', '1') !== false;
}
public function getUnixConfigureArg(bool $shared = false): string
{
return '--enable-opcache';
$phpVersionID = $this->builder->getPHPVersionID();
$opcache_jit = ' --enable-opcache-jit';
if ((SPCTarget::getTargetOS() === 'Linux' &&
SPCTarget::getLibc() === 'musl' &&
$this->builder->getOption('enable-zts') &&
arch2gnu(php_uname('m')) === 'x86_64' &&
$phpVersionID < 80500) ||
$this->builder->getOption('disable-opcache-jit')
) {
$opcache_jit = ' --disable-opcache-jit';
}
return '--enable-opcache' . ($shared ? '=shared' : '') . $opcache_jit;
}
public function getDistName(): string

View File

@@ -12,6 +12,7 @@ class openssl extends Extension
{
public function patchBeforeMake(): bool
{
$patched = parent::patchBeforeMake();
// patch openssl3 with php8.0 bug
if ($this->builder->getPHPVersionID() < 80100) {
$openssl_c = file_get_contents(SOURCE_PATH . '/php-src/ext/openssl/openssl.c');
@@ -20,12 +21,25 @@ class openssl extends Extension
return true;
}
return false;
return $patched;
}
public function getUnixConfigureArg(bool $shared = false): string
{
$openssl_dir = $this->builder->getPHPVersionID() >= 80400 ? '' : ' --with-openssl-dir=' . BUILD_ROOT_PATH;
return '--with-openssl=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $openssl_dir;
$args = '--with-openssl=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $openssl_dir;
if ($this->builder->getPHPVersionID() >= 80500 || ($this->builder->getPHPVersionID() >= 80400 && !$this->builder->getOption('enable-zts'))) {
$args .= ' --with-openssl-argon2 OPENSSL_LIBS="-lz"';
}
return $args;
}
public function getWindowsConfigureArg(bool $shared = false): string
{
$args = '--with-openssl';
if ($this->builder->getPHPVersionID() >= 80500 || ($this->builder->getPHPVersionID() >= 80400 && !$this->builder->getOption('enable-zts'))) {
$args .= ' --with-openssl-argon2';
}
return $args;
}
}

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\ValidationException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
use SPC\util\GlobalEnvManager;
@@ -15,7 +16,7 @@ class opentelemetry extends Extension
public function validate(): void
{
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new \RuntimeException('The opentelemetry extension requires PHP 8.0 or later');
throw new ValidationException('The opentelemetry extension requires PHP 8.0 or later');
}
}
@@ -34,6 +35,7 @@ class opentelemetry extends Extension
public function patchBeforeMake(): bool
{
parent::patchBeforeMake();
// add -Wno-strict-prototypes
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -Wno-strict-prototypes');
return true;

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\ValidationException;
use SPC\util\CustomExt;
#[CustomExt('password-argon2')]
@@ -20,7 +20,36 @@ class password_argon2 extends Extension
{
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n -r "assert(defined(\'PASSWORD_ARGON2I\'));"');
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
throw new ValidationException('extension ' . $this->getName() . ' failed sanity check', validation_module: 'password_argon2 function check');
}
}
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
{
if ($this->builder->getLib('openssl') !== null) {
if ($this->builder->getPHPVersionID() >= 80500 || ($this->builder->getPHPVersionID() >= 80400 && !$this->builder->getOption('enable-zts'))) {
return '--without-password-argon2'; // use --with-openssl-argon2 in openssl extension instead
}
}
return '--with-password-argon2';
}
}

View File

@@ -5,16 +5,12 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('pdo_sqlite')]
class pdo_sqlite extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFileRegex(

View File

@@ -5,20 +5,12 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('pgsql')]
class pgsql extends Extension
{
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFileRegex(
@@ -29,10 +21,6 @@ class pgsql extends Extension
return true;
}
/**
* @throws WrongUsageException
* @throws RuntimeException
*/
public function getUnixConfigureArg(bool $shared = false): string
{
if ($this->builder->getPHPVersionID() >= 80400) {
@@ -46,10 +34,6 @@ class pgsql extends Extension
return '--with-pgsql=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH;
}
/**
* @throws WrongUsageException
* @throws RuntimeException
*/
public function getWindowsConfigureArg(bool $shared = false): string
{
if ($this->builder->getPHPVersionID() >= 80400) {
@@ -57,4 +41,11 @@ class pgsql extends Extension
}
return '--with-pgsql=' . BUILD_ROOT_PATH;
}
protected function getExtraEnv(): array
{
return [
'CFLAGS' => '-Wno-int-conversion',
];
}
}

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\ValidationException;
use SPC\util\CustomExt;
#[CustomExt('protobuf')]
@@ -13,12 +14,12 @@ class protobuf extends Extension
public function validate(): void
{
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new \RuntimeException('The latest protobuf extension requires PHP 8.0 or later');
throw new ValidationException('The latest protobuf extension requires PHP 8.0 or later');
}
$grpc = $this->builder->getExt('grpc');
// protobuf conflicts with grpc
if ($grpc?->isBuildStatic()) {
throw new \RuntimeException('protobuf conflicts with grpc, please remove grpc or protobuf extension');
throw new ValidationException('protobuf conflicts with grpc, please remove grpc or protobuf extension');
}
}
}

View File

@@ -6,16 +6,12 @@ namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('rar')]
class rar extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeBuildconf(): bool
{
// workaround for newer Xcode clang (>= 15.0)

View File

@@ -20,6 +20,7 @@ class rdkafka extends Extension
public function patchBeforeMake(): bool
{
parent::patchBeforeMake();
// when compiling rdkafka with inline builds, it shows some errors, I don't know why.
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/ext/rdkafka/rdkafka.c',

View File

@@ -5,16 +5,12 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('readline')]
class readline extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFileRegex(
@@ -27,7 +23,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

View File

@@ -13,8 +13,15 @@ class redis extends Extension
public function getUnixConfigureArg(bool $shared = false): string
{
$arg = '--enable-redis';
$arg .= $this->builder->getExt('session') ? ' --enable-redis-session' : ' --disable-redis-session';
$arg .= $this->builder->getExt('igbinary') ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary';
if ($this->isBuildStatic()) {
$arg .= $this->builder->getExt('session')?->isBuildStatic() ? ' --enable-redis-session' : ' --disable-redis-session';
$arg .= $this->builder->getExt('igbinary')?->isBuildStatic() ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary';
$arg .= $this->builder->getExt('msgpack')?->isBuildStatic() ? ' --enable-redis-msgpack' : ' --disable-redis-msgpack';
} else {
$arg .= $this->builder->getExt('session') ? ' --enable-redis-session' : ' --disable-redis-session';
$arg .= $this->builder->getExt('igbinary') ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary';
$arg .= $this->builder->getExt('msgpack') ? ' --enable-redis-msgpack' : ' --disable-redis-msgpack';
}
if ($this->builder->getLib('zstd')) {
$arg .= ' --enable-redis-zstd --with-libzstd="' . BUILD_ROOT_PATH . '"';
}

View File

@@ -6,6 +6,8 @@ namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\toolchain\ToolchainManager;
use SPC\toolchain\ZigToolchain;
use SPC\util\CustomExt;
#[CustomExt('simdjson')]
@@ -17,7 +19,7 @@ class simdjson extends Extension
FileSystem::replaceFileRegex(
SOURCE_PATH . '/php-src/ext/simdjson/config.m4',
'/php_version=(`.*`)$/m',
'php_version=' . strval($php_ver)
'php_version=' . $php_ver
);
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/ext/simdjson/config.m4',
@@ -31,4 +33,18 @@ class simdjson extends Extension
);
return true;
}
public function getSharedExtensionEnv(): array
{
$env = parent::getSharedExtensionEnv();
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
$extra = getenv('SPC_COMPILER_EXTRA');
if (!str_contains((string) $extra, '-lstdc++')) {
f_putenv('SPC_COMPILER_EXTRA=' . clean_spaces($extra . ' -lstdc++'));
}
$env['CFLAGS'] .= ' -Xclang -target-feature -Xclang +evex512';
$env['CXXFLAGS'] .= ' -Xclang -target-feature -Xclang +evex512';
}
return $env;
}
}

View File

@@ -6,16 +6,12 @@ namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('snappy')]
class snappy extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFileRegex(

View File

@@ -24,7 +24,7 @@ class sqlsrv extends Extension
return false;
}
public function patchBeforeConfigure(): bool
public function patchBeforeWindowsConfigure(): bool
{
if ($this->pdo_sqlsrv_patched) {
// revert pdo_sqlsrv patch

View File

@@ -5,16 +5,12 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('ssh2')]
class ssh2 extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFileRegex(

View File

@@ -8,19 +8,26 @@ use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
use SPC\util\SPCConfigUtil;
use SPC\util\SPCTarget;
#[CustomExt('swoole')]
class swoole extends Extension
{
public function patchBeforeMake(): bool
{
$patched = parent::patchBeforeMake();
if ($this->builder instanceof MacOSBuilder) {
// Fix swoole with event extension <util.h> conflict bug
$util_path = shell()->execWithResult('xcrun --show-sdk-path', false)[1][0] . '/usr/include/util.h';
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/swoole/thirdparty/php/standard/proc_open.cc', 'include <util.h>', 'include "' . $util_path . '"');
FileSystem::replaceFileStr(
"{$this->source_dir}/thirdparty/php/standard/proc_open.cc",
'include <util.h>',
'include "' . $util_path . '"',
);
return true;
}
return false;
return $patched;
}
public function getExtVersion(): ?string
@@ -38,32 +45,40 @@ class swoole extends Extension
public function getUnixConfigureArg(bool $shared = false): string
{
// enable swoole
$arg = '--enable-swoole';
$arg = '--enable-swoole' . ($shared ? '=shared' : '');
// commonly-used feature: coroutine-time, disable-thread-context
$arg .= ' --enable-swoole-coro-time --disable-thread-context';
// commonly used feature: coroutine-time
$arg .= ' --enable-swoole-coro-time --with-pic';
// required feature: curl, openssl (but curl hook is buggy for php 8.0)
$arg .= $this->builder->getOption('enable-zts') ? ' --enable-swoole-thread --disable-thread-context' : ' --disable-swoole-thread --enable-thread-context';
// required features: curl, openssl (but curl hook is buggy for php 8.0)
$arg .= $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl';
$arg .= ' --enable-openssl';
// additional feature: c-ares, brotli, nghttp2 (can be disabled, but we enable it by default in config to support full network feature)
// additional features that only require libraries
$arg .= $this->builder->getLib('libcares') ? ' --enable-cares' : '';
if (!$shared) {
$arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : '';
}
$arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : '';
$arg .= $this->builder->getLib('nghttp2') ? (' --with-nghttp2-dir=' . BUILD_ROOT_PATH) : '';
$arg .= $this->builder->getLib('zstd') ? ' --enable-zstd' : '';
$arg .= $this->builder->getLib('liburing') ? ' --enable-iouring' : '';
$arg .= $this->builder->getExt('sockets') ? ' --enable-sockets' : '';
// additional feature: swoole-pgsql, it should depend on lib [postgresql], but it will lack of CFLAGS etc.
// so this is a tricky way (enable ext [pgsql,pdo] to add postgresql hook and pdo_pgsql support)
$arg .= $this->builder->getExt('swoole-hook-pgsql') ? '' : ' --disable-swoole-pgsql';
// enable additional features that require the pdo extension, but conflict with pdo_* extensions
// to make sure everything works as it should, this is done in fake addon extensions
$arg .= $this->builder->getExt('swoole-hook-pgsql') ? ' --enable-swoole-pgsql' : ' --disable-swoole-pgsql';
$arg .= $this->builder->getExt('swoole-hook-mysql') ? ' --enable-mysqlnd' : ' --disable-mysqlnd';
$arg .= $this->builder->getExt('swoole-hook-sqlite') ? ' --enable-swoole-sqlite' : ' --disable-swoole-sqlite';
// enable this feature , need remove pdo_sqlite
// more info : https://wenda.swoole.com/detail/109023
$arg .= $this->builder->getExt('swoole-hook-sqlite') ? '' : ' --disable-swoole-sqlite';
if ($this->builder->getExt('swoole-hook-odbc')) {
$config = (new SPCConfigUtil($this->builder, ['libs_only_deps' => true]))->config([], ['unixodbc']);
$arg .= ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH . ' SWOOLE_ODBC_LIBS="' . $config['libs'] . '"';
}
if (SPCTarget::getTargetOS() === 'Darwin') {
$arg .= ' ac_cv_lib_pthread_pthread_barrier_init=no';
}
// enable this feature , need stop pdo_*
// $arg .= $this->builder->getLib('unixodbc') ? ' --with-swoole-odbc=unixODBC,' : ' ';
return $arg;
}
}

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\ValidationException;
use SPC\util\CustomExt;
#[CustomExt('swoole-hook-mysql')]
@@ -16,26 +16,15 @@ class swoole_hook_mysql extends Extension
return 'swoole';
}
public function getUnixConfigureArg(bool $shared = false): string
{
// pdo_mysql doesn't need to be disabled
// enable swoole-hook-mysql will enable mysqli, pdo, pdo_mysql, we don't need to add any additional options
return '';
}
public function runCliCheckUnix(): void
{
// skip if not enable swoole
if ($this->builder->getExt('swoole') === null) {
return;
}
[$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $this->getSharedExtensionLoadString() . ' --ri "swoole"', false);
$out = implode('', $out);
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: 'extension swoole_hook_mysql sanity check');
}
if (!str_contains($out, 'mysqlnd')) {
throw new RuntimeException('swoole mysql hook is not enabled correctly.');
throw new ValidationException('swoole mysql hook is not enabled correctly.', validation_module: 'Extension swoole mysql hook availability check');
}
}
}

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\ValidationException;
use SPC\exception\WrongUsageException;
use SPC\util\CustomExt;
#[CustomExt('swoole-hook-odbc')]
class swoole_hook_odbc extends Extension
{
public function getDistName(): string
{
return 'swoole';
}
public function validate(): void
{
// pdo_pgsql need to be disabled
if ($this->builder->getExt('pdo_odbc')?->isBuildStatic()) {
throw new WrongUsageException('swoole-hook-odbc provides pdo_odbc, if you enable odbc hook for swoole, you must remove pdo_odbc extension.');
}
}
public function runCliCheckUnix(): void
{
$sharedExtensions = $this->getSharedExtensionLoadString();
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"', false);
$out = implode('', $out);
if ($ret !== 0) {
throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: "Extension {$this->getName()} sanity check");
}
if (!str_contains($out, 'coroutine_odbc')) {
throw new ValidationException('swoole odbc hook is not enabled correctly.', validation_module: 'Extension swoole odbc hook availability check');
}
}
}

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\ValidationException;
use SPC\exception\WrongUsageException;
use SPC\util\CustomExt;
@@ -20,31 +20,27 @@ class swoole_hook_pgsql extends Extension
public function validate(): void
{
// pdo_pgsql need to be disabled
if ($this->builder->getExt('pdo_pgsql') !== null) {
if ($this->builder->getExt('pdo_pgsql')?->isBuildStatic()) {
throw new WrongUsageException('swoole-hook-pgsql provides pdo_pgsql, if you enable pgsql hook for swoole, you must remove pdo_pgsql extension.');
}
}
public function getUnixConfigureArg(bool $shared = false): string
{
// enable swoole pgsql hook
return '--enable-swoole-pgsql';
}
public function runCliCheckUnix(): void
{
// skip if not enable swoole
if ($this->builder->getExt('swoole') === null) {
return;
}
$sharedExtensions = $this->getSharedExtensionLoadString();
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"', false);
$out = implode('', $out);
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
throw new ValidationException(
"extension {$this->getName()} failed sanity check: php-cli returned {$ret}",
validation_module: 'Extension swoole-hook-pgsql sanity check'
);
}
if (!str_contains($out, 'coroutine_pgsql')) {
throw new RuntimeException('swoole pgsql hook is not enabled correctly.');
throw new ValidationException(
'swoole pgsql hook is not enabled correctly.',
validation_module: 'Extension swoole pgsql hook availability check'
);
}
}
}

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\ValidationException;
use SPC\exception\WrongUsageException;
use SPC\util\CustomExt;
@@ -20,31 +20,21 @@ class swoole_hook_sqlite extends Extension
public function validate(): void
{
// pdo_pgsql need to be disabled
if ($this->builder->getExt('pdo_sqlite') !== null) {
if ($this->builder->getExt('pdo_sqlite')?->isBuildStatic()) {
throw new WrongUsageException('swoole-hook-sqlite provides pdo_sqlite, if you enable sqlite hook for swoole, you must remove pdo_sqlite extension.');
}
}
public function getUnixConfigureArg(bool $shared = false): string
{
// enable swoole pgsql hook
return '--enable-swoole-sqlite';
}
public function runCliCheckUnix(): void
{
// skip if not enable swoole
if ($this->builder->getExt('swoole') === null) {
return;
}
$sharedExtensions = $this->getSharedExtensionLoadString();
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"', false);
$out = implode('', $out);
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: "Extension {$this->getName()} sanity check");
}
if (!str_contains($out, 'coroutine_sqlite')) {
throw new RuntimeException('swoole sqlite hook is not enabled correctly.');
throw new ValidationException('swoole sqlite hook is not enabled correctly.', validation_module: 'Extension swoole sqlite hook availability check');
}
}
}

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\ValidationException;
use SPC\util\CustomExt;
#[CustomExt('swow')]
@@ -14,7 +14,7 @@ class swow extends Extension
public function validate(): void
{
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new RuntimeException('The latest swow extension requires PHP 8.0 or later');
throw new ValidationException('The latest swow extension requires PHP 8.0 or later');
}
}
@@ -26,9 +26,6 @@ class swow extends Extension
return $arg;
}
/**
* @throws RuntimeException
*/
public function patchBeforeBuildconf(): bool
{
if ($this->builder->getPHPVersionID() >= 80000 && !is_link(SOURCE_PATH . '/php-src/ext/swow')) {

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\ValidationException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
@@ -14,12 +15,13 @@ class uv extends Extension
public function validate(): void
{
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new \RuntimeException('The latest uv extension requires PHP 8.0 or later');
throw new ValidationException('The latest uv extension requires PHP 8.0 or later');
}
}
public function patchBeforeSharedMake(): bool
{
parent::patchBeforeSharedMake();
if (PHP_OS_FAMILY !== 'Linux' || arch2gnu(php_uname('m')) !== 'aarch64') {
return false;
}

View File

@@ -27,16 +27,17 @@ class xlswriter extends Extension
public function patchBeforeMake(): bool
{
$patched = parent::patchBeforeMake();
if (PHP_OS_FAMILY === 'Windows') {
// fix windows build with openssl extension duplicate symbol bug
SourcePatcher::patchFile('spc_fix_xlswriter_win32.patch', $this->source_dir);
$content = file_get_contents($this->source_dir . '/library/libxlsxwriter/src/theme.c');
$bom = pack('CCC', 0xEF, 0xBB, 0xBF);
if (substr($content, 0, 3) !== $bom) {
if (!str_starts_with($content, $bom)) {
file_put_contents($this->source_dir . '/library/libxlsxwriter/src/theme.c', $bom . $content);
}
return true;
}
return false;
return $patched;
}
}

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\exception\SPCInternalException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
@@ -16,9 +16,6 @@ use SPC\util\CustomExt;
#[CustomExt('simplexml')]
class xml extends Extension
{
/**
* @throws RuntimeException
*/
public function getUnixConfigureArg(bool $shared = false): string
{
$arg = match ($this->name) {
@@ -27,7 +24,7 @@ class xml extends Extension
'xmlreader' => '--enable-xmlreader',
'xmlwriter' => '--enable-xmlwriter',
'simplexml' => '--enable-simplexml',
default => throw new RuntimeException('Not accept non-xml extension'),
default => throw new SPCInternalException('Not accept non-xml extension'),
};
$arg .= ($shared ? '=shared' : '') . ' --with-libxml="' . BUILD_ROOT_PATH . '"';
return $arg;
@@ -47,7 +44,7 @@ class xml extends Extension
'xmlreader' => '--enable-xmlreader',
'xmlwriter' => '--enable-xmlwriter',
'simplexml' => '--with-simplexml',
default => throw new RuntimeException('Not accept non-xml extension'),
default => throw new SPCInternalException('Not accept non-xml extension'),
};
$arg .= ' --with-libxml';
return $arg;

View File

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

View File

@@ -5,8 +5,6 @@ declare(strict_types=1);
namespace SPC\builder\freebsd;
use SPC\builder\unix\UnixBuilderBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem;
use SPC\store\SourcePatcher;
@@ -16,11 +14,6 @@ class BSDBuilder extends UnixBuilderBase
/** @var bool Micro patch phar flag */
private bool $phar_patched = false;
/**
* @throws RuntimeException
* @throws WrongUsageException
* @throws FileSystemException
*/
public function __construct(array $options = [])
{
$this->options = $options;
@@ -32,10 +25,6 @@ class BSDBuilder extends UnixBuilderBase
f_putenv('CXX=' . $this->getOption('cxx', 'clang++'));
// set PATH
f_putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH'));
// set PKG_CONFIG
f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config');
// set PKG_CONFIG_PATH
f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig/');
// set arch (default: current)
$this->setOptionIfNotExist('arch', php_uname('m'));
@@ -56,25 +45,10 @@ class BSDBuilder extends UnixBuilderBase
/**
* Just start to build statically linked php binary
*
* @param int $build_target build target
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
* @param int $build_target build target
*/
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
{
// ---------- Update extra-libs ----------
$extra_libs = $this->getOption('extra-libs', '');
// add libc++, some extensions or libraries need it (C++ cannot be linked statically)
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lc++ ' : '');
if (!$this->getOption('bloat', false)) {
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles());
} else {
logger()->info('bloat linking');
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', array_map(fn ($x) => "-Wl,-force_load,{$x}", array_filter($this->getAllStaticLibFiles())));
}
$this->setOption('extra-libs', $extra_libs);
$this->emitPatchPoint('before-php-buildconf');
SourcePatcher::patchBeforeBuildconf($this);
@@ -144,6 +118,11 @@ class BSDBuilder extends UnixBuilderBase
}
$this->buildEmbed();
}
$shared_extensions = array_map('trim', array_filter(explode(',', $this->getOption('build-shared'))));
if (!empty($shared_extensions)) {
logger()->info('Building shared extensions ...');
$this->buildSharedExts();
}
if ($enableFrankenphp) {
logger()->info('building frankenphp');
$this->buildFrankenphp();
@@ -160,9 +139,6 @@ class BSDBuilder extends UnixBuilderBase
/**
* Build cli sapi
*
* @throws RuntimeException
* @throws FileSystemException
*/
protected function buildCli(): void
{
@@ -182,10 +158,6 @@ class BSDBuilder extends UnixBuilderBase
/**
* Build phpmicro sapi
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected function buildMicro(): void
{
@@ -210,7 +182,7 @@ class BSDBuilder extends UnixBuilderBase
->exec("make -j{$this->concurrency} {$vars} micro");
if (!$this->getOption('no-strip', false)) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/micro')->exec('strip --strip-all micro.sfx');
shell()->cd(SOURCE_PATH . '/php-src/sapi/micro')->exec('strip --strip-unneeded micro.sfx');
}
$this->deployBinary(BUILD_TARGET_MICRO);
@@ -221,9 +193,6 @@ class BSDBuilder extends UnixBuilderBase
/**
* Build fpm sapi
*
* @throws RuntimeException
* @throws FileSystemException
*/
protected function buildFpm(): void
{
@@ -242,8 +211,6 @@ class BSDBuilder extends UnixBuilderBase
/**
* Build embed sapi
*
* @throws RuntimeException
*/
protected function buildEmbed(): void
{

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace SPC\builder\freebsd;
use SPC\builder\traits\UnixSystemUtilTrait;
use SPC\exception\RuntimeException;
use SPC\exception\EnvironmentException;
use SPC\exception\WrongUsageException;
class SystemUtil
@@ -15,14 +15,15 @@ class SystemUtil
/**
* Get Logic CPU Count for macOS
*
* @throws RuntimeException
*/
public static function getCpuCount(): int
{
[$ret, $output] = shell()->execWithResult('sysctl -n hw.ncpu');
if ($ret !== 0) {
throw new RuntimeException('Failed to get cpu count');
throw new EnvironmentException(
'Failed to get cpu count from FreeBSD sysctl',
'Please ensure you are running this command on a FreeBSD system and have the sysctl command available.'
);
}
return (int) $output[0];
@@ -31,9 +32,8 @@ class SystemUtil
/**
* Get Target Arch CFlags
*
* @param string $arch Arch Name
* @return string return Arch CFlags string
* @throws WrongUsageException
* @param string $arch Arch Name
* @return string return Arch CFlags string
*/
public static function getArchCFlags(string $arch): string
{

View File

@@ -9,13 +9,4 @@ class curl extends BSDLibraryBase
use \SPC\builder\unix\library\curl;
public const NAME = 'curl';
public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true, bool $include_self = true): string
{
$libs = parent::getStaticLibFiles($style, $recursive, $include_self);
if ($this->builder->getLib('openssl')) {
$this->builder->setOption('extra-libs', $this->builder->getOption('extra-libs') . ' /usr/lib/libpthread.a /usr/lib/libdl.a');
}
return $libs;
}
}

View File

@@ -22,19 +22,11 @@ declare(strict_types=1);
namespace SPC\builder\freebsd\library;
use SPC\builder\macos\library\MacOSLibraryBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
class openssl extends BSDLibraryBase
{
public const NAME = 'openssl';
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected function build(): void
{
[$lib,,$destdir] = SEPARATED_PATH;

View File

@@ -5,55 +5,32 @@ declare(strict_types=1);
namespace SPC\builder\linux;
use SPC\builder\unix\UnixBuilderBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\PatchException;
use SPC\exception\WrongUsageException;
use SPC\store\FileSystem;
use SPC\store\SourcePatcher;
use SPC\util\GlobalEnvManager;
use SPC\util\SPCConfigUtil;
use SPC\util\SPCTarget;
class LinuxBuilder extends UnixBuilderBase
{
/** @var bool Micro patch phar flag */
private bool $phar_patched = false;
/**
* @throws FileSystemException
* @throws WrongUsageException
*/
public function __construct(array $options = [])
{
$this->options = $options;
// check musl-cross make installed if we use musl-cross-make
$arch = arch2gnu(php_uname('m'));
GlobalEnvManager::init();
if (getenv('SPC_LIBC') === 'musl' && !SystemUtil::isMuslDist()) {
$this->setOptionIfNotExist('library_path', "LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\"");
$this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\"");
$configure = getenv('SPC_CMD_PREFIX_PHP_CONFIGURE');
$configure = "LD_LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\" " . $configure;
GlobalEnvManager::putenv("SPC_CMD_PREFIX_PHP_CONFIGURE={$configure}");
if (!file_exists("/usr/local/musl/{$arch}-linux-musl/lib/libc.a")) {
throw new WrongUsageException('You are building with musl-libc target in glibc distro, but musl-toolchain is not installed, please install musl-toolchain first. (You can use `doctor` command to install it)');
}
}
GlobalEnvManager::afterInit();
// concurrency
$this->concurrency = intval(getenv('SPC_CONCURRENCY'));
$this->concurrency = (int) getenv('SPC_CONCURRENCY');
// cflags
$this->arch_c_flags = getenv('SPC_DEFAULT_C_FLAGS');
$this->arch_cxx_flags = getenv('SPC_DEFAULT_CXX_FLAGS');
// cross-compiling is not supported yet
/*if (php_uname('m') !== $this->arch) {
$this->cross_compile_prefix = SystemUtil::getCrossCompilePrefix($this->cc, $this->arch);
logger()->info('using cross compile prefix: ' . $this->cross_compile_prefix);
$this->configure_env .= " CROSS_COMPILE='{$this->cross_compile_prefix}'";
}*/
$this->arch_ld_flags = getenv('SPC_DEFAULT_LD_FLAGS');
// create pkgconfig and include dir (some libs cannot create them automatically)
f_mkdir(BUILD_LIB_PATH . '/pkgconfig', recursive: true);
@@ -63,24 +40,10 @@ class LinuxBuilder extends UnixBuilderBase
/**
* Build PHP from source.
*
* @param int $build_target Build target, use `BUILD_TARGET_*` constants
* @throws RuntimeException
* @throws FileSystemException
* @throws WrongUsageException
* @param int $build_target Build target, use `BUILD_TARGET_*` constants
*/
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
{
// ---------- Update extra-libs ----------
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
// bloat means force-load all static libraries, even if they are not used
if (!$this->getOption('bloat', false)) {
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles());
} else {
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", array_filter($this->getAllStaticLibFiles())));
}
// add libstdc++, some extensions or libraries need it
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : '');
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
$cflags = $this->arch_c_flags;
f_putenv('CFLAGS=' . $cflags);
@@ -95,6 +58,14 @@ class LinuxBuilder extends UnixBuilderBase
$phpVersionID = $this->getPHPVersionID();
$json_74 = $phpVersionID < 80000 ? '--enable-json ' : '';
$opcache_jit = !$this->getOption('disable-opcache-jit', false);
if ($opcache_jit && ($phpVersionID >= 80500 || $this->getExt('opcache'))) {
// php 8.5 contains opcache extension by default,
// if opcache_jit is enabled for 8.5 or opcache enabled,
// we need to disable undefined behavior sanitizer.
f_putenv('SPC_COMPILER_EXTRA=-fno-sanitize=undefined');
}
if ($this->getOption('enable-zts', false)) {
$maxExecutionTimers = $phpVersionID >= 80100 ? '--enable-zend-max-execution-timers ' : '';
$zts = '--enable-zts --disable-zend-signals ';
@@ -102,7 +73,6 @@ class LinuxBuilder extends UnixBuilderBase
$maxExecutionTimers = '';
$zts = '';
}
$disable_jit = $this->getOption('disable-opcache-jit', false) ? '--disable-opcache-jit ' : '';
$config_file_path = $this->getOption('with-config-file-path', false) ?
('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : '';
@@ -114,42 +84,43 @@ class LinuxBuilder extends UnixBuilderBase
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
$enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
$enableFrankenphp = ($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP;
$enableCgi = ($build_target & BUILD_TARGET_CGI) === BUILD_TARGET_CGI;
$mimallocLibs = $this->getLib('mimalloc') !== null ? BUILD_LIB_PATH . '/mimalloc.o ' : '';
// prepare build php envs
$envs_build_php = SystemUtil::makeEnvVarString([
// $musl_flag = SPCTarget::getLibc() === 'musl' ? ' -D__MUSL__' : ' -U__MUSL__';
$php_configure_env = SystemUtil::makeEnvVarString([
'CFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS'),
'CPPFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS'),
'LDFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS'),
'LIBS' => $mimallocLibs . getenv('SPC_CMD_VAR_PHP_CONFIGURE_LIBS'),
'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, // . ' -Dsomethinghere', // . $musl_flag,
'LDFLAGS' => '-L' . BUILD_LIB_PATH,
// 'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions!
]);
// process micro upx patch if micro sapi enabled
if ($enableMicro) {
if (version_compare($this->getMicroVersion(), '0.2.0') < 0) {
// for phpmicro 0.1.x
$this->processMicroUPXLegacy();
}
// micro latest needs do strip and upx pack later (strip, upx, cut binary manually supported)
}
$phpvars = getenv('SPC_EXTRA_PHP_VARS') ?: '';
$embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static';
shell()->cd(SOURCE_PATH . '/php-src')
->exec(
if ($embed_type !== 'static' && SPCTarget::isStatic()) {
throw new WrongUsageException(
'Linux does not support loading shared libraries when linking libc statically. ' .
'Change SPC_CMD_VAR_PHP_EMBED_TYPE to static.'
);
}
$this->seekPhpSrcLogFileOnException(fn () => shell()->cd(SOURCE_PATH . '/php-src')->exec(
$php_configure_env . ' ' .
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
($enableCli ? '--enable-cli ' : '--disable-cli ') .
($enableFpm ? '--enable-fpm ' . ($this->getLib('libacl') !== null ? '--with-fpm-acl ' : '') : '--disable-fpm ') .
($enableEmbed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') .
($enableCgi ? '--enable-cgi ' : '--disable-cgi ') .
$config_file_path .
$config_file_scan_dir .
$disable_jit .
$json_74 .
$zts .
$maxExecutionTimers .
$this->makeStaticExtensionArgs() .
' ' . $envs_build_php . ' '
);
"{$phpvars} " .
$this->makeStaticExtensionArgs() . ' '
));
$this->emitPatchPoint('before-php-make');
SourcePatcher::patchBeforeMake($this);
@@ -164,6 +135,10 @@ class LinuxBuilder extends UnixBuilderBase
logger()->info('building fpm');
$this->buildFpm();
}
if ($enableCgi) {
logger()->info('building cgi');
$this->buildCgi();
}
if ($enableMicro) {
logger()->info('building micro');
$this->buildMicro();
@@ -179,6 +154,18 @@ class LinuxBuilder extends UnixBuilderBase
logger()->info('building frankenphp');
$this->buildFrankenphp();
}
$shared_extensions = array_map('trim', array_filter(explode(',', $this->getOption('build-shared'))));
if (!empty($shared_extensions)) {
if (SPCTarget::isStatic()) {
throw new WrongUsageException(
"You're building against musl libc statically (the default on Linux), but you're trying to build shared extensions.\n" .
'Static musl libc does not implement `dlopen`, so your php binary is not able to load shared extensions.' . "\n" .
'Either use SPC_LIBC=glibc to link against glibc on a glibc OS, or use SPC_TARGET="native-native-musl -dynamic" to link against musl libc dynamically using `zig cc`.'
);
}
logger()->info('Building shared extensions...');
$this->buildSharedExts();
}
}
public function testPHP(int $build_target = BUILD_TARGET_NONE)
@@ -189,35 +176,54 @@ class LinuxBuilder extends UnixBuilderBase
/**
* Build cli sapi
*
* @throws RuntimeException
* @throws FileSystemException
*/
protected function buildCli(): void
{
if ($this->getExt('readline')) {
SourcePatcher::patchFile('musl_static_readline.patch', SOURCE_PATH . '/php-src');
}
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
$SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make';
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} cli");
if ($this->getExt('readline')) {
SourcePatcher::patchFile('musl_static_readline.patch', SOURCE_PATH . '/php-src', true);
}
if (!$this->getOption('no-strip', false)) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')->exec('strip --strip-unneeded php');
}
if ($this->getOption('with-upx-pack')) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')
->exec('strip --strip-all php')
->exec(getenv('UPX_EXEC') . ' --best php');
} elseif (!$this->getOption('no-strip', false)) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')->exec('strip --strip-all php');
}
$this->deployBinary(BUILD_TARGET_CLI);
}
protected function buildCgi(): void
{
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
$SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make';
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} cgi");
if (!$this->getOption('no-strip', false)) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/cgi')->exec('strip --strip-unneeded php-cgi');
}
if ($this->getOption('with-upx-pack')) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/cgi')
->exec(getenv('UPX_EXEC') . ' --best php-cgi');
}
$this->deployBinary(BUILD_TARGET_CGI);
}
/**
* Build phpmicro sapi
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected function buildMicro(): void
{
@@ -252,9 +258,6 @@ class LinuxBuilder extends UnixBuilderBase
/**
* Build fpm sapi
*
* @throws FileSystemException
* @throws RuntimeException
*/
protected function buildFpm(): void
{
@@ -264,20 +267,18 @@ class LinuxBuilder extends UnixBuilderBase
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} fpm");
if (!$this->getOption('no-strip', false)) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')->exec('strip --strip-unneeded php-fpm');
}
if ($this->getOption('with-upx-pack')) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')
->exec('strip --strip-all php-fpm')
->exec(getenv('UPX_EXEC') . ' --best php-fpm');
} elseif (!$this->getOption('no-strip', false)) {
shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')->exec('strip --strip-all php-fpm');
}
$this->deployBinary(BUILD_TARGET_FPM);
}
/**
* Build embed sapi
*
* @throws RuntimeException
*/
protected function buildEmbed(): void
{
@@ -288,96 +289,110 @@ class LinuxBuilder extends UnixBuilderBase
->exec('sed -i "s|^EXTENSION_DIR = .*|EXTENSION_DIR = /' . basename(BUILD_MODULES_PATH) . '|" Makefile')
->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install");
$ldflags = getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS');
$ldflags = getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS') ?: '';
$libDir = BUILD_LIB_PATH;
$modulesDir = BUILD_MODULES_PATH;
$libphpSo = "{$libDir}/libphp.so";
$realLibName = 'libphp.so';
$cwd = getcwd();
if (preg_match('/-release\s+(\S+)/', $ldflags, $matches)) {
$release = $matches[1];
$realLibName = 'libphp-' . $release . '.so';
$realLib = BUILD_LIB_PATH . '/' . $realLibName;
rename(BUILD_LIB_PATH . '/libphp.so', $realLib);
$cwd = getcwd();
chdir(BUILD_LIB_PATH);
symlink($realLibName, 'libphp.so');
chdir(BUILD_MODULES_PATH);
foreach ($this->getExts() as $ext) {
if (!$ext->isBuildShared()) {
continue;
$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);
}
$name = $ext->getName();
$versioned = "{$name}-{$release}.so";
$unversioned = "{$name}.so";
if (is_file(BUILD_MODULES_PATH . "/{$versioned}")) {
rename(BUILD_MODULES_PATH . "/{$versioned}", BUILD_MODULES_PATH . "/{$unversioned}");
shell()->cd(BUILD_MODULES_PATH)
->exec(sprintf(
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($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)
));
}
}
}
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') {
$AR = getenv('AR') ?: 'ar';
f_passthru("{$AR} -t " . BUILD_LIB_PATH . "/libphp.a | grep '\\.a$' | xargs -n1 {$AR} d " . BUILD_LIB_PATH . '/libphp.a');
// export dynamic symbols
SystemUtil::exportDynamicSymbols(BUILD_LIB_PATH . '/libphp.a');
}
if (!$this->getOption('no-strip', false) && file_exists(BUILD_LIB_PATH . '/' . $realLibName)) {
shell()->cd(BUILD_LIB_PATH)->exec("strip --strip-unneeded {$realLibName}");
}
$this->patchPhpScripts();
}
/**
* Return extra variables for php make command.
*/
private function getMakeExtraVars(): array
{
$config = (new SPCConfigUtil($this, ['libs_only_deps' => true, 'absolute_libs' => true]))->config($this->ext_list, $this->lib_list, $this->getOption('with-suggested-exts'), $this->getOption('with-suggested-libs'));
$static = SPCTarget::isStatic() ? '-all-static' : '';
$lib = BUILD_LIB_PATH;
return [
'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
'EXTRA_LIBS' => getenv('SPC_EXTRA_LIBS') . ' ' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS'),
'EXTRA_LIBS' => $config['libs'],
'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'),
'EXTRA_LDFLAGS_PROGRAM' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM'),
'EXTRA_LDFLAGS_PROGRAM' => "-L{$lib} {$static} -pie",
];
}
/**
* Apply option --no-strip and --with-upx-pack for micro sapi (only for phpmicro 0.1.x)
*
* @throws FileSystemException
* Strip micro.sfx for Linux.
* The micro.sfx does not support UPX directly, but we can remove UPX-info segment to adapt.
* This will also make micro.sfx with upx-packed more like a malware fore antivirus :(
*/
private function processMicroUPXLegacy(): void
{
// upx pack and strip for micro
// but always restore Makefile.frag.bak first
if (file_exists(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.bak')) {
copy(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.bak', SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag');
}
if ($this->getOption('with-upx-pack', false)) {
// judge $(MAKE) micro_2s_objs SFX_FILESIZE=`$(STAT_SIZE) $(SAPI_MICRO_PATH)` count
// if 2, replace src/globals/extra/micro-triple-Makefile.frag file content
if (substr_count(FileSystem::readFile(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag'), '$(MAKE) micro_2s_objs SFX_FILESIZE=`$(STAT_SIZE) $(SAPI_MICRO_PATH)`') === 2) {
// bak first
copy(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.bak');
// replace Makefile.frag content
FileSystem::writeFile(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', FileSystem::readFile(ROOT_DIR . '/src/globals/extra/micro-triple-Makefile.frag'));
}
// with upx pack always need strip
FileSystem::replaceFileRegex(
SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag',
'/POST_MICRO_BUILD_COMMANDS=.*/',
'POST_MICRO_BUILD_COMMANDS=\$(STRIP) \$(MICRO_STRIP_FLAGS) \$(SAPI_MICRO_PATH) && ' . getenv('UPX_EXEC') . ' --best \$(SAPI_MICRO_PATH)',
);
} elseif (!$this->getOption('no-strip', false)) {
// not-no-strip means strip (default behavior)
FileSystem::replaceFileRegex(
SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag',
'/POST_MICRO_BUILD_COMMANDS=.*/',
'POST_MICRO_BUILD_COMMANDS=\$(STRIP) \$(MICRO_STRIP_FLAGS) \$(SAPI_MICRO_PATH)',
);
} else {
// just no strip
FileSystem::replaceFileRegex(
SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag',
'/POST_MICRO_BUILD_COMMANDS=.*/',
'POST_MICRO_BUILD_COMMANDS=true',
);
}
}
private function processMicroUPX(): void
{
if (version_compare($this->getMicroVersion(), '0.2.0') >= 0 && !$this->getOption('no-strip', false)) {
shell()->exec('strip --strip-all ' . SOURCE_PATH . '/php-src/sapi/micro/micro.sfx');
shell()->exec('strip --strip-unneeded ' . SOURCE_PATH . '/php-src/sapi/micro/micro.sfx');
if ($this->getOption('with-upx-pack')) {
// strip first
@@ -387,7 +402,7 @@ class LinuxBuilder extends UnixBuilderBase
$out[1] = explode(' ', $out[1]);
$offset = $out[1][0];
if ($ret !== 0 || !str_starts_with($offset, '0x')) {
throw new RuntimeException('Cannot find offset in readelf output');
throw new PatchException('phpmicro UPX patcher', 'Cannot find offset in readelf output');
}
$offset = hexdec($offset);
// remove upx extra wastes

View File

@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace SPC\builder\linux;
use SPC\builder\traits\UnixSystemUtilTrait;
use SPC\exception\RuntimeException;
class SystemUtil
{
@@ -75,37 +74,6 @@ class SystemUtil
return $ncpu;
}
/**
* @throws RuntimeException
*/
public static function getCCType(string $cc): string
{
return match (true) {
str_ends_with($cc, 'c++'), str_ends_with($cc, 'cc'), str_ends_with($cc, 'g++'), str_ends_with($cc, 'gcc') => 'gcc',
$cc === 'clang++', $cc === 'clang', str_starts_with($cc, 'musl-clang') => 'clang',
default => throw new RuntimeException("unknown cc type: {$cc}"),
};
}
/**
* @throws RuntimeException
* @noinspection PhpUnused
*/
public static function getCrossCompilePrefix(string $cc, string $arch): string
{
return match (static::getCCType($cc)) {
// guessing clang toolchains
'clang' => match ($arch) {
'x86_64' => 'x86_64-linux-gnu-',
'arm64', 'aarch64' => 'aarch64-linux-gnu-',
default => throw new RuntimeException('unsupported arch: ' . $arch),
},
// remove gcc postfix
'gcc' => str_replace('-cc', '', str_replace('-gcc', '', $cc)) . '-',
default => throw new RuntimeException('unsupported cc'),
};
}
public static function findStaticLib(string $name): ?array
{
$paths = getenv('LIBPATH');
@@ -188,12 +156,12 @@ class SystemUtil
/**
* Get libc version string from ldd
*/
public static function getLibcVersionIfExists(): ?string
public static function getLibcVersionIfExists(?string $libc = null): ?string
{
if (self::$libc_version !== null) {
return self::$libc_version;
}
if (PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') === 'glibc') {
if ($libc === 'glibc') {
$result = shell()->execWithResult('ldd --version', false);
if ($result[0] !== 0) {
return null;
@@ -208,11 +176,14 @@ class SystemUtil
}
return null;
}
if (PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') === 'musl') {
if ($libc === 'musl') {
if (self::isMuslDist()) {
$result = shell()->execWithResult('ldd 2>&1', false);
} else {
} elseif (is_file('/usr/local/musl/lib/libc.so')) {
$result = shell()->execWithResult('/usr/local/musl/lib/libc.so 2>&1', false);
} else {
$arch = php_uname('m');
$result = shell()->execWithResult("/lib/ld-musl-{$arch}.so.1 2>&1", false);
}
// Match Version * line
// match ldd version: "Version 1.2.3" match 1.2.3

View File

@@ -9,13 +9,4 @@ class curl extends LinuxLibraryBase
use \SPC\builder\unix\library\curl;
public const NAME = 'curl';
public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true, bool $include_self = true): string
{
$libs = parent::getStaticLibFiles($style, $recursive, $include_self);
if ($this->builder->getLib('openssl')) {
$libs .= ' -ldl -lpthread';
}
return $libs;
}
}

Some files were not shown because too many files have changed in this diff Show More