Skip to content

Commit e145766

Browse files
committed
Minimize changes to dtrace execution environment
We are experiencing an issue when building PHP with DTrace enabled with SystemTap (see GH-11847).† SystemTap, unlike Oracle DTrace, Open DTrace or their forks, relies on both external C compiler and external preprocessor. We have recently aligned both of these with compiler and preprocessor we use to build regular C source code (see GH-11643).‡ We set CPP environment variable to the value of our CPP macro which defaults to C preprocessor detected by configure script. Similarly, we set CC environment variable to the value of our CC macro which defaults to C compiler detected by configure script. C compiler flags from CFLAGS_CLEAN macro have already been in place since versions 5.4.20 and 5.5.4 from 2013-09-18. We have modified all dtrace invocations in the same way to make it look consistent. However, SystemTap dtrace needs C preprocessor only when it generates header files (-h option) with preprocessing (-C option). Similarly, it needs C compiler only when it generates object files with probe definitions (-G option). External C preprocessor use via the -C option is actually common to dtrace implementations other than SystemTap even for actions other than generating header files. However, customization of C preprocessor differs widely between SystemTap and the rest of DTrace ecosystem (for example, no other implementation uses environment variables). Before, we fix the issue itself, we stop setting all these environment variables when invoking dtrace. We set only those necessary for particular action: 1. When generating headers file (-h option) with the help of C preprocessor (-C option), we pass the C processor the user chose or configure detected (CPP). No CC nor CFLAGS environment variables. 2. When generating object files with probes (-G option), we pass the C compiler and its flags the user chose or configure detected (CC and CFLAGS). No CPP environment variable. We hope this code style inconsistency in dtrace invocation will actually be useful in that it allows simpler fix to the issue we are experiencing when building PHP with DTrace enabled with SystemTap. We believe this also makes clearer the fact this is a strange area of PHP build process and vendor-independent invocation of dtrace is tricky. Hopefully, if there is some future need to change how we define and build statically-defined traces, people will notice differences between uses for dtrace. Properly solving this would require implementing non-trivial m4 macros, which is probably not warranted given this affects 8 lines of make commands… Moreover, such macros probably belong to a project like GNU Autoconf rather than to PHP. Therefore, intentional code seems like the best next option. Please note, all this is specific to SystemTap which is itself available only on Linux. Oracle DTrace, Open DTrace or their forks do not use environment variables (they ignore them). † #11847#11643
1 parent 1b092c6 commit e145766

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

build/php.m4

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,7 +2389,7 @@ dnl overwritten (Bug 61268).
23892389
$abs_srcdir/$ac_provsrc:;
23902390
23912391
$ac_bdir[$]ac_hdrobj: $abs_srcdir/$ac_provsrc
2392-
CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHP_,DTRACE_,g' \$[]@.bak > \$[]@
2392+
CPP="\$(CPP)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHP_,DTRACE_,g' \$[]@.bak > \$[]@
23932393
23942394
\$(PHP_DTRACE_OBJS): $ac_bdir[$]ac_hdrobj
23952395
@@ -2409,12 +2409,12 @@ EOF
24092409
$ac_bdir[$]ac_provsrc.lo: \$(PHP_DTRACE_OBJS)
24102410
echo "[#] Generated by Makefile for libtool" > \$[]@
24112411
@test -d "$dtrace_lib_dir" || mkdir $dtrace_lib_dir
2412-
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 [\\]
2412+
if 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 [\\]
24132413
echo "pic_object=['].libs/$dtrace_prov_name[']" >> \$[]@ [;\\]
24142414
else [\\]
24152415
echo "pic_object='none'" >> \$[]@ [;\\]
24162416
fi
2417-
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 [\\]
2417+
if 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 [\\]
24182418
echo "non_pic_object=[']$dtrace_prov_name[']" >> \$[]@ [;\\]
24192419
else [\\]
24202420
echo "non_pic_object='none'" >> \$[]@ [;\\]
@@ -2426,7 +2426,7 @@ EOF
24262426
*)
24272427
cat>>Makefile.objects<<EOF
24282428
$ac_bdir[$]ac_provsrc.o: \$(PHP_DTRACE_OBJS)
2429-
CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $abs_srcdir/$ac_provsrc $dtrace_objs
2429+
CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $abs_srcdir/$ac_provsrc $dtrace_objs
24302430
24312431
EOF
24322432
;;

ext/oci8/config.m4

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ dnl overwritten (Bug 61268).
124124
PHP_EXT_SRCDIR([oci8])/$ac_provsrc:;
125125
126126
$ac_bdir[$]ac_hdrobj: $ac_srcdir[$]ac_provsrc
127-
CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHPOCI_,DTRACE_,g' \$[]@.bak > \$[]@
127+
CPP="\$(CPP)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHPOCI_,DTRACE_,g' \$[]@.bak > \$[]@
128128
129129
\$(OCI8_DTRACE_OBJS): $ac_bdir[$]ac_hdrobj
130130
@@ -145,12 +145,12 @@ EOF
145145
$ac_bdir[$]ac_provsrc.lo: \$(OCI8_DTRACE_OBJS)
146146
echo "[#] Generated by Makefile for libtool" > \$[]@
147147
@test -d "$dtrace_lib_dir" || mkdir $dtrace_lib_dir
148-
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 [\\]
148+
if 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 [\\]
149149
echo "pic_object=['].libs/$dtrace_prov_name[']" >> \$[]@ [;\\]
150150
else [\\]
151151
echo "pic_object='none'" >> \$[]@ [;\\]
152152
fi
153-
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 [\\]
153+
if 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 [\\]
154154
echo "non_pic_object=[']$dtrace_prov_name[']" >> \$[]@ [;\\]
155155
else [\\]
156156
echo "non_pic_object='none'" >> \$[]@ [;\\]
@@ -162,7 +162,7 @@ EOF
162162
AC_MSG_WARN([OCI8 extension: OCI8 DTrace support is not confirmed on this platform])
163163
cat>>Makefile.objects<<EOF
164164
$ac_bdir[$]ac_provsrc.o: \$(OCI8_DTRACE_OBJS)
165-
CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $ac_srcdir[$]ac_provsrc $dtrace_oci8_objs
165+
CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $ac_srcdir[$]ac_provsrc $dtrace_oci8_objs
166166
167167
EOF
168168
;;

0 commit comments

Comments
 (0)