diff --git a/.github/workflows/static.yaml b/.github/workflows/static.yaml index 293640fbce..e7d87eec96 100644 --- a/.github/workflows/static.yaml +++ b/.github/workflows/static.yaml @@ -400,6 +400,7 @@ jobs: "${BINARY}" list-modules | grep http.handlers.mercure "${BINARY}" list-modules | grep http.handlers.vulcain "${BINARY}" php-cli -r "echo 'Sanity check passed';" + "${BINARY}" php-cli -d ffi.enable=1 -r 'exit(FFI::cdef("int abs(int);", "libc.so.6")->abs(-42) === 42 ? 0 : 1);' env: BINARY: ./gh-output/frankenphp-linux-${{ matrix.platform == 'linux/amd64' && 'x86_64' || 'aarch64' }}-gnu diff --git a/build-static.sh b/build-static.sh index 5aa4a04c8c..fd954877af 100755 --- a/build-static.sh +++ b/build-static.sh @@ -13,7 +13,7 @@ set -o pipefail # # Supported variables: # - PHP_VERSION: PHP version to build (default: the one pinned in craft.yml) -# - PHP_EXTENSIONS: comma-separated extensions (default: the list in craft.yml) +# - PHP_EXTENSIONS: comma-separated extensions (default: the list in craft.yml, plus ffi on glibc Linux builds) # - PHP_EXTENSION_LIBS: comma-separated extra libraries (default: the list in craft.yml) # - XCADDY_ARGS: extra Caddy modules to pass to xcaddy (default: the list in craft.yml) # - FRANKENPHP_VERSION: FrankenPHP version (default: current Git commit) @@ -168,7 +168,13 @@ while IFS= read -r line || [ -n "${line}" ]; do [ -n "${PHP_VERSION}" ] && line="php-version: \"${PHP_VERSION}\"" ;; "extensions:"*) - [ -n "${PHP_EXTENSIONS}" ] && line="extensions: \"${PHP_EXTENSIONS}\"" + if [ -n "${PHP_EXTENSIONS}" ]; then + line="extensions: \"${PHP_EXTENSIONS}\"" + elif [[ "${bin_os}" == linux && "${line}" != *[\",]ffi[\",]* ]]; then + case "${SPC_TARGET:-${LIBC}}" in + gnu | *-linux-gnu*) line="${line%\"},ffi\"" ;; + esac + fi ;; "packages:"*) packages="${PHP_EXTENSION_LIBS}"