From 2b2aeb989e4e18582b0a665a33dfd8712275dd5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 7 Mar 2022 12:04:21 +0100 Subject: [PATCH] Fix GH-8160: ZTS support on Alpine is broken We need to export `__MUSL__` so that phpize builds can see the proper macro, and also need to fix "_tsrm_ls_cache" usage for musl. Closes GH-8180. --- NEWS | 1 + TSRM/TSRM.c | 4 ++-- configure.ac | 2 +- ext/opcache/jit/zend_jit_x86.dasc | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 13192978701..6b31ab2f7c8 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ PHP NEWS . Fixed freeing of internal attribute arguments. (Bob) . Fixed bug GH-8070 (memory leak of internal function attribute hash). (Tim Düsterhus) + . Fixed bug GH-8160 (ZTS support on Alpine is broken). (Michael Voříšek) - Intl: . Fixed bug GH-8142 (Compilation error on cygwin). (David Carlier) diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c index 3d93accddde..c2a9130b5d4 100644 --- a/TSRM/TSRM.c +++ b/TSRM/TSRM.c @@ -736,13 +736,13 @@ TSRM_API size_t tsrm_get_ls_cache_tcb_offset(void) #if defined(__APPLE__) && defined(__x86_64__) // TODO: Implement support for fast JIT ZTS code ??? return 0; -#elif defined(__x86_64__) && defined(__GNUC__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) +#elif defined(__x86_64__) && defined(__GNUC__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__MUSL__) size_t ret; asm ("movq _tsrm_ls_cache@gottpoff(%%rip),%0" : "=r" (ret)); return ret; -#elif defined(__i386__) && defined(__GNUC__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) +#elif defined(__i386__) && defined(__GNUC__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__MUSL__) size_t ret; asm ("leal _tsrm_ls_cache@ntpoff,%0" diff --git a/configure.ac b/configure.ac index 8f83ad06c07..a60c3533897 100644 --- a/configure.ac +++ b/configure.ac @@ -260,7 +260,7 @@ AC_MSG_CHECKING([whether we are using musl libc]) if command -v ldd >/dev/null && ldd --version 2>&1 | grep -q ^musl then AC_MSG_RESULT(yes) - CPPFLAGS="$CPPFLAGS -D__MUSL__" + AC_DEFINE([__MUSL__], [1], [Define when using musl libc]) else AC_MSG_RESULT(no) fi diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index b0635a77029..bcf5459ba42 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -2974,7 +2974,7 @@ static int zend_jit_setup(void) # elif defined(__GNUC__) && defined(__x86_64__) tsrm_ls_cache_tcb_offset = tsrm_get_ls_cache_tcb_offset(); if (tsrm_ls_cache_tcb_offset == 0) { -#if defined(__has_attribute) && __has_attribute(tls_model) && !defined(__FreeBSD__) && !defined(__OpenBSD__) +#if defined(__has_attribute) && __has_attribute(tls_model) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__MUSL__) size_t ret; asm ("movq _tsrm_ls_cache@gottpoff(%%rip),%0" @@ -2993,7 +2993,7 @@ static int zend_jit_setup(void) # elif defined(__GNUC__) && defined(__i386__) tsrm_ls_cache_tcb_offset = tsrm_get_ls_cache_tcb_offset(); if (tsrm_ls_cache_tcb_offset == 0) { -#if !defined(__FreeBSD__) && !defined(__OpenBSD__) +#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__MUSL__) size_t ret; asm ("leal _tsrm_ls_cache@ntpoff,%0\n"