Compare commits

..

1 Commits

Author SHA1 Message Date
crazywhalecc
9e00814bfe Fix postgresql 2.17 aarch64 gnu bug 2026-02-11 23:24:56 +08:00
61 changed files with 166 additions and 964 deletions

View File

@@ -29,9 +29,6 @@ on:
description: Extensions to build (comma separated) description: Extensions to build (comma separated)
required: true required: true
type: string type: string
shared-extensions:
description: Shared extensions to build (optional, comma separated)
type: string
extra-libs: extra-libs:
description: Extra libraries to build (optional, comma separated) description: Extra libraries to build (optional, comma separated)
type: string type: string
@@ -45,22 +42,10 @@ on:
build-fpm: build-fpm:
description: Build fpm binary description: Build fpm binary
type: boolean type: boolean
build-frankenphp:
description: Build frankenphp binary (requires ZTS)
type: boolean
default: false
enable-zts:
description: Enable ZTS
type: boolean
default: false
prefer-pre-built: prefer-pre-built:
description: Prefer pre-built binaries (reduce build time) description: Prefer pre-built binaries (reduce build time)
type: boolean type: boolean
default: true default: true
with-suggested-libs:
description: Build with suggested libs
type: boolean
default: false
debug: debug:
description: Show full build logs description: Show full build logs
type: boolean type: boolean
@@ -84,9 +69,6 @@ on:
description: Extensions to build (comma separated) description: Extensions to build (comma separated)
required: true required: true
type: string type: string
shared-extensions:
description: Shared extensions to build (optional, comma separated)
type: string
extra-libs: extra-libs:
description: Extra libraries to build (optional, comma separated) description: Extra libraries to build (optional, comma separated)
type: string type: string
@@ -100,22 +82,10 @@ on:
build-fpm: build-fpm:
description: Build fpm binary description: Build fpm binary
type: boolean type: boolean
build-frankenphp:
description: Build frankenphp binary (requires ZTS)
type: boolean
default: false
enable-zts:
description: Enable ZTS
type: boolean
default: false
prefer-pre-built: prefer-pre-built:
description: Prefer pre-built binaries (reduce build time) description: Prefer pre-built binaries (reduce build time)
type: boolean type: boolean
default: true default: true
with-suggested-libs:
description: Include suggested libs
type: boolean
default: false
debug: debug:
description: Show full build logs description: Show full build logs
type: boolean type: boolean
@@ -174,19 +144,8 @@ jobs:
RUNS_ON="macos-15" RUNS_ON="macos-15"
;; ;;
esac esac
STATIC_EXTS="${{ inputs.extensions }}" DOWN_CMD="$DOWN_CMD --with-php=${{ inputs.php-version }} --for-extensions=${{ inputs.extensions }} --ignore-cache-sources=php-src"
SHARED_EXTS="${{ inputs['shared-extensions'] }}" BUILD_CMD="$BUILD_CMD ${{ inputs.extensions }}"
BUILD_FRANKENPHP="${{ inputs['build-frankenphp'] }}"
ENABLE_ZTS="${{ inputs['enable-zts'] }}"
ALL_EXTS="$STATIC_EXTS"
if [ -n "$SHARED_EXTS" ]; then
ALL_EXTS="$ALL_EXTS,$SHARED_EXTS"
fi
DOWN_CMD="$DOWN_CMD --with-php=${{ inputs.php-version }} --for-extensions=$ALL_EXTS --ignore-cache-sources=php-src"
BUILD_CMD="$BUILD_CMD $STATIC_EXTS"
if [ -n "$SHARED_EXTS" ]; then
BUILD_CMD="$BUILD_CMD --build-shared=$SHARED_EXTS"
fi
if [ -n "${{ inputs.extra-libs }}" ]; then if [ -n "${{ inputs.extra-libs }}" ]; then
DOWN_CMD="$DOWN_CMD --for-libs=${{ inputs.extra-libs }}" DOWN_CMD="$DOWN_CMD --for-libs=${{ inputs.extra-libs }}"
BUILD_CMD="$BUILD_CMD --with-libs=${{ inputs.extra-libs }}" BUILD_CMD="$BUILD_CMD --with-libs=${{ inputs.extra-libs }}"
@@ -198,9 +157,6 @@ jobs:
if [ ${{ inputs.prefer-pre-built }} == true ]; then if [ ${{ inputs.prefer-pre-built }} == true ]; then
DOWN_CMD="$DOWN_CMD --prefer-pre-built" DOWN_CMD="$DOWN_CMD --prefer-pre-built"
fi fi
if [ ${{ inputs.with-suggested-libs }} == true ]; then
BUILD_CMD="$BUILD_CMD --with-suggested-libs"
fi
if [ ${{ inputs.build-cli }} == true ]; then if [ ${{ inputs.build-cli }} == true ]; then
BUILD_CMD="$BUILD_CMD --build-cli" BUILD_CMD="$BUILD_CMD --build-cli"
fi fi
@@ -210,12 +166,6 @@ jobs:
if [ ${{ inputs.build-fpm }} == true ]; then if [ ${{ inputs.build-fpm }} == true ]; then
BUILD_CMD="$BUILD_CMD --build-fpm" BUILD_CMD="$BUILD_CMD --build-fpm"
fi fi
if [ "$BUILD_FRANKENPHP" = "true" ]; then
BUILD_CMD="$BUILD_CMD --build-frankenphp"
fi
if [ "$ENABLE_ZTS" = "true" ]; then
BUILD_CMD="$BUILD_CMD --enable-zts"
fi
echo 'download='"$DOWN_CMD" >> "$GITHUB_OUTPUT" echo 'download='"$DOWN_CMD" >> "$GITHUB_OUTPUT"
echo 'build='"$BUILD_CMD" >> "$GITHUB_OUTPUT" echo 'build='"$BUILD_CMD" >> "$GITHUB_OUTPUT"
echo 'run='"$RUNS_ON" >> "$GITHUB_OUTPUT" echo 'run='"$RUNS_ON" >> "$GITHUB_OUTPUT"
@@ -238,27 +188,6 @@ jobs:
env: env:
phpts: nts phpts: nts
- if: ${{ inputs['build-frankenphp'] == true }}
name: "Install go-xcaddy for FrankenPHP"
run: |
case "${{ inputs.os }}" in
linux-x86_64|linux-aarch64)
./bin/spc-alpine-docker install-pkg go-xcaddy
;;
linux-x86_64-glibc|linux-aarch64-glibc)
./bin/spc-gnu-docker install-pkg go-xcaddy
;;
macos-x86_64|macos-aarch64)
composer update --no-dev --classmap-authoritative
./bin/spc doctor --auto-fix
./bin/spc install-pkg go-xcaddy
;;
*)
echo "Unsupported OS for go-xcaddy install: ${{ inputs.os }}"
exit 1
;;
esac
# Cache downloaded source # Cache downloaded source
- id: cache-download - id: cache-download
uses: actions/cache@v4 uses: actions/cache@v4
@@ -273,14 +202,6 @@ jobs:
# if: ${{ failure() }} # if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3 # uses: mxschmitt/action-tmate@v3
# Upload debug logs
- if: ${{ inputs.debug && failure() }}
name: "Upload build logs on failure"
uses: actions/upload-artifact@v4
with:
name: spc-logs-${{ inputs.php-version }}-${{ inputs.os }}
path: log/*.log
# Upload cli executable # Upload cli executable
- if: ${{ inputs.build-cli == true }} - if: ${{ inputs.build-cli == true }}
name: "Upload PHP cli SAPI" name: "Upload PHP cli SAPI"
@@ -305,22 +226,7 @@ jobs:
name: php-fpm-${{ inputs.php-version }}-${{ inputs.os }} name: php-fpm-${{ inputs.php-version }}-${{ inputs.os }}
path: buildroot/bin/php-fpm path: buildroot/bin/php-fpm
# Upload frankenphp executable
- if: ${{ inputs['build-frankenphp'] == true }}
name: "Upload FrankenPHP SAPI"
uses: actions/upload-artifact@v4
with:
name: php-frankenphp-${{ inputs.php-version }}-${{ inputs.os }}
path: buildroot/bin/frankenphp
# Upload extensions metadata # Upload extensions metadata
- if: ${{ inputs['shared-extensions'] != '' }}
name: "Upload shared extensions"
uses: actions/upload-artifact@v4
with:
name: php-shared-ext-${{ inputs.php-version }}-${{ inputs.os }}
path: |
buildroot/modules/*.so
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
name: "Upload License Files" name: "Upload License Files"
with: with:

View File

@@ -148,8 +148,6 @@ SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-
SPC_CMD_VAR_PHP_EMBED_TYPE="static" SPC_CMD_VAR_PHP_EMBED_TYPE="static"
; EXTRA_CFLAGS for `configure` and `make` php ; EXTRA_CFLAGS for `configure` and `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie -Werror=unknown-warning-option ${SPC_DEFAULT_C_FLAGS}" SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie -Werror=unknown-warning-option ${SPC_DEFAULT_C_FLAGS}"
; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS=""
; minimum compatible macOS version (LLVM vars, availability not guaranteed) ; minimum compatible macOS version (LLVM vars, availability not guaranteed)
MACOSX_DEPLOYMENT_TARGET=12.0 MACOSX_DEPLOYMENT_TARGET=12.0

View File

@@ -63,8 +63,7 @@
], ],
"ext-depends-windows": [ "ext-depends-windows": [
"zlib", "zlib",
"openssl", "openssl"
"brotli"
] ]
}, },
"dba": { "dba": {
@@ -74,19 +73,6 @@
"qdbm" "qdbm"
] ]
}, },
"decimal": {
"type": "external",
"source": "ext-decimal",
"arg-type": "custom",
"lib-depends": [
"libmpdec"
]
},
"deepclone": {
"type": "external",
"source": "deepclone",
"arg-type": "enable"
},
"dio": { "dio": {
"support": { "support": {
"BSD": "wip" "BSD": "wip"
@@ -266,7 +252,6 @@
"arg-type-unix": "enable-path", "arg-type-unix": "enable-path",
"cpp-extension": true, "cpp-extension": true,
"lib-depends": [ "lib-depends": [
"grpc",
"zlib", "zlib",
"openssl", "openssl",
"libcares" "libcares"

View File

@@ -109,7 +109,8 @@
"krb5" "krb5"
], ],
"lib-suggests-windows": [ "lib-suggests-windows": [
"brotli" "brotli",
"zstd"
], ],
"frameworks": [ "frameworks": [
"CoreFoundation", "CoreFoundation",
@@ -142,7 +143,9 @@
"zlib" "zlib"
], ],
"lib-suggests": [ "lib-suggests": [
"libpng" "libpng",
"bzip2",
"brotli"
] ]
}, },
"gettext": { "gettext": {
@@ -352,9 +355,6 @@
"static-libs-unix": [ "static-libs-unix": [
"libaom.a" "libaom.a"
], ],
"static-libs-windows": [
"aom.lib"
],
"cpp-library": true "cpp-library": true
}, },
"libargon2": { "libargon2": {
@@ -373,15 +373,6 @@
], ],
"static-libs-windows": [ "static-libs-windows": [
"avif.lib" "avif.lib"
],
"lib-depends": [
"libaom"
],
"lib-suggests": [
"libwebp",
"libjpeg",
"libxml2",
"libpng"
] ]
}, },
"libcares": { "libcares": {
@@ -493,7 +484,7 @@
"static-libs-windows": [ "static-libs-windows": [
"libjpeg_a.lib" "libjpeg_a.lib"
], ],
"lib-depends": [ "lib-suggests-windows": [
"zlib" "zlib"
] ]
}, },
@@ -528,18 +519,6 @@
"maxminddb_config.h" "maxminddb_config.h"
] ]
}, },
"libmpdec": {
"source": "libmpdec",
"static-libs-unix": [
"libmpdec.a"
],
"static-libs-windows": [
"libmpdec_a.lib"
],
"headers": [
"mpdecimal.h"
]
},
"libmemcached": { "libmemcached": {
"source": "libmemcached", "source": "libmemcached",
"cpp-library": true, "cpp-library": true,
@@ -774,6 +753,7 @@
"xz" "xz"
], ],
"lib-suggests-windows": [ "lib-suggests-windows": [
"zstd",
"openssl" "openssl"
] ]
}, },
@@ -873,9 +853,6 @@
}, },
"openssl": { "openssl": {
"source": "openssl", "source": "openssl",
"pkg-configs": [
"openssl"
],
"static-libs-unix": [ "static-libs-unix": [
"libssl.a", "libssl.a",
"libcrypto.a" "libcrypto.a"
@@ -988,11 +965,6 @@
}, },
"unixodbc": { "unixodbc": {
"source": "unixodbc", "source": "unixodbc",
"pkg-configs": [
"odbc",
"odbccr",
"odbcinst"
],
"static-libs-unix": [ "static-libs-unix": [
"libodbc.a", "libodbc.a",
"libodbccr.a", "libodbccr.a",
@@ -1010,9 +982,6 @@
], ],
"headers": [ "headers": [
"wtr/watcher-c.h" "wtr/watcher-c.h"
],
"frameworks": [
"CoreServices"
] ]
}, },
"xz": { "xz": {
@@ -1037,9 +1006,6 @@
}, },
"zlib": { "zlib": {
"source": "zlib", "source": "zlib",
"pkg-configs": [
"zlib"
],
"static-libs-unix": [ "static-libs-unix": [
"libz.a" "libz.a"
], ],
@@ -1053,9 +1019,6 @@
}, },
"zstd": { "zstd": {
"source": "zstd", "source": "zstd",
"pkg-configs": [
"libzstd"
],
"static-libs-unix": [ "static-libs-unix": [
"libzstd.a" "libzstd.a"
], ],

View File

@@ -84,25 +84,6 @@
"path": "COPYING" "path": "COPYING"
} }
}, },
"ext-decimal": {
"type": "ghtagtar",
"repo": "php-decimal/ext-decimal",
"match": "v2\\.\\d.*",
"path": "php-src/ext/decimal",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"deepclone": {
"type": "ghtagtar",
"repo": "symfony/php-ext-deepclone",
"path": "php-src/ext/deepclone",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"dio": { "dio": {
"type": "url", "type": "url",
"url": "https://pecl.php.net/get/dio", "url": "https://pecl.php.net/get/dio",
@@ -246,7 +227,7 @@
}, },
"ext-rdkafka": { "ext-rdkafka": {
"type": "ghtar", "type": "ghtar",
"repo": "php-rdkafka/php-rdkafka", "repo": "arnaud-lb/php-rdkafka",
"path": "php-src/ext/rdkafka", "path": "php-src/ext/rdkafka",
"license": { "license": {
"type": "file", "type": "file",
@@ -333,9 +314,10 @@
} }
}, },
"ext-zstd": { "ext-zstd": {
"type": "ghtagtar", "type": "git",
"repo": "kjdev/php-ext-zstd",
"path": "php-src/ext/zstd", "path": "php-src/ext/zstd",
"rev": "master",
"url": "https://github.com/kjdev/php-ext-zstd",
"license": { "license": {
"type": "file", "type": "file",
"path": "LICENSE" "path": "LICENSE"
@@ -379,7 +361,7 @@
}, },
"gmp": { "gmp": {
"type": "filelist", "type": "filelist",
"url": "https://ftp.gnu.org/gnu/gmp/", "url": "https://gmplib.org/download/gmp/",
"regex": "/href=\"(?<file>gmp-(?<version>[^\"]+)\\.tar\\.xz)\"/", "regex": "/href=\"(?<file>gmp-(?<version>[^\"]+)\\.tar\\.xz)\"/",
"provide-pre-built": true, "provide-pre-built": true,
"alt": { "alt": {
@@ -480,8 +462,10 @@
} }
}, },
"krb5": { "krb5": {
"type": "url", "type": "ghtagtar",
"url": "https://web.mit.edu/kerberos/dist/krb5/1.22/krb5-1.22.2.tar.gz", "repo": "krb5/krb5",
"match": "krb5.+-final",
"prefer-stable": true,
"license": { "license": {
"type": "file", "type": "file",
"path": "NOTICE" "path": "NOTICE"
@@ -542,7 +526,7 @@
"libavif": { "libavif": {
"type": "ghtar", "type": "ghtar",
"repo": "AOMediaCodec/libavif", "repo": "AOMediaCodec/libavif",
"provide-pre-built": false, "provide-pre-built": true,
"license": { "license": {
"type": "file", "type": "file",
"path": "LICENSE" "path": "LICENSE"
@@ -657,7 +641,6 @@
"libjpeg": { "libjpeg": {
"type": "ghtar", "type": "ghtar",
"repo": "libjpeg-turbo/libjpeg-turbo", "repo": "libjpeg-turbo/libjpeg-turbo",
"prefer-stable": true,
"license": { "license": {
"type": "file", "type": "file",
"path": "LICENSE.md" "path": "LICENSE.md"
@@ -699,14 +682,6 @@
"path": "LICENSE" "path": "LICENSE"
} }
}, },
"libmpdec": {
"type": "url",
"url": "https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-4.0.1.tar.gz",
"license": {
"type": "file",
"path": "COPYRIGHT.txt"
}
},
"libmemcached": { "libmemcached": {
"type": "ghtagtar", "type": "ghtagtar",
"repo": "awesomized/libmemcached", "repo": "awesomized/libmemcached",
@@ -999,7 +974,7 @@
"openssl": { "openssl": {
"type": "ghrel", "type": "ghrel",
"repo": "openssl/openssl", "repo": "openssl/openssl",
"match": "openssl-3.+\\.tar\\.gz", "match": "openssl.+\\.tar\\.gz",
"prefer-stable": true, "prefer-stable": true,
"alt": { "alt": {
"type": "filelist", "type": "filelist",
@@ -1079,7 +1054,7 @@
}, },
"protobuf": { "protobuf": {
"type": "url", "type": "url",
"url": "https://pecl.php.net/get/protobuf-5.34.1.tgz", "url": "https://pecl.php.net/get/protobuf",
"path": "php-src/ext/protobuf", "path": "php-src/ext/protobuf",
"filename": "protobuf.tgz", "filename": "protobuf.tgz",
"license": { "license": {
@@ -1193,6 +1168,7 @@
"path": "php-src/ext/swoole", "path": "php-src/ext/swoole",
"type": "ghtar", "type": "ghtar",
"repo": "swoole/swoole-src", "repo": "swoole/swoole-src",
"match": "v6\\.+",
"prefer-stable": true, "prefer-stable": true,
"license": { "license": {
"type": "file", "type": "file",

View File

@@ -16,10 +16,8 @@ while also defining the extensions to compile.
1. Fork project. 1. Fork project.
2. Go to the Actions of the project and select `CI`. 2. Go to the Actions of the project and select `CI`.
3. Select `Run workflow`, fill in the PHP version you want to compile, the target type, and the list of static extensions. (comma separated, e.g. `bcmath,curl,mbstring`) 3. Select `Run workflow`, fill in the PHP version you want to compile, the target type, and the list of extensions. (extensions comma separated, e.g. `bcmath,curl,mbstring`)
4. If you need shared extensions (for example `xdebug`), set `shared-extensions` (comma separated, e.g. `xdebug`). 4. After waiting for about a period of time, enter the corresponding task and get `Artifacts`.
5. If you need FrankenPHP, enable `build-frankenphp` and also enable `enable-zts`.
6. After waiting for about a period of time, enter the corresponding task and get `Artifacts`.
If you enable `debug`, all logs will be output at build time, including compiled logs, for troubleshooting. If you enable `debug`, all logs will be output at build time, including compiled logs, for troubleshooting.

View File

@@ -14,9 +14,7 @@ Action 构建指的是直接使用 GitHub Action 进行编译。
1. Fork 本项目。 1. Fork 本项目。
2. 进入项目的 Actions选择 CI 开头的 Workflow根据你需要的操作系统选择 2. 进入项目的 Actions选择 CI 开头的 Workflow根据你需要的操作系统选择
3. 选择 `Run workflow`,填入你要编译的 PHP 版本、目标类型、扩展列表。(扩展列表使用英文逗号分割,例如 `bcmath,curl,mbstring` 3. 选择 `Run workflow`,填入你要编译的 PHP 版本、目标类型、扩展列表。(扩展列表使用英文逗号分割,例如 `bcmath,curl,mbstring`
4. 如果需要共享扩展(例如 `xdebug`),请设置 `shared-extensions`(使用英文逗号分割,例如 `xdebug` 4. 等待大约一段时间后,进入对应的任务中,获取 `Artifacts`
5. 如果需要 FrankenPHP请启用 `build-frankenphp`,同时也需要启用 `enable-zts`
6. 等待大约一段时间后,进入对应的任务中,获取 `Artifacts`
如果你选择了 `debug`,则会在构建时输出所有日志,包括编译的日志,以供排查错误。 如果你选择了 `debug`,则会在构建时输出所有日志,包括编译的日志,以供排查错误。

View File

@@ -14,7 +14,6 @@ parameters:
- PHP_OS_FAMILY - PHP_OS_FAMILY
excludePaths: excludePaths:
analyseAndScan: analyseAndScan:
- ./src/globals/ext-tests/decimal.php
- ./src/globals/ext-tests/swoole.php - ./src/globals/ext-tests/swoole.php
- ./src/globals/ext-tests/swoole.phpt - ./src/globals/ext-tests/swoole.phpt
- ./src/globals/test-extensions.php - ./src/globals/test-extensions.php

View File

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

View File

@@ -11,9 +11,6 @@ use SPC\exception\ValidationException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use SPC\store\Config; use SPC\store\Config;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\toolchain\ToolchainManager;
use SPC\toolchain\ZigToolchain;
use SPC\util\GlobalEnvManager;
use SPC\util\SPCConfigUtil; use SPC\util\SPCConfigUtil;
use SPC\util\SPCTarget; use SPC\util\SPCTarget;
@@ -99,8 +96,7 @@ class Extension
fn ($x) => $x->getStaticLibFiles(), fn ($x) => $x->getStaticLibFiles(),
$this->getLibraryDependencies(recursive: true) $this->getLibraryDependencies(recursive: true)
); );
$libs = implode(' ', $ret); return implode(' ', $ret);
return deduplicate_flags($libs);
} }
/** /**
@@ -234,7 +230,7 @@ class Extension
if (preg_match('/^(.*_SHARED_LIBADD\s*=\s*)(.*)$/m', $makefileContent, $matches)) { if (preg_match('/^(.*_SHARED_LIBADD\s*=\s*)(.*)$/m', $makefileContent, $matches)) {
$prefix = $matches[1]; $prefix = $matches[1];
$currentLibs = trim($matches[2]); $currentLibs = trim($matches[2]);
$newLibs = clean_spaces("{$currentLibs} {$staticLibs} {$lstdcpp}"); $newLibs = trim("{$currentLibs} {$staticLibs} {$lstdcpp}");
$deduplicatedLibs = deduplicate_flags($newLibs); $deduplicatedLibs = deduplicate_flags($newLibs);
FileSystem::replaceFileRegex( FileSystem::replaceFileRegex(
@@ -546,11 +542,6 @@ class Extension
*/ */
protected function getSharedExtensionEnv(): array protected function getSharedExtensionEnv(): array
{ {
$compiler_extra = getenv('SPC_COMPILER_EXTRA') ?: '';
if (!str_contains($compiler_extra, '-lcompiler_rt') && ToolchainManager::getToolchainClass() === ZigToolchain::class) {
$compiler_extra = trim($compiler_extra . ' -lcompiler_rt');
GlobalEnvManager::putenv("SPC_COMPILER_EXTRA={$compiler_extra}");
}
$config = (new SPCConfigUtil($this->builder, ['no_php' => true]))->getExtensionConfig($this); $config = (new SPCConfigUtil($this->builder, ['no_php' => true]))->getExtensionConfig($this);
[$staticLibs, $sharedLibs] = $this->splitLibsIntoStaticAndShared($config['libs']); [$staticLibs, $sharedLibs] = $this->splitLibsIntoStaticAndShared($config['libs']);
$preStatic = PHP_OS_FAMILY === 'Darwin' ? '' : '-Wl,--start-group '; $preStatic = PHP_OS_FAMILY === 'Darwin' ? '' : '-Wl,--start-group ';

View File

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

View File

@@ -1,46 +0,0 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('decimal')]
class decimal extends Extension
{
// TODO: remove this when https://github.com/php-decimal/ext-decimal/issues/92 is merged
public function patchBeforeBuildconf(): bool
{
FileSystem::replaceFileStr(
$this->source_dir . '/php_decimal.c',
[
'zend_module_entry decimal_module_entry',
'ZEND_GET_MODULE(decimal)',
],
[
'zend_module_entry php_decimal_module_entry',
'ZEND_GET_MODULE(php_decimal)',
]
);
FileSystem::replaceFileStr(
$this->source_dir . '/config.w32',
'ARG_WITH("decimal", "for decimal support", "no");',
'ARG_WITH("decimal", "for decimal support", "no");' . "\n" .
'ADD_EXTENSION_DEP("decimal", "json");'
);
return true;
}
public function getUnixConfigureArg(bool $shared = false): string
{
return '--enable-decimal --with-libmpdec-path="' . BUILD_ROOT_PATH . '"';
}
public function getWindowsConfigureArg(bool $shared = false): string
{
return '--with-decimal';
}
}

View File

@@ -5,21 +5,11 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\builder\linux\SystemUtil;
use SPC\store\SourcePatcher;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('ffi')] #[CustomExt('ffi')]
class ffi extends Extension class ffi extends Extension
{ {
public function patchBeforeBuildconf(): bool
{
if (PHP_OS_FAMILY === 'Linux' && SystemUtil::getOSRelease()['dist'] === 'centos') {
return SourcePatcher::patchFfiCentos7FixO3strncmp();
}
return false;
}
public function getUnixConfigureArg(bool $shared = false): string public function getUnixConfigureArg(bool $shared = false): string
{ {
return '--with-ffi' . ($shared ? '=shared' : '') . ' --enable-zend-signals'; return '--with-ffi' . ($shared ? '=shared' : '') . ' --enable-zend-signals';

View File

@@ -11,6 +11,7 @@ use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
use SPC\util\GlobalEnvManager; use SPC\util\GlobalEnvManager;
use SPC\util\SPCConfigUtil; use SPC\util\SPCConfigUtil;
use SPC\util\SPCTarget;
#[CustomExt('grpc')] #[CustomExt('grpc')]
class grpc extends Extension class grpc extends Extension
@@ -20,59 +21,18 @@ class grpc extends Extension
if ($this->builder instanceof WindowsBuilder) { if ($this->builder instanceof WindowsBuilder) {
throw new ValidationException('grpc extension does not support windows yet'); throw new ValidationException('grpc extension does not support windows yet');
} }
// Fix deprecated PHP API usage in call.c
FileSystem::replaceFileStr( FileSystem::replaceFileStr(
"{$this->source_dir}/src/php/ext/grpc/call.c", $this->source_dir . '/src/php/ext/grpc/call.c',
'zend_exception_get_default(TSRMLS_C),', 'zend_exception_get_default(TSRMLS_C),',
'zend_ce_exception,', 'zend_ce_exception,',
); );
if (SPCTarget::getTargetOS() === 'Darwin') {
// Fix include path conflict with pdo_sqlsrv: grpc's PHP ext dir is added to the global include path via FileSystem::replaceFileRegex(
$grpc_php_dir = "{$this->source_dir}/src/php/ext/grpc"; $this->source_dir . '/config.m4',
if (file_exists("{$grpc_php_dir}/version.h")) { '/GRPC_LIBDIR=.*$/m',
copy("{$grpc_php_dir}/version.h", "{$grpc_php_dir}/php_grpc_version.h"); 'GRPC_LIBDIR=' . BUILD_LIB_PATH . "\n" . 'LDFLAGS="$LDFLAGS -framework CoreFoundation"'
unlink("{$grpc_php_dir}/version.h"); );
FileSystem::replaceFileStr("{$grpc_php_dir}/php_grpc.h", '#include "version.h"', '#include "php_grpc_version.h"');
FileSystem::replaceFileStr("{$grpc_php_dir}/php_grpc.c", '#include "version.h"', '#include "php_grpc_version.h"');
} }
$config_m4 = <<<'M4'
PHP_ARG_ENABLE(grpc, [whether to enable grpc support], [AS_HELP_STRING([--enable-grpc], [Enable grpc support])])
if test "$PHP_GRPC" != "no"; then
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/include)
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/php/ext/grpc)
GRPC_LIBDIR=@@build_lib_path@@
PHP_ADD_LIBPATH($GRPC_LIBDIR)
PHP_ADD_LIBRARY(grpc,,GRPC_SHARED_LIBADD)
LIBS="-lpthread $LIBS"
PHP_ADD_LIBRARY(pthread)
case $host in
*darwin*)
PHP_ADD_LIBRARY(c++,1,GRPC_SHARED_LIBADD)
;;
*)
PHP_ADD_LIBRARY(stdc++,1,GRPC_SHARED_LIBADD)
PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD)
PHP_ADD_LIBRARY(rt)
;;
esac
PHP_NEW_EXTENSION(grpc, @grpc_c_files@, $ext_shared, , -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1)
PHP_SUBST(GRPC_SHARED_LIBADD)
PHP_INSTALL_HEADERS([ext/grpc], [php_grpc.h])
fi
M4;
$replace = get_pack_replace();
// load grpc c files from src/php/ext/grpc
$c_files = glob($this->source_dir . '/src/php/ext/grpc/*.c');
$replace['@grpc_c_files@'] = implode(" \\\n ", array_map(fn ($f) => 'src/php/ext/grpc/' . basename($f), $c_files));
$config_m4 = str_replace(array_keys($replace), array_values($replace), $config_m4);
file_put_contents($this->source_dir . '/config.m4', $config_m4);
copy($this->source_dir . '/src/php/ext/grpc/php_grpc.h', $this->source_dir . '/php_grpc.h');
return true; return true;
} }
@@ -88,6 +48,7 @@ M4;
public function patchBeforeMake(): bool public function patchBeforeMake(): bool
{ {
parent::patchBeforeMake(); 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'); GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -Wno-strict-prototypes');
return true; return true;
} }

View File

@@ -5,22 +5,11 @@ declare(strict_types=1);
namespace SPC\builder\extension; namespace SPC\builder\extension;
use SPC\builder\Extension; use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt; use SPC\util\CustomExt;
#[CustomExt('mongodb')] #[CustomExt('mongodb')]
class mongodb extends Extension class mongodb extends Extension
{ {
public function patchBeforeBuildconf(): bool
{
FileSystem::replaceFileRegex(
SOURCE_PATH . '/php-src/ext/mongodb/config.m4',
'/^(\s+)(src\/libmongoc\/)/m',
'$1${ac_config_dir}/$2'
);
return true;
}
public function getUnixConfigureArg(bool $shared = false): string public function getUnixConfigureArg(bool $shared = false): string
{ {
$arg = ' --enable-mongodb' . ($shared ? '=shared' : '') . ' '; $arg = ' --enable-mongodb' . ($shared ? '=shared' : '') . ' ';

View File

@@ -26,7 +26,7 @@ class password_argon2 extends Extension
public function getConfigureArg(bool $shared = false): string public function getConfigureArg(bool $shared = false): string
{ {
if ($this->builder->getExt('openssl')?->isBuildStatic() || $this->isBuildShared()) { if ($this->builder->getLib('openssl') !== null) {
if ($this->builder->getPHPVersionID() >= 80500 || ($this->builder->getPHPVersionID() >= 80400 && !$this->builder->getOption('enable-zts'))) { 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 '--without-password-argon2'; // use --with-openssl-argon2 in openssl extension instead
} }

View File

@@ -33,14 +33,4 @@ class sqlsrv extends Extension
} }
return false; return false;
} }
public function patchBeforeMake(): bool
{
$makefile = SOURCE_PATH . '/php-src/Makefile';
$makeContent = file_get_contents($makefile);
$makeContent = preg_replace('/^(CFLAGS_(?:PDO_)?SQLSRV=.*?)\s+\/W4\b/m', '$1', $makeContent);
$makeContent = preg_replace('/^(CFLAGS_(?:PDO_)?SQLSRV=.*?)\s+\/WX\b/m', '$1', $makeContent);
file_put_contents($makefile, $makeContent);
return true;
}
} }

View File

@@ -50,16 +50,19 @@ class swoole extends Extension
// commonly used feature: coroutine-time // commonly used feature: coroutine-time
$arg .= ' --enable-swoole-coro-time --with-pic'; $arg .= ' --enable-swoole-coro-time --with-pic';
$arg .= ' --enable-swoole-ssh --enable-swoole-curl';
$arg .= $this->builder->getOption('enable-zts') ? ' --enable-swoole-thread --disable-thread-context' : ' --disable-swoole-thread --enable-thread-context'; $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 features that only require libraries // additional features that only require libraries
$arg .= $this->builder->getLib('libcares') ? ' --enable-cares' : ''; $arg .= $this->builder->getLib('libcares') ? ' --enable-cares' : '';
$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('nghttp2') ? (' --with-nghttp2-dir=' . BUILD_ROOT_PATH) : '';
$arg .= $this->builder->getLib('zstd') ? ' --enable-zstd' : ''; $arg .= $this->builder->getLib('zstd') ? ' --enable-zstd' : '';
$arg .= $this->builder->getLib('liburing') && getenv('SPC_LIBC') !== 'glibc' ? ' --enable-iouring --enable-uring-socket' : '--disable-iouring'; $arg .= $this->builder->getLib('liburing') ? ' --enable-iouring' : '';
$arg .= $this->builder->getExt('sockets') ? ' --enable-sockets' : ''; $arg .= $this->builder->getExt('sockets') ? ' --enable-sockets' : '';
// enable additional features that require the pdo extension, but conflict with pdo_* extensions // enable additional features that require the pdo extension, but conflict with pdo_* extensions
@@ -71,7 +74,6 @@ class swoole extends Extension
$config = (new SPCConfigUtil($this->builder))->getLibraryConfig($this->builder->getLib('unixodbc')); $config = (new SPCConfigUtil($this->builder))->getLibraryConfig($this->builder->getLib('unixodbc'));
$arg .= ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH . ' SWOOLE_ODBC_LIBS="' . $config['libs'] . '"'; $arg .= ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH . ' SWOOLE_ODBC_LIBS="' . $config['libs'] . '"';
} }
$arg .= $this->builder->getExt('ftp')?->isBuildStatic() ? ' --disable-swoole-ftp' : ' --enable-swoole-ftp';
if ($this->getExtVersion() >= '6.1.0') { if ($this->getExtVersion() >= '6.1.0') {
$arg .= ' --enable-swoole-stdext'; $arg .= ' --enable-swoole-stdext';

View File

@@ -1,12 +0,0 @@
<?php
declare(strict_types=1);
namespace SPC\builder\freebsd\library;
class libmpdec extends BSDLibraryBase
{
use \SPC\builder\unix\library\libmpdec;
public const NAME = 'libmpdec';
}

View File

@@ -11,8 +11,6 @@ use SPC\store\Config;
use SPC\store\DirDiff; use SPC\store\DirDiff;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\store\SourcePatcher; use SPC\store\SourcePatcher;
use SPC\toolchain\ToolchainManager;
use SPC\toolchain\ZigToolchain;
use SPC\util\GlobalEnvManager; use SPC\util\GlobalEnvManager;
use SPC\util\SPCConfigUtil; use SPC\util\SPCConfigUtil;
use SPC\util\SPCTarget; use SPC\util\SPCTarget;
@@ -67,8 +65,7 @@ class LinuxBuilder extends UnixBuilderBase
// php 8.5 contains opcache extension by default, // php 8.5 contains opcache extension by default,
// if opcache_jit is enabled for 8.5 or opcache enabled, // if opcache_jit is enabled for 8.5 or opcache enabled,
// we need to disable undefined behavior sanitizer. // we need to disable undefined behavior sanitizer.
$compiler_extra = getenv('SPC_COMPILER_EXTRA') ?: ''; f_putenv('SPC_COMPILER_EXTRA=-fno-sanitize=undefined');
f_putenv('SPC_COMPILER_EXTRA=' . trim($compiler_extra . ' -fno-sanitize=undefined'));
} }
if ($this->getOption('enable-zts', false)) { if ($this->getOption('enable-zts', false)) {
@@ -165,7 +162,7 @@ class LinuxBuilder extends UnixBuilderBase
throw new WrongUsageException( throw new WrongUsageException(
"You're building against musl libc statically (the default on Linux), but you're trying to build shared extensions.\n" . "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" . '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, use SPC_TARGET="native-native-musl -dynamic" to link against musl libc dynamically using `zig cc` or use SPC_MUSL_DYNAMIC=true on alpine.' '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...'); logger()->info('Building shared extensions...');
@@ -269,11 +266,6 @@ class LinuxBuilder extends UnixBuilderBase
*/ */
protected function buildEmbed(): void protected function buildEmbed(): void
{ {
$compiler_extra = getenv('SPC_COMPILER_EXTRA') ?: '';
if (!str_contains($compiler_extra, '-lcompiler_rt') && ToolchainManager::getToolchainClass() === ZigToolchain::class) {
$compiler_extra = trim($compiler_extra . ' -lcompiler_rt');
GlobalEnvManager::putenv("SPC_COMPILER_EXTRA={$compiler_extra}");
}
$sharedExts = array_filter($this->exts, static fn ($ext) => $ext->isBuildShared()); $sharedExts = array_filter($this->exts, static fn ($ext) => $ext->isBuildShared());
$sharedExts = array_filter($sharedExts, static function ($ext) { $sharedExts = array_filter($sharedExts, static function ($ext) {
return Config::getExt($ext->getName(), 'build-with-php') === true; return Config::getExt($ext->getName(), 'build-with-php') === true;

View File

@@ -1,12 +0,0 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class libmpdec extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libmpdec;
public const NAME = 'libmpdec';
}

View File

@@ -1,12 +0,0 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
class libmpdec extends MacOSLibraryBase
{
use \SPC\builder\unix\library\libmpdec;
public const NAME = 'libmpdec';
}

View File

@@ -50,7 +50,7 @@ trait UnixSystemUtilTrait
$defined = array_unique($defined); $defined = array_unique($defined);
sort($defined); sort($defined);
// export // export
if (SPCTarget::getTargetOS() === 'Linux' && ToolchainManager::getToolchainClass() !== ZigToolchain::class) { if (SPCTarget::getTargetOS() === 'Linux') {
file_put_contents("{$lib_file}.dynsym", "{\n" . implode("\n", array_map(fn ($x) => " {$x};", $defined)) . "};\n"); file_put_contents("{$lib_file}.dynsym", "{\n" . implode("\n", array_map(fn ($x) => " {$x};", $defined)) . "};\n");
} else { } else {
file_put_contents("{$lib_file}.dynsym", implode("\n", $defined) . "\n"); file_put_contents("{$lib_file}.dynsym", implode("\n", $defined) . "\n");

View File

@@ -365,7 +365,6 @@ abstract class UnixBuilderBase extends BuilderBase
$frankenphpAppPath = $this->getOption('with-frankenphp-app'); $frankenphpAppPath = $this->getOption('with-frankenphp-app');
if ($frankenphpAppPath) { if ($frankenphpAppPath) {
$frankenphpAppPath = trim($frankenphpAppPath, "\"'");
if (!is_dir($frankenphpAppPath)) { if (!is_dir($frankenphpAppPath)) {
throw new WrongUsageException("The path provided to --with-frankenphp-app is not a valid directory: {$frankenphpAppPath}"); throw new WrongUsageException("The path provided to --with-frankenphp-app is not a valid directory: {$frankenphpAppPath}");
} }
@@ -456,17 +455,14 @@ abstract class UnixBuilderBase extends BuilderBase
'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs}", 'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs}",
'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' . 'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' .
'-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . '-ldflags \"-linkmode=external ' . $extLdFlags . ' ' .
'-X \'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy\' ' .
'-X \'github.com/caddyserver/caddy/v2.CustomBinaryName=frankenphp\' ' .
'-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' . '-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' .
"v{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " . "v{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " .
"-tags={$muslTags}nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}", "-tags={$muslTags}nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}",
'LD_LIBRARY_PATH' => BUILD_LIB_PATH, 'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
], ...GoXcaddy::getEnvironment()]; ], ...GoXcaddy::getEnvironment()];
$pgo = file_exists("{$frankenphpSourceDir}/caddy/frankenphp/default.pgo") ? "--pgo {$frankenphpSourceDir}/caddy/frankenphp/default.pgo " : '';
shell()->cd(BUILD_BIN_PATH) shell()->cd(BUILD_BIN_PATH)
->setEnv($env) ->setEnv($env)
->exec("xcaddy build --output frankenphp {$pgo}{$xcaddyModules}"); ->exec("xcaddy build --output frankenphp {$xcaddyModules}");
$this->deploySAPIBinary(BUILD_TARGET_FRANKENPHP); $this->deploySAPIBinary(BUILD_TARGET_FRANKENPHP);
} }

View File

@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\store\FileSystem;
use SPC\util\executor\UnixCMakeExecutor; use SPC\util\executor\UnixCMakeExecutor;
trait curl trait curl
@@ -33,16 +32,8 @@ trait curl
) )
->build(); ->build();
// patch pkgconf
$this->patchPkgconfPrefix(['libcurl.pc']); $this->patchPkgconfPrefix(['libcurl.pc']);
// On glibc <2.28 without built-in pthreads, FindThreads sets
// INTERFACE_LINK_LIBRARIES to '-lpthread'
// curls .pc generator walks and prepends '-l' to each
// entry, resulting in -l-lpthread
FileSystem::replaceFileRegex(
BUILD_LIB_PATH . '/pkgconfig/libcurl.pc',
'/-l(-l\S+)/',
'$1'
);
shell()->cd(BUILD_LIB_PATH . '/cmake/CURL/') shell()->cd(BUILD_LIB_PATH . '/cmake/CURL/')
->exec("sed -ie 's|\"/lib/libcurl.a\"|\"" . BUILD_LIB_PATH . "/libcurl.a\"|g' CURLTargets-release.cmake"); ->exec("sed -ie 's|\"/lib/libcurl.a\"|\"" . BUILD_LIB_PATH . "/libcurl.a\"|g' CURLTargets-release.cmake");
} }

View File

@@ -13,8 +13,8 @@ trait freetype
{ {
$cmake = UnixCMakeExecutor::create($this) $cmake = UnixCMakeExecutor::create($this)
->optionalLib('libpng', ...cmake_boolean_args('FT_DISABLE_PNG', true)) ->optionalLib('libpng', ...cmake_boolean_args('FT_DISABLE_PNG', true))
->addConfigureArgs('-DFT_DISABLE_BZIP2=ON') ->optionalLib('bzip2', ...cmake_boolean_args('FT_DISABLE_BZIP2', true))
->addConfigureArgs('-DFT_DISABLE_BROTLI=ON') ->optionalLib('brotli', ...cmake_boolean_args('FT_DISABLE_BROTLI', true))
->addConfigureArgs('-DFT_DISABLE_HARFBUZZ=ON'); ->addConfigureArgs('-DFT_DISABLE_HARFBUZZ=ON');
// fix cmake 4.0 compatibility // fix cmake 4.0 compatibility

View File

@@ -4,8 +4,6 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\toolchain\ToolchainManager;
use SPC\toolchain\ZigToolchain;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
use SPC\util\SPCConfigUtil; use SPC\util\SPCConfigUtil;
@@ -15,10 +13,7 @@ trait krb5
{ {
$origin_source_dir = $this->source_dir; $origin_source_dir = $this->source_dir;
$this->source_dir .= '/src'; $this->source_dir .= '/src';
shell()->cd($this->source_dir)->exec('ls -lah'); shell()->cd($this->source_dir)->exec('autoreconf -if');
if (!file_exists($this->source_dir . '/configure')) {
shell()->cd($this->source_dir)->exec('autoreconf -if');
}
$libs = array_map(fn ($x) => $x->getName(), $this->getDependencies(true)); $libs = array_map(fn ($x) => $x->getName(), $this->getDependencies(true));
$spc = new SPCConfigUtil($this->builder, ['no_php' => true, 'libs_only_deps' => true]); $spc = new SPCConfigUtil($this->builder, ['no_php' => true, 'libs_only_deps' => true]);
$config = $spc->config(libraries: $libs, include_suggest_lib: $this->builder->getOption('with-suggested-libs', false)); $config = $spc->config(libraries: $libs, include_suggest_lib: $this->builder->getOption('with-suggested-libs', false));
@@ -41,16 +36,12 @@ trait krb5
$extraEnv['LDFLAGS'] = '-framework Kerberos'; $extraEnv['LDFLAGS'] = '-framework Kerberos';
$args[] = 'ac_cv_func_secure_getenv=no'; $args[] = 'ac_cv_func_secure_getenv=no';
} }
$make = UnixAutoconfExecutor::create($this) UnixAutoconfExecutor::create($this)
->appendEnv($extraEnv) ->appendEnv($extraEnv)
->optionalLib('ldap', '--with-ldap', '--without-ldap') ->optionalLib('ldap', '--with-ldap', '--without-ldap')
->optionalLib('libedit', '--with-libedit', '--without-libedit') ->optionalLib('libedit', '--with-libedit', '--without-libedit')
->configure(...$args); ->configure(...$args)
->make();
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
$make->exec('find . -name Makefile -exec sed -i "s/-Werror=incompatible-pointer-types//g" {} +');
}
$make->make();
$this->patchPkgconfPrefix([ $this->patchPkgconfPrefix([
'krb5-gssapi.pc', 'krb5-gssapi.pc',
'krb5.pc', 'krb5.pc',

View File

@@ -11,11 +11,6 @@ trait libavif
protected function build(): void protected function build(): void
{ {
UnixCMakeExecutor::create($this) UnixCMakeExecutor::create($this)
->optionalLib('libaom', '-DAVIF_CODEC_AOM=SYSTEM', '-DAVIF_CODEC_AOM=OFF')
->optionalLib('libsharpyuv', '-DAVIF_LIBSHARPYUV=SYSTEM', '-DAVIF_LIBSHARPYUV=OFF')
->optionalLib('libjpeg', '-DAVIF_JPEG=SYSTEM', '-DAVIF_JPEG=OFF')
->optionalLib('libxml2', '-DAVIF_LIBXML2=SYSTEM', '-DAVIF_LIBXML2=OFF')
->optionalLib('libpng', '-DAVIF_LIBPNG=SYSTEM', '-DAVIF_LIBPNG=OFF')
->addConfigureArgs('-DAVIF_LIBYUV=OFF') ->addConfigureArgs('-DAVIF_LIBYUV=OFF')
->build(); ->build();
// patch pkgconfig // patch pkgconfig

View File

@@ -11,11 +11,7 @@ trait libde265
protected function build(): void protected function build(): void
{ {
UnixCMakeExecutor::create($this) UnixCMakeExecutor::create($this)
->addConfigureArgs( ->addConfigureArgs('-DENABLE_SDL=OFF')
'-DENABLE_SDL=OFF',
'-DENABLE_DECODER=OFF',
'-DHAVE_NEON=OFF',
)
->build(); ->build();
$this->patchPkgconfPrefix(['libde265.pc']); $this->patchPkgconfPrefix(['libde265.pc']);
} }

View File

@@ -11,28 +11,15 @@ trait libheif
{ {
public function patchBeforeBuild(): bool public function patchBeforeBuild(): bool
{ {
$patched = false;
if (!str_contains(file_get_contents($this->source_dir . '/CMakeLists.txt'), 'libbrotlienc')) { if (!str_contains(file_get_contents($this->source_dir . '/CMakeLists.txt'), 'libbrotlienc')) {
FileSystem::replaceFileStr( FileSystem::replaceFileStr(
$this->source_dir . '/CMakeLists.txt', $this->source_dir . '/CMakeLists.txt',
'list(APPEND REQUIRES_PRIVATE "libbrotlidec")', 'list(APPEND REQUIRES_PRIVATE "libbrotlidec")',
'list(APPEND REQUIRES_PRIVATE "libbrotlidec")' . "\n" . ' list(APPEND REQUIRES_PRIVATE "libbrotlienc")' 'list(APPEND REQUIRES_PRIVATE "libbrotlidec")' . "\n" . ' list(APPEND REQUIRES_PRIVATE "libbrotlienc")'
); );
$patched = true; return true;
} }
// libheif 1.22+ ships a C-incompatible header: `struct heif_bad_pixel` return false;
$heif_properties = $this->source_dir . '/libheif/api/libheif/heif_properties.h';
if (file_exists($heif_properties)
&& str_contains(file_get_contents($heif_properties), 'struct heif_bad_pixel { uint32_t row; uint32_t column; };')
) {
FileSystem::replaceFileStr(
$heif_properties,
'struct heif_bad_pixel { uint32_t row; uint32_t column; };',
'typedef struct heif_bad_pixel { uint32_t row; uint32_t column; } heif_bad_pixel;'
);
$patched = true;
}
return $patched;
} }
protected function build(): void protected function build(): void

View File

@@ -14,10 +14,6 @@ trait libjpeg
->addConfigureArgs( ->addConfigureArgs(
'-DENABLE_STATIC=ON', '-DENABLE_STATIC=ON',
'-DENABLE_SHARED=OFF', '-DENABLE_SHARED=OFF',
'-DWITH_SYSTEM_ZLIB=ON',
'-DWITH_TOOLS=OFF',
'-DWITH_TESTS=OFF',
'-DWITH_SIMD=OFF',
) )
->build(); ->build();
// patch pkgconfig // patch pkgconfig

View File

@@ -1,17 +0,0 @@
<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\util\executor\UnixAutoconfExecutor;
trait libmpdec
{
protected function build(): void
{
UnixAutoconfExecutor::create($this)
->configure('--disable-cxx --disable-shared --enable-static')
->make();
}
}

View File

@@ -4,14 +4,29 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem; use SPC\store\FileSystem;
use SPC\util\PkgConfigUtil; use SPC\util\PkgConfigUtil;
use SPC\util\SPCConfigUtil; use SPC\util\SPCConfigUtil;
use SPC\util\SPCTarget;
trait postgresql trait postgresql
{ {
public function patchBeforeBuild(): bool public function patchBeforeBuild(): bool
{ {
// fix aarch64 build on glibc 2.17 (e.g. CentOS 7)
if (SPCTarget::getLibcVersion() === '2.17' && GNU_ARCH === 'aarch64') {
try {
// FileSystem::replaceFileStr("{$this->source_dir}/src/port/pg_popcount_aarch64.c", 'HWCAP_SVE', '0');
FileSystem::replaceFileStr(
"{$this->source_dir}/src/port/pg_crc32c_armv8_choose.c",
'#if defined(__linux__) && !defined(__aarch64__) && !defined(HWCAP2_CRC32)',
'#if defined(__linux__) && !defined(HWCAP_CRC32)'
);
} catch (FileSystemException) {
// allow file not-existence to make it compatible with old and new version
}
}
// skip the test on platforms where libpq infrastructure may be provided by statically-linked libraries // skip the test on platforms where libpq infrastructure may be provided by statically-linked libraries
FileSystem::replaceFileStr("{$this->source_dir}/src/interfaces/libpq/Makefile", 'invokes exit\'; exit 1;', 'invokes exit\';'); FileSystem::replaceFileStr("{$this->source_dir}/src/interfaces/libpq/Makefile", 'invokes exit\'; exit 1;', 'invokes exit\';');
// disable shared libs build // disable shared libs build
@@ -93,7 +108,8 @@ trait postgresql
// remove dynamic libs // remove dynamic libs
shell()->cd($this->source_dir . '/build') shell()->cd($this->source_dir . '/build')
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so*") ->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so.*")
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so")
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.dylib"); ->exec("rm -rf {$this->getBuildRootPath()}/lib/*.dylib");
FileSystem::replaceFileStr("{$this->getLibDir()}/pkgconfig/libpq.pc", '-lldap', '-lldap -llber'); FileSystem::replaceFileStr("{$this->getLibDir()}/pkgconfig/libpq.pc", '-lldap', '-lldap -llber');

View File

@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use SPC\store\FileSystem;
use SPC\util\executor\UnixAutoconfExecutor; use SPC\util\executor\UnixAutoconfExecutor;
trait unixodbc trait unixodbc
@@ -31,15 +30,7 @@ trait unixodbc
'--enable-gui=no', '--enable-gui=no',
) )
->make(); ->make();
$pkgConfigs = ['odbc.pc', 'odbccr.pc', 'odbcinst.pc']; $this->patchPkgconfPrefix(['odbc.pc', 'odbccr.pc', 'odbcinst.pc']);
$this->patchPkgconfPrefix($pkgConfigs);
foreach ($pkgConfigs as $file) {
FileSystem::replaceFileStr(
BUILD_LIB_PATH . "/pkgconfig/{$file}",
'$(top_build_prefix)libltdl/libltdlc.la',
''
);
}
$this->patchLaDependencyPrefix(); $this->patchLaDependencyPrefix();
} }
} }

View File

@@ -1,36 +0,0 @@
<?php
declare(strict_types=1);
namespace SPC\builder\windows\library;
use SPC\store\FileSystem;
class brotli extends WindowsLibraryBase
{
public const NAME = 'brotli';
protected function build(): void
{
// reset cmake
FileSystem::resetDir($this->source_dir . '\build');
// start build
cmd()->cd($this->source_dir)
->execWithWrapper(
$this->builder->makeSimpleWrapper('cmake'),
'-B build ' .
'-A x64 ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DBUILD_SHARED_LIBS=OFF ' .
'-DBROTLI_BUILD_TOOLS=OFF ' .
'-DBROTLI_BUNDLED_MODE=OFF ' .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' '
)
->execWithWrapper(
$this->builder->makeSimpleWrapper('cmake'),
"--build build --config Release --target install -j{$this->builder->concurrency}"
);
}
}

View File

@@ -24,8 +24,6 @@ class freetype extends WindowsLibraryBase
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'-DCMAKE_BUILD_TYPE=Release ' . '-DCMAKE_BUILD_TYPE=Release ' .
'-DBUILD_SHARED_LIBS=OFF ' . '-DBUILD_SHARED_LIBS=OFF ' .
'-DFT_DISABLE_BROTLI=TRUE ' .
'-DFT_DISABLE_BZIP2=TRUE ' .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' '
) )
->execWithWrapper( ->execWithWrapper(

View File

@@ -12,16 +12,16 @@ class icu_static_win extends WindowsLibraryBase
protected function build(): void protected function build(): void
{ {
copy("{$this->source_dir}\\lib\\icudt.lib", "{$this->getLibDir()}\\icudt.lib"); copy("{$this->source_dir}\\x64-windows-static\\lib\\icudt.lib", "{$this->getLibDir()}\\icudt.lib");
copy("{$this->source_dir}\\lib\\icuin.lib", "{$this->getLibDir()}\\icuin.lib"); copy("{$this->source_dir}\\x64-windows-static\\lib\\icuin.lib", "{$this->getLibDir()}\\icuin.lib");
copy("{$this->source_dir}\\lib\\icuio.lib", "{$this->getLibDir()}\\icuio.lib"); copy("{$this->source_dir}\\x64-windows-static\\lib\\icuio.lib", "{$this->getLibDir()}\\icuio.lib");
copy("{$this->source_dir}\\lib\\icuuc.lib", "{$this->getLibDir()}\\icuuc.lib"); copy("{$this->source_dir}\\x64-windows-static\\lib\\icuuc.lib", "{$this->getLibDir()}\\icuuc.lib");
// create libpq folder in buildroot/includes/libpq // create libpq folder in buildroot/includes/libpq
if (!file_exists("{$this->getIncludeDir()}\\unicode")) { if (!file_exists("{$this->getIncludeDir()}\\unicode")) {
mkdir("{$this->getIncludeDir()}\\unicode"); mkdir("{$this->getIncludeDir()}\\unicode");
} }
FileSystem::copyDir("{$this->source_dir}\\include\\unicode", "{$this->getIncludeDir()}\\unicode"); FileSystem::copyDir("{$this->source_dir}\\x64-windows-static\\include\\unicode", "{$this->getIncludeDir()}\\unicode");
} }
} }

View File

@@ -1,41 +0,0 @@
<?php
declare(strict_types=1);
namespace SPC\builder\windows\library;
use SPC\store\FileSystem;
class libaom extends WindowsLibraryBase
{
public const NAME = 'libaom';
protected function build(): void
{
// libaom source tree contains a build/cmake/ directory with its own
// cmake modules, so we must use a different name for the build dir.
FileSystem::resetDir($this->source_dir . '\builddir');
// start build
cmd()->cd($this->source_dir)
->execWithWrapper(
$this->builder->makeSimpleWrapper('cmake'),
'-S . -B builddir ' .
'-A x64 ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DBUILD_SHARED_LIBS=OFF ' .
'-DAOM_TARGET_CPU=generic ' .
'-DENABLE_DOCS=OFF ' .
'-DENABLE_EXAMPLES=OFF ' .
'-DENABLE_TESTDATA=OFF ' .
'-DENABLE_TESTS=OFF ' .
'-DENABLE_TOOLS=OFF ' .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' '
)
->execWithWrapper(
$this->builder->makeSimpleWrapper('cmake'),
"--build builddir --config Release --target install -j{$this->builder->concurrency}"
);
}
}

View File

@@ -28,7 +28,6 @@ class libjpeg extends WindowsLibraryBase
'-DENABLE_STATIC=ON ' . '-DENABLE_STATIC=ON ' .
'-DBUILD_TESTING=OFF ' . '-DBUILD_TESTING=OFF ' .
'-DWITH_JAVA=OFF ' . '-DWITH_JAVA=OFF ' .
'-DWITH_SIMD=OFF ' .
'-DWITH_CRT_DLL=OFF ' . '-DWITH_CRT_DLL=OFF ' .
"-DENABLE_ZLIB_COMPRESSION={$zlib} " . "-DENABLE_ZLIB_COMPRESSION={$zlib} " .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' '

View File

@@ -1,31 +0,0 @@
<?php
declare(strict_types=1);
namespace SPC\builder\windows\library;
class libmpdec extends WindowsLibraryBase
{
public const NAME = 'libmpdec';
protected function build(): void
{
$makefile_dir = $this->source_dir . '\libmpdec';
$nmake = $this->builder->makeSimpleWrapper('nmake /nologo');
cmd()->cd($makefile_dir)
->exec('copy /y Makefile.vc Makefile')
->execWithWrapper($nmake, 'clean')
->execWithWrapper($nmake, 'MACHINE=x64');
// Copy static lib (rename from versioned name to libmpdec_a.lib)
$libs = glob($makefile_dir . '\libmpdec-*.lib');
foreach ($libs as $lib) {
if (!str_contains($lib, '.dll.')) {
copy($lib, BUILD_LIB_PATH . '\libmpdec_a.lib');
break;
}
}
copy($makefile_dir . '\mpdecimal.h', BUILD_INCLUDE_PATH . '\mpdecimal.h');
}
}

View File

@@ -29,7 +29,6 @@ class ngtcp2 extends WindowsLibraryBase
'-DBUILD_SHARED_LIBS=OFF ' . '-DBUILD_SHARED_LIBS=OFF ' .
'-DENABLE_STATIC_CRT=ON ' . '-DENABLE_STATIC_CRT=ON ' .
'-DENABLE_LIB_ONLY=ON ' . '-DENABLE_LIB_ONLY=ON ' .
'-DENABLE_OPENSSL=OFF ' .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' '
) )
->execWithWrapper( ->execWithWrapper(

View File

@@ -10,9 +10,9 @@ class postgresql_win extends WindowsLibraryBase
protected function build(): void protected function build(): void
{ {
copy($this->source_dir . '\lib\libpq.lib', BUILD_LIB_PATH . '\libpq.lib'); copy($this->source_dir . '\pgsql\lib\libpq.lib', BUILD_LIB_PATH . '\libpq.lib');
copy($this->source_dir . '\lib\libpgport.lib', BUILD_LIB_PATH . '\libpgport.lib'); copy($this->source_dir . '\pgsql\lib\libpgport.lib', BUILD_LIB_PATH . '\libpgport.lib');
copy($this->source_dir . '\lib\libpgcommon.lib', BUILD_LIB_PATH . '\libpgcommon.lib'); copy($this->source_dir . '\pgsql\lib\libpgcommon.lib', BUILD_LIB_PATH . '\libpgcommon.lib');
// create libpq folder in buildroot/includes/libpq // create libpq folder in buildroot/includes/libpq
if (!file_exists(BUILD_INCLUDE_PATH . '\libpq')) { if (!file_exists(BUILD_INCLUDE_PATH . '\libpq')) {
@@ -21,7 +21,7 @@ class postgresql_win extends WindowsLibraryBase
$headerFiles = ['libpq-fe.h', 'postgres_ext.h', 'pg_config_ext.h', 'libpq\libpq-fs.h']; $headerFiles = ['libpq-fe.h', 'postgres_ext.h', 'pg_config_ext.h', 'libpq\libpq-fs.h'];
foreach ($headerFiles as $header) { foreach ($headerFiles as $header) {
copy($this->source_dir . '\include\\' . $header, BUILD_INCLUDE_PATH . '\\' . $header); copy($this->source_dir . '\pgsql\include\\' . $header, BUILD_INCLUDE_PATH . '\\' . $header);
} }
} }
} }

View File

@@ -31,24 +31,8 @@ class zlib extends WindowsLibraryBase
$this->builder->makeSimpleWrapper('cmake'), $this->builder->makeSimpleWrapper('cmake'),
"--build build --config Release --target install -j{$this->builder->concurrency}" "--build build --config Release --target install -j{$this->builder->concurrency}"
); );
$detect_list = [ copy(BUILD_LIB_PATH . '\zlibstatic.lib', BUILD_LIB_PATH . '\zlib_a.lib');
'zlibstatic.lib', unlink(BUILD_ROOT_PATH . '\bin\zlib.dll');
'zs.lib', unlink(BUILD_LIB_PATH . '\zlib.lib');
'libzs.lib',
'libz.lib',
];
foreach ($detect_list as $item) {
if (file_exists(BUILD_LIB_PATH . '\\' . $item)) {
FileSystem::copy(BUILD_LIB_PATH . '\\' . $item, BUILD_LIB_PATH . '\zlib_a.lib');
FileSystem::copy(BUILD_LIB_PATH . '\\' . $item, BUILD_LIB_PATH . '\zlibstatic.lib');
break;
}
}
FileSystem::removeFileIfExists(BUILD_ROOT_PATH . '\bin\zlib.dll');
FileSystem::removeFileIfExists(BUILD_LIB_PATH . '\zlib.lib');
FileSystem::removeFileIfExists(BUILD_LIB_PATH . '\libz.dll');
FileSystem::removeFileIfExists(BUILD_LIB_PATH . '\libz.lib');
FileSystem::removeFileIfExists(BUILD_LIB_PATH . '\z.lib');
FileSystem::removeFileIfExists(BUILD_LIB_PATH . '\z.dll');
} }
} }

View File

@@ -30,7 +30,7 @@ class DownloadCommand extends BaseCommand
$this->addArgument('sources', InputArgument::REQUIRED, 'The sources will be compiled, comma separated'); $this->addArgument('sources', InputArgument::REQUIRED, 'The sources will be compiled, comma separated');
$this->addOption('shallow-clone', null, null, 'Clone shallow'); $this->addOption('shallow-clone', null, null, 'Clone shallow');
$this->addOption('with-openssl11', null, null, 'Use openssl 1.1'); $this->addOption('with-openssl11', null, null, 'Use openssl 1.1');
$this->addOption('with-php', null, InputOption::VALUE_REQUIRED, 'version in major.minor format (default 8.5)', '8.5'); $this->addOption('with-php', null, InputOption::VALUE_REQUIRED, 'version in major.minor format (default 8.4)', '8.4');
$this->addOption('clean', null, null, 'Clean old download cache and source before fetch'); $this->addOption('clean', null, null, 'Clean old download cache and source before fetch');
$this->addOption('all', 'A', null, 'Fetch all sources that static-php-cli needed'); $this->addOption('all', 'A', null, 'Fetch all sources that static-php-cli needed');
$this->addOption('custom-url', 'U', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Specify custom source download url, e.g "php-src:https://downloads.php.net/~eric/php-8.3.0beta1.tar.gz"'); $this->addOption('custom-url', 'U', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Specify custom source download url, e.g "php-src:https://downloads.php.net/~eric/php-8.3.0beta1.tar.gz"');

View File

@@ -109,7 +109,7 @@ class LinuxToolCheckList
public function fixBuildTools(array $distro, array $missing): bool public function fixBuildTools(array $distro, array $missing): bool
{ {
$install_cmd = match ($distro['dist']) { $install_cmd = match ($distro['dist']) {
'ubuntu', 'debian', 'linuxmint', 'Deepin' => 'apt-get install -y', 'ubuntu', 'debian', 'Deepin' => 'apt-get install -y',
'alpine' => 'apk add', 'alpine' => 'apk add',
'redhat' => 'dnf install -y', 'redhat' => 'dnf install -y',
'centos' => 'yum install -y', 'centos' => 'yum install -y',

View File

@@ -98,50 +98,31 @@ class Downloader
{ {
logger()->debug("finding {$name} source from github {$type} tarball"); logger()->debug("finding {$name} source from github {$type} tarball");
$source['query'] ??= ''; $source['query'] ??= '';
$data = json_decode(self::curlExec(
url: "https://api.github.com/repos/{$source['repo']}/{$type}{$source['query']}",
hooks: [[CurlHook::class, 'setupGithubToken']],
retries: self::getRetryAttempts()
), true, 512, JSON_THROW_ON_ERROR);
// Use /releases/latest when possible: it returns the semantically latest stable $url = null;
// release regardless of publish order, avoiding issues with concurrent release branches. foreach ($data as $rel) {
if ($type === 'releases' && empty($source['query']) && !($source['match'] ?? null)) { if (($rel['prerelease'] ?? false) === true && ($source['prefer-stable'] ?? false)) {
$data = json_decode(self::curlExec( continue;
url: "https://api.github.com/repos/{$source['repo']}/releases/latest",
hooks: [[CurlHook::class, 'setupGithubToken']],
retries: self::getRetryAttempts()
), true, 512, JSON_THROW_ON_ERROR);
if (!is_array($data) || empty($data['tarball_url'])) {
throw new DownloaderException("failed to find {$name} source");
} }
$url = $data['tarball_url']; if (($rel['draft'] ?? false) === true && (($source['prefer-stable'] ?? false) || !$rel['tarball_url'])) {
$version = $data['tag_name'] ?? $data['name'] ?? null; continue;
} else {
$data = json_decode(self::curlExec(
url: "https://api.github.com/repos/{$source['repo']}/{$type}{$source['query']}",
hooks: [[CurlHook::class, 'setupGithubToken']],
retries: self::getRetryAttempts()
), true, 512, JSON_THROW_ON_ERROR);
$url = null;
$version = null;
foreach ($data as $rel) {
if (($rel['prerelease'] ?? false) === true && ($source['prefer-stable'] ?? false)) {
continue;
}
if (($rel['draft'] ?? false) === true && (($source['prefer-stable'] ?? false) || !$rel['tarball_url'])) {
continue;
}
if (!($source['match'] ?? null)) {
$url = $rel['tarball_url'] ?? null;
$version = $rel['tag_name'] ?? $rel['name'] ?? null;
break;
}
if (preg_match('|' . $source['match'] . '|', $rel['tarball_url'])) {
$url = $rel['tarball_url'];
$version = $rel['tag_name'] ?? $rel['name'] ?? null;
break;
}
} }
if (!$url) { if (!($source['match'] ?? null)) {
throw new DownloaderException("failed to find {$name} source"); $url = $rel['tarball_url'] ?? null;
break;
} }
if (preg_match('|' . $source['match'] . '|', $rel['tarball_url'])) {
$url = $rel['tarball_url'];
break;
}
}
if (!$url) {
throw new DownloaderException("failed to find {$name} source");
} }
$headers = self::curlExec( $headers = self::curlExec(
url: $url, url: $url,
@@ -153,7 +134,7 @@ class Downloader
if ($matches) { if ($matches) {
$filename = $matches['filename']; $filename = $matches['filename'];
} else { } else {
$filename = "{$name}-" . ($version ?? 'latest') . '.tar.gz'; $filename = "{$name}-" . ($type === 'releases' ? $data['tag_name'] : $data['name']) . '.tar.gz';
} }
return [$url, $filename]; return [$url, $filename];

View File

@@ -152,7 +152,7 @@ class FileSystem
$src_path = FileSystem::convertPath($from); $src_path = FileSystem::convertPath($from);
switch (PHP_OS_FAMILY) { switch (PHP_OS_FAMILY) {
case 'Windows': case 'Windows':
f_passthru('xcopy "' . $src_path . '" "' . $dst_path . '" /s/e/y/i'); f_passthru('xcopy "' . $src_path . '" "' . $dst_path . '" /s/e/v/y/i');
break; break;
case 'Linux': case 'Linux':
case 'Darwin': case 'Darwin':

View File

@@ -22,7 +22,7 @@ class SourcePatcher
FileSystem::addSourceExtractHook('swoole', [__CLASS__, 'patchSwoole']); FileSystem::addSourceExtractHook('swoole', [__CLASS__, 'patchSwoole']);
FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchPhpLibxml212']); FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchPhpLibxml212']);
FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchGDWin32']); FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchGDWin32']);
// FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchFfiCentos7FixO3strncmp']); FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchFfiCentos7FixO3strncmp']);
FileSystem::addSourceExtractHook('sqlsrv', [__CLASS__, 'patchSQLSRVWin32']); FileSystem::addSourceExtractHook('sqlsrv', [__CLASS__, 'patchSQLSRVWin32']);
FileSystem::addSourceExtractHook('pdo_sqlsrv', [__CLASS__, 'patchSQLSRVWin32']); FileSystem::addSourceExtractHook('pdo_sqlsrv', [__CLASS__, 'patchSQLSRVWin32']);
FileSystem::addSourceExtractHook('pdo_sqlsrv', [__CLASS__, 'patchSQLSRVPhp85']); FileSystem::addSourceExtractHook('pdo_sqlsrv', [__CLASS__, 'patchSQLSRVPhp85']);
@@ -95,10 +95,6 @@ class SourcePatcher
// patch php-src/build/php.m4 PKG_CHECK_MODULES -> PKG_CHECK_MODULES_STATIC // patch php-src/build/php.m4 PKG_CHECK_MODULES -> PKG_CHECK_MODULES_STATIC
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/build/php.m4', 'PKG_CHECK_MODULES(', 'PKG_CHECK_MODULES_STATIC('); FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/build/php.m4', 'PKG_CHECK_MODULES(', 'PKG_CHECK_MODULES_STATIC(');
if ($builder->getPHPVersionID() >= 80300 && $builder->getPHPVersionID() < 80400) {
self::patchFile('spc_fix_avx512_cache_before_80400.patch', SOURCE_PATH . '/php-src');
}
if ($builder->getOption('enable-micro-win32')) { if ($builder->getOption('enable-micro-win32')) {
self::patchMicroWin32(); self::patchMicroWin32();
} else { } else {
@@ -129,15 +125,6 @@ class SourcePatcher
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/have_capstone="yes"/', 'have_capstone="no"'); FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/have_capstone="yes"/', 'have_capstone="no"');
} }
// PHP 8.2 and below: bcmath libbcmath uses K&R style C function
if (is_unix() && $builder->getPHPVersionID() < 80300) {
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/configure',
"for ac_arg in '' -std=gnu23",
"for ac_arg in '' -std=gnu17",
);
}
if (file_exists(SOURCE_PATH . '/php-src/configure.ac.bak')) { if (file_exists(SOURCE_PATH . '/php-src/configure.ac.bak')) {
// restore configure.ac // restore configure.ac
FileSystem::restoreBackupFile(SOURCE_PATH . '/php-src/configure.ac'); FileSystem::restoreBackupFile(SOURCE_PATH . '/php-src/configure.ac');
@@ -647,13 +634,7 @@ class SourcePatcher
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/gd/libgd/gdft.c', '#ifndef MSWIN32', '#ifndef _WIN32'); FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/gd/libgd/gdft.c', '#ifndef MSWIN32', '#ifndef _WIN32');
} }
// custom config.w32, because official config.w32 is hard-coded many things // custom config.w32, because official config.w32 is hard-coded many things
if ($ver_id >= 80500) { $origin = $ver_id >= 80100 ? file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_81.w32') : file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_80.w32');
$origin = file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_85.w32');
} elseif ($ver_id >= 80100) {
$origin = file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_81.w32');
} else {
$origin = file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_80.w32');
}
file_put_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32.bak', file_get_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32')); file_put_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32.bak', file_get_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32'));
return file_put_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32', $origin) !== false; return file_put_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32', $origin) !== false;
} }

View File

@@ -30,8 +30,8 @@ class GoXcaddy extends CustomPackage
public function fetch(string $name, bool $force = false, ?array $config = null): void public function fetch(string $name, bool $force = false, ?array $config = null): void
{ {
$pkgroot = PKG_ROOT_PATH; $pkgroot = PKG_ROOT_PATH;
$go_exec = "{$pkgroot}/go-xcaddy/bin/go"; $go_exec = "{$pkgroot}/{$name}/bin/go";
$xcaddy_exec = "{$pkgroot}/go-xcaddy/bin/xcaddy"; $xcaddy_exec = "{$pkgroot}/{$name}/bin/xcaddy";
if ($force) { if ($force) {
FileSystem::removeDir("{$pkgroot}/{$name}"); FileSystem::removeDir("{$pkgroot}/{$name}");
} }
@@ -85,7 +85,7 @@ class GoXcaddy extends CustomPackage
'GOBIN' => "{$pkgroot}/go-xcaddy/bin", 'GOBIN' => "{$pkgroot}/go-xcaddy/bin",
'GOPATH' => "{$pkgroot}/go", 'GOPATH' => "{$pkgroot}/go",
]) ])
->exec('CGO_ENABLED=0 go install github.com/caddyserver/xcaddy/cmd/xcaddy@master'); ->exec('CC=cc go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest');
} }
public static function getEnvironment(): array public static function getEnvironment(): array

View File

@@ -6,21 +6,15 @@ namespace SPC\store\source;
use JetBrains\PhpStorm\ArrayShape; use JetBrains\PhpStorm\ArrayShape;
use SPC\exception\DownloaderException; use SPC\exception\DownloaderException;
use SPC\exception\SPCException;
use SPC\store\Downloader; use SPC\store\Downloader;
class PhpSource extends CustomSourceBase class PhpSource extends CustomSourceBase
{ {
public const string NAME = 'php-src'; public const NAME = 'php-src';
public const array WEB_PHP_DOMAINS = [
'https://www.php.net',
'https://phpmirror.static-php.dev',
];
public function fetch(bool $force = false, ?array $config = null, int $lock_as = SPC_DOWNLOAD_SOURCE): void public function fetch(bool $force = false, ?array $config = null, int $lock_as = SPC_DOWNLOAD_SOURCE): void
{ {
$major = defined('SPC_BUILD_PHP_VERSION') ? SPC_BUILD_PHP_VERSION : '8.5'; $major = defined('SPC_BUILD_PHP_VERSION') ? SPC_BUILD_PHP_VERSION : '8.4';
if ($major === 'git') { if ($major === 'git') {
Downloader::downloadSource('php-src', ['type' => 'git', 'url' => 'https://github.com/php/php-src.git', 'rev' => 'master'], $force); Downloader::downloadSource('php-src', ['type' => 'git', 'url' => 'https://github.com/php/php-src.git', 'rev' => 'master'], $force);
} else { } else {
@@ -34,26 +28,21 @@ class PhpSource extends CustomSourceBase
#[ArrayShape(['type' => 'string', 'path' => 'string', 'rev' => 'string', 'url' => 'string'])] #[ArrayShape(['type' => 'string', 'path' => 'string', 'rev' => 'string', 'url' => 'string'])]
public function getLatestPHPInfo(string $major_version): array public function getLatestPHPInfo(string $major_version): array
{ {
foreach (self::WEB_PHP_DOMAINS as $domain) { // 查找最新的小版本号
try { $info = json_decode(Downloader::curlExec(
$info = json_decode(Downloader::curlExec( url: "https://www.php.net/releases/index.php?json&version={$major_version}",
url: "{$domain}/releases/index.php?json&version={$major_version}", retries: (int) getenv('SPC_DOWNLOAD_RETRIES') ?: 0
retries: (int) getenv('SPC_DOWNLOAD_RETRIES') ?: 0 ), true);
), true); if (!isset($info['version'])) {
if (!isset($info['version'])) { throw new DownloaderException("Version {$major_version} not found.");
throw new DownloaderException("Version {$major_version} not found.");
}
$version = $info['version'];
return [
'type' => 'url',
'url' => "{$domain}/distributions/php-{$version}.tar.xz",
];
} catch (SPCException) {
logger()->warning('Failed to fetch latest PHP version for major version {$major_version} from {$domain}, trying next mirror if available.');
continue;
}
} }
// exception if all mirrors failed
throw new DownloaderException("Failed to fetch latest PHP version for major version {$major_version} from all tried mirrors."); $version = $info['version'];
// 从官网直接下载
return [
'type' => 'url',
'url' => "https://www.php.net/distributions/php-{$version}.tar.xz",
];
} }
} }

View File

@@ -393,7 +393,7 @@ class ConfigValidator
} }
// check php-version // check php-version
if (isset($craft['php-version'])) { if (isset($craft['php-version'])) {
// validate version, accept 8.x, 7.x, 8.x.x, 7.x.x, 8, 7 // validdate version, accept 8.x, 7.x, 8.x.x, 7.x.x, 8, 7
$version = strval($craft['php-version']); $version = strval($craft['php-version']);
if (!preg_match('/^(\d+)(\.\d+)?(\.\d+)?$/', $version, $matches)) { if (!preg_match('/^(\d+)(\.\d+)?(\.\d+)?$/', $version, $matches)) {
throw new ValidationException('Craft file php-version is invalid'); throw new ValidationException('Craft file php-version is invalid');

View File

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

View File

@@ -182,8 +182,7 @@ class UnixCMakeExecutor extends Executor
$target_arch = arch2gnu(php_uname('m')); $target_arch = arch2gnu(php_uname('m'));
$cflags = getenv('SPC_DEFAULT_C_FLAGS'); $cflags = getenv('SPC_DEFAULT_C_FLAGS');
$cc = getenv('CC'); $cc = getenv('CC');
$cxx = getenv('CXX'); $cxx = getenv('CCX');
$include = BUILD_INCLUDE_PATH;
logger()->debug("making cmake tool chain file for {$os} {$target_arch} with CFLAGS='{$cflags}'"); logger()->debug("making cmake tool chain file for {$os} {$target_arch} with CFLAGS='{$cflags}'");
$root = BUILD_ROOT_PATH; $root = BUILD_ROOT_PATH;
$pkgConfigExecutable = PkgConfigUtil::findPkgConfig(); $pkgConfigExecutable = PkgConfigUtil::findPkgConfig();
@@ -211,8 +210,6 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES "{$include}")
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES "{$include}")
set(CMAKE_EXE_LINKER_FLAGS "-ldl -lpthread -lm -lutil") set(CMAKE_EXE_LINKER_FLAGS "-ldl -lpthread -lm -lutil")
CMAKE; CMAKE;
// Whoops, linux may need CMAKE_AR sometimes // Whoops, linux may need CMAKE_AR sometimes

View File

@@ -1,12 +1,17 @@
#include <sapi/embed/php_embed.h> #include <sapi/embed/php_embed.h>
int main(int argc, char **argv) { int main(int argc,char **argv){
PHP_EMBED_START_BLOCK(argc, argv)
PHP_EMBED_START_BLOCK(argc,argv)
zend_file_handle file_handle; zend_file_handle file_handle;
zend_stream_init_filename(&file_handle, "embed.php");
if(!php_execute_script(&file_handle)) { zend_stream_init_filename(&file_handle,"embed.php");
if(!php_execute_script(&file_handle)){
php_printf("Failed to execute PHP script.\n"); php_printf("Failed to execute PHP script.\n");
} }
PHP_EMBED_END_BLOCK() PHP_EMBED_END_BLOCK()
return 0; return 0;
} }

View File

@@ -25,16 +25,12 @@ const DANGER_CMD = [
// spc internal extensions // spc internal extensions
const SPC_INTERNAL_EXTENSIONS = [ const SPC_INTERNAL_EXTENSIONS = [
'core', 'core',
'date',
'hash', 'hash',
'json', 'json',
'lexbor',
'pcre', 'pcre',
'random',
'reflection', 'reflection',
'spl', 'spl',
'standard', 'standard',
'uri',
]; ];
// spc extension alias // spc extension alias

View File

@@ -1,10 +0,0 @@
<?php
declare(strict_types=1);
assert(class_exists('Decimal\Decimal'));
assert(method_exists('Decimal\Decimal', 'valueOf'));
assert(0.1 + 0.2 !== 0.3);
$result = Decimal\Decimal::valueOf('0.1') + Decimal\Decimal::valueOf('0.2');
$expected = Decimal\Decimal::valueOf('0.3');
assert($result == $expected);

View File

@@ -31,6 +31,6 @@ if (file_exists('/etc/ssl/openssl.cnf')) {
} }
assert($valid); assert($valid);
} }
if (PHP_VERSION_ID >= 80500 && (!PHP_ZTS || PHP_OS_FAMILY !== 'Windows') && defined('OPENSSL_VERSION_NUMBER') && OPENSSL_VERSION_NUMBER >= 0x30200000) { if (PHP_VERSION_ID >= 80500 && defined('OPENSSL_VERSION_NUMBER') && OPENSSL_VERSION_NUMBER >= 0x30200000) {
assert(function_exists('openssl_password_hash')); assert(function_exists('openssl_password_hash'));
} }

View File

@@ -1,94 +0,0 @@
// vim:ft=javascript
ARG_WITH("gd", "Bundled GD support", "yes");
if (PHP_GD != "no") {
// check for gd.h (required)
if (!CHECK_HEADER_ADD_INCLUDE("gd.h", "CFLAGS_GD", PHP_GD + ";ext\\gd\\libgd")) {
ERROR("gd not enabled; libraries and headers not found");
}
// zlib ext support (required)
if (!CHECK_LIB("zlib_a.lib;zlib.lib", "gd", PHP_GD)) {
ERROR("gd not enabled; zlib not enabled");
}
// libjpeg lib support
if (CHECK_LIB("libjpeg_a.lib;libjpeg.lib", "gd", PHP_GD) &&
CHECK_HEADER_ADD_INCLUDE("jpeglib.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include")) {
AC_DEFINE("HAVE_LIBJPEG", 1, "JPEG support");
AC_DEFINE("HAVE_GD_JPG", 1, "JPEG support");
}
// libpng16 lib support
if (CHECK_LIB("libpng_a.lib;libpng.lib", "gd", PHP_GD) &&
CHECK_HEADER_ADD_INCLUDE("png.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\libpng16")) {
AC_DEFINE("HAVE_LIBPNG", 1, "PNG support");
AC_DEFINE("HAVE_GD_PNG", 1, "PNG support");
}
// freetype lib support
if (CHECK_LIB("libfreetype_a.lib;libfreetype.lib", "gd", PHP_GD) &&
CHECK_HEADER_ADD_INCLUDE("ft2build.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\freetype2;" + PHP_PHP_BUILD + "\\include\\freetype")) {
AC_DEFINE("HAVE_LIBFREETYPE", 1, "FreeType support");
AC_DEFINE("HAVE_GD_FREETYPE", 1, "FreeType support");
}
// xpm lib support
if (CHECK_LIB("libXpm_a.lib", "gd", PHP_GD) &&
CHECK_HEADER_ADD_INCLUDE("xpm.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\X11")) {
AC_DEFINE("HAVE_LIBXPM", 1, "XPM support");
AC_DEFINE("HAVE_GD_XPM", 1, "XPM support");
}
// iconv lib support
if ((CHECK_LIB("libiconv_a.lib;libiconv.lib", "gd", PHP_GD) || CHECK_LIB("iconv_a.lib;iconv.lib", "gd", PHP_GD)) &&
CHECK_HEADER_ADD_INCLUDE("iconv.h", "CFLAGS_GD", PHP_GD)) {
AC_DEFINE("HAVE_LIBICONV", 1, "Iconv support");
}
// libwebp lib support
if ((CHECK_LIB("libwebp_a.lib", "gd", PHP_GD) || CHECK_LIB("libwebp.lib", "gd", PHP_GD)) &&
CHECK_LIB("libsharpyuv.lib", "gd", PHP_GD) &&
CHECK_HEADER_ADD_INCLUDE("decode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp") &&
CHECK_HEADER_ADD_INCLUDE("encode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp")) {
AC_DEFINE("HAVE_LIBWEBP", 1, "WebP support");
AC_DEFINE("HAVE_GD_WEBP", 1, "WebP support");
}
// libavif lib support
if (CHECK_LIB("avif_a.lib", "gd", PHP_GD) &&
CHECK_LIB("aom_a.lib", "gd", PHP_GD) &&
CHECK_HEADER_ADD_INCLUDE("avif.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\avif")) {
ADD_FLAG("CFLAGS_GD", "/D HAVE_LIBAVIF /D HAVE_GD_AVIF");
} else if (CHECK_LIB("avif.lib", "gd", PHP_GD) &&
CHECK_HEADER_ADD_INCLUDE("avif.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\avif")) {
ADD_FLAG("CFLAGS_GD", "/D HAVE_LIBAVIF /D HAVE_GD_AVIF");
}
CHECK_LIB("User32.lib", "gd", PHP_GD);
CHECK_LIB("Gdi32.lib", "gd", PHP_GD);
EXTENSION("gd", "gd.c", null, "-Iext/gd/libgd");
ADD_SOURCES("ext/gd/libgd", "gd.c \
gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c \
gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \
gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \
gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c gd_xbm.c gd_security.c gd_transform.c \
gd_filter.c gd_rotate.c gd_color_match.c gd_webp.c gd_avif.c \
gd_crop.c gd_interpolation.c gd_matrix.c gd_bmp.c gd_tga.c", "gd");
AC_DEFINE('HAVE_LIBGD', 1, 'GD support');
AC_DEFINE('HAVE_GD_BUNDLED', 1, "Bundled GD");
AC_DEFINE('HAVE_GD_BMP', 1, "BMP support");
AC_DEFINE('HAVE_GD_TGA', 1, "TGA support");
ADD_FLAG("CFLAGS_GD", " \
/D PHP_GD_EXPORTS=1 \
/D HAVE_GD_GET_INTERPOLATION \
");
if (ICC_TOOLSET) {
ADD_FLAG("LDFLAGS_GD", "/nodefaultlib:libcmt");
}
PHP_INSTALL_HEADERS("", "ext/gd ext/gd/libgd");
}

View File

@@ -1,91 +0,0 @@
--- a/build/php.m4
+++ b/build/php.m4
@@ -2812,27 +2812,26 @@
dnl PHP_CHECK_AVX512_SUPPORTS
dnl
AC_DEFUN([PHP_CHECK_AVX512_SUPPORTS], [
- AC_MSG_CHECKING([for avx512 supports in compiler])
- save_CFLAGS="$CFLAGS"
- CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw $CFLAGS"
-
- AC_LINK_IFELSE([AC_LANG_SOURCE([[
- #include <immintrin.h>
- int main(void) {
- __m512i mask = _mm512_set1_epi32(0x1);
- char out[32];
- _mm512_storeu_si512(out, _mm512_shuffle_epi8(mask, mask));
- return 0;
- }]])], [
+ AC_CACHE_CHECK([whether compiler supports AVX-512], [php_cv_have_avx512], [
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw $CFLAGS"
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[
+ #include <immintrin.h>
+ int main(void) {
+ __m512i mask = _mm512_set1_epi32(0x1);
+ char out[32];
+ _mm512_storeu_si512(out, _mm512_shuffle_epi8(mask, mask));
+ return 0;
+ }]])],
+ [php_cv_have_avx512=yes],
+ [php_cv_have_avx512=no])
+ CFLAGS="$save_CFLAGS"
+ ])
+ if test "$php_cv_have_avx512" = "yes"; then
have_avx512_supports=1
- AC_MSG_RESULT([yes])
- ], [
+ else
have_avx512_supports=0
- AC_MSG_RESULT([no])
- ])
-
- CFLAGS="$save_CFLAGS"
-
+ fi
AC_DEFINE_UNQUOTED([PHP_HAVE_AVX512_SUPPORTS],
[$have_avx512_supports], [Whether the compiler supports AVX512])
])
@@ -2841,24 +2840,26 @@
dnl PHP_CHECK_AVX512_VBMI_SUPPORTS
dnl
AC_DEFUN([PHP_CHECK_AVX512_VBMI_SUPPORTS], [
- AC_MSG_CHECKING([for avx512 vbmi supports in compiler])
- save_CFLAGS="$CFLAGS"
- CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw -mavx512vbmi $CFLAGS"
- AC_LINK_IFELSE([AC_LANG_SOURCE([[
- #include <immintrin.h>
- int main(void) {
- __m512i mask = _mm512_set1_epi32(0x1);
- char out[32];
- _mm512_storeu_si512(out, _mm512_permutexvar_epi8(mask, mask));
- return 0;
- }]])], [
+ AC_CACHE_CHECK([whether compiler supports AVX-512 VBMI], [php_cv_have_avx512vbmi], [
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw -mavx512vbmi $CFLAGS"
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[
+ #include <immintrin.h>
+ int main(void) {
+ __m512i mask = _mm512_set1_epi32(0x1);
+ char out[32];
+ _mm512_storeu_si512(out, _mm512_permutexvar_epi8(mask, mask));
+ return 0;
+ }]])],
+ [php_cv_have_avx512vbmi=yes],
+ [php_cv_have_avx512vbmi=no])
+ CFLAGS="$save_CFLAGS"
+ ])
+ if test "$php_cv_have_avx512vbmi" = "yes"; then
have_avx512_vbmi_supports=1
- AC_MSG_RESULT([yes])
- ], [
+ else
have_avx512_vbmi_supports=0
- AC_MSG_RESULT([no])
- ])
- CFLAGS="$save_CFLAGS"
+ fi
AC_DEFINE_UNQUOTED([PHP_HAVE_AVX512_VBMI_SUPPORTS],
[$have_avx512_vbmi_supports], [Whether the compiler supports AVX512 VBMI])
])

View File

@@ -29,7 +29,7 @@ $test_os = [
'ubuntu-22.04', // bin/spc-gnu-docker for x86_64 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64
// 'ubuntu-24.04', // bin/spc for x86_64 // 'ubuntu-24.04', // bin/spc for x86_64
'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64
// 'ubuntu-24.04-arm', // bin/spc for arm64 'ubuntu-24.04-arm', // bin/spc for arm64
// 'windows-2022', // .\bin\spc.ps1 // 'windows-2022', // .\bin\spc.ps1
// 'windows-2025', // 'windows-2025',
]; ];
@@ -42,16 +42,16 @@ $no_strip = false;
// compress with upx // compress with upx
$upx = false; $upx = false;
// whether to test frankenphp build, only available for macOS and linux // whether to test frankenphp build, only available for macos and linux
$frankenphp = true; $frankenphp = false;
// prefer downloading pre-built packages to speed up the build process // prefer downloading pre-built packages to speed up the build process
$prefer_pre_built = true; $prefer_pre_built = false;
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) { $extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'curl,gd', 'Linux', 'Darwin' => 'pgsql',
'Windows' => 'bcmath,brotli,bz2,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,iconv,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pdo,pdo_mysql,pdo_pgsql,pgsql,session,simdjson,simplexml,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,zip,zlib', 'Windows' => 'com_dotnet',
}; };
// If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`).
@@ -62,7 +62,7 @@ $shared_extensions = match (PHP_OS_FAMILY) {
}; };
// If you want to test lib-suggests for all extensions and libraries, set it to true. // If you want to test lib-suggests for all extensions and libraries, set it to true.
$with_suggested_libs = true; $with_suggested_libs = false;
// If you want to test extra libs for extensions, add them below (comma separated, example `libwebp,libavif`). Unnecessary, when $with_suggested_libs is true. // If you want to test extra libs for extensions, add them below (comma separated, example `libwebp,libavif`). Unnecessary, when $with_suggested_libs is true.
$with_libs = match (PHP_OS_FAMILY) { $with_libs = match (PHP_OS_FAMILY) {

View File

@@ -12,15 +12,6 @@ use SPC\exception\SPCInternalException;
function f_exec(string $command, mixed &$output, mixed &$result_code): bool function f_exec(string $command, mixed &$output, mixed &$result_code): bool
{ {
$result_code = 0; $result_code = 0;
if (str_contains($command, 'https://api.github.com/repos/AOMediaCodec/libavif/releases/latest')) {
$output = explode("\n", json_encode([
'tag_name' => 'v1.1.1',
'tarball_url' => 'https://api.github.com/repos/AOMediaCodec/libavif/tarball/v1.1.1',
'prerelease' => false,
'draft' => false,
]));
return true;
}
if (str_contains($command, 'https://api.github.com/repos/AOMediaCodec/libavif/releases')) { if (str_contains($command, 'https://api.github.com/repos/AOMediaCodec/libavif/releases')) {
$output = explode("\n", gzdecode(file_get_contents(__DIR__ . '/../assets/github_api_AOMediaCodec_libavif_releases.json.gz'))); $output = explode("\n", gzdecode(file_get_contents(__DIR__ . '/../assets/github_api_AOMediaCodec_libavif_releases.json.gz')));
return true; return true;