From 0bc143cac38deb11ff1b03ffc0f49ba097a7aad3 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 20 Mar 2025 09:22:10 +0800 Subject: [PATCH 01/15] Fix windows curl build >= 8.3 (#660) * Test windows curl * Test windows curl * Fix windows curl build for PHP 8.3 and 8.4 --- config/lib.json | 2 +- src/SPC/builder/windows/library/curl.php | 2 ++ src/globals/test-extensions.php | 16 ++++++++-------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/config/lib.json b/config/lib.json index 33841c7b0..8e728ccd5 100644 --- a/config/lib.json +++ b/config/lib.json @@ -68,7 +68,7 @@ "libcurl.a" ], "static-libs-windows": [ - "libcurl.lib" + "libcurl_a.lib" ], "headers": [ "curl" diff --git a/src/SPC/builder/windows/library/curl.php b/src/SPC/builder/windows/library/curl.php index 1ba0eb064..df195735d 100644 --- a/src/SPC/builder/windows/library/curl.php +++ b/src/SPC/builder/windows/library/curl.php @@ -48,5 +48,7 @@ protected function build(): void $this->builder->makeSimpleWrapper('cmake'), "--build cmakebuild --config Release --target install -j{$this->builder->concurrency}" ); + // move libcurl.lib to libcurl_a.lib + rename(BUILD_LIB_PATH . '\libcurl.lib', BUILD_LIB_PATH . '\libcurl_a.lib'); } } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index a42210b91..1f67b2eb6 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,18 +13,18 @@ // test php version $test_php_version = [ - // '8.1', - // '8.2', + '8.1', + '8.2', '8.3', '8.4', ]; // test os (macos-13, macos-14, ubuntu-latest, windows-latest are available) $test_os = [ - 'macos-13', - 'macos-14', - 'ubuntu-latest', - // 'windows-latest', + // 'macos-13', + // 'macos-14', + // 'ubuntu-latest', + 'windows-latest', ]; // whether enable thread safe @@ -41,13 +41,13 @@ // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { 'Linux', 'Darwin' => 'gd', - 'Windows' => 'bcmath', + 'Windows' => 'bz2,ctype,curl,dom,filter,gd,iconv,mbstring,opcache,openssl,pdo,pdo_sqlite,phar,session,simplexml,sqlite3,tokenizer,xml,xmlwriter,yaml,zip,zlib', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). $with_libs = match (PHP_OS_FAMILY) { 'Linux', 'Darwin' => 'freetype', - 'Windows' => '', + 'Windows' => 'libjpeg,libavif,freetype,libwebp', }; // Please change your test base combination. We recommend testing with `common`. From 6447fec02847f4de455f512308353368a818b7b4 Mon Sep 17 00:00:00 2001 From: Marc Henderkes Date: Thu, 20 Mar 2025 04:36:46 +0100 Subject: [PATCH 02/15] mimalloc WIP --- config/lib.json | 9 +++++ config/source.json | 10 ++++++ src/SPC/builder/linux/library/mimalloc.php | 12 +++++++ src/SPC/builder/unix/library/mimalloc.php | 38 ++++++++++++++++++++++ src/SPC/store/Downloader.php | 19 +++++++---- 5 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 src/SPC/builder/linux/library/mimalloc.php create mode 100644 src/SPC/builder/unix/library/mimalloc.php diff --git a/config/lib.json b/config/lib.json index 8e728ccd5..696f38a73 100644 --- a/config/lib.json +++ b/config/lib.json @@ -589,6 +589,15 @@ "openssl" ] }, + "mimalloc": { + "source": "mimalloc", + "static-libs-unix": [ + "mimalloc.o" + ], + "static-libs-windows": [ + "mimalloc.lib" + ] + }, "ncurses": { "source": "ncurses", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index e5cc92123..006c9d6b2 100644 --- a/config/source.json +++ b/config/source.json @@ -636,6 +636,16 @@ "path": "LICENSE" } }, + "mimalloc": { + "type": "ghtagtar", + "repo": "microsoft/mimalloc", + "match": "v2.+", + "provide-pre-built": false, + "license": { + "type": "file", + "path": "LICENSE" + } + }, "mongodb": { "type": "ghrel", "repo": "mongodb/mongo-php-driver", diff --git a/src/SPC/builder/linux/library/mimalloc.php b/src/SPC/builder/linux/library/mimalloc.php new file mode 100644 index 000000000..7ea6d8335 --- /dev/null +++ b/src/SPC/builder/linux/library/mimalloc.php @@ -0,0 +1,12 @@ +source_dir . '/build'); + shell()->cd($this->source_dir . '/build') + ->exec( + 'cmake ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + $args . + '..' + ) + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install'); + } +} diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 16edeeae1..fbaeb7a78 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -69,14 +69,19 @@ public static function getLatestGithubTarball(string $name, array $source, strin retry: self::getRetryTime() ), true); - if (($source['prefer-stable'] ?? false) === false) { - $url = $data[0]['tarball_url']; - } else { - $id = 0; - while ($data[$id]['prerelease'] === true) { - ++$id; + $url = null; + for ($i = 0; $i < count($data); ++$i) { + if (($data[$i]['prerelease'] ?? false) === true && ($source['prefer-stable'] ?? false)) { + continue; + } + if (!($source['match'] ?? null)) { + $url = $data[$i]['tarball_url'] ?? null; + break; + } + if (preg_match('|' . $source['match'] . '|', $data[$i]['tarball_url'])) { + $url = $data[$i]['tarball_url']; + break; } - $url = $data[$id]['tarball_url'] ?? null; } if (!$url) { throw new DownloaderException("failed to find {$name} source"); From 92470a35da579d915231522f5e7ac6a860d7f006 Mon Sep 17 00:00:00 2001 From: Marc Henderkes Date: Thu, 20 Mar 2025 06:22:11 +0100 Subject: [PATCH 03/15] replace allocator with mimalloc (works for cli/fpm, embed needs to be tested) --- src/SPC/builder/linux/LinuxBuilder.php | 3 ++- src/SPC/builder/unix/library/mimalloc.php | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 671bb28b3..3e0edb2dd 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -150,12 +150,13 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void $enable_micro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; $enable_embed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; + $mimalloc = $this->getLib('mimalloc') !== null ? BUILD_LIB_PATH . '/mimalloc.o ' : ''; // prepare build php envs $envs_build_php = 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' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_LIBS'), + 'LIBS' => $mimalloc . getenv('SPC_CMD_VAR_PHP_CONFIGURE_LIBS'), ]); // process micro upx patch if micro sapi enabled diff --git a/src/SPC/builder/unix/library/mimalloc.php b/src/SPC/builder/unix/library/mimalloc.php index 495ce6323..40790a98a 100644 --- a/src/SPC/builder/unix/library/mimalloc.php +++ b/src/SPC/builder/unix/library/mimalloc.php @@ -24,7 +24,7 @@ protected function build(): void $args .= '-DMI_INSTALL_TOPLEVEL=ON '; FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') - ->exec( + ->execWithEnv( 'cmake ' . '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . @@ -32,7 +32,7 @@ protected function build(): void $args . '..' ) - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install'); + ->execWithEnv("make -j{$this->builder->concurrency}") + ->execWithEnv('make install'); } } From 0ce2c894e9d4fe8ee1ce0daff71457f9253dca8c Mon Sep 17 00:00:00 2001 From: Marc Henderkes Date: Thu, 20 Mar 2025 07:27:38 +0100 Subject: [PATCH 04/15] juggle mimalloc.o to the beginning --- src/SPC/builder/linux/LinuxBuilder.php | 12 +++++++++--- src/SPC/util/SPCConfigUtil.php | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 3e0edb2dd..1159b120b 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -150,13 +150,13 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void $enable_micro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; $enable_embed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; - $mimalloc = $this->getLib('mimalloc') !== null ? BUILD_LIB_PATH . '/mimalloc.o ' : ''; + $mimallocLibs = $this->getLib('mimalloc') !== null ? BUILD_LIB_PATH . '/mimalloc.o ' : ''; // prepare build php envs $envs_build_php = 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' => $mimalloc . getenv('SPC_CMD_VAR_PHP_CONFIGURE_LIBS'), + 'LIBS' => $mimallocLibs . getenv('SPC_CMD_VAR_PHP_CONFIGURE_LIBS'), ]); // process micro upx patch if micro sapi enabled @@ -311,7 +311,13 @@ protected function buildEmbed(): void shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') ->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install"); - FileSystem::replaceFileStr(BUILD_BIN_PATH . '/php-config', 'prefix=""', 'prefix="' . BUILD_ROOT_PATH . '"'); + $php_config_str = FileSystem::readFile(BUILD_BIN_PATH . '/php-config'); + str_replace('prefix=""', 'prefix="' . BUILD_ROOT_PATH . '"', $php_config_str); + // move mimalloc to the beginning of libs + $php_config_str = preg_replace('/(libs=")(.*?)\s*(' . preg_quote(BUILD_LIB_PATH, '/') . '\/mimalloc\.o)\s*(.*?)"/', '$1$3 $2 $4"', $php_config_str); + // move lstdc++ to the end of libs + $php_config_str = preg_replace('/(libs=")(.*?)\s*(-lstdc\+\+)\s*(.*?)"/', '$1$2 $4 $3"', $php_config_str); + FileSystem::writeFile(BUILD_BIN_PATH . '/php-config', $php_config_str); } private function getMakeExtraVars(): array diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index 2961ef90b..f4a121eb7 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -42,6 +42,10 @@ public function config(array $extensions = [], array $libraries = [], bool $incl if ($this->builder->hasCpp()) { $libs .= $this->builder instanceof MacOSBuilder ? ' -lc++' : ' -lstdc++'; } + // mimalloc must come first + if (str_contains($libs, BUILD_LIB_PATH . '/mimalloc.o')) { + $libs = BUILD_LIB_PATH . '/mimalloc.o ' . str_replace(BUILD_LIB_PATH . '/mimalloc.o', '', $libs); + } return [ 'cflags' => $cflags, 'ldflags' => $ldflags, From 347785758439d178f1e97082d14eae3c37561965 Mon Sep 17 00:00:00 2001 From: Marc Henderkes Date: Thu, 20 Mar 2025 07:41:13 +0100 Subject: [PATCH 05/15] mimalloc on mac (untested) --- config/lib.json | 3 --- src/SPC/builder/macos/MacOSBuilder.php | 8 ++++++++ src/SPC/builder/macos/library/mimalloc.php | 12 ++++++++++++ src/globals/test-extensions.php | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 src/SPC/builder/macos/library/mimalloc.php diff --git a/config/lib.json b/config/lib.json index 696f38a73..eb009f217 100644 --- a/config/lib.json +++ b/config/lib.json @@ -593,9 +593,6 @@ "source": "mimalloc", "static-libs-unix": [ "mimalloc.o" - ], - "static-libs-windows": [ - "mimalloc.lib" ] }, "ncurses": { diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index ce82ab109..176bd21e5 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -148,10 +148,12 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void $enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; // prepare build php envs + $mimallocLibs = $this->getLib('mimalloc') !== null ? BUILD_LIB_PATH . '/mimalloc.o ' : ''; $envs_build_php = 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'), ]); if ($this->getLib('postgresql')) { @@ -298,6 +300,12 @@ protected function buildEmbed(): void ->exec('rm ' . BUILD_ROOT_PATH . '/lib/libphp.a') ->exec('ar rcs ' . BUILD_ROOT_PATH . '/lib/libphp.a *.o') ->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o'); + + $php_config_str = FileSystem::readFile(BUILD_BIN_PATH . '/php-config'); + str_replace('prefix=""', 'prefix="' . BUILD_ROOT_PATH . '"', $php_config_str); + // move mimalloc to the beginning of libs + $php_config_str = preg_replace('/(libs=")(.*?)\s*(' . preg_quote(BUILD_LIB_PATH, '/') . '\/mimalloc\.o)\s*(.*?)"/', '$1$3 $2 $4"', $php_config_str); + FileSystem::writeFile(BUILD_BIN_PATH . '/php-config', $php_config_str); } private function getMakeExtraVars(): array diff --git a/src/SPC/builder/macos/library/mimalloc.php b/src/SPC/builder/macos/library/mimalloc.php new file mode 100644 index 000000000..c86c8ed6c --- /dev/null +++ b/src/SPC/builder/macos/library/mimalloc.php @@ -0,0 +1,12 @@ + 'freetype', + 'Linux', 'Darwin' => 'mimalloc', 'Windows' => 'libjpeg,libavif,freetype,libwebp', }; From 1b29803ed240e74d0a97f92cd2cb567040d5e1da Mon Sep 17 00:00:00 2001 From: Marc Henderkes Date: Thu, 20 Mar 2025 08:00:35 +0100 Subject: [PATCH 06/15] docs --- docs/en/guide/extension-notes.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/en/guide/extension-notes.md b/docs/en/guide/extension-notes.md index 914281f2f..1d9209c99 100644 --- a/docs/en/guide/extension-notes.md +++ b/docs/en/guide/extension-notes.md @@ -76,8 +76,7 @@ and this extension cannot be compiled into php by static linking, so it cannot b ## xdebug -1. Xdebug is a Zend extension. The functions of Xdebug depend on PHP's Zend engine and underlying code. -If you want to statically compile it into PHP, you may need a huge amount of patch code, which is not feasible. +1. Xdebug is only buildable as a shared extension. On Linux, you need to use static-php-cli with SPC_LIBC=glibc and then compile php-xdebug from source with the option `--with-php-config=/path/to/buildroot/bin/php-config`. 2. The macOS platform can compile an xdebug extension under PHP compiled on the same platform, extract the `xdebug.so` file, and then use the `--no-strip` parameter in static-php-cli to retain the debug symbol table and add the `ffi` extension. 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`. @@ -149,3 +148,9 @@ Parallel is only supported on PHP 8.0 ZTS and above. 1. The [SPX extension](https://github.com/NoiseByNorthwest/php-spx) only supports NTS mode. 2. SPX does not support Windows, and the official repository does not support static compilation. static-php-cli uses a [modified version](https://github.com/static-php/php-spx). + +## mimalloc + +1. This is not technically an extension, but a library. +2. Building with `--with-libs="mimalloc"` on Linux or macOS will override the default allocator. +3. This is experimental for now, but is recommended in threaded environments. \ No newline at end of file From 6fb9c2df3b42b3248300589363e95a3a3b9375f4 Mon Sep 17 00:00:00 2001 From: Marc Henderkes Date: Thu, 20 Mar 2025 08:46:54 +0100 Subject: [PATCH 07/15] test macos --- src/globals/test-extensions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 8b7a05e5f..d725e312f 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -22,9 +22,9 @@ // test os (macos-13, macos-14, ubuntu-latest, windows-latest are available) $test_os = [ // 'macos-13', - // 'macos-14', - // 'ubuntu-latest', - 'windows-latest', + 'macos-14', + 'ubuntu-latest', + // 'windows-latest', ]; // whether enable thread safe From 6b5e83b98ec6e9a10063ef5bc7a22d670c20a6cf Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 20 Mar 2025 16:06:33 +0800 Subject: [PATCH 08/15] Sync Chinese docs --- docs/zh/guide/extension-notes.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/zh/guide/extension-notes.md b/docs/zh/guide/extension-notes.md index cdd66ef2e..c13deeeab 100644 --- a/docs/zh/guide/extension-notes.md +++ b/docs/zh/guide/extension-notes.md @@ -70,7 +70,7 @@ bin/spc build gd --with-libs=freetype,libjpeg,libavif,libwebp --build-cli ## xdebug -1. Xdebug 是一个 Zend 扩展,Xdebug 的功能依赖于 PHP 的 Zend 引擎和底层代码,如果要将其静态编译到 PHP 中,可能需要巨量的 patch 代码,这是不可行的。 +1. Xdebug 只能作为共享扩展构建。在 Linux 上,您需要使用带有 `SPC_LIBC=glibc` 的 static-php-cli,然后使用选项 `--with-php-config=/path/to/buildroot/bin/php-config` 从源代码编译 php-xdebug。 2. macOS 平台可以通过在相同平台编译的 PHP 下编译一个 xdebug 扩展,并提取其中的 `xdebug.so` 文件,再在 static-php-cli 中使用 `--no-strip` 参数保留调试符号表,同时加入 `ffi` 扩展。 编译的 `./php` 二进制可以通过指定 INI 配置并运行,例如`./php -d 'zend_extension=xdebug.so' your-code.php`。 @@ -136,3 +136,9 @@ parallel 扩展只支持 PHP 8.0 及以上版本,并只支持 ZTS 构建(`-- 1. [SPX 扩展](https://github.com/NoiseByNorthwest/php-spx) 只支持非线程模式。 2. SPX 目前不支持 Windows,且官方仓库也不支持静态编译,static-php-cli 使用了 [修改版本](https://github.com/static-php/php-spx)。 + +## mimalloc + +1. 从技术上讲,这不是扩展,而是一个库。 +2. 在 Linux 或 macOS 上使用 `--with-libs="mimalloc"` 进行构建将覆盖默认分配器。 +3. 目前,这还处于实验阶段,但建议在线程环境中使用。 \ No newline at end of file From 1ad33556e99077f247129b5680d124582afc480b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 20 Mar 2025 16:11:45 +0800 Subject: [PATCH 09/15] Add full tests --- src/globals/test-extensions.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index d725e312f..85f47e1e6 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -6,12 +6,12 @@ /** * This is GitHub Actions automatic test extension args generator. - * You can edit $extensions, $with_libs and $base_combination. + * You can edit $test_php_version, $test_os, $zts, $no_strip, $upx, $prefer_pre_built, $extensions, $with_libs and $base_combination. */ // --------------------------------- edit area --------------------------------- -// test php version +// test php version (8.1 ~ 8.4 available, multiple for matrix) $test_php_version = [ '8.1', '8.2', @@ -21,7 +21,7 @@ // test os (macos-13, macos-14, ubuntu-latest, windows-latest are available) $test_os = [ - // 'macos-13', + 'macos-13', 'macos-14', 'ubuntu-latest', // 'windows-latest', @@ -40,7 +40,7 @@ // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'gd', + 'Linux', 'Darwin' => '', 'Windows' => 'bz2,ctype,curl,dom,filter,gd,iconv,mbstring,opcache,openssl,pdo,pdo_sqlite,phar,session,simplexml,sqlite3,tokenizer,xml,xmlwriter,yaml,zip,zlib', }; @@ -54,7 +54,7 @@ // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'minimal', + 'Linux', 'Darwin' => 'bulk', 'Windows' => 'none', }; From 1f7c805da442dbd284be6a3daace9c4b7ccf8b12 Mon Sep 17 00:00:00 2001 From: Marc Henderkes Date: Fri, 21 Mar 2025 07:35:06 +0100 Subject: [PATCH 10/15] fix typo in gettext --- src/SPC/builder/unix/library/gettext.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/unix/library/gettext.php b/src/SPC/builder/unix/library/gettext.php index 277df171a..69736c364 100644 --- a/src/SPC/builder/unix/library/gettext.php +++ b/src/SPC/builder/unix/library/gettext.php @@ -17,13 +17,17 @@ protected function build(): void $ldflags = $this->builder->getOption('enable-zts') ? '-lpthread' : ''; shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => "{$this->getLibExtraCFlags()} {$cflags}", 'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags, 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => "{$this->getLibExtraCFlags()} {$cflags}", + 'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags, + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv( './configure ' . '--enable-static ' . '--disable-shared ' . '--disable-java ' . - '--disable-c+ ' . + '--disable-c++ ' . $zts . $extra . '--with-included-gettext ' . From 1552d992df71e2c605bf0d59ce5974a693bf20e3 Mon Sep 17 00:00:00 2001 From: Marc Henderkes Date: Fri, 21 Mar 2025 07:35:06 +0100 Subject: [PATCH 11/15] fix typo in gettext --- src/SPC/builder/unix/library/gettext.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/unix/library/gettext.php b/src/SPC/builder/unix/library/gettext.php index 277df171a..69736c364 100644 --- a/src/SPC/builder/unix/library/gettext.php +++ b/src/SPC/builder/unix/library/gettext.php @@ -17,13 +17,17 @@ protected function build(): void $ldflags = $this->builder->getOption('enable-zts') ? '-lpthread' : ''; shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => "{$this->getLibExtraCFlags()} {$cflags}", 'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags, 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => "{$this->getLibExtraCFlags()} {$cflags}", + 'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags, + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv( './configure ' . '--enable-static ' . '--disable-shared ' . '--disable-java ' . - '--disable-c+ ' . + '--disable-c++ ' . $zts . $extra . '--with-included-gettext ' . From 918223e7da9ae15d518193cbcc3f8c806ea191dd Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 23 Mar 2025 12:38:35 +0700 Subject: [PATCH 12/15] fix phpize using wrong paths --- src/SPC/builder/linux/LinuxBuilder.php | 2 ++ src/SPC/builder/macos/MacOSBuilder.php | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 671bb28b3..d2f98692f 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -311,6 +311,8 @@ protected function buildEmbed(): void ->exec('sed -i "s|//lib|/lib|g" Makefile') ->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install"); FileSystem::replaceFileStr(BUILD_BIN_PATH . '/php-config', 'prefix=""', 'prefix="' . BUILD_ROOT_PATH . '"'); + FileSystem::replaceFileStr(BUILD_BIN_PATH . '/phpize', "prefix=''", "prefix='" . BUILD_ROOT_PATH . "'"); + FileSystem::replaceFileStr(BUILD_BIN_PATH . '/phpize', 's##', 's#/usr/local#'); } private function getMakeExtraVars(): array diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index ce82ab109..36102a967 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -298,6 +298,9 @@ protected function buildEmbed(): void ->exec('rm ' . BUILD_ROOT_PATH . '/lib/libphp.a') ->exec('ar rcs ' . BUILD_ROOT_PATH . '/lib/libphp.a *.o') ->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o'); + FileSystem::replaceFileStr(BUILD_BIN_PATH . '/php-config', 'prefix=""', 'prefix="' . BUILD_ROOT_PATH . '"'); + FileSystem::replaceFileStr(BUILD_BIN_PATH . '/phpize', "prefix=''", "prefix='" . BUILD_ROOT_PATH . "'"); + FileSystem::replaceFileStr(BUILD_BIN_PATH . '/phpize', 's##', 's#/usr/local#'); } private function getMakeExtraVars(): array From 7b6fae6d920e877a083d6c461b8ac226d6acaa36 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sun, 23 Mar 2025 22:33:26 +0800 Subject: [PATCH 13/15] Fix windows ssl bug for curl (#674) --- config/lib.json | 1 - src/SPC/ConsoleApplication.php | 2 +- src/SPC/builder/windows/library/curl.php | 2 ++ src/globals/ext-tests/curl.php | 13 +++++++++++++ src/globals/test-extensions.php | 14 +++++++------- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/config/lib.json b/config/lib.json index eb009f217..9656fcc11 100644 --- a/config/lib.json +++ b/config/lib.json @@ -78,7 +78,6 @@ "zlib" ], "lib-depends-windows": [ - "openssl", "zlib", "libssh2", "nghttp2" diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 752cb999d..5240ca55f 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -32,7 +32,7 @@ */ final class ConsoleApplication extends Application { - public const VERSION = '2.5.0'; + public const VERSION = '2.5.1'; public function __construct() { diff --git a/src/SPC/builder/windows/library/curl.php b/src/SPC/builder/windows/library/curl.php index df195735d..a758bf051 100644 --- a/src/SPC/builder/windows/library/curl.php +++ b/src/SPC/builder/windows/library/curl.php @@ -37,6 +37,8 @@ protected function build(): void '-DBUILD_EXAMPLES=OFF ' . // disable examples '-DUSE_LIBIDN2=OFF ' . // disable libidn2 '-DCURL_USE_LIBPSL=OFF ' . // disable libpsl + '-DCURL_USE_SCHANNEL=ON ' . // use Schannel instead of OpenSSL + '-DCURL_USE_OPENSSL=OFF ' . // disable openssl due to certificate issue '-DCURL_ENABLE_SSL=ON ' . '-DUSE_NGHTTP2=ON ' . // enable nghttp2 '-DCURL_USE_LIBSSH2=ON ' . // enable libssh2 diff --git a/src/globals/ext-tests/curl.php b/src/globals/ext-tests/curl.php index e088cbf46..a890a8cf9 100644 --- a/src/globals/ext-tests/curl.php +++ b/src/globals/ext-tests/curl.php @@ -3,3 +3,16 @@ declare(strict_types=1); assert(function_exists('curl_init')); +assert(function_exists('curl_setopt')); +assert(function_exists('curl_exec')); +assert(function_exists('curl_close')); +$curl_version = curl_version(); +if (stripos($curl_version['ssl_version'], 'schannel') !== false) { + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, 'https://example.com/'); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_HEADER, 0); + $data = curl_exec($curl); + curl_close($curl); + assert($data !== false); +} diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 85f47e1e6..9322cee15 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -21,10 +21,10 @@ // test os (macos-13, macos-14, ubuntu-latest, windows-latest are available) $test_os = [ - 'macos-13', - 'macos-14', + // 'macos-13', + // 'macos-14', 'ubuntu-latest', - // 'windows-latest', + 'windows-latest', ]; // whether enable thread safe @@ -41,20 +41,20 @@ // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { 'Linux', 'Darwin' => '', - 'Windows' => 'bz2,ctype,curl,dom,filter,gd,iconv,mbstring,opcache,openssl,pdo,pdo_sqlite,phar,session,simplexml,sqlite3,tokenizer,xml,xmlwriter,yaml,zip,zlib', + 'Windows' => 'mbstring,tokenizer,phar,curl,openssl', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). $with_libs = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'mimalloc', - 'Windows' => 'libjpeg,libavif,freetype,libwebp', + 'Linux', 'Darwin' => '', + 'Windows' => '', }; // Please change your test base combination. We recommend testing with `common`. // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'bulk', + 'Linux', 'Darwin' => 'minimal', 'Windows' => 'none', }; From 161a3924d2aceb61cf78b28a29a6e754bd3d534d Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sun, 23 Mar 2025 22:55:25 +0800 Subject: [PATCH 14/15] Fix windows micro logo changer bug (illegal realpath) (#675) --- src/SPC/builder/windows/WindowsBuilder.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index 1c43c3758..fb7eaa0fe 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -95,8 +95,9 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void if (($logo = $this->getOption('with-micro-logo')) !== null) { // realpath - $logo = realpath($logo); + // $logo = realpath($logo); $micro_logo = '--enable-micro-logo=' . $logo . ' '; + copy($logo, SOURCE_PATH . '\php-src\\' . $logo); } else { $micro_logo = ''; } From 3ba215c35c6ae27689fd1cdb47c93049a13ddd81 Mon Sep 17 00:00:00 2001 From: tricker Date: Sun, 23 Mar 2025 16:26:36 +0100 Subject: [PATCH 15/15] enable PDO_ODBC and ODBC extension statically (#661) * enable PDO_ODBC and ODBC extension statically * fix sorting of ext.json * add odbc and pdo_odbc extension to tests * Add full tests, remove pdo_odbc from bulk * Remove windows support for docs * Add ODBC and PDO_ODBC extension * Revert curl static lib * Add full tests * Add iconv for macOS * Add tests * Fix linux pdo_odbc patch * Sort config --------- Co-authored-by: crazywhalecc --- config/ext.json | 25 ++++++++++++++++++++++ src/SPC/builder/extension/odbc.php | 17 +++++++++++++++ src/SPC/builder/extension/pdo_odbc.php | 29 ++++++++++++++++++++++++++ src/globals/test-extensions.php | 8 +++---- 4 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 src/SPC/builder/extension/odbc.php create mode 100644 src/SPC/builder/extension/pdo_odbc.php diff --git a/config/ext.json b/config/ext.json index 4d6044b3b..5650b9d8d 100644 --- a/config/ext.json +++ b/config/ext.json @@ -426,6 +426,17 @@ }, "notes": true }, + "odbc": { + "support": { + "BSD": "wip", + "Windows": "wip" + }, + "type": "builtin", + "arg-type-unix": "custom", + "lib-depends-unix": [ + "unixodbc" + ] + }, "opcache": { "type": "builtin", "arg-type-unix": "custom" @@ -492,6 +503,20 @@ "mysqlnd" ] }, + "pdo_odbc": { + "support": { + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "custom", + "lib-depends-unix": [ + "unixodbc" + ], + "ext-depends": [ + "pdo", + "odbc" + ] + }, "pdo_pgsql": { "support": { "Windows": "wip", diff --git a/src/SPC/builder/extension/odbc.php b/src/SPC/builder/extension/odbc.php new file mode 100644 index 000000000..6234f4e82 --- /dev/null +++ b/src/SPC/builder/extension/odbc.php @@ -0,0 +1,17 @@ + '', - 'Windows' => 'mbstring,tokenizer,phar,curl,openssl', + 'Linux', 'Darwin' => 'odbc,pdo_odbc', + 'Windows' => 'odbc,pdo_odbc', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).