Trouble cross-building ./kernel/tools/perf for ARM/Android

1,295 views
Skip to first unread message

Ryan V. Bissell

unread,
Nov 13, 2013, 9:32:24 AM11/13/13
to android...@googlegroups.com

Hi,

The Android Open Source Project (AOSP) includes a copy of the Linux kernel's "Perf" tool, but it is quite old.  Furthermore, as of 3.10, the Linux kernel includes ./tools/perf/Documentation/android.txt, which purports to explain how to cross-build Perf for Android (ARM or x86).

https://android.googlesource.com/kernel/common/+/android-3.10/tools/perf/Documentation/android.txt

However, when following those directions, I get an error about an unfound "bitsperlong.h" file, and I have not been able to suss out the reason.

My steps:

1. Download AOSP
2. Download linux 3.10.17, extract to $HOME/work/aosp/kernel
3. Build AOSP (which won't actually build the above kernel, but this is expected)
4. Generate or supply appropriate .config for kernel, and cross-build kernel with:
make ARCH=arm CROSS_COMPILE=/home/rbissell/work/aosp/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-

5. Follow the instructions "./kernel/tools/perf/Documentation/android.txt", for cross-building Perf for ARM, using a sysroot derived from the AOSP source tree:

$ cd ~/work/aosp
$ source build/envsetup.sh
$ lunch
$ cd ${ANDROID_BUILD_TOP}/ndk
$ ./build/tools/build-ndk-sysroot.sh --abi=arm
$ export NDK_SYSROOT=${ANDROID_BUILD_TOP}/ndk/build/platforms/android-3/arch-arm
$ export NDK_TOOLCHAIN=${ANDROID_TOOLCHAIN}/arm-linux-androideabi-
$ cd ${ANDROID_BUILD_TOP}/kernel/tools/perf
$ make ARCH=arm CROSS_COMPILE=${NDK_TOOLCHAIN} CFLAGS="--sysroot=${NDK_SYSROOT}"


The final step above fails with the error message below.   (However, if I just build Perf for the host system (x86_64), it builds fine.)

In file included from /home/rbissell/work/aosp/kernel/arch/arm/include/uapi/asm/posix_types.h:35:0,
                 from /home/rbissell/work/aosp/kernel/include/uapi/linux/posix_types.h:35,
                 from /home/rbissell/work/aosp/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/../lib/gcc/arm-linux-androideabi/4.7/include-fixed/sys/types.h:46,
                 from /home/rbissell/work/aosp/ndk/build/platforms/android-3/arch-arm/usr/include/unistd.h:33,
                 from util/util.h:44,
                 from builtin.h:4,
                 from perf.c:9:
/home/rbissell/work/aosp/kernel/include/uapi/asm-generic/posix_types.h:4:29: fatal error: asm/bitsperlong.h: No such file or directory


I am uncertain what is wrong.  There is a "bitsperlong.h" in the kernel tree, but it exists in asm-generic/, not asm/.  Elsewhere on the internet, people suggest copying the file or creating a symbolic link.  Not only does that not feel like a correct solution to this problem-- native build doesn't require doing that-- it actually doesn't work (just leads to further compilation errors.)

I think I must be overlooking something?

</ryan>

Zhenhua Zhu

unread,
Nov 13, 2013, 7:58:07 PM11/13/13
to android...@googlegroups.com
maybe you need sync your kernel source header to android external/kernel-header manually

在 2013年11月13日星期三UTC+8下午10时32分24秒,Ryan V. Bissell写道:

Hiep Trinh

unread,
Nov 26, 2013, 2:51:11 AM11/26/13
to android...@googlegroups.com
Hi,
I also follow this intructions, but after final step:

make ARCH=arm CROSS_COMPILE=${NDK_TOOLCHAIN} CFLAGS="--sysroot=${NDK_SYSROOT}"
I received error:
config/Makefile:159: *** No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static.  Stop.
I search and know that gnu/libc-version.h appears in my aosp r/prebuilt/linux-x86/toolchain/i686-linux-glibc2.7-4.4.3/sysroot/usr/include/gnu/libc-version.h
and /usr/include/x86_64-linux-gnu/gnu/libc-version.h
 
What's wrong?





Vào 21:32:24 UTC+7 Thứ tư, ngày 13 tháng mười một năm 2013, Ryan V. Bissell đã viết:

Kris Smith

unread,
Jul 9, 2014, 2:16:44 PM7/9/14
to android...@googlegroups.com, trinh...@gmail.com
Did you figure out this error? I am running into the same issue trying to compile the linux perf tools for android on OS X.

Damjan Velickovski

unread,
Sep 6, 2014, 1:24:03 PM9/6/14
to android...@googlegroups.com, trinh...@gmail.com
I have this problem too, have anyone worked this one out?

Probir Roy

unread,
Sep 29, 2014, 12:06:37 PM9/29/14
to android...@googlegroups.com, trinh...@gmail.com
Did you find the solution of the problem?


On Tuesday, November 26, 2013 2:51:11 AM UTC-5, Hiep Trinh wrote:

Damjan Velickovski

unread,
Oct 1, 2014, 6:13:00 PM10/1/14
to android...@googlegroups.com
Unfortunately no, I needed to do a performance analysis on Nexus 7 (2012) and I went with nVidia Tegra System Profiler which also resisted to be set up correctly but I managed to make it work. If you need any help with it I will gladly help.

Also if you overcome this issue don't forget to post here how you did it.

--
--
unsubscribe: android-kerne...@googlegroups.com
website: http://groups.google.com/group/android-kernel
---
You received this message because you are subscribed to the Google Groups "Android Linux Kernel Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-kerne...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages