summaryrefslogtreecommitdiff
path: root/configure.in
diff options
context:
space:
mode:
authorngoto <ngoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-18 08:24:24 +0000
committerngoto <ngoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-18 08:24:24 +0000
commit1f225be2e51f0ff7376846d5631fd6287eb03d14 (patch)
treee2f44294d784990242f2a3b988a14af1cdb13c8d /configure.in
parent42d38decda9249ba77b365f2b242a76e7e109945 (diff)
* configure.in, Makefile.in, common.mk: support DTrace on Solaris 10,
based on r26235 by Yugui. On Solaris 10, low optimization level may also be needed, e.g. optflags="-xO1" or "-xO0" with Oracle SolarisStudio 12.3 cc. * configure.in (--enable-dtrace): new option to enable/disable DTrace support. By default, trying to enable if dtrace command is found on the system. It is disabled when cross compiling. * configure.in (RUBY_DTRACE_POSTPROCESS): new macro. checks whether the dtrace on the system needs postprocessing with "dtrace -G". The postprocessing is needed on Solaris 10 and other platforms. * configure.in (RUBY_DTRACE_BSD_BROKEN): new macro. checks whether the dtrace supports USDT. * configure.in (DTRACE): move after RUBY_DTRACE_POSTPROCESS. * configure.in (LD): On Solaris, /usr/ccs/bin/ld is preferred. * configure.in, Makefile.in, common.mk (DTRACE_OBJ): new macro for DTrace probe object generated by postprocessing with "dtrace -G". * Makefile.in, common.mk (probes.$(OBJEXT)): DTrace probe object generated by the postprocessing. New file probes.stamp is for rebuilding related objects that may be modified by "dtrace -G". * configure.in, Makefile.in, common.mk (DTRACE_GLOMMED_OBJ): new macro for DTrace static library hacks. * configure.in, Makefile.in (LIBRUBY_A_OBJS): ditto. * Makefile.in, common.mk (ruby-glommed.$(OBJEXT)): new target with rule for DTrace static library hacks. * common.mk (DTRACE_DEPENDENT_OBJS): objects depended on probes.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in111
1 files changed, 96 insertions, 15 deletions
diff --git a/configure.in b/configure.in
index 8560bee456..2afe75498f 100644
--- a/configure.in
+++ b/configure.in
@@ -378,7 +378,9 @@ AC_PROG_CXX
RUBY_MINGW32
AC_PROG_GCC_TRADITIONAL
AC_SUBST(GCC)
-AC_CHECK_TOOL([LD], [ld], [ld])
+AS_CASE(["$target_os"],
+[solaris*], [AC_PATH_TOOL([LD], [ld], [/usr/ccs/bin/ld], [/usr/ccs/bin:$PATH])],
+[AC_CHECK_TOOL([LD], [ld], [ld])])
AC_SUBST(LD)
if test "$GCC" = yes; then
linker_flag=-Wl,
@@ -388,20 +390,6 @@ else
linker_flag=
fi
-AC_CHECK_PROG([DTRACE], [${ac_tool_prefix}dtrace], [${ac_tool_prefix}dtrace])
-if test "$cross_compiling:$ac_cv_prog_DTRACE" = no: -a -n "$ac_tool_prefix"; then
- AC_CHECK_PROG([DTRACE], [dtrace], [dtrace])
-fi
-AS_CASE(["$target_os"],
-[freebsd*], [DTRACE=]
-)
-if test -n "$DTRACE"; then
- DTRACE_EXT=d
-else
- DTRACE_EXT=dmyh
-fi
-AC_SUBST(DTRACE_EXT)
-
RUBY_PROG_GNU_LD
RUBY_CPPOUTFILE
@@ -476,6 +464,54 @@ fi
MAKEDIRS="$MKDIR_P"
AC_SUBST(MAKEDIRS)
+AC_DEFUN([RUBY_DTRACE_POSTPROCESS],
+[AC_CACHE_CHECK(whether $DTRACE needs post processing, rb_cv_prog_dtrace_g,
+[
+ echo "int main(void){ return 0; }" > conftest.c
+ echo "provider conftest{};" > conftest_provider.d
+ $CC $CFLAGS -c -o conftest.o conftest.c
+ if $DTRACE -G -s conftest_provider.d conftest.o 2>/dev/null; then
+ rb_cv_prog_dtrace_g=yes
+ $1
+ else
+ rb_cv_prog_dtrace_g=no
+ $2
+ fi
+ rm -f conftest.o conftest.c conftest_provider.d conftest_provider.o
+])
+])
+
+AC_DEFUN([RUBY_DTRACE_BSD_BROKEN],
+[AC_CACHE_CHECK(whether dtrace USDT is broken, rb_cv_dtrace_bsd_broken,
+[
+ cat <<EOF > conftest.c
+#define _DTRACE_VERSION 1
+#include "conftest_provider.h"
+int main(void)
+{
+ if (CONFTEST_FIRE_ENABLED()) CONFTEST_FIRE();
+ return 0;
+}
+EOF
+ echo "provider conftest{ probe fire(); };" > conftest_provider.d
+ $DTRACE -h -o conftest_provider.h -s conftest_provider.d
+ $CC $CFLAGS -c -o conftest.o conftest.c
+ if $DTRACE -G -o conftest_provider.o -s conftest_provider.d conftest.o >/dev/null 2>/dev/null; then
+ rb_cv_dtrace_bsd_broken=no
+ $2
+ else
+ rb_cv_dtrace_bsd_broken=yes
+ $1
+ fi
+ rm -f conftest.[co] conftest_provider.[dho]
+])
+])
+
+AC_CHECK_PROG([DTRACE], [${ac_tool_prefix}dtrace], [${ac_tool_prefix}dtrace])
+if test "$cross_compiling:$ac_cv_prog_DTRACE" = no: -a -n "$ac_tool_prefix"; then
+ AC_CHECK_PROG([DTRACE], [dtrace], [dtrace])
+fi
+
AC_CHECK_PROGS(DOT, dot)
AC_CHECK_PROGS(DOXYGEN, doxygen)
AS_CASE(["${host_os}"], [nacl], [AC_PATH_PROG(PYTHON, python)])
@@ -2693,6 +2729,51 @@ if test "$EXEEXT" = .exe; then
AC_SUBST(EXECUTABLE_EXTS)
fi
+AC_ARG_ENABLE(dtrace,
+ AS_HELP_STRING([--enable-dtrace],
+ [enable DTrace for tracing ruby's internal.]),
+ [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_POSTPROCESS()
+ if test "$rb_cv_prog_dtrace_g" = 'yes'; then
+ RUBY_DTRACE_BSD_BROKEN([enable_dtrace=no], [enable_dtrace=yes])
+ else
+ enable_dtrace=yes
+ AS_CASE(["$target_os"],
+ [freebsd*], [enable_dtrace=no]
+ )
+ fi
+ else
+ enable_dtrace=no
+ fi
+fi
+
+LIBRUBY_A_OBJS='$(OBJS)'
+if test "${enable_dtrace}" = "yes"; then
+ if test -z "$DTRACE"; then
+ AC_MSG_ERROR([dtrace(1) is missing])
+ elif test "$cross_compiling" = yes; then
+ AC_MSG_ERROR([--enable-dtrace, however, cross compiling])
+ else
+ RUBY_DTRACE_POSTPROCESS()
+ if test "$rb_cv_prog_dtrace_g" = 'yes'; then
+ RUBY_DTRACE_BSD_BROKEN([AC_MSG_ERROR([--enable-dtrace, however, USDT is broken])], [])
+ DTRACE_OBJ='probes.$(OBJEXT)'
+ DTRACE_GLOMMED_OBJ='ruby-glommed.$(OBJEXT)'
+ LIBRUBY_A_OBJS='$(DTRACE_GLOMMED_OBJ)'
+ fi
+ fi
+ DTRACE_EXT=d
+else
+ DTRACE_EXT=dmyh
+fi
+AC_SUBST(DTRACE_EXT)
+AC_SUBST(DTRACE_OBJ)
+AC_SUBST(DTRACE_GLOMMED_OBJ)
+AC_SUBST(LIBRUBY_A_OBJS)
+
}
{ # build section