Skip to content

Commit 804420b

Browse files
committed
Detect musl libc to not set tls_model attribute on that platform
This fixes: ``_tsrm_ls_cache: initial-exec TLS resolves to dynamic definition`` in shared extensions.
1 parent bf21261 commit 804420b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

TSRM/TSRM.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ TSRM_API const char *tsrm_api_name(void);
147147
# define __has_attribute(x) 0
148148
#endif
149149

150-
#if !__has_attribute(tls_model) || defined(__FreeBSD__)
150+
#if !__has_attribute(tls_model) || defined(__FreeBSD__) || defined(__MUSL__)
151151
# define TSRM_TLS_MODEL_ATTR
152152
#elif __PIC__
153153
# define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("initial-exec")))

configure.ac

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,17 @@ case $host_alias in
255255
;;
256256
esac
257257

258+
dnl Detect musl libc
259+
AC_MSG_CHECKING([whether we are using musl libc])
260+
if command -v ldd >/dev/null && ldd --version 2>&1 | grep -q ^musl
261+
then
262+
AC_MSG_RESULT(yes)
263+
CPPFLAGS="$CPPFLAGS -D__MUSL__"
264+
else
265+
AC_MSG_RESULT(no)
266+
fi
267+
268+
258269
dnl Include Zend configurations.
259270
dnl ----------------------------------------------------------------------------
260271

0 commit comments

Comments
 (0)