Skip to content

DTrace enabled build is broken #11847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
remicollet opened this issue Aug 1, 2023 · 10 comments
Closed

DTrace enabled build is broken #11847

remicollet opened this issue Aug 1, 2023 · 10 comments

Comments

@remicollet
Copy link
Member

remicollet commented Aug 1, 2023

Description

/bin/sh /builddir/build/BUILD/php-8.3.0beta2/build-cgi/libtool --silent --preserve-dup-deps --tag CC --mode=link gcc -export-dynamic -fno-common -Wstrict-prototypes -Wformat-truncation -Wlogical-op -Wduplicated-cond -Wno-clobbered -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-strict-aliasing -Wno-pointer-sign -fvisibility=hidden -Wimplicit-fallthrough=1 -DZEND_SIGNALS   -Wl,-zcommon-page-size=2097152 -Wl,-zmax-page-size=2097152 -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes  Zend/zend_dtrace.d.o ext/date/php_date.o ext/date/lib/astro.o ext/date/lib/dow.o ext/date/lib/parse_date.o ext/date/lib/parse_tz.o ext/date/lib/parse_posix.o ext/date/lib/timelib.o ext/date/lib/tm2unixtime.o ext/date/lib/unixtime2tm.o ext/date/lib/parse_iso_intervals.o ext/date/lib/interval.o ext/libxml/libxml.o ext/openssl/openssl.o ext/openssl/xp_ssl.o ext/pcre/php_pcre.o ext/zlib/zlib.o ext/zlib/zlib_fopen_wrapper.o ext/zlib/zlib_filter.o ext/filter/filter.o ext/filter/sanitizing_filters.o ext/filter/logical_filters.o ext/filter/callback_filter.o ext/hash/hash.o ext/hash/hash_md.o ext/hash/hash_sha.o ext/hash/hash_ripemd.o ext/hash/hash_haval.o ext/hash/hash_tiger.o ext/hash/hash_gost.o ext/hash/hash_snefru.o ext/hash/hash_whirlpool.o ext/hash/hash_adler32.o ext/hash/hash_crc32.o ext/hash/hash_fnv.o ext/hash/hash_joaat.o ext/hash/sha3/generic64lc/KeccakP-1600-opt64.o ext/hash/sha3/generic64lc/KeccakHash.o ext/hash/sha3/generic64lc/KeccakSponge.o ext/hash/hash_sha3.o ext/hash/murmur/PMurHash.o ext/hash/murmur/PMurHash128.o ext/hash/hash_murmur.o ext/hash/hash_xxhash.o ext/json/json.o ext/json/json_encoder.o ext/json/json_parser.o ext/json/json_scanner.o ext/pcntl/pcntl.o ext/pcntl/php_signal.o ext/random/random.o ext/random/csprng.o ext/random/engine_combinedlcg.o ext/random/engine_mt19937.o ext/random/engine_pcgoneseq128xslrr64.o ext/random/engine_xoshiro256starstar.o ext/random/engine_secure.o ext/random/engine_user.o ext/random/gammasection.o ext/random/randomizer.o ext/readline/readline.o ext/readline/readline_cli.o ext/reflection/php_reflection.o ext/session/mod_user_class.o ext/session/session.o ext/session/mod_files.o ext/session/mod_mm.o ext/session/mod_user.o ext/spl/php_spl.o ext/spl/spl_functions.o ext/spl/spl_iterators.o ext/spl/spl_array.o ext/spl/spl_directory.o ext/spl/spl_exceptions.o ext/spl/spl_observer.o ext/spl/spl_dllist.o ext/spl/spl_heap.o ext/spl/spl_fixedarray.o ext/standard/array.o ext/standard/base64.o ext/standard/basic_functions.o ext/standard/browscap.o ext/standard/crc32.o ext/standard/crypt.o ext/standard/datetime.o ext/standard/dir.o ext/standard/dl.o ext/standard/dns.o ext/standard/exec.o ext/standard/file.o ext/standard/filestat.o ext/standard/flock_compat.o ext/standard/formatted_print.o ext/standard/fsock.o ext/standard/head.o ext/standard/html.o ext/standard/image.o ext/standard/info.o ext/standard/iptc.o ext/standard/link.o ext/standard/mail.o ext/standard/math.o ext/standard/md5.o ext/standard/metaphone.o ext/standard/microtime.o ext/standard/pack.o ext/standard/pageinfo.o ext/standard/quot_print.o ext/standard/soundex.o ext/standard/string.o ext/standard/scanf.o ext/standard/syslog.o ext/standard/type.o ext/standard/uniqid.o ext/standard/url.o ext/standard/var.o ext/standard/versioning.o ext/standard/assert.o ext/standard/strnatcmp.o ext/standard/levenshtein.o ext/standard/incomplete_class.o ext/standard/url_scanner_ex.o ext/standard/ftp_fopen_wrapper.o ext/standard/http_fopen_wrapper.o ext/standard/php_fopen_wrapper.o ext/standard/credits.o ext/standard/css.o ext/standard/var_unserializer.o ext/standard/ftok.o ext/standard/sha1.o ext/standard/user_filters.o ext/standard/uuencode.o ext/standard/filters.o ext/standard/proc_open.o ext/standard/streamsfuncs.o ext/standard/http.o ext/standard/password.o ext/standard/net.o ext/standard/hrtime.o ext/standard/crc32_x86.o ext/standard/libavifinfo/avifinfo.o Zend/asm/make_x86_64_sysv_elf_gas.o Zend/asm/jump_x86_64_sysv_elf_gas.o TSRM/TSRM.o main/main.o main/snprintf.o main/spprintf.o main/fopen_wrappers.o main/php_scandir.o main/php_ini_builder.o main/php_ini.o main/SAPI.o main/rfc1867.o main/php_content_types.o main/strlcpy.o main/strlcat.o main/explicit_bzero.o main/reentrancy.o main/php_variables.o main/php_ticks.o main/network.o main/php_open_temporary_file.o main/php_odbc_utils.o main/safe_bcmp.o main/output.o main/getopt.o main/php_syslog.o main/streams/streams.o main/streams/cast.o main/streams/memory.o main/streams/filter.o main/streams/plain_wrapper.o main/streams/userspace.o main/streams/transports.o main/streams/xp_socket.o main/streams/mmap.o main/streams/glob_wrapper.o Zend/zend_language_parser.o Zend/zend_language_scanner.o Zend/zend_ini_parser.o Zend/zend_ini_scanner.o Zend/zend_alloc.o Zend/zend_call_stack.o Zend/zend_compile.o Zend/zend_constants.o Zend/zend_dtrace.o Zend/zend_execute_API.o Zend/zend_highlight.o Zend/zend_llist.o Zend/zend_vm_opcodes.o Zend/zend_opcode.o Zend/zend_operators.o Zend/zend_ptr_stack.o Zend/zend_stack.o Zend/zend_variables.o Zend/zend.o Zend/zend_API.o Zend/zend_extensions.o Zend/zend_hash.o Zend/zend_list.o Zend/zend_builtin_functions.o Zend/zend_attributes.o Zend/zend_execute.o Zend/zend_ini.o Zend/zend_sort.o Zend/zend_multibyte.o Zend/zend_stream.o Zend/zend_iterators.o Zend/zend_interfaces.o Zend/zend_exceptions.o Zend/zend_strtod.o Zend/zend_gc.o Zend/zend_closures.o Zend/zend_weakrefs.o Zend/zend_float.o Zend/zend_string.o Zend/zend_signal.o Zend/zend_generators.o Zend/zend_virtual_cwd.o Zend/zend_ast.o Zend/zend_objects.o Zend/zend_object_handlers.o Zend/zend_objects_API.o Zend/zend_default_classes.o Zend/zend_inheritance.o Zend/zend_smart_str.o Zend/zend_cpuinfo.o Zend/zend_gdb.o Zend/zend_observer.o Zend/zend_system_id.o Zend/zend_enum.o Zend/zend_fibers.o Zend/zend_atomic.o Zend/zend_max_execution_timer.o Zend/zend_hrtime.o Zend/Optimizer/zend_optimizer.o Zend/Optimizer/pass1.o Zend/Optimizer/pass3.o Zend/Optimizer/optimize_func_calls.o Zend/Optimizer/block_pass.o Zend/Optimizer/optimize_temp_vars_5.o Zend/Optimizer/nop_removal.o Zend/Optimizer/compact_literals.o Zend/Optimizer/zend_cfg.o Zend/Optimizer/zend_dfg.o Zend/Optimizer/dfa_pass.o Zend/Optimizer/zend_ssa.o Zend/Optimizer/zend_inference.o Zend/Optimizer/zend_func_info.o Zend/Optimizer/zend_call_graph.o Zend/Optimizer/sccp.o Zend/Optimizer/scdf.o Zend/Optimizer/dce.o Zend/Optimizer/escape_analysis.o Zend/Optimizer/compact_vars.o Zend/Optimizer/zend_dump.o main/internal_functions_cli.o main/fastcgi.o sapi/cgi/cgi_main.o -lcrypt -lcrypt -lncurses -lrt -lstdc++ -lrt -lm -lxml2 -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lssl -lcrypto -lpcre2-8 -lz -ledit -lcrypt  -o sapi/cgi/php-cgi
/usr/bin/ld: main/main.o: in function `php_request_startup':
/builddir/build/BUILD/php-8.3.0beta2/main/main.c:1722: undefined reference to `DTRACE_REQUEST_STARTUP'
/usr/bin/ld: main/main.o: in function `php_request_shutdown':
/builddir/build/BUILD/php-8.3.0beta2/main/main.c:1913: undefined reference to `DTRACE_REQUEST_SHUTDOWN'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_compile_file':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:47: undefined reference to `DTRACE_COMPILE_FILE_ENTRY'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:49: undefined reference to `DTRACE_COMPILE_FILE_RETURN'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_execute_ex':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:62: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:62: undefined reference to `DTRACE_EXECUTE_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:68: undefined reference to `DTRACE_FUNCTION_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:68: undefined reference to `DTRACE_FUNCTION_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:73: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:77: undefined reference to `DTRACE_FUNCTION_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:78: undefined reference to `DTRACE_FUNCTION_ENTRY'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:83: undefined reference to `DTRACE_FUNCTION_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:87: undefined reference to `DTRACE_EXECUTE_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:83: undefined reference to `DTRACE_FUNCTION_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:88: undefined reference to `DTRACE_EXECUTE_RETURN'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:84: undefined reference to `DTRACE_FUNCTION_RETURN'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:73: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:74: undefined reference to `DTRACE_EXECUTE_ENTRY'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:83: undefined reference to `DTRACE_FUNCTION_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:63: undefined reference to `DTRACE_FUNCTION_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:63: undefined reference to `DTRACE_FUNCTION_RETURN_ENABLED'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_execute_internal':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:96: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:96: undefined reference to `DTRACE_EXECUTE_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:101: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:107: undefined reference to `DTRACE_EXECUTE_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:101: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:102: undefined reference to `DTRACE_EXECUTE_ENTRY'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_error_notify_cb':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:114: undefined reference to `DTRACE_ERROR_ENABLED'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_execute_internal':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:108: undefined reference to `DTRACE_EXECUTE_RETURN'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_error_notify_cb':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:115: undefined reference to `DTRACE_ERROR'
/usr/bin/ld: main/main.o: in function `php_request_startup':
/builddir/build/BUILD/php-8.3.0beta2/main/main.c:1722: undefined reference to `DTRACE_REQUEST_STARTUP'
/usr/bin/ld: main/main.o: in function `php_request_shutdown':
/builddir/build/BUILD/php-8.3.0beta2/main/main.c:1913: undefined reference to `DTRACE_REQUEST_SHUTDOWN'
/usr/bin/ld: /usr/bin/ld: main/main.o: in function `php_request_startup':
/builddir/build/BUILD/php-8.3.0beta2/main/main.c:1722: undefined reference to `DTRACE_REQUEST_STARTUP'
/usr/bin/ld: main/main.o: in function `php_request_shutdown':
/builddir/build/BUILD/php-8.3.0beta2/main/main.c:1913: undefined reference to `DTRACE_REQUEST_SHUTDOWN'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_compile_file':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:47: undefined reference to `DTRACE_COMPILE_FILE_ENTRY'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:49: undefined reference to `DTRACE_COMPILE_FILE_RETURN'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_execute_ex':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:62: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:62: undefined reference to `DTRACE_EXECUTE_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:68: undefined reference to `DTRACE_FUNCTION_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:68: undefined reference to `DTRACE_FUNCTION_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:73: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:77: undefined reference to `DTRACE_FUNCTION_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:78: undefined reference to `DTRACE_FUNCTION_ENTRY'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:83: undefined reference to `DTRACE_FUNCTION_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:87: undefined reference to `DTRACE_EXECUTE_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:83: undefined reference to `DTRACE_FUNCTION_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:88: undefined reference to `DTRACE_EXECUTE_RETURN'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:84: undefined reference to `DTRACE_FUNCTION_RETURN'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:73: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:74: undefined reference to `DTRACE_EXECUTE_ENTRY'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:83: undefined reference to `DTRACE_FUNCTION_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:63: undefined reference to `DTRACE_FUNCTION_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:63: undefined reference to `DTRACE_FUNCTION_RETURN_ENABLED'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_execute_internal':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:96: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:96: undefined reference to `DTRACE_EXECUTE_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:101: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:107: undefined reference to `DTRACE_EXECUTE_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:101: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:102: undefined reference to `DTRACE_EXECUTE_ENTRY'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_error_notify_cb':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:114: undefined reference to `DTRACE_ERROR_ENABLED'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_execute_internal':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:108: undefined reference to `DTRACE_EXECUTE_RETURN'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_error_notify_cb':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:115: undefined reference to `DTRACE_ERROR'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_compile_file':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:47: undefined reference to `DTRACE_COMPILE_FILE_ENTRY'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:49: undefined reference to `DTRACE_COMPILE_FILE_RETURN'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_execute_ex':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:62: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:62: undefined reference to `DTRACE_EXECUTE_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:68: undefined reference to `DTRACE_FUNCTION_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:68: undefined reference to `DTRACE_FUNCTION_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:73: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:77: undefined reference to `DTRACE_FUNCTION_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:78: undefined reference to `DTRACE_FUNCTION_ENTRY'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:83: undefined reference to `DTRACE_FUNCTION_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:87: undefined reference to `DTRACE_EXECUTE_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:83: undefined reference to `DTRACE_FUNCTION_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:88: undefined reference to `DTRACE_EXECUTE_RETURN'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:84: undefined reference to `DTRACE_FUNCTION_RETURN'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:73: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:74: undefined reference to `DTRACE_EXECUTE_ENTRY'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:83: undefined reference to `DTRACE_FUNCTION_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:63: undefined reference to `DTRACE_FUNCTION_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:63: undefined reference to `DTRACE_FUNCTION_RETURN_ENABLED'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_execute_internal':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:96: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:96: undefined reference to `DTRACE_EXECUTE_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:101: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:107: undefined reference to `DTRACE_EXECUTE_RETURN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:101: undefined reference to `DTRACE_EXECUTE_ENTRY_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:102: undefined reference to `DTRACE_EXECUTE_ENTRY'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_error_notify_cb':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:114: undefined reference to `DTRACE_ERROR_ENABLED'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_execute_internal':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:108: undefined reference to `DTRACE_EXECUTE_RETURN'
/usr/bin/ld: Zend/zend_dtrace.o: in function `dtrace_error_notify_cb':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_dtrace.c:115: undefined reference to `DTRACE_ERROR'
/usr/bin/ld: /usr/bin/ld: Zend/zend_execute.o: in function `ZEND_CATCH_SPEC_CONST_HANDLER':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_vm_execute.h:4739: undefined reference to `DTRACE_EXCEPTION_CAUGHT_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_vm_execute.h:4740: undefined reference to `DTRACE_EXCEPTION_CAUGHT'
/usr/bin/ld: Zend/zend_exceptions.o: in function `zend_throw_exception_internal':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_exceptions.c:173: undefined reference to `DTRACE_EXCEPTION_THROWN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_exceptions.c:175: undefined reference to `DTRACE_EXCEPTION_THROWN'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_exceptions.c:177: undefined reference to `DTRACE_EXCEPTION_THROWN'
Zend/zend_execute.o: in function `ZEND_CATCH_SPEC_CONST_HANDLER':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_vm_execute.h:4739: undefined reference to `DTRACE_EXCEPTION_CAUGHT_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_vm_execute.h:4740: undefined reference to `DTRACE_EXCEPTION_CAUGHT'
Zend/zend_execute.o: in function `ZEND_CATCH_SPEC_CONST_HANDLER':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_vm_execute.h:4739: undefined reference to `DTRACE_EXCEPTION_CAUGHT_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_vm_execute.h:4740: undefined reference to `DTRACE_EXCEPTION_CAUGHT'
/usr/bin/ld: Zend/zend_exceptions.o: in function `zend_throw_exception_internal':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_exceptions.c:173: undefined reference to `DTRACE_EXCEPTION_THROWN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_exceptions.c:175: undefined reference to `DTRACE_EXCEPTION_THROWN'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_exceptions.c:177: undefined reference to `DTRACE_EXCEPTION_THROWN'
/usr/bin/ld: Zend/zend_exceptions.o: in function `zend_throw_exception_internal':
/builddir/build/BUILD/php-8.3.0beta2/Zend/zend_exceptions.c:173: undefined reference to `DTRACE_EXCEPTION_THROWN_ENABLED'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_exceptions.c:175: undefined reference to `DTRACE_EXCEPTION_THROWN'
/usr/bin/ld: /builddir/build/BUILD/php-8.3.0beta2/Zend/zend_exceptions.c:177: undefined reference to `DTRACE_EXCEPTION_THROWN'
/bin/sh /builddir/build/BUILD/php-8.3.0beta2/build-cgi/libtool --silent --preserve-dup-deps --tag CC --mode=link gcc -shared -I/builddir/build/BUILD/php-8.3.0beta2/build-cgi/include -I/builddir/build/BUILD/php-8.3.0beta2/build-cgi/main -I/builddir/build/BUILD/php-8.3.0beta2 -I/builddir/build/BUILD/php-8.3.0beta2/build-cgi/ext/date/lib -I/builddir/build/BUILD/php-8.3.0beta2/ext/date/lib -I/usr/include/libxml2 -I/usr/include/enchant-2 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/webp -I/usr/include/imap -I/builddir/build/BUILD/php-8.3.0beta2/ext/mbstring/libmbfl -I/builddir/build/BUILD/php-8.3.0beta2/build-cgi/ext/mbstring/libmbfl -I/builddir/build/BUILD/php-8.3.0beta2/ext/mbstring/libmbfl/mbfl -I/builddir/build/BUILD/php-8.3.0beta2/build-cgi/ext/mbstring/libmbfl/mbfl -I/usr/include/oracle/21.10/client64 -I/usr/include/capstone -I/usr/include/pspell -I/usr/include/editline -I/builddir/build/BUILD/php-8.3.0beta2/build-cgi/TSRM -I/builddir/build/BUILD/php-8.3.0beta2/build-cgi/Zend -I/builddir/build/BUILD/php-8.3.0beta2/main -I/builddir/build/BUILD/php-8.3.0beta2/Zend -I/builddir/build/BUILD/php-8.3.0beta2/TSRM -I/builddir/build/BUILD/php-8.3.0beta2/build-cgi/  -D_GNU_SOURCE -I/usr/include/imap  -fno-common -Wstrict-prototypes -Wformat-truncation -Wlogical-op -Wduplicated-cond -Wno-clobbered -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-strict-aliasing -Wno-pointer-sign -fvisibility=hidden -Wimplicit-fallthrough=1 -DZEND_SIGNALS   -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes  -o ext/opcache/opcache.la -export-dynamic -avoid-version -prefer-pic -module -rpath /builddir/build/BUILD/php-8.3.0beta2/build-cgi/modules -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes ext/opcache/ZendAccelerator.lo ext/opcache/zend_accelerator_blacklist.lo ext/opcache/zend_accelerator_debug.lo ext/opcache/zend_accelerator_hash.lo ext/opcache/zend_accelerator_module.lo ext/opcache/zend_persist.lo ext/opcache/zend_persist_calc.lo ext/opcache/zend_file_cache.lo ext/opcache/zend_shared_alloc.lo ext/opcache/zend_accelerator_util_funcs.lo ext/opcache/shared_alloc_shm.lo ext/opcache/shared_alloc_mmap.lo ext/opcache/shared_alloc_posix.lo ext/opcache/jit/zend_jit.lo ext/opcache/jit/zend_jit_gdb.lo ext/opcache/jit/zend_jit_vm_helpers.lo -lcapstone -lrt
collect2: error: ld returned 1 exit status

PHP Version

PHP 8.3.0beta2

Operating System

Fedora and RHEL

@remicollet
Copy link
Member Author

@petk perhaps related to 475fd29

@remicollet
Copy link
Member Author

I confirm, a simple revert fix the build

@petk
Copy link
Member

petk commented Aug 1, 2023

Thanks for finding this. I'll check it out soon. Pinging also @f4z4on if he knows what is happening here.

@Girgias
Copy link
Member

Girgias commented Aug 1, 2023

We really should have a CI build which builds with DTrace.

@remicollet
Copy link
Member Author

Perhaps related to CPP being defined as "gcc -E" on such distribution, don't know if this is supported by dtrace (ex: if run some king of "which $CPP")

@f4z4on
Copy link
Contributor

f4z4on commented Aug 1, 2023

And by the way, if I remember correctly, the issue is that the “make” rule I mentioned above:

Zend/zend_dtrace_gen.h: /Users/f4z4/Developer/PHP/php-src/Zend/zend_dtrace.d     
        CPP="$(CPP)" CC="$(CC)" CFLAGS="$(CFLAGS_CLEAN)" dtrace -h -C -s /Users/f4z4/Developer/PHP/php-src/Zend/zend_dtrace.d -o $@.bak && $(SED) -e 's,PHP_,DTRACE_,g' $@.bak > $@

generates empty Zend/zend_dtrace_gen.h because of that broken execution of program referenced by CPP environment variable. Everything starts cracking after that…

@f4z4on
Copy link
Contributor

f4z4on commented Aug 1, 2023

Another by the way, this is an issue with SystemTap. It should work with or without workaround with or without spaces in CPP when using Oracle’s DTrace or its forks. It certainly works on my Mac… These implementations do not use C compiler and preprocessor (at least not in the way SystemTap’s dtrace does).

@petk
Copy link
Member

petk commented Aug 1, 2023

Thanks for the info. Wouldn't it be simpler to introduce something like DTRACE_CPP variable instead? That way the DTrace specific preprocessor can be set for cases that want that (DTRACE_CPP="..." ./configure --enable-dtrace), otherwise the default system preprocessor is used (cpp or which ever it is linked to on the system). The produced Makefile, dtrace Python script and those spaces seem to work correctly. Issue seems to be more with the way gcc -E and cpp operates on some specific system. Maybe adding more options to the gcc -E command would produce the same Zend/zend_dtrace_gen.h but that is kind of beyond the issue here. And for the CC I think that's fine as it is now.

Edit: Something like this:

diff --git a/build/php.m4 b/build/php.m4
index 921a78eb78..83e6aa9a85 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
-	CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHP_,DTRACE_,g' \$[]@.bak > \$[]@
+	CC="\$(CC)" $DTRACE_CPP 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 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 [\\]
+	if CC="\$(CC)" $DTRACE_CPP 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 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 [\\]
+	if CC="\$(CC)" $DTRACE_CPP 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)
-	CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $abs_srcdir/$ac_provsrc $dtrace_objs
+	CC="\$(CC)" $DTRACE_CPP CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $abs_srcdir/$ac_provsrc $dtrace_objs
 
 EOF
     ;;
diff --git a/configure.ac b/configure.ac
index 66503615ed..cfc3b77f3e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1043,6 +1043,10 @@ if test "$PHP_IPV6" != "no" && test "$ac_cv_ipv6_support" = yes; then
 fi
 
 dnl DTRACE checks. Note: this has to be done after SAPI configuration.
+AC_ARG_VAR([DTRACE_CPP],[Override default DTrace cpp preprocessor when using --enable-dtrace option])
+dnl
+AS_IF([test -z "$DTRACE_CPP"],[],[DTRACE_CPP="CPP=\"$DTRACE_CPP\""])
+
 PHP_ARG_ENABLE([dtrace],
   [whether to enable DTrace support],
   [AS_HELP_STRING([--enable-dtrace],
diff --git a/ext/oci8/config.m4 b/ext/oci8/config.m4
index 883e272fb1..51b147a6c6 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
-	CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHPOCI_,DTRACE_,g' \$[]@.bak > \$[]@
+	CC="\$(CC)" $DTRACE_CPP 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 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 [\\]
+	if CC="\$(CC)" $DTRACE_CPP 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 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 [\\]
+	if CC="\$(CC)" $DTRACE_CPP 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)
-	CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $ac_srcdir[$]ac_provsrc $dtrace_oci8_objs
+	CC="\$(CC)" $DTRACE_CPP CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $ac_srcdir[$]ac_provsrc $dtrace_oci8_objs
 
 EOF
     ;;

Edit 2: For example, passing the -xc option to gcc -E seems to work correctly then. Yeah, this needs to be fine tuned probably just a bit further... CPP="gcc -E -xc" dtrace -h -C -s Zend/zend_dtrace.d -o Zend/zend_dtrace_gen.h

petk added a commit to petk/php-src that referenced this issue Aug 1, 2023
The way the DTrace generates files depend on the given preprocessor.
Without passing the CPP environment variable dtrace Python script uses
the cpp by default.

For systems where the CPP is set to something else, the generated files
won't be created the same way, so instead the DTrace preprocessor can be
overriden manually with the new DTRACE_CPP variable. For example:

./configure DTRACE_CPP="gcc -E -xc"

Fixes #phpGH-11847
petk added a commit to petk/php-src that referenced this issue Aug 1, 2023
The way DTrace generates files depend on the given preprocessor. Without
passing the CPP environment variable dtrace Python script uses the cpp
by default.

For systems where the CPP is set to something else, the generated files
won't be created the same way, so instead the DTrace preprocessor can be
overriden manually with the new DTRACE_CPP variable. For example:

./configure DTRACE_CPP="gcc -E -xc" --enable-dtrace

Fixes #phpGH-11847
petk added a commit to petk/php-src that referenced this issue Aug 1, 2023
The way DTrace generates files depend on the given preprocessor. Without
passing the CPP environment variable dtrace Python script uses the cpp
by default.

For systems where the CPP is set to something else, the generated files
won't be created the same way, so instead the DTrace preprocessor can be
overriden manually with the new DTRACE_CPP variable. For example:

./configure DTRACE_CPP="gcc -E -xc" --enable-dtrace

Fixes phpGH-11847
petk added a commit to petk/php-src that referenced this issue Aug 1, 2023
The way DTrace generates files depend on the given preprocessor. Without
passing the CPP environment variable dtrace Python script uses the cpp
by default.

For systems where the CPP is set to something else, the generated files
won't be created the same way, so instead the DTrace preprocessor can be
overriden manually with the new DTRACE_CPP variable. For example:

./configure DTRACE_CPP="gcc -E -xc" --enable-dtrace

Fixes phpGH-11847
@f4z4on
Copy link
Contributor

f4z4on commented Aug 2, 2023

I’ve accidentally deleted my long comment musing about possible causes and so on. With the newer information from previous comments, the only important bit that someone may need is, that a quick workaround for majority of cases is explicitly setting CPP when running configure script or executing make. For example:

./configure CPP=cpp && make

Or:

./configure && make CPP=cpp

f4z4on added a commit to f4z4on/php-src that referenced this issue Aug 2, 2023
We are experiencing an issue when building PHP with DTrace enabled with
SystemTap (see phpGH-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 phpGH-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 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).

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 precessor the user chose or
   configure detected (CPP).

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).

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… Therefore, intentional code seems like the best next
option.

Please note, all of 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). The same is true about
-C option which is specific to SystemTap which is also ignored by other
DTrace implementations.

† php#11847php#11643
f4z4on added a commit to f4z4on/php-src that referenced this issue Aug 2, 2023
We are experiencing an issue when building PHP with DTrace enabled with
SystemTap (see phpGH-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 phpGH-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 phpGH-11847php#11847php#11643
f4z4on added a commit to f4z4on/php-src that referenced this issue Aug 2, 2023
We are experiencing an issue when building PHP with DTrace enabled with
SystemTap (see phpGH-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 phpGH-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 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).

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).

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).

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… Therefore, intentional code seems like the best next
option.

Please note, all of 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). The same is true about
-C option which is specific to SystemTap which is also ignored by other
DTrace implementations.

† php#11847php#11643
f4z4on added a commit to f4z4on/php-src that referenced this issue Aug 2, 2023
We are experiencing an issue when building PHP with DTrace enabled with
SystemTap (see phpGH-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 phpGH-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 phpGH-11847php#11847php#11643
@f4z4on
Copy link
Contributor

f4z4on commented Aug 2, 2023

I'm copying my comments from pull request #11853 here. I've also submitted alternative pull request #11858. I guess it would be better to debate the merits here rather spreading it across many different places. Here are my comments:

Wow 🤯 That is definitely the issue. Spaces are alright… I’ll describe my thinking here (you PHP implementation folks all probably know this already 😅).

I was not aware of the difference between cpp and gcc -E. It’s probably the .d file extension which confuses gcc executable while cpp probably defaults to C. Proper D language does not have a preprocessor. However, DTrace uses #pragma directives (that is C preprocessing macro) for statically-defined traces (like PHP does) and scripts. Therefore -xc is correct, I guess. SystemTap’s dtrace defaults to cpp, so that issue wasn't visible until I started meddling with PHP cross compilation with DTrace enabled which requires different compiler executables altogether.

Now to possible solution…

I don’t think DTrace needs its own preprocessor. If so, people should be able to override it when invoking both ./configure and make. Much like CC, CFLAGS and so on. Good build systems following ./configure && make && make check paradigm do that. All in all, I still think there should not be a separate macro for users to set.

There may be a macro derived from CPP macro, similar to what CFLAGS and CFLAGS_CLEAN are doing. If someone really really wanted to override that, they still could, but I’d say that is a very obscure use case.

Or, and I prefer this one, we may simply force -xc after CPP when invoking dtrace -h -C on non-C files (that is files with .d extension). There is only one such invocation (two if you count oci8 extension), and it is that make rule I cherry-picked in my previous comment. The other invocations do not use preprocessing. So, perhaps even ditching CPP from their invocations to be more deliberate about it. Similarly ditching CC and CFLAGS from other dtrace -h -C invocations. This is SystemTap-specific behavior. The -C option is as well, and that is the option enabling C preprocessor use. SystemTap is Linux-only. Others ignore all of this… It just works for everyone… Anyone stumbling upon this code in years to come would see there is some complicated story right away because dtrace invocations differ. There is no silver bullet that would not introduce more complexity (i.e., additional m4 macros, macro dependencies, …) and I believe that’s something everyone should strive for to avoid unless necessary.

diff --git a/build/php.m4 b/build/php.m4
index 921a78eb78..73dd1e8e27 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
-	CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHP_,DTRACE_,g' \$[]@.bak > \$[]@
+	CPP="\$(CPP) -xc" 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 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 [\\]
+	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 [\\]
 	  echo "pic_object=['].libs/$dtrace_prov_name[']" >> \$[]@ [;\\]
 	else [\\]
 	  echo "pic_object='none'" >> \$[]@ [;\\]
 	fi
-	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 [\\]
+	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 [\\]
 	  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)
-	CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $abs_srcdir/$ac_provsrc $dtrace_objs
+	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 883e272fb1..6fcc6d9eab 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
-	CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHPOCI_,DTRACE_,g' \$[]@.bak > \$[]@
+	CPP="\$(CPP) -xc" 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 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 [\\]
+	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 [\\]
 	  echo "pic_object=['].libs/$dtrace_prov_name[']" >> \$[]@ [;\\]
 	else [\\]
 	  echo "pic_object='none'" >> \$[]@ [;\\]
 	fi
-	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 [\\]
+	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 [\\]
 	  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)
-	CPP="\$(CPP)" CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $ac_srcdir[$]ac_provsrc $dtrace_oci8_objs
+	CC="\$(CC)" CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $ac_srcdir[$]ac_provsrc $dtrace_oci8_objs
 
 EOF
     ;;

But… I’m talking here as a user of PHP build system who builds PHP regularly, including cross-compiling. There may be other consideration I am not aware of. From the outside, I prefer a simple solution which works and if there is a need for something obscure, people needing it are expected to understand how build systems work and how to modify them — there is no need to cater to them at the expense of introducing bloat. I believe a use case of using completely separate CPP just for dtrace utility from SystemTap on Linux is such an obscure case. These are just C macros, it’s just that we have found some C preprocessor invocations which do not default to C when processing source files with .d extension… Luckily on Linux with SystemTap, there’s a safe and broadly-implemented way of forcing it via that -xc option.

Another option is to stop setting CPP. As I mentioned above, SystemTap’s dtrace defaults to cpp and that just works… If I'm not mistaken, header files generated by dtrace are architecture-independent. I think I tested this, when I was working on #11643 because I originally wanted to only add CC. Then I thought that CPP is part of the suit along with CC, so if we’re passing along customized CC, we should also respect customized CPP. But as far as I can tell, it’s not necessary. I don't like this option though.

I still prefer appending -xc to CC and setting only the necessary environment variables for SystemTap’s dtrace based on what we want from dtrace in that particular invocation. (See the quote above)

@petk petk linked a pull request Aug 3, 2023 that will close this issue
f4z4on added a commit to f4z4on/php-src that referenced this issue Aug 4, 2023
We are experiencing an issue when building PHP with DTrace enabled with
SystemTap (see phpGH-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 phpGH-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).

† php#11847php#11643
f4z4on added a commit to f4z4on/php-src that referenced this issue Aug 4, 2023
We are experiencing an issue when building PHP with DTrace enabled with
SystemTap (see phpGH-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 phpGH-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 had 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). Therefore, we have recently stopped setting all
these environment variables when invoking dtrace. We set only what is
necessary for particular action. We hope it 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 macros. 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 to “cpp”, 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. D programs for DTrace commonly use C
language preprocessor. This includes statically-defined tracing probes
which can contain 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 may recognize this option too (most notably Clang). 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. This limitation of using only GCC-compatible compiler suite
does not apply to applications with statically-defined tracing. 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 the -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…
Moreover, such macros probably belong to a project like GNU Autoconf
rather than to PHP.

This has no effect on Oracle DTrace, Open DTrace or any of their forks
because they do not allow customization of preprocessor nor compiler via
environment variables. They simply ignore CPP, CC, and CFLAGS
environment variables, so it does not matter what values we set there.

Fixes phpGH-11847php#11847php#11643
f4z4on added a commit to f4z4on/php-src that referenced this issue Aug 30, 2023
We are experiencing an issue when building PHP with DTrace enabled with
SystemTap (see phpGH-11847).† The issue is caused by inappropriate use C
preprocessor detected by GNU Autoconf in our “configure” script. C
preprocessor configuration found by AC_PROG_CPP macro is portable only
to run on files with “.c” extension.‡ However, statically-defined tracing
is described by D programs with “.d” extension which causes the issue.
We experience this even on typical Linux distribution with GNU Compiler
Collection (GCC) unless we override the defaults detected by our
“configure” script.

Many major Linux distributions use SystemTap to provide “dtrace”
utility. It relies on both external C preprocessor and external C
compiler. C preprocessor can be customized via CPP environment variable.
Similarly, C compiler can be customized via CC environment variable. It
also allows customization of C compiler flags via CFLAGS environment
variable. We have recently aligned both CPP and CC environment variable
with C preprocessor and C compiler we use to build regular C source code
as provided by our “configure” script (see phpGH-11643).* We wanted to
allow cross-compilation on Linux for which this was the only blocker. 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 had modified all “dtrace” invocations in the same way to make it look
consistent. However, only the C compiler (CC environment variable) is
necessary to for cross-compilation. There have never been any reported
issue with the C preprocessor. We acknowledge it would be great to allow
C preprocessor customization as well. However, the implementation would
require a lot of effort to do correctly given the limitations of
AC_PROG_CPP macro from GNU Autoconf. This would be further complicated
by the fact that all DTrace implementations, not just SystemTap, allow C
preprocessor customization but Oracle DTrace, Open DTrace, and their
forks do it differently. Nevertheless, they all default to “cpp” utility
and they all have or had been working fine. Therefore, we believe simply
removing CPP stabilizes “dtrace” invocation on Linux systems with
SystemTap and aligns it with other system configurations on other
platforms, until someone comes with complete solution with custom “m4”
and “make” macros, while our build system on Linux with SystemTap
supports cross-compilation.

Fixes phpGH-11847php#11847https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.71/autoconf.html#index-AC_005fPROG_005fCPP-1
* php#11643
@petk petk linked a pull request Aug 30, 2023 that will close this issue
@bukka bukka closed this as completed in 02b3fb1 Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants