Issue #13041 has been updated by Nobuyoshi Nakada.

Status changed from Open to Feedback

Does this patch work?

```diff
diff --git c/Makefile.in i/Makefile.in
index 9c8748aa4d..52618232b0 100644
--- c/Makefile.in
+++ i/Makefile.in
@@ -174,7 +174,7 @@ OBJDUMP       = @OBJDUMP@
 OBJCOPY       = @OBJCOPY@
 VCS           = @VCS@
 VCSUP         = @VCSUP@
-DTRACE        = @DTRACE@
+DTRACE        = @DTRACE@ @DTRACE_OPT@
 DTRACE_EXT    = @DTRACE_EXT@
 DTRACE_OBJ    = @DTRACE_OBJ@
 DTRACE_REBUILD= @DTRACE_REBUILD@
diff --git c/configure.in i/configure.in
index 3e41be3b6d..2ab336ee23 100644
--- c/configure.in
+++ i/configure.in
@@ -640,18 +640,19 @@ AC_DEFUN([RUBY_DTRACE_AVAILABLE],
 [AC_CACHE_CHECK(whether dtrace USDT is available, rb_cv_dtrace_available,
 [
     echo "provider conftest{ probe fire(); };" > conftest_provider.d
-    if $DTRACE -h -o conftest_provider.h -s conftest_provider.d >/dev/null 2>/dev/null; then
-      AC_TRY_COMPILE([@%:@include "conftest_provider.h"], [CONFTEST_FIRE();], [
-	# DTrace is available on the system
-	rb_cv_dtrace_available=yes
-      ], [rb_cv_dtrace_available=no])
-    else
-      # DTrace is not available while dtrace command exists
-      # for example FreeBSD 8 or FreeBSD 9 without DTrace build option
-      rb_cv_dtrace_available=no
-    fi
+    rb_cv_dtrace_available=no
+    AS_FOR(opt, rb_dtrace_opt, ["-xnolibs" ""], [
+	AS_IF([$DTRACE -h -o conftest_provider.h -s conftest_provider.d >/dev/null 2>/dev/null],
+	    [AC_TRY_COMPILE([@%:@include "conftest_provider.h"], [CONFTEST_FIRE();], [
+		# DTrace is available on the system
+		rb_cv_dtrace_available=yes${rb_dtrace_opt:+"(opt)"}
+		break
+	    ])])
+    ])
     rm -f conftest.[co] conftest_provider.[dho]
 ])
+AS_CASE(["$rb_cv_dtrace_available"], ["yes("*")"],
+    [DTRACE_OPT=`expr "$rb_cv_dtrace_available" : "yes(\(.*\))"`])
 ])
 
 AC_DEFUN([RUBY_DTRACE_POSTPROCESS],
@@ -3990,48 +3991,45 @@ AC_ARG_ENABLE(dtrace,
         [enable DTrace for tracing inside ruby. enabled by default on systems having dtrace]),
         [enable_dtrace=$enableval], [enable_dtrace=auto])
 
-if test "${enable_dtrace}" = "auto"; then
-    if test x"$DTRACE" != x -a x"$cross_compiling" != xyes; then
-        RUBY_DTRACE_AVAILABLE()
-        enable_dtrace=$rb_cv_dtrace_available
-    else
-        enable_dtrace=no
-    fi
-fi
-
 LIBRUBY_A_OBJS='$(OBJS)'
 DTRACE_REBUILD=
-if test "${enable_dtrace}" = "yes"; then
-    if test -z "$DTRACE"; then
+AS_CASE(["${enable_dtrace}"], [yes|auto], [
+    RUBY_DTRACE_AVAILABLE()
+], [
+    rb_cv_dtrace_available=no
+])
+AS_CASE(["${enable_dtrace}"], [yes], [
+    AS_IF([test -z "$DTRACE"], [
         AC_MSG_ERROR([dtrace(1) is missing])
-    elif test "$cross_compiling" = yes; then
+    ], [test "$cross_compiling" = yes], [
         AC_MSG_ERROR([--enable-dtrace, however, cross compiling])
-    else
-        RUBY_DTRACE_AVAILABLE()
-        enable_dtrace=$rb_cv_dtrace_available
-        if test "${enable_dtrace}" = "no"; then
-            AC_MSG_ERROR([--enable-dtrace, however, USDT is not available])
-        fi
-        RUBY_DTRACE_POSTPROCESS()
-        if test "$rb_cv_prog_dtrace_g" != 'no'; then
-            DTRACE_OBJ='probes.$(OBJEXT)'
-        fi
-        if test "$rb_cv_prog_dtrace_g" = 'rebuild'; then
-            DTRACE_REBUILD=yes
-            LIBRUBY_A_OBJS='$(DTRACE_GLOMMED_OBJ)'
-        fi
-        AS_CASE("${target_os}", [freebsd*], [
-            # FreeBSD's dtrace requires libelf
-            LIBS="-lelf $LIBS"
-        ])
+    ], [test "${rb_cv_dtrace_available}" = "no"], [
+        AC_MSG_ERROR([--enable-dtrace, however, USDT is not available])
+    ])
+])
+AS_CASE([$rb_cv_dtrace_available],
+[yes*], [
+    RUBY_DTRACE_POSTPROCESS()
+    if test "$rb_cv_prog_dtrace_g" != 'no'; then
+        DTRACE_OBJ='probes.$(OBJEXT)'
     fi
+    if test "$rb_cv_prog_dtrace_g" = 'rebuild'; then
+        DTRACE_REBUILD=yes
+        LIBRUBY_A_OBJS='$(DTRACE_GLOMMED_OBJ)'
+    fi
+    AS_CASE("${target_os}", [freebsd*], [
+        # FreeBSD's dtrace requires libelf
+        LIBS="-lelf $LIBS"
+    ])
     DTRACE_EXT=d
-else
+], [
+    enable_dtrace=no
     DTRACE_EXT=dmyh
-fi
+])
 AC_SUBST(DTRACE_EXT)
 AC_SUBST(DTRACE_OBJ)
 AC_SUBST(DTRACE_REBUILD)
+AC_SUBST(DTRACE_OPT)
 AC_SUBST(LIBRUBY_A_OBJS)
 
 RUBY_SETJMP_TYPE
```

----------------------------------------
Bug #13041: ruby 2.4 rc1 dtrace build fixes
https://bugs.ruby-lang.org/issues/13041#change-62057

* Author: Steve Wills
* Status: Feedback
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
In FreeBSD before 11.0, using dtrace -G or -h will not work in a jail or without dtrace kernel modules loaded unless the -xnolibs flag is passed as well. Since we build in jails, this is needed during our build, so we have this patch:

https://svnweb.freebsd.org/ports/head/lang/ruby22/files/patch-Makefile.in?revision=369732&view=markup

We have used it with ruby 2.2, and 2.3 for a long time. Please consider it or a similar change for Ruby 2.4



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>