summaryrefslogtreecommitdiffstats
path: root/php-dtrace.patch
diff options
context:
space:
mode:
Diffstat (limited to 'php-dtrace.patch')
-rw-r--r--php-dtrace.patch126
1 files changed, 126 insertions, 0 deletions
diff --git a/php-dtrace.patch b/php-dtrace.patch
new file mode 100644
index 0000000..b9e21b5
--- /dev/null
+++ b/php-dtrace.patch
@@ -0,0 +1,126 @@
+From 475fd29527ffd86297e7cd61fd1617a7374c5220 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Filip=20Zr=C5=AFst?=
+ <128540+f4z4on@users.noreply.github.com>
+Date: Wed, 19 Jul 2023 15:30:02 +0200
+Subject: [PATCH] Improve DTrace probe generation /w non-default compiler
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+With DTrace support enabled during ./configure, our custom Autoconf
+macro PHP_INIT_DTRACE creates make rules to generate header and object
+files using dtrace utility. SystemTap† implementation of dtrace relies
+on other utilities to provide header preprocessing and final object file
+compilation. These utilities are configured by common environment
+variables with common defaults:‡
+
+* preprocessor from CPP defaults to “cpp”
+* compiler from CC defaults to “gcc”
+* compiler arguments can be expanded with CFLAGS
+
+This has been in SystemTap since version 1.5 released on 2011-05-23. We
+have been setting CFLAGS for dtrace since 717b367 released in versions
+5.4.20 and 5.5.4 on 2013-09-18. This change fixed build against
+SystemTap. It fixes majority of cases since practically all free Linux
+distributions use SystemTap for DTrace-like dynamic tracing and
+practically all of them use GCC or compatible compiler suite. However,
+this becomes an issue when cross-compiling using GCC because utility
+names contain target triplets. Autoconf already handles
+cross-compilation well —setting correct CC and CPP make macros
+(variables).
+
+Therefore, we simply set CC and CPP environment variables using
+respective macros when executing dtrace. Although SystemTap dtrace does
+not always use CC nor CPP, we set it every time. SystemTap documentation
+does not talk about this at all¶, so it is safer to always set it. We
+also follow how we set CFLAGS every time in the past.
+
+Original (or ported) DTrace mainly used on Oracle Linux, Solaris and
+macOS ignores these and does not support cross compilation.§
+
+† Well-known dynamic tracing infrastructure for Linux compatible with
+statically-defined tracing from DTrace.
+‡ https://sourceware.org/git/?p=systemtap.git;a=blob;f=dtrace.in;h=73a6f22e2de072773c692e3fea05c4b8cf814e43;hb=ebb424eee5599fcc131901c0d82d0bfc0d2f57ab
+¶ https://sourceware.org/systemtap/man/dtrace.1.html
+§ https://docs.oracle.com/cd/E88353_01/html/E72487/dtrace-8.html
+
+Closes GH-11643
+---
+ build/php.m4 | 8 ++++----
+ ext/oci8/config.m4 | 8 ++++----
+ 2 files changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/build/php.m4 b/build/php.m4
+index 919279833f79..921a78eb78e3 100644
+--- a/build/php.m4
++++ b/build/php.m4
+@@ -2389,7 +2389,7 @@ dnl overwritten (Bug 61268).
+ $abs_srcdir/$ac_provsrc:;
+
+ $ac_bdir[$]ac_hdrobj: $abs_srcdir/$ac_provsrc
+- CFLAGS="\$(CFLAGS_CLEAN)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHP_,DTRACE_,g' \$[]@.bak > \$[]@
++ CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHP_,DTRACE_,g' \$[]@.bak > \$[]@
+
+ \$(PHP_DTRACE_OBJS): $ac_bdir[$]ac_hdrobj
+
+@@ -2409,12 +2409,12 @@ EOF
+ $ac_bdir[$]ac_provsrc.lo: \$(PHP_DTRACE_OBJS)
+ echo "[#] Generated by Makefile for libtool" > \$[]@
+ @test -d "$dtrace_lib_dir" || mkdir $dtrace_lib_dir
+- if CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o $dtrace_d_obj -s $abs_srcdir/$ac_provsrc $dtrace_lib_objs 2> /dev/null && test -f "$dtrace_d_obj"; then [\\]
++ if CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o $dtrace_d_obj -s $abs_srcdir/$ac_provsrc $dtrace_lib_objs 2> /dev/null && test -f "$dtrace_d_obj"; then [\\]
+ echo "pic_object=['].libs/$dtrace_prov_name[']" >> \$[]@ [;\\]
+ else [\\]
+ echo "pic_object='none'" >> \$[]@ [;\\]
+ fi
+- if CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o $ac_bdir[$]ac_provsrc.o -s $abs_srcdir/$ac_provsrc $dtrace_nolib_objs 2> /dev/null && test -f "$ac_bdir[$]ac_provsrc.o"; then [\\]
++ if CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o $ac_bdir[$]ac_provsrc.o -s $abs_srcdir/$ac_provsrc $dtrace_nolib_objs 2> /dev/null && test -f "$ac_bdir[$]ac_provsrc.o"; then [\\]
+ echo "non_pic_object=[']$dtrace_prov_name[']" >> \$[]@ [;\\]
+ else [\\]
+ echo "non_pic_object='none'" >> \$[]@ [;\\]
+@@ -2426,7 +2426,7 @@ EOF
+ *)
+ cat>>Makefile.objects<<EOF
+ $ac_bdir[$]ac_provsrc.o: \$(PHP_DTRACE_OBJS)
+- CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $abs_srcdir/$ac_provsrc $dtrace_objs
++ CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $abs_srcdir/$ac_provsrc $dtrace_objs
+
+ EOF
+ ;;
+diff --git a/ext/oci8/config.m4 b/ext/oci8/config.m4
+index 714c655be439..883e272fb1fa 100644
+--- a/ext/oci8/config.m4
++++ b/ext/oci8/config.m4
+@@ -124,7 +124,7 @@ dnl overwritten (Bug 61268).
+ PHP_EXT_SRCDIR([oci8])/$ac_provsrc:;
+
+ $ac_bdir[$]ac_hdrobj: $ac_srcdir[$]ac_provsrc
+- CFLAGS="\$(CFLAGS_CLEAN)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHPOCI_,DTRACE_,g' \$[]@.bak > \$[]@
++ CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHPOCI_,DTRACE_,g' \$[]@.bak > \$[]@
+
+ \$(OCI8_DTRACE_OBJS): $ac_bdir[$]ac_hdrobj
+
+@@ -145,12 +145,12 @@ EOF
+ $ac_bdir[$]ac_provsrc.lo: \$(OCI8_DTRACE_OBJS)
+ echo "[#] Generated by Makefile for libtool" > \$[]@
+ @test -d "$dtrace_lib_dir" || mkdir $dtrace_lib_dir
+- if CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o $dtrace_d_obj -s $ac_srcdir[$]ac_provsrc $dtrace_oci8_lib_objs 2> /dev/null && test -f "$dtrace_d_obj"; then [\\]
++ if CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o $dtrace_d_obj -s $ac_srcdir[$]ac_provsrc $dtrace_oci8_lib_objs 2> /dev/null && test -f "$dtrace_d_obj"; then [\\]
+ echo "pic_object=['].libs/$dtrace_prov_name[']" >> \$[]@ [;\\]
+ else [\\]
+ echo "pic_object='none'" >> \$[]@ [;\\]
+ fi
+- if CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o $ac_bdir[$]ac_provsrc.o -s $ac_srcdir[$]ac_provsrc $dtrace_nolib_objs 2> /dev/null && test -f "$ac_bdir[$]ac_provsrc.o"; then [\\]
++ if CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o $ac_bdir[$]ac_provsrc.o -s $ac_srcdir[$]ac_provsrc $dtrace_nolib_objs 2> /dev/null && test -f "$ac_bdir[$]ac_provsrc.o"; then [\\]
+ echo "non_pic_object=[']$dtrace_prov_name[']" >> \$[]@ [;\\]
+ else [\\]
+ echo "non_pic_object='none'" >> \$[]@ [;\\]
+@@ -162,7 +162,7 @@ EOF
+ AC_MSG_WARN([OCI8 extension: OCI8 DTrace support is not confirmed on this platform])
+ cat>>Makefile.objects<<EOF
+ $ac_bdir[$]ac_provsrc.o: \$(OCI8_DTRACE_OBJS)
+- CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $ac_srcdir[$]ac_provsrc $dtrace_oci8_objs
++ CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $ac_srcdir[$]ac_provsrc $dtrace_oci8_objs
+
+ EOF
+ ;;