From 34cb1f602a6446fbbed275c353c36e9d9bf9cde2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 16 Dec 2024 22:16:18 +0100 Subject: [PATCH] fix: dynamic libphp linking on Mac --- NEWS | 3 +++ build/Makefile.global | 4 ++++ sapi/embed/config.m4 | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/NEWS b/NEWS index f7565624ad7b0..96e771a2ad800 100644 --- a/NEWS +++ b/NEWS @@ -27,6 +27,9 @@ PHP NEWS - Curl: . Fix various memory leaks in curl mime handling. (nielsdos) +- Embed: + . Fixed GH-8533 (Unable to link dynamic libphp on Mac). (Kévin Dunglas) + - FPM: . Fixed GH-16432 (PHP-FPM 8.2 SIGSEGV in fpm_get_status). (Jakub Zelenka) diff --git a/build/Makefile.global b/build/Makefile.global index b11ce20aae87a..ec19efcbc5894 100644 --- a/build/Makefile.global +++ b/build/Makefile.global @@ -19,6 +19,10 @@ libphp.la: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(LIBTOOL) --tag=CC --mode=link $(CC) $(LIBPHP_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ -@$(LIBTOOL) --silent --tag=CC --mode=install cp $@ $(phptempdir)/$@ >/dev/null 2>&1 +libphp.dylib: libphp.la + $(LIBTOOL) --tag=CC --mode=link $(CC) -dynamiclib $(LIBPHP_CFLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -rpath $(phptempdir) -install_name @rpath/$@ $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ + -@$(LIBTOOL) --silent --tag=CC --mode=install cp $@ $(phptempdir)/$@ >/dev/null 2>&1 + libs/libphp.bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp.so diff --git a/sapi/embed/config.m4 b/sapi/embed/config.m4 index 39d7dcf0a3ff2..f8cfd9d30a0e6 100644 --- a/sapi/embed/config.m4 +++ b/sapi/embed/config.m4 @@ -12,6 +12,7 @@ if test "$PHP_EMBED" != "no"; then yes|shared) LIBPHP_CFLAGS="-shared" PHP_EMBED_TYPE=shared + AS_CASE(["$host_alias"], [*darwin*], [SAPI_SHARED="libs/libphp.dylib"], []) INSTALL_IT="\$(mkinstalldirs) \$(INSTALL_ROOT)\$(prefix)/lib; \$(INSTALL) -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)\$(prefix)/lib" ;; static) @@ -26,6 +27,9 @@ if test "$PHP_EMBED" != "no"; then if test "$PHP_EMBED_TYPE" != "no"; then PHP_SUBST(LIBPHP_CFLAGS) PHP_SELECT_SAPI(embed, $PHP_EMBED_TYPE, php_embed.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) + if test "$SAPI_SHARED" = "libs/libphp.dylib"; then + OVERALL_TARGET=libphp.dylib + fi PHP_INSTALL_HEADERS([sapi/embed/php_embed.h]) fi AC_MSG_RESULT([$PHP_EMBED_TYPE])