Bug 778740 - Allow to use Linux kernel headers for perf events. r=khuey
authorMike Hommey <mh+mozilla@glandium.org>
Sat, 04 Aug 2012 08:55:00 +0200
changeset 101421 040c3b5a99d09e1017d221fe3dfb24dfa92f3ec0
parent 101420 47b9642f6f1b45eb3596922ed0ea95904e85f937
child 101422 a8c1c8501141ea8e36d2f0e9de0c9507231c1691
push id23232
push useremorley@mozilla.com
push dateSat, 04 Aug 2012 18:12:50 +0000
treeherdermozilla-central@0a17cde2a4b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs778740
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 778740 - Allow to use Linux kernel headers for perf events. r=khuey
aclocal.m4
build/autoconf/linux.m4
configure.in
js/src/Makefile.in
js/src/aclocal.m4
js/src/build/autoconf/linux.m4
js/src/configure.in
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -18,16 +18,17 @@ builtin(include, build/autoconf/acwinpat
 builtin(include, build/autoconf/lto.m4)dnl
 builtin(include, build/autoconf/gcc-pr49911.m4)dnl
 builtin(include, build/autoconf/frameptr.m4)dnl
 builtin(include, build/autoconf/compiler-opts.m4)dnl
 builtin(include, build/autoconf/expandlibs.m4)dnl
 builtin(include, build/autoconf/arch.m4)dnl
 builtin(include, build/autoconf/android.m4)dnl
 builtin(include, build/autoconf/zlib.m4)dnl
+builtin(include, build/autoconf/linux.m4)dnl
 
 MOZ_PROG_CHECKMSYS()
 
 # Read the user's .mozconfig script.  We can't do this in
 # configure.in: autoconf puts the argument parsing code above anything
 # expanded from configure.in, and we need to get the configure options
 # from .mozconfig in place before that argument parsing code.
 MOZ_READ_MOZCONFIG(.)
new file mode 100644
--- /dev/null
+++ b/build/autoconf/linux.m4
@@ -0,0 +1,39 @@
+dnl This Source Code Form is subject to the terms of the Mozilla Public
+dnl License, v. 2.0. If a copy of the MPL was not distributed with this
+dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+AC_DEFUN([MOZ_LINUX_PERF_EVENT],
+[
+
+MOZ_ARG_WITH_STRING(linux-headers,
+[  --with-linux-headers=DIR
+                          location where the Linux kernel headers can be found],
+    linux_headers=$withval)
+
+LINUX_HEADERS_INCLUDES=
+
+if test "$linux_headers"; then
+    LINUX_HEADERS_INCLUDES="-I$linux_headers"
+fi
+
+_SAVE_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $LINUX_HEADERS_INCLUDES"
+
+dnl Performance measurement headers.
+MOZ_CHECK_HEADER(linux/perf_event.h,
+    [AC_CACHE_CHECK(for perf_event_open system call,ac_cv_perf_event_open,
+        [AC_TRY_COMPILE([#include <asm/unistd.h>],[return sizeof(__NR_perf_event_open);],
+        ac_cv_perf_event_open=yes,
+        ac_cv_perf_event_open=no)])])
+if test "$ac_cv_perf_event_open" = "yes"; then
+    HAVE_LINUX_PERF_EVENT_H=1
+else
+    HAVE_LINUX_PERF_EVENT_H=
+    LINUX_HEADERS_INCLUDES=
+fi
+AC_SUBST(HAVE_LINUX_PERF_EVENT_H)
+AC_SUBST(LINUX_HEADERS_INCLUDES)
+
+CFLAGS="$_SAVE_CFLAGS"
+
+])
--- a/configure.in
+++ b/configure.in
@@ -2985,16 +2985,18 @@ AC_SUBST(HAVE_DTRACE)
 case $target in
 *-aix4.3*|*-aix5*)
 	;;
 *)
 	MOZ_CHECK_HEADERS(sys/cdefs.h)
 	;;
 esac
 
+MOZ_LINUX_PERF_EVENT
+
 dnl Checks for libraries.
 dnl ========================================================
 case $target in
 *-hpux11.*)
 	;;
 *)
 	AC_CHECK_LIB(c_r, gethostbyname_r)
 	;;
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -838,16 +838,20 @@ ifdef HAVE_DTRACE
 	    -e '/const/!s/char \*/const char */g' \
 	    javascript-trace.h.in > javascript-trace.h
 
 # We can't automatically generate dependencies on auto-generated headers;
 # we have to list them explicitly.
 $(addsuffix .$(OBJ_SUFFIX),jsprobes jsinterp jsobj): $(CURDIR)/javascript-trace.h
 endif
 
+ifdef HAVE_LINUX_PERF_EVENT_H
+pm_linux.$(OBJ_SUFFIX): CXXFLAGS += $(LINUX_HEADERS_INCLUDES)
+endif
+
 ###############################################
 # BEGIN kludges for the Nitro assembler
 #
 
 # Needed to "configure" it correctly.  Unfortunately these
 # flags wind up being applied to all code in js/src, not just
 # the code in js/src/assembler.
 CXXFLAGS += -DUSE_SYSTEM_MALLOC=1 -DENABLE_ASSEMBLER=1
--- a/js/src/aclocal.m4
+++ b/js/src/aclocal.m4
@@ -17,10 +17,11 @@ builtin(include, build/autoconf/acwinpat
 builtin(include, build/autoconf/lto.m4)dnl
 builtin(include, build/autoconf/gcc-pr49911.m4)dnl
 builtin(include, build/autoconf/frameptr.m4)dnl
 builtin(include, build/autoconf/compiler-opts.m4)dnl
 builtin(include, build/autoconf/expandlibs.m4)dnl
 builtin(include, build/autoconf/arch.m4)dnl
 builtin(include, build/autoconf/android.m4)dnl
 builtin(include, build/autoconf/zlib.m4)dnl
+builtin(include, build/autoconf/linux.m4)dnl
 
 MOZ_PROG_CHECKMSYS()
new file mode 100644
--- /dev/null
+++ b/js/src/build/autoconf/linux.m4
@@ -0,0 +1,39 @@
+dnl This Source Code Form is subject to the terms of the Mozilla Public
+dnl License, v. 2.0. If a copy of the MPL was not distributed with this
+dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+AC_DEFUN([MOZ_LINUX_PERF_EVENT],
+[
+
+MOZ_ARG_WITH_STRING(linux-headers,
+[  --with-linux-headers=DIR
+                          location where the Linux kernel headers can be found],
+    linux_headers=$withval)
+
+LINUX_HEADERS_INCLUDES=
+
+if test "$linux_headers"; then
+    LINUX_HEADERS_INCLUDES="-I$linux_headers"
+fi
+
+_SAVE_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $LINUX_HEADERS_INCLUDES"
+
+dnl Performance measurement headers.
+MOZ_CHECK_HEADER(linux/perf_event.h,
+    [AC_CACHE_CHECK(for perf_event_open system call,ac_cv_perf_event_open,
+        [AC_TRY_COMPILE([#include <asm/unistd.h>],[return sizeof(__NR_perf_event_open);],
+        ac_cv_perf_event_open=yes,
+        ac_cv_perf_event_open=no)])])
+if test "$ac_cv_perf_event_open" = "yes"; then
+    HAVE_LINUX_PERF_EVENT_H=1
+else
+    HAVE_LINUX_PERF_EVENT_H=
+    LINUX_HEADERS_INCLUDES=
+fi
+AC_SUBST(HAVE_LINUX_PERF_EVENT_H)
+AC_SUBST(LINUX_HEADERS_INCLUDES)
+
+CFLAGS="$_SAVE_CFLAGS"
+
+])
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -2572,28 +2572,17 @@ AC_SUBST(HAVE_DTRACE)
 case $target in
 *-aix4.3*|*-aix5*)
 	;;
 *)
     MOZ_CHECK_HEADERS(sys/cdefs.h)
 	;;
 esac
 
-dnl Performance measurement headers.
-MOZ_CHECK_HEADER(linux/perf_event.h,
-    [AC_CACHE_CHECK(for perf_event_open system call,ac_cv_perf_event_open,
-        [AC_TRY_COMPILE([#include <sys/syscall.h>],[return sizeof(__NR_perf_event_open);],
-        ac_cv_perf_event_open=yes,
-        ac_cv_perf_event_open=no)])])
-if test "$ac_cv_perf_event_open" = "yes"; then
-    HAVE_LINUX_PERF_EVENT_H=1
-else
-    HAVE_LINUX_PERF_EVENT_H=
-fi
-AC_SUBST(HAVE_LINUX_PERF_EVENT_H)
+MOZ_LINUX_PERF_EVENT
 
 dnl Checks for libraries.
 dnl ========================================================
 case $target in
 *-hpux11.*)
 	;;
 *)
 	AC_CHECK_LIB(c_r, gethostbyname_r)