From c0e0c2d07ff9d193d7585b919da4217eb0accd86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Wed, 18 Dec 2024 07:17:42 +0100 Subject: [PATCH] fix(static): fix builds by switching to spc-config (#1231) * chore: remove useless SPC workarounds * use spc-config --- build-static.sh | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/build-static.sh b/build-static.sh index c72594094..529c3cbba 100755 --- a/build-static.sh +++ b/build-static.sh @@ -10,6 +10,8 @@ fi arch="$(uname -m)" os="$(uname -s | tr '[:upper:]' '[:lower:]')" +# FIXME: re-enable PHP errors when SPC will be compatible with PHP 8.4 +spcCommand="php -ddisplay_errors=Off ./bin/spc" md5binary="md5sum" if [ "${os}" = "darwin" ]; then os="mac" @@ -114,10 +116,10 @@ else extraOpts="${extraOpts} --no-strip" fi - ./bin/spc doctor --auto-fix - ./bin/spc download --with-php="${PHP_VERSION}" --for-extensions="${PHP_EXTENSIONS}" --for-libs="${PHP_EXTENSION_LIBS}" --ignore-cache-sources=php-src --prefer-pre-built + ${spcCommand} doctor --auto-fix + ${spcCommand} download --with-php="${PHP_VERSION}" --for-extensions="${PHP_EXTENSIONS}" --for-libs="${PHP_EXTENSION_LIBS}" --ignore-cache-sources=php-src --prefer-pre-built # shellcheck disable=SC2086 - ./bin/spc build --debug --enable-zts --build-embed ${extraOpts} "${PHP_EXTENSIONS}" --with-libs="${PHP_EXTENSION_LIBS}" + ${spcCommand} build --debug --enable-zts --build-embed ${extraOpts} "${PHP_EXTENSIONS}" --with-libs="${PHP_EXTENSION_LIBS}" fi curlGitHubHeaders=(--header "X-GitHub-Api-Version: 2022-11-28") @@ -144,7 +146,7 @@ cp -R include/wtr/watcher-c.h ../../buildroot/include/wtr/watcher-c.h cd ../../ # See https://github.com/docker-library/php/blob/master/8.3/alpine3.20/zts/Dockerfile#L53-L55 -CGO_CFLAGS="-DFRANKENPHP_VERSION=${FRANKENPHP_VERSION} -I${PWD}/buildroot/include/ $(./buildroot/bin/php-config --includes | sed s#-I/#-I"${PWD}"/buildroot/#g)" +CGO_CFLAGS="-DFRANKENPHP_VERSION=${FRANKENPHP_VERSION} -I${PWD}/buildroot/include/ $(${spcCommand} spc-config "${PHP_EXTENSIONS}" --with-libs="${PHP_EXTENSION_LIBS}" --includes)" if [ -n "${DEBUG_SYMBOLS}" ]; then CGO_CFLAGS="-g ${CGO_CFLAGS}" else @@ -159,12 +161,7 @@ elif [ "${os}" = "linux" ] && [ -z "${DEBUG_SYMBOLS}" ]; then CGO_LDFLAGS="-Wl,-O1 -pie" fi -# Temporary workaround for https://github.com/crazywhalecc/static-php-cli/issues/560 -if [[ "${PHP_EXTENSIONS}" == *"pgsql"* ]]; then - CGO_LDFLAGS="${CGO_LDFLAGS} ${PWD}/buildroot/lib/libpgcommon.a ${PWD}/buildroot/lib/libpgport.a ${PWD}/buildroot/lib/libpq.a" -fi - -CGO_LDFLAGS="${CGO_LDFLAGS} ${PWD}/buildroot/lib/libbrotlicommon.a ${PWD}/buildroot/lib/libbrotlienc.a ${PWD}/buildroot/lib/libbrotlidec.a ${PWD}/buildroot/lib/libwatcher-c.a $(./buildroot/bin/php-config --ldflags || true) $(./buildroot/bin/php-config --libs | sed -e 's/-lgcc_s//g' || true)" +CGO_LDFLAGS="${CGO_LDFLAGS} ${PWD}/buildroot/lib/libbrotlicommon.a ${PWD}/buildroot/lib/libbrotlienc.a ${PWD}/buildroot/lib/libbrotlidec.a ${PWD}/buildroot/lib/libwatcher-c.a $(${spcCommand} spc-config "${PHP_EXTENSIONS}" --with-libs="${PHP_EXTENSION_LIBS}" --libs)" if [ "${os}" = "linux" ]; then if echo "${PHP_EXTENSIONS}" | grep -qE "\b(intl|imagick|grpc|v8js|protobuf|mongodb|tbb)\b"; then CGO_LDFLAGS="${CGO_LDFLAGS} -lstdc++" @@ -173,11 +170,7 @@ fi export CGO_LDFLAGS -#LIBPHP_VERSION="$(./buildroot/bin/php-config --version)" -# Temporary workaround for https://github.com/crazywhalecc/static-php-cli/issues/563 -if [[ $(cat buildroot/include/php/main/php_version.h) =~ (define PHP_VERSION \"([0-9\.]+)) ]]; then - export LIBPHP_VERSION=${BASH_REMATCH[2]} -fi +LIBPHP_VERSION="$(./buildroot/bin/php-config --version)" cd ../