From: Kevin V. W. <va...@sa...> - 2013-04-08 19:04:48
|
On Mon, Apr 8, 2013 at 12:20 PM, Maynard Johnson <may...@us...> wrote: > On 04/03/2013 06:23 PM, Maynard Johnson wrote: >> Fix broken --with-kernel configure option > > Kevin, > If you have a chance to test this patch, your feedback would be appreciated. I'd like to know if this fixes your issue. Yep, that works. Thanks a bunch. > > -Maynard >> >> The --with-kernel configure option was improperly expecting to >> find necessary kernel headers in the pointed-to kernel source >> tree in some guaranteed locations, but this was a bad assumption. >> Instead, the user should run 'make headers_install' for their >> custom kernel and use the location of where the headers were >> installed when running oprofile's 'configure --with-kernel'. >> This patch fixes the configure script to give helpful messages >> to the user about how to properly install the kernel header >> files. >> >> A secondary fix is made to m4/kernelversion.m4 to remove the >> '-D__KERNEL__' flag. This flag isn't necessary, and I found that >> it causes problems with some kernel versions. >> >> Signed-off-by: Maynard Johnson <may...@us...> >> --- >> configure.ac | 33 ++++++++++++++++++++++++++++----- >> m4/kernelversion.m4 | 2 +- >> 2 files changed, 29 insertions(+), 6 deletions(-) >> >> diff --git a/configure.ac b/configure.ac >> index 872d776..a985d1d 100644 >> --- a/configure.ac >> +++ b/configure.ac >> @@ -66,16 +66,23 @@ If this option is not specified, configure will look for kernel header files in >> for a kernel-headers package -- /usr. Use this option in cross-compile enviroments >> or in situations where the host system does not support perf_events but you wish to build binaries >> for a target system that does support perf_events. Because of OProfile's use of syscalls, >> -kernel headers used during build must match the architecture of the intended target system.])], >> +kernel headers used during build must match the architecture of the intended target system. >> +NOTE: Run the command 'make headers_install INSTALL_HDR_PATH=<kernel-hdrs-install-dir>' >> +from the root directory of your kernel source tree, and use <kernel-hdrs-install-dir> for >> +oprofile's '--with-kernel' configure option.])], >> KERNELDIR=$withval) >> >> >> dnl Check kernel version for perf_events supported >> if test "$KERNELDIR" != ""; then >> - KINC="$KERNELDIR/include" >> - PERF_EVENT_FLAGS=" -I$KERNELDIR/include" >> - AC_SUBST(PERF_EVENT_FLAGS) >> - PERF_EVENT_H="$KERNELDIR/include/linux/perf_event.h" >> + if test -d $KERNELDIR; then >> + KINC="$KERNELDIR/include" >> + PERF_EVENT_FLAGS=" -I$KERNELDIR/include" >> + AC_SUBST(PERF_EVENT_FLAGS) >> + PERF_EVENT_H="$KERNELDIR/include/linux/perf_event.h" >> + else >> + echo "$KERNELDIR does not exist." >> + fi >> else >> PERF_EVENT_H="/usr/include/linux/perf_event.h" >> fi >> @@ -472,5 +479,21 @@ if test "$PERF_EVENT_H_EXISTS" != "yes" && test "$kernel_may_have_perf_events_s >> echo "Warning: perf_event.h not found. Either install the kernel headers package or" >> echo "use the --with-kernel option if you want the non-root, single application" >> echo "profiling support provided by operf." >> + echo "" >> + echo "If you run 'make' now, only the legacy ocontrol-based profiler will be built." >> fi >> >> +if test "$KERNELDIR" != "" && test "$kernel_has_perf_events_support" != "yes"; then >> + if ! test -d $KERNELDIR; then >> + echo "WARNING: You passed '--with-kernel=$KERNELDIR', but $KERNELDIR" >> + echo "does not exist." >> + else >> + echo "Warning: You requested to build with the '--with-kernel' option, but your kernel" >> + echo "headers were not accessible at the given location. Be sure you have run the following" >> + echo "command from within your kernel source tree:" >> + echo " make headers_install INSTALL_HDR_PATH=<kernel-hdrs-install-dir>" >> + echo "Then pass <kernel-hdrs-install-dir> to oprofile's '--with-kernel' configure option." >> + fi >> + echo "" >> + echo "If you run 'make' now, only the legacy ocontrol-based profiler will be built." >> +fi >> diff --git a/m4/kernelversion.m4 b/m4/kernelversion.m4 >> index db4b805..6655703 100644 >> --- a/m4/kernelversion.m4 >> +++ b/m4/kernelversion.m4 >> @@ -1,7 +1,7 @@ >> dnl AX_KERNEL_VERSION(major, minor, level, comparison, action-if-true, action-if-false) >> AC_DEFUN([AX_KERNEL_VERSION], [ >> SAVE_CFLAGS=$CFLAGS >> -CFLAGS="-I$KINC -D__KERNEL__ -Werror" >> +CFLAGS="-I$KINC -Werror" >> AC_TRY_COMPILE( >> [ >> #include <linux/version.h> >> > -- Kevin Van Workum, PhD Sabalcore Computing Inc. "Where Data Becomes Discovery" http://www.sabalcore.com 877-492-8027 ext. 11 -- |