Bug #21271
openRuby build failure due to invalid probe specifier for dtrace
Description
I've noticed that building the master branch of Ruby fails on my MacBook with the following error about dtrace and probes.h:
% make
BASERUBY = /Users/nekketsuuu/.rbenv/shims/ruby --disable=gems
CC = clang
LD = ld
LDSHARED = clang -dynamiclib
CFLAGS = -isystem/opt/homebrew/include -isystem/opt/homebrew/include -fstack-protector-strong -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wmisleading-indentation -Wundef -pipe -arch arm64
XCFLAGS = -fno-strict-overflow -fvisibility=hidden -fexcess-precision=standard -DRUBY_EXPORT -fPIE -I. -I.ext/include/arm64-darwin24 -I../include -I.. -I../prism -I../enc/unicode/15.0.0 -Dmodular_gc_dir=
CPPFLAGS = -I/opt/homebrew/opt/openssl/include -I/opt/homebrew/opt/mysql-client@8.4/include -I/opt/homebrew/opt/libffi/include -isystem/opt/homebrew/include -I/opt/homebrew/opt/openssl/include -I/opt/homebrew/opt/mysql-client@8.4/include -I/opt/homebrew/opt/libffi/include -isystem/opt/homebrew/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT
DLDFLAGS = -L/opt/homebrew/opt/openssl/lib -L/opt/homebrew/opt/mysql-client@8.4/lib -L/opt/homebrew/opt/libffi/lib -L/opt/homebrew/lib -L/opt/homebrew/opt/openssl/lib -L/opt/homebrew/opt/mysql-client@8.4/lib -L/opt/homebrew/opt/libffi/lib -L/opt/homebrew/lib -Wl,-undefined,dynamic_lookup -fstack-protector-strong -Wl,-pie -framework CoreFoundation -arch arm64
SOLIBS = -lgmp -ldl -lobjc -lpthread
LANG = ja_JP.UTF-8
LC_ALL =
LC_CTYPE =
MFLAGS =
RUSTC = rustc
YJIT_RUSTC_ARGS = --crate-name=yjit --crate-type=staticlib --edition=2021 -g -C lto=thin -C opt-level=3 -C overflow-checks=on '--out-dir=/Users/nekketsuuu/dev/src/github.com/ruby/ruby/build/yjit/target/release/' ../yjit/src/lib.rs
Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin24.4.0
Thread model: posix
InstalledDir: /Applications/Xcode_16.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
compiling ../main.c
compiling ../dmydln.c
generating id.h
id.h updated
generating miniprelude.c
miniprelude.c updated
compiling ../miniinit.c
making ../array.rbinc
/Users/nekketsuuu/.rbenv/shims/ruby --disable=gems ../tool/gen_dummy_probes.rb ../probes.d > probes.dmyh
translating probes ../probes.d
dtrace: invalid probe specifier system/opt/homebrew/include: syntax error near end of input
make: *** [probes.h] Error 1
With running git bisect
, I found that the build started failing after the commit 060ae17c806f0ba955b1c5d825b890b6de6c47e3 https://github.com/ruby/ruby/commit/060ae17c806f0ba955b1c5d825b890b6de6c47e3 (between Ruby 3.4.3 d0b7e5b6a04bde21ca483d20a1546b28b401c2d4 and the HEAD 7e2ba5a91bcdc31e14502f797a6184e3f4d41747).
I'm not sure if this is a problem of my local configurations or a build script. Here is a summary of my configurations:
Configuration summary for ruby version 3.5.0
* Installation prefix: /Users/nekketsuuu/.rbenv/versions/master
* exec prefix: ${prefix}
* arch: arm64-darwin24
* site arch: ${arch}
* RUBY_BASE_NAME: ruby
* ruby lib prefix: ${libdir}/${RUBY_BASE_NAME}
* site libraries path: ${rubylibprefix}/${sitearch}
* vendor path: ${rubylibprefix}/vendor_ruby
* target OS: darwin24
* compiler: clang
* with thread: pthread
* with coroutine: arm64
* with modular GC: no
* enable shared libs: no
* dynamic library ext: bundle
* CFLAGS: ${hardenflags} -fdeclspec ${optflags} \
${debugflags} ${warnflags}
* LDFLAGS: -L. -L/opt/homebrew/opt/openssl/lib \
-L/opt/homebrew/opt/mysql-client@8.4/lib \
-L/opt/homebrew/opt/libffi/lib \
-L/opt/homebrew/lib \
-L/opt/homebrew/opt/openssl/lib \
-L/opt/homebrew/opt/mysql-client@8.4/lib \
-L/opt/homebrew/opt/libffi/lib \
-L/opt/homebrew/lib -fstack-protector-strong
* DLDFLAGS: -L/opt/homebrew/opt/openssl/lib \
-L/opt/homebrew/opt/mysql-client@8.4/lib \
-L/opt/homebrew/opt/libffi/lib \
-L/opt/homebrew/lib \
-L/opt/homebrew/opt/openssl/lib \
-L/opt/homebrew/opt/mysql-client@8.4/lib \
-L/opt/homebrew/opt/libffi/lib \
-L/opt/homebrew/lib -Wl,-undefined,dynamic_lookup
* optflags: -O3 -fno-fast-math
* debugflags: -ggdb3
* warnflags: -Wall -Wextra -Wextra-tokens \
-Wdeprecated-declarations -Wdivision-by-zero \
-Wdiv-by-zero -Wimplicit-function-declaration \
-Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 \
-Wwrite-strings -Wold-style-definition \
-Wmissing-noreturn -Wno-cast-function-type \
-Wno-constant-logical-operand -Wno-long-long \
-Wno-missing-field-initializers \
-Wno-overlength-strings -Wno-parentheses-equality \
-Wno-self-assign -Wno-tautological-compare \
-Wno-unused-parameter -Wno-unused-value \
-Wunused-variable -Wmisleading-indentation -Wundef
* hardenflags: -fstack-protector-strong -U_FORTIFY_SOURCE \
-D_FORTIFY_SOURCE=2
* strip command: strip -A -n
* install doc: rdoc
* YJIT support: yes
* RJIT support: yes
* man page type: doc
* BASERUBY -v: ruby 3.4.1 (2024-12-25 revision 48d4efcb85) \
+PRISM [arm64-darwin24]
and here is a full command logs by make Q=
:
translating probes ../probes.d
dtrace -xnolibs -o probes.h.tmp -h -C -I. -I.ext/include/arm64-darwin24 -I../include -I.. -I../prism -I../enc/unicode/15.0.0 -I/opt/homebrew/opt/openssl/include -I/opt/homebrew/opt/mysql-client@8.4/include -I/opt/homebrew/opt/libffi/include -isystem/opt/homebrew/include -I/opt/homebrew/opt/openssl/include -I/opt/homebrew/opt/mysql-client@8.4/include -I/opt/homebrew/opt/libffi/include -isystem/opt/homebrew/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -s ../probes.d
dtrace: invalid probe specifier system/opt/homebrew/include: syntax error near end of input
make: *** [probes.h] Error 1
It appears that CPPFLAGS contains -isystem
flag, and dtrace might handle it as -i
flag.
This is my first time submitting a bug issue here. Feel free to correct me if there are any mistakes. Also, let me know if more information is needed.
Updated by nekketsuuu (Takuma Ishikawa) 9 days ago
@nobu (Nobuyoshi Nakada) Do you remember why CPPFLAGS is needed for dtrace in this commit https://github.com/ruby/ruby/commit/060ae17c806f0ba955b1c5d825b890b6de6c47e3? In my understanding, according to the dtrace manual, -I
options passed to dtrace are forwarded to CPP as-is, along with a few other options. So it seems reasonable to provide CPPFLAGS to dtrace in principle, but the issue is that CPPFLAGS might contain options that dtrace itself doesn't understand.
Since the options passed to CPP are not always compatible with dtrace, I'm considering if we can transform or filter CPPFLAGS before passing them to dtrace -- for example, by just ignoring some unsupported options, or converting some search-path-related options to -I
. Alternatively, we could simply disable dtrace if CPPFLAGS includes unsupported options (i.e., if dtrace raises an error while configuring it with CPPFLAGS). Do you have any thoughts or suggestions on how best to handle this?
As a workaround, I was able to get the build to succeed in my environment by passing --enable-dtrace=no
to configure
. So this is no longer an urgent issue for me, but I'm curious how many others are running into the same problem, since my setup is just a standard MacBook Pro with Homebrew.