diff mbox

[3,of,3] oprofile 0.9.8: fix compilation on powerpc

Message ID e866a53b0e64b92f119b.1363111856@BEANTN0L019720
State Superseded
Headers show

Commit Message

Thomas De Schampheleire March 12, 2013, 6:10 p.m. UTC
The oprofile build was broken on powerpc since version 0.9.8.
This was detected in several autobuilds, like
http://autobuild.buildroot.net/results/6f6c02d18495907d50fcdfc6003ac20d493c55fe/

The problem can be fixed by adding libpfm4 into the build and making a few
changes in the configure script. Because the configure script is changed,
we additionally need to prevent autoreconfiguring (which fails).
At the same time, I fixed the removed  --with-kernel-support configure
option.

Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>

---
 package/oprofile/Config.in                        |   1 +
 package/oprofile/oprofile-0.9.8-003-powerpc.patch |  27 +++++++++++++++++++++++++++
 package/oprofile/oprofile.mk                      |  16 ++++++++++++++--
 3 files changed, 42 insertions(+), 2 deletions(-)

Note: this is compile-tested on x86 and powerpc, but I was not able to test
it on target.

Comments

Reuben Dowle March 12, 2013, 8:20 p.m. UTC | #1
This series of patches fixes my build error I got when updating to latest buildroot sources on Friday. Fixing this was going to be my first task this Monday. Thanks!

I will check everything is working on my target later today. One possible minor change below:

> diff --git a/package/oprofile/oprofile.mk
> b/package/oprofile/oprofile.mk
> --- a/package/oprofile/oprofile.mk
> +++ b/package/oprofile/oprofile.mk
> @@ -8,7 +8,7 @@ OPROFILE_VERSION = 0.9.8
>  OPROFILE_SITE =
> http://downloads.sourceforge.net/project/oprofile/oprofile/oprofile-
> $(OPROFILE_VERSION)
>  OPROFILE_LICENSE = GPLv2+
>  OPROFILE_LICENSE_FILES = COPYING
> -OPROFILE_CONF_OPT = --localstatedir=/var --with-kernel-support
> +OPROFILE_CONF_OPT = --localstatedir=/var --with-kernel=$(SYSROOT_DIR)
>  OPROFILE_BINARIES = utils/ophelp pp/opannotate pp/oparchive pp/opgprof
>  OPROFILE_BINARIES += pp/opreport opjitconv/opjitconv daemon/oprofiled
>  OPROFILE_BINARIES += utils/op-check-perfevents pe_profiling/operf
> libabi/opimport
> @@ -29,7 +29,19 @@ ifeq ($(OPROFILE_ARCH),)
>  OPROFILE_ARCH = $(BR2_ARCH)
>  endif
>
> -OPROFILE_DEPENDENCIES = popt binutils
> +OPROFILE_DEPENDENCIES = popt binutils libpfm4

I think this dependency is only needed for powerpc. So something like:

OPROFILE_DEPENDENCIES = popt binutils
ifeq ($(BR2_powerpc),y)
OPROFILE_DEPENDENCIES += libpfm4
Endif

Might be better?

> +
> +define OPROFILE_PREVENT_AUTOMAKE
> +     # Prevent automake from running.
> +     (cd $(@D); touch -c config* aclocal.m4 Makefile*);
> +endef
> +
> +define OPROFILE_FIX_CROSS_UNAME
> +     $(SED) 's/`uname -m`/$(OPROFILE_ARCH)/' $(@D)/configure
> +endef
> +
> +OPROFILE_POST_PATCH_HOOKS += OPROFILE_PREVENT_AUTOMAKE
> +OPROFILE_POST_PATCH_HOOKS += OPROFILE_FIX_CROSS_UNAME
>
>  define OPROFILE_INSTALL_TARGET_CMDS
>       $(INSTALL) -d -m 755 $(TARGET_DIR)/usr/bin
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
The information in this email communication (inclusive of attachments) is confidential to 4RF Limited and the intended recipient(s). If you are not the intended recipient(s), please note that any use, disclosure, distribution or copying of this information or any part thereof is strictly prohibited and that the author accepts no liability for the consequences of any action taken on the basis of the information provided. If you have received this email in error, please notify the sender immediately by return email and then delete all instances of this email from your system. 4RF Limited will not accept responsibility for any consequences associated with the use of this email (including, but not limited to, damages sustained as a result of any viruses and/or any action or lack of action taken in reliance on it).
Thomas De Schampheleire March 13, 2013, 4:14 p.m. UTC | #2
Hi Reuben,

On Tue, Mar 12, 2013 at 9:20 PM, Reuben Dowle <reuben.dowle@4rf.com> wrote:
> This series of patches fixes my build error I got when updating to latest buildroot sources on Friday. Fixing this was going to be my first task this Monday. Thanks!
>
> I will check everything is working on my target later today. One possible minor change below:

Thanks for your feedback.
I noticed there is still a problem with one of the patches, but I'm
already looking forward to your runtime test.
See below...

>
>> diff --git a/package/oprofile/oprofile.mk
>> b/package/oprofile/oprofile.mk
>> --- a/package/oprofile/oprofile.mk
>> +++ b/package/oprofile/oprofile.mk
>> @@ -8,7 +8,7 @@ OPROFILE_VERSION = 0.9.8
>>  OPROFILE_SITE =
>> http://downloads.sourceforge.net/project/oprofile/oprofile/oprofile-
>> $(OPROFILE_VERSION)
>>  OPROFILE_LICENSE = GPLv2+
>>  OPROFILE_LICENSE_FILES = COPYING
>> -OPROFILE_CONF_OPT = --localstatedir=/var --with-kernel-support
>> +OPROFILE_CONF_OPT = --localstatedir=/var --with-kernel=$(SYSROOT_DIR)
>>  OPROFILE_BINARIES = utils/ophelp pp/opannotate pp/oparchive pp/opgprof
>>  OPROFILE_BINARIES += pp/opreport opjitconv/opjitconv daemon/oprofiled
>>  OPROFILE_BINARIES += utils/op-check-perfevents pe_profiling/operf
>> libabi/opimport
>> @@ -29,7 +29,19 @@ ifeq ($(OPROFILE_ARCH),)
>>  OPROFILE_ARCH = $(BR2_ARCH)
>>  endif
>>
>> -OPROFILE_DEPENDENCIES = popt binutils
>> +OPROFILE_DEPENDENCIES = popt binutils libpfm4
>
> I think this dependency is only needed for powerpc. So something like:
>
> OPROFILE_DEPENDENCIES = popt binutils
> ifeq ($(BR2_powerpc),y)
> OPROFILE_DEPENDENCIES += libpfm4
> Endif
>
> Might be better?

As far as I understand, these dependencies are only used for
build-time ordering. This means that libfm4, *if selected in the
config* will be built before oprofile. However, if libpfm4 is not
selected, and you're not on powerpc, you can still build oprofile.
The only benefit from the suggested code above, I think, is that on
non-powerpc targets the unnecessary ordering of oprofile / libpfm4 is
not enforced, but I think this will hardly give an impact on build
time.

Best regards,
Thomas
Arnout Vandecappelle March 13, 2013, 8:18 p.m. UTC | #3
On 03/13/13 17:14, Thomas De Schampheleire wrote:
> Hi Reuben,
>
> On Tue, Mar 12, 2013 at 9:20 PM, Reuben Dowle <reuben.dowle@4rf.com> wrote:
[snip]
>>> -OPROFILE_DEPENDENCIES = popt binutils
>>> +OPROFILE_DEPENDENCIES = popt binutils libpfm4
>>
>> I think this dependency is only needed for powerpc. So something like:
>>
>> OPROFILE_DEPENDENCIES = popt binutils
>> ifeq ($(BR2_powerpc),y)
>> OPROFILE_DEPENDENCIES += libpfm4
>> Endif
>>
>> Might be better?
>
> As far as I understand, these dependencies are only used for
> build-time ordering. This means that libfm4, *if selected in the
> config* will be built before oprofile.

  Nope. If libpfm4 is a dependency, it will be built even if you haven't 
configured it. So libpfm4 will be built unnecessarily.

  Regards,
  Arnout

> However, if libpfm4 is not
> selected, and you're not on powerpc, you can still build oprofile.
> The only benefit from the suggested code above, I think, is that on
> non-powerpc targets the unnecessary ordering of oprofile / libpfm4 is
> not enforced, but I think this will hardly give an impact on build
> time.
>
> Best regards,
> Thomas
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
>
diff mbox

Patch

diff --git a/package/oprofile/Config.in b/package/oprofile/Config.in
--- a/package/oprofile/Config.in
+++ b/package/oprofile/Config.in
@@ -2,6 +2,7 @@  config BR2_PACKAGE_OPROFILE
 	bool "oprofile"
 	select BR2_PACKAGE_POPT
 	select BR2_PACKAGE_BINUTILS
+	select BR2_PACKAGE_LIBPFM4 if BR2_powerpc
 	depends on BR2_INSTALL_LIBSTDCPP
 	depends on !BR2_aarch64 # binutils
 	help
diff --git a/package/oprofile/oprofile-0.9.8-003-powerpc.patch b/package/oprofile/oprofile-0.9.8-003-powerpc.patch
new file mode 100644
--- /dev/null
+++ b/package/oprofile/oprofile-0.9.8-003-powerpc.patch
@@ -0,0 +1,27 @@ 
+
+Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
+
+diff --git a/configure.ac b/configure.ac
+--- a/configure.ac
++++ b/configure.ac
+@@ -104,7 +104,7 @@ AC_DEFINE_UNQUOTED(HAVE_PERF_EVENTS, $HA
+ if test "$HAVE_PERF_EVENTS" = "1"; then
+ 	PFM_LIB=
+ 	arch="`uname -m`"
+-	if test "$arch" = "ppc64"; then
++	if test "$arch" = "ppc64" || test "$arch" = "ppc"; then
+ 		AC_CHECK_HEADER(perfmon/pfmlib.h,,[AC_MSG_ERROR([pfmlib.h not found; usually provided in papi devel package])])
+ 		AC_CHECK_LIB(pfm,pfm_get_event_name, HAVE_LIBPFM3='1'; HAVE_LIBPFM='1', [
+ 			AC_CHECK_LIB(pfm,pfm_get_os_event_encoding, HAVE_LIBPFM3='0'; HAVE_LIBPFM='1',
+diff --git a/configure b/configure
+--- a/configure
++++ b/configure
+@@ -16985,7 +16985,7 @@ cat >>confdefs.h <<_ACEOF
+ if test "$HAVE_PERF_EVENTS" = "1"; then
+ 	PFM_LIB=
+ 	arch="`uname -m`"
+-	if test "$arch" = "ppc64"; then
++	if test "$arch" = "ppc64" || test "$arch" = "ppc"; then
+ 		if test "${ac_cv_header_perfmon_pfmlib_h+set}" = set; then
+   { $as_echo "$as_me:$LINENO: checking for perfmon/pfmlib.h" >&5
+ $as_echo_n "checking for perfmon/pfmlib.h... " >&6; }
diff --git a/package/oprofile/oprofile.mk b/package/oprofile/oprofile.mk
--- a/package/oprofile/oprofile.mk
+++ b/package/oprofile/oprofile.mk
@@ -8,7 +8,7 @@  OPROFILE_VERSION = 0.9.8
 OPROFILE_SITE = http://downloads.sourceforge.net/project/oprofile/oprofile/oprofile-$(OPROFILE_VERSION)
 OPROFILE_LICENSE = GPLv2+
 OPROFILE_LICENSE_FILES = COPYING
-OPROFILE_CONF_OPT = --localstatedir=/var --with-kernel-support
+OPROFILE_CONF_OPT = --localstatedir=/var --with-kernel=$(SYSROOT_DIR)
 OPROFILE_BINARIES = utils/ophelp pp/opannotate pp/oparchive pp/opgprof
 OPROFILE_BINARIES += pp/opreport opjitconv/opjitconv daemon/oprofiled
 OPROFILE_BINARIES += utils/op-check-perfevents pe_profiling/operf libabi/opimport
@@ -29,7 +29,19 @@  ifeq ($(OPROFILE_ARCH),)
 OPROFILE_ARCH = $(BR2_ARCH)
 endif
 
-OPROFILE_DEPENDENCIES = popt binutils
+OPROFILE_DEPENDENCIES = popt binutils libpfm4
+
+define OPROFILE_PREVENT_AUTOMAKE
+	# Prevent automake from running.
+	(cd $(@D); touch -c config* aclocal.m4 Makefile*);
+endef
+
+define OPROFILE_FIX_CROSS_UNAME
+	$(SED) 's/`uname -m`/$(OPROFILE_ARCH)/' $(@D)/configure
+endef
+
+OPROFILE_POST_PATCH_HOOKS += OPROFILE_PREVENT_AUTOMAKE
+OPROFILE_POST_PATCH_HOOKS += OPROFILE_FIX_CROSS_UNAME
 
 define OPROFILE_INSTALL_TARGET_CMDS
 	$(INSTALL) -d -m 755 $(TARGET_DIR)/usr/bin