Skip to content

Commit cb22f22

Browse files
committed
Fix DTrace build with SystemTap and GCC defaults
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 C compiler and 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 have already been in place since versions 5.4.20 and 5.5.4 from 2013-09-18. We had modified all dtrace invocation 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). Therefore, we have recently stopped setting all these environment variables when invoking dtrace. We set only what is necessary for particular action. We hope this makes this fix simpler and clearer without introducing additional complexity to our build system. The cause of our issue is the fact that GCC preprocessor, when invoked via “gcc” binary, detects the language for preprocessing from source file extensions. Because DTrace probes and providers for statically-defined tracing are in files with “.d” extension, GCC detection fails because it probably thinks it is processing proper D programing language source code (somewhat different from what DTrace uses) which has no C-style preprocessing. People have noticed, because configure script on systems with GCC sets CPP make macro to “gcc -E”. Therefore practically everyone, who does not override C preprocessor, who is building PHP with DTrace enabled on Linux with SystemTap, experiences this issue. We force C language when passing C preprocessor as set by the user or detected by the configure script. SystemTap dtrace expects C language preprocessor because pragmas in D programming language used by DTrace are the same #pragma directives known from C and similar languages. We use -x option from GCC to force C. Other compilers suites and their preprocessors (most notably Clang) recognize this option too. Many probably do not. However, this issue is specific to SystemTap, which is itself specific to Linux and has to be build using the same compiler as Linux kernel, which only supports building using GCC-compatible compilers. We can definitely imagine someone building PHP with DTrace enabled using SystemTap and wanting to use compiler suite or preprocessor which is different from what they used to build SystemTap itself or their Linux kernel and which does not recognize -x option. However, we do not think it is reasonable to accommodate for such use case. Properly solving this would require implementing non-trivial m4 macros, which is probably not warranted given this affects 2 lines of make commands… This has no effect on Oracle DTrace, Open DTrace or any of their forks because they do not allow customization of preprocessor nor compiler. They simply ignore CPP, CC, and CFLAGS environment variables, so it does not matter what values we set there. Fixes GH-11847#11847#11643
1 parent 096ac94 commit cb22f22

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

build/php.m4

Lines changed: 1 addition & 1 deletion
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)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHP_,DTRACE_,g' \$[]@.bak > \$[]@
2392+
CPP="\$(CPP) -xc" 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

ext/oci8/config.m4

Lines changed: 1 addition & 1 deletion
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)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHPOCI_,DTRACE_,g' \$[]@.bak > \$[]@
127+
CPP="\$(CPP) -xc" 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

0 commit comments

Comments
 (0)