编译arm perf

lepd需要调用perf采集数据。perf在ubuntu可以使用如下命令安装:

sudo apt-get install linux-tools-common


但arm的perf就需要自己动手编译了。


首先确认kernel打开如下开关;


CONFIG_PERF_EVENTS=y
CONFIG_HW_PERF_EVENTS=y


然后定义一个环境变量:CROSS_COMPILE_DIR= /home/xxx/linuxep/perf-toolchain

接下来做如下步骤操作:


1, 编译zlib(http://zlib.net/)


1)CC=arm-linux-gnueabi-gcc ./configure --prefix=$CROSS_COMPILE_DIR/libc/usr/
2)make
3)make install

2,编译elfutil:(https://kojipkgs.fedoraproject.org/packages/elfutils/)


1)./configure --host=arm-linux-gnueabi --prefix=$CROSS_COMPILE_DIR/libc/usr/ --exec-prefix=$CROSS_COMPILE_DIR/libc/usr/

2)编辑Makefile:

from
SUBDIRS = config m4 lib libelf libebl libdwfl libdw libcpu libasm backends \
      src po tests
to
SUBDIRS = config m4 lib libelf libebl libdwfl libdw libasm backends \
      src po tests

3)编辑backend/Makefile

from
libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \
        libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \
        libebl_sparc_pic.a libebl_ppc_pic.a libebl_ppc64_pic.a \
        libebl_s390_pic.a
to
libebl_pic = libebl_sh_pic.a \
        libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \
        libebl_sparc_pic.a libebl_ppc_pic.a libebl_ppc64_pic.a \
        libebl_s390_pic.a

按如下方式注释掉一些代码:

noinst_LIBRARIES = $(libebl_pic)
noinst_DATA = $(libebl_pic:_pic.a=.so)
libelf = ../libelf/libelf.so
#libdw = ../libdw/libdw.a
#i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \
#       i386_retval.c i386_regs.c i386_auxv.c i386_syscall.c
#cpu_i386 = ../libcpu/libcpu_i386.a
#libebl_i386_pic_a_SOURCES = $(i386_SRCS)
#am_libebl_i386_pic_a_OBJECTS = $(i386_SRCS:.c=.os)
sh_SRCS = sh_init.c sh_symbol.c sh_corenote.c sh_regs.c sh_retval.c
libebl_sh_pic_a_SOURCES = $(sh_SRCS)
am_libebl_sh_pic_a_OBJECTS = $(sh_SRCS:.c=.os)
#x86_64_SRCS = x86_64_init.c x86_64_symbol.c x86_64_corenote.c x86_64_cfi.c \
#x86_64_retval.c x86_64_regs.c i386_auxv.c x86_64_syscall.c
#cpu_x86_64 = ../libcpu/libcpu_x86_64.a
#libebl_x86_64_pic_a_SOURCES = $(x86_64_SRCS)
#am_libebl_x86_64_pic_a_OBJECTS = $(x86_64_SRCS:.c=.os)
#libebl_i386.so: $(cpu_i386)
#libebl_x86_64.so: $(cpu_x86_64)


4)在lib/Makefile libasm/Makefile src/Makefile删除Werror 

5)make
6)make install


3, 可以开始编译perf了,代码在kernel/tools/perf里

1)编辑makefileCFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
EXTLIBS = -lpthread -lrt -lelf -lm -lebl -ldl -L$(CROSS_COMPILE_DIR)/libc/usr/lib
ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -I$(CROSS_COMPILE_DIR)/libc/usr/include

2)make LDFLAGS=-static ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- DEBUG=1 LIBDW_DIR=$CROSS_COMPILE_DIR/libc/usr/ HAVE_CPLUS_DEMANGLE=1

没什么问题的话,就可以得到arm指令的perf了,enjoy。


上述步骤主要参考http://www.cnblogs.com/helloworldtoyou/p/5585152.html


没什么








你可能感兴趣的:(编译arm perf)