Backport patches for Alpine 3.22 + ZTS

This commit is contained in:
Tianon Gravi
2025-06-09 15:07:45 -07:00
parent 904a84a176
commit 9c90483c2b
5 changed files with 74 additions and 7 deletions

View File

@ -130,6 +130,12 @@ RUN set -eux; \
echo 'ed10a1b254091ad676ed204e55628ecbd6c8962004d6185a1821cedecd526c0f *14834.patch' | sha256sum -c -; \
filterdiff -x '*/NEWS' 14834.patch | patch -p1; \
rm 14834.patch; \
# https://github.com/php/php-src/issues/18743 "Incompatibility in Inline TLS Assembly on Alpine 3.22 with zend_jit_ir.c"
# https://github.com/docker-library/php/pull/1580
curl -fL 'https://github.com/php/php-src/commit/6b105d4bc57e20a2472c9a6ff11fba32768556d4.patch?full_index=1' -o 18743.patch; \
echo '037e1610ae5d444e9a8c3ecd9d5f0cd215fd0aac90bdd7b9f0b259bffdf3566b *18743.patch' | sha256sum -c -; \
filterdiff -x '*/NEWS' 18743.patch | patch -p1; \
rm 18743.patch; \
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
./configure \
--build="$gnuArch" \

View File

@ -100,6 +100,8 @@ RUN set -eux; \
linux-headers \
oniguruma-dev \
openssl-dev \
patch \
patchutils \
readline-dev \
sqlite-dev \
; \
@ -117,6 +119,12 @@ RUN set -eux; \
; \
docker-php-source extract; \
cd /usr/src/php; \
# https://github.com/php/php-src/issues/18743 "Incompatibility in Inline TLS Assembly on Alpine 3.22 with zend_jit_ir.c"
# https://github.com/docker-library/php/pull/1580
curl -fL 'https://github.com/php/php-src/commit/b3c8afe272a6919248986c703c2e1defc73ff707.patch?full_index=1' -o 18743.patch; \
echo 'b334f73434c9732a4b27a42eb5d417e10df842e854c02a3e753b2479f8978bf5 *18743.patch' | sha256sum -c -; \
filterdiff -x '*/NEWS' 18743.patch | patch -p1; \
rm 18743.patch; \
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
./configure \
--build="$gnuArch" \

View File

@ -100,6 +100,8 @@ RUN set -eux; \
linux-headers \
oniguruma-dev \
openssl-dev \
patch \
patchutils \
readline-dev \
sqlite-dev \
; \
@ -117,6 +119,12 @@ RUN set -eux; \
; \
docker-php-source extract; \
cd /usr/src/php; \
# https://github.com/php/php-src/issues/18743 "Incompatibility in Inline TLS Assembly on Alpine 3.22 with zend_jit_ir.c"
# https://github.com/docker-library/php/pull/1580
curl -fL 'https://github.com/php/php-src/commit/b3c8afe272a6919248986c703c2e1defc73ff707.patch?full_index=1' -o 18743.patch; \
echo 'b334f73434c9732a4b27a42eb5d417e10df842e854c02a3e753b2479f8978bf5 *18743.patch' | sha256sum -c -; \
filterdiff -x '*/NEWS' 18743.patch | patch -p1; \
rm 18743.patch; \
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
./configure \
--build="$gnuArch" \

View File

@ -100,6 +100,8 @@ RUN set -eux; \
linux-headers \
oniguruma-dev \
openssl-dev \
patch \
patchutils \
readline-dev \
sqlite-dev \
; \
@ -117,6 +119,12 @@ RUN set -eux; \
; \
docker-php-source extract; \
cd /usr/src/php; \
# https://github.com/php/php-src/issues/18743 "Incompatibility in Inline TLS Assembly on Alpine 3.22 with zend_jit_ir.c"
# https://github.com/docker-library/php/pull/1580
curl -fL 'https://github.com/php/php-src/commit/4c7220322bc74b0fc8416e1958cadd7bc51fe1b7.diff?full_index=1' -o 18743.patch; \
echo 'a19e795b24c52d4d1aa3d45b67339e1b62a5365b37cf4418b83e2709fc98bcb5 *18743.patch' | sha256sum -c -; \
filterdiff -x '*/NEWS' 18743.patch | patch -p1; \
rm 18743.patch; \
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
./configure \
--build="$gnuArch" \

View File

@ -12,6 +12,26 @@
;
def is_alpine:
env.from | startswith("alpine")
;
def rcVersion:
env.version | rtrimstr("-rc")
;
def need_patch_11678:
# https://github.com/docker-library/php/pull/1552
# https://github.com/php/php-src/issues/11678 "Build fails on musl 1.2.4 - lfs64" stream_cookie_seeker
# https://github.com/php/php-src/issues/14834 "Error installing PHP when --with-pear is used" xml errors
is_alpine and rcVersion == "8.1"
;
def need_patch_18743:
# https://github.com/docker-library/php/pull/1580
# https://github.com/php/php-src/issues/18743 "Incompatibility in Inline TLS Assembly on Alpine 3.22 with zend_jit_ir.c"
env.variant == "zts" # only needed for ZTS builds
and is_alpine
and (env.from != "alpine:3.21") # only needed for Alpine 3.22+
and (
IN(rcVersion; "8.1", "8.2")
or IN(.version; "8.3.22", "8.4.8") # https://github.com/docker-library/php/pull/1580#issuecomment-2955259172
)
-}}
FROM {{ env.from }}
@ -190,7 +210,7 @@ ENV GPG_KEYS {{
"39B6 4134 3D8C 104B 2B14 6DC3 F9C3 9DC0 B969 8544", # ramsey
"F1F6 9223 8FBC 1666 E5A5 CCD4 199F 9DFE F6FF BAFD" # patrickallaert
],
}[env.version | rtrimstr("-rc")] // error("missing GPG keys for " + env.version)
}[rcVersion] // error("missing GPG keys for " + rcVersion)
| map(gsub(" "; ""))
| join(" ")
}}
@ -261,8 +281,8 @@ RUN set -eux; \
"libsodium-dev",
"libxml2-dev",
"openssl-dev",
# https://github.com/docker-library/php/pull/1552
if env.version | rtrimstr("-rc") == "8.1" then "patch", "patchutils" else empty end,
# https://github.com/docker-library/php/pull/1552 (11678) & https://github.com/docker-library/php/pull/1580 (14834)
if need_patch_11678 or need_patch_18743 then "patch", "patchutils" else empty end,
"readline-dev",
"sqlite-dev",
# https://github.com/docker-library/php/issues/888
@ -306,7 +326,7 @@ RUN set -eux; \
; \
docker-php-source extract; \
cd /usr/src/php; \
{{ if is_alpine and (env.version | rtrimstr("-rc") == "8.1") then ( -}}
{{ if need_patch_11678 then ( -}}
# Apply patches; see https://github.com/docker-library/php/pull/1552
# https://github.com/php/php-src/issues/11678
curl -fL 'https://github.com/php/php-src/commit/577b8ae4226368e66fee7a9b5c58f9e2428372fc.patch?full_index=1' -o 11678.patch; \
@ -318,6 +338,23 @@ RUN set -eux; \
echo 'ed10a1b254091ad676ed204e55628ecbd6c8962004d6185a1821cedecd526c0f *14834.patch' | sha256sum -c -; \
filterdiff -x '*/NEWS' 14834.patch | patch -p1; \
rm 14834.patch; \
{{ ) else "" end -}}
{{
if need_patch_18743 then
# https://github.com/docker-library/php/pull/1580#issuecomment-2957191901
{
"8.1": { url: "https://github.com/php/php-src/commit/6b105d4bc57e20a2472c9a6ff11fba32768556d4.patch?full_index=1", sha256: "037e1610ae5d444e9a8c3ecd9d5f0cd215fd0aac90bdd7b9f0b259bffdf3566b" },
"8.4": { url: "https://github.com/php/php-src/commit/4c7220322bc74b0fc8416e1958cadd7bc51fe1b7.diff?full_index=1", sha256: "a19e795b24c52d4d1aa3d45b67339e1b62a5365b37cf4418b83e2709fc98bcb5" },
}[rcVersion]
// { url: "https://github.com/php/php-src/commit/b3c8afe272a6919248986c703c2e1defc73ff707.patch?full_index=1", sha256: "b334f73434c9732a4b27a42eb5d417e10df842e854c02a3e753b2479f8978bf5" }
| (
-}}
# https://github.com/php/php-src/issues/18743 "Incompatibility in Inline TLS Assembly on Alpine 3.22 with zend_jit_ir.c"
# https://github.com/docker-library/php/pull/1580
curl -fL {{ .url | @sh }} -o 18743.patch; \
echo {{ "\(.sha256) *18743.patch" | @sh }} | sha256sum -c -; \
filterdiff -x '*/NEWS' 18743.patch | patch -p1; \
rm 18743.patch; \
{{ ) else "" end -}}
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
{{ if is_alpine then "" else ( -}}
@ -341,7 +378,7 @@ RUN set -eux; \
# https://github.com/docker-library/php/issues/822
--with-pic \
\
{{ if env.version | rtrimstr("-rc") == "8.1" then ( -}}
{{ if rcVersion == "8.1" then ( -}}
# --enable-ftp is included here for compatibility with existing versions. ftp_ssl_connect() needed ftp to be compiled statically before PHP 7.0 (see https://github.com/docker-library/php/issues/236).
--enable-ftp \
{{ ) else "" end -}}
@ -375,7 +412,7 @@ RUN set -eux; \
# in PHP 7.4+, the pecl/pear installers are officially deprecated (requiring an explicit "--with-pear")
--with-pear \
\
{{ if env.version | rtrimstr("-rc") | IN("8.1", "8.2") then ( -}}
{{ if rcVersion | IN("8.1", "8.2") then ( -}}
# bundled pcre does not support JIT on riscv64 until 10.41 (php 8.3+)
# https://github.com/PCRE2Project/pcre2/commits/pcre2-10.41/src/sljit/sljitNativeRISCV_64.c
# https://github.com/php/php-src/tree/php-8.3.0/ext/pcre/pcre2lib
@ -412,7 +449,7 @@ RUN set -eux; \
--enable-zts \
# https://externals.io/message/118859
--disable-zend-signals \
{{ if env.version | rtrimstr("-rc") | IN("8.1", "8.2") then ( -}}
{{ if rcVersion | IN("8.1", "8.2") then ( -}}
--enable-zend-max-execution-timers \
{{ ) else "" end -}}
{{ ) else "" end -}}