编译oprofile的FAQ

 

Q1:

下载从http://oprofile.sourceforge.net/download/  网址下载 oprofile-0.9.5.tar.gz文件,将其放到我虚拟机的/nfs/memtest/oprofile文件夹下面并将其解压缩。

[root@localhost oprofile-0.9.5]# ./configure --with-kernel-support --target=arm-linux --host=arm-none-linux-gnueabi --build=i686-pc-linux-gnu --prefix=/nfs/memtest/oprofile/oprofile-0.9.5/usr/

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

checking for gawk... gawk

checking whether make sets $(MAKE)... yes

checking for arm-none-linux-gnueabi-strip... arm-none-linux-gnueabi-strip

checking for style of include used by make... GNU

checking for arm-none-linux-gnueabi-gcc... arm-none-linux-gnueabi-gcc

checking for C compiler default output file name... a.out

checking whether the C compiler works... yes

checking whether we are cross compiling... yes

checking for kernel OProfile support... yes

checking whether malloc attribute is understood... no

checking whether __builtin_expect is understood... yes

checking for sched_setaffinity... yes

checking for perfmonctl... no

checking for poptGetContext in -lpopt... no

configure: error: popt library not found

看来需要popt库才行啊

http://download.chinaunix.net/download.php?id=16763&ResourceID=8268地方

下载popt-1.7.tar.gz文件

cp  /work/popt/poptinstall/lib/*  /opt/crosstool/gcc-3.4.1-glibc-2.3.3/arm-9tdmi-linux-gnu/arm-9tdmi-linux-gnu/lib

/usr/local/arm/arm-2008q3/arm-none-linux-gnueabi/libc/lib

 

Q2:

接着再编译,还是有问题啊:

[root@localhost oprofile-0.9.5]# ./configure --with-kernel-support --target=arm-linux --host=arm-none-linux-gnueabi --build=i686-pc-linux-gnu --prefix=/nfs/memtest/oprofile/oprofile-0.9.5/usr/

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

checking for gawk... gawk

checking whether make sets $(MAKE)... yes

checking whether __builtin_expect is understood... yes

checking for sched_setaffinity... yes

checking for perfmonctl... no

checking for poptGetContext in -lpopt... yes

checking libiberty.h usability... no

checking libiberty.h presence... no

checking for libiberty.h... no

checking for cplus_demangle in -liberty... no

configure: error: liberty library not found

 

看来还得下载libiberty库,这个库是干吗的呢??

原来它真正的是:binutils库,他是一个大杂烩,包括对一些内存管理、字符串处理函数的扩充。看看目录树差不多就可知道一个大概,基本上 是一个文件实现一个函数。

我接着又去http://download.chinaunix.net/download.php?id=25887&ResourceID=900下载

binutils-2.19.51.0.12.tar.bz2文件

再将其解压,安装下

 

Q3:

接着编译发现还是不行啊:

[root@localhost oprofile-0.9.5]# ./configure --with-kernel-support --target=arm-linux --host=arm-none-linux-gnueabi --build=i686-pc-linux-gnu --prefix=/nfs/memtest/oprofile/oprofile-0.9.5/usr/

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

checking for gawk... gawk

checking whether make sets $(MAKE)... yes

checking for arm-none-linux-gnueabi-strip... arm-none-linux-gnueabi-strip

checking for style of include used by make... GNU

checking for arm-none-linux-gnueabi-gcc... arm-none-linux-gnueabi-gcc

checking for C compiler default output file name...

checking whether __builtin_expect is understood... yes

checking for sched_setaffinity... yes

checking for perfmonctl... no

checking for poptGetContext in -lpopt... yes

checking libiberty.h usability... no

checking libiberty.h presence... no

checking for libiberty.h... no

checking for cplus_demangle in -liberty... yes

checking for xcalloc... yes

checking for xmemdup... yes

checking for dlopen in -ldl... yes

checking for main in -lintl... no

checking for bfd_openr in -lbfd... no

checking for compress in -lz... no

configure: error: libz library not found; required by libbfd

 

nnd,怎么编译了半天还是和arm-linux-gcc3.4.1一样啊,出现这个问题,上网查了下发现原来libbfd就是binutils一部分,只是你在默认的情况下编译binutils时是不会去安装libbfd,你必须要指明--enable-install-libbfd,这样才能显示安装libbfd库的,于是我在binutils-2.19.51.0.12文件夹下面直接找到了bfd文件夹,在其下的文件中找到了libbfd.a静态库,将其直接拷贝到/usr/local/arm/arm-2008q3/arm-none-linux-gnueabi/libc/lib

然后接着再回到oprofile-0.9.5目录下继续交叉编译oprofile-0.9.5

[root@localhost oprofile-0.9.5]# ./configure --with-kernel-support --target=arm-linux --host=arm-none-linux-gnueabi --build=i686-pc-linux-gnu --prefix=/nfs/memtest/oprofile/oprofile-0.9.5/usr/

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

checking for gawk... gawk

checking whether make sets $(MAKE)... yes

checking for arm-none-linux-gnueabi-strip... arm-none-linux-gnueabi-strip

checking for style of include used by make... GNU

checking for arm-none-linux-gnueabi-gcc... arm-none-linux-gnueabi-gcc

config.status: executing depfiles commands

Warning: a working Qt not found; no GUI will be built

Warning: The user account 'oprofile:oprofile' does not exist on the system.

         To profile JITed code, this special user account must exist.

         Please add the following user and group:

             user name : 'oprofile'

             group name: 'oprofile'

         The 'oprofile' group must be the default group for the 'oprofile' user.

总算成功交叉配置了oprofile-0.9.5,哈哈

 

Q5:

现在开始编译oprofile-0.9.5,刚一开始敲make命令就发现出现错误了:

[root@localhost oprofile-0.9.5]# make

make  all-recursive

make[1]: Entering directory `/nfs/memtest/oprofile/oprofile-0.9.5'

Making all in .

make[2]: Entering directory `/nfs/memtest/oprofile/oprofile-0.9.5'

make[2]: Nothing to be done for `all-am'.

make[2]: Leaving directory `/nfs/memtest/oprofile/oprofile-0.9.5'

Making all in m4

make[2]: Entering directory `/nfs/memtest/oprofile/oprofile-0.9.5/m4'

make[2]: Nothing to be done for `all'.

make[2]: Leaving directory `/nfs/memtest/oprofile/oprofile-0.9.5/m4'

opagent.c:63:17: error: bfd.h: No such file or directory

opagent.c: In function 'define_bfd_vars':

opagent.c:77: error: 'bfd' undeclared (first use in this function)

opagent.c:77: error: (Each undeclared identifier is reported only once

opagent.c:77: error: for each function it appears in.)

opagent.c:78: error: 'bfd_boolean' undeclared (first use in this function)

opagent.c:78: error: expected ';' before 'r'

opagent.c:103: error: 'r' undeclared (first use in this function)

opagent.c:103: error: 'bfd_object' undeclared (first use in this function)

make[2]: *** [libopagent_la-opagent.lo] 错误 1

make[2]: Leaving directory `/nfs/memtest/oprofile/oprofile-0.9.5/libopagent'

make[1]: *** [all-recursive] 错误 1

make[1]: Leaving directory `/nfs/memtest/oprofile/oprofile-0.9.5'

make: *** [all] 错误 2

原来是bfd.h头文件找不到,nnd于是我又到binutils-2.19.51.0.12下面去找bfd.h头文件,接着又把bfd.h相关的ansidecl.hsymcat.h总共这三个文件都拷贝到/usr/local/arm/arm-2008q3/arm-none-linux-gnueabi/include目录下面,接着再次make,哈哈,成功过关!!

[root@localhost oprofile-0.9.5]# make

make  all-recursive

make[1]: Entering directory `/nfs/memtest/oprofile/oprofile-0.9.5'

Making all in .

make[2]: Entering directory `/nfs/memtest/oprofile/oprofile-0.9.5'

make[2]: Nothing to be done for `all-am'.

make[2]: Leaving directory `/nfs/memtest/oprofile/oprofile-0.9.5'

Making all in m4

make[2]: Entering directory `/nfs/memtest/oprofile/oprofile-0.9.5/m4'make[2]: Leaving directory `/nfs/memtest/oprofile/oprofile-0.9.5/gui'

Making all in agents

make[2]: Entering directory `/nfs/memtest/oprofile/oprofile-0.9.5/agents'

make[3]: Entering directory `/nfs/memtest/oprofile/oprofile-0.9.5/agents'

make[3]: Nothing to be done for `all-am'.

make[3]: Leaving directory `/nfs/memtest/oprofile/oprofile-0.9.5/agents'

make[2]: Leaving directory `/nfs/memtest/oprofile/oprofile-0.9.5/agents'

make[1]: Leaving directory `/nfs/memtest/oprofile/oprofile-0.9.5'

再接着make install一下就会在/nfs/memtest/oprofile/oprofile-0.9.5/usr/bin目录opcontrolopgprog等工具,哈哈

[root@localhost bin]# ls

arm-linux-addr2line  arm-linux-c++filt  arm-linux-nm       arm-linux-ranlib   arm-linux-strings  oparchive  ophelp     opreport

arm-linux-ar         arm-linux-gprof    arm-linux-objcopy  arm-linux-readelf  arm-linux-strip    opcontrol  opimport   oprofiled

arm-linux-as         arm-linux-ld       arm-linux-objdump  arm-linux-size     opannotate         opgprof    opjitconv

 

接着再把oprofile相关的工具都拷贝到我们的网络文件系统的/usr/sbin下面去,这样我们就能在SEP4020开发板上使用这些工具了

 

Q6:开始真正地在SEP4020开发板上运行程序了

启动内核,挂载文件系统,这里需要注意的是,我的内核的profile选项是都选择上的,注意另外还需要将eabi选项也选上才行.

等文件系统挂载上去后就需要输入以下命令:但出现错误了。

/dev # opcontrol --init

/usr/sbin/opcontrol: line 1114: syntax error: Bad substitution

上网找了下,需要给我们的arm平台的opcontrol脚本打一个补丁:

diff -ru orig/utils/opcontrol new/utils/opcontrol
--- orig/utils/opcontrol        2009-07-31 11:10:18.000000000 -0600
+++ new/utils/opcontrol 2009-10-05 11:55:15.000000000 -0600
@@ -1111,9 +1111,7 @@
 {
        case "$1" in
                ppc64/*)
-                       tmp="${1/cell/CELL}"
-                       if test "$1" = "$tmp"; then
-                       #No substituion occurred, so cputype is not cell
+                       if echo $1 | grep -q cell ; then
                                return 1
                        else
                                return 0

 

Q7:

现在再执行下,但还是出问题:

/dev # opcontrol --init

Kernel support not available, missing opcontrol --init as root ?

嗯,居然权限出问题了,重启一下再执行,这个问题是没了,可是又出现新的问题了:

/dev # opcontrol --init

cat: can't open '/dev/oprofile/cpu_type': No such file or directory

/usr/sbin/ophelp: error while loading shared libraries: libpopt.so.0: cannot open shared object file: No such file or directory

看来第二问题是库没从安装文件夹里拷到我们的网络文件系统/nfs/lib下面来,于是我去拷过来,有出现下面的问题:

/dev # opcontrol --init

cat: can't open '/dev/oprofile/cpu_type': No such file or directory

Unable to open cpu_type file for reading

Make sure you have done opcontrol --init

cpu_type 'unset' is not valid

you should upgrade oprofile or force the use of timer mode

晕的啦

 

Q7: cat: can't open '/dev/oprofile/cpu_type': No such file or directory

Step1:重新启动target
step2
:执行
# ./opcontrol --init
      
显示:


        # ./opcontrol --init
        cat: can't open '/dev/oprofile/cpu_type': No such file or directory
        Unable to open cpu_type file for reading
        Make sure you have done opcontrol --init
        cpu_type 'unset' is not valid
        you should upgrade oprofile or force the use of timer mode

Step3:
删除/etc目录下的mtab文件
          Rm -f /etc/mtab
Step4:
执行# ./opcontrol --init
      
显示:

       # ./opcontrol --init
       grep: /etc/mtab: No such file or directory
       grep: /etc/mtab: No such file or directory

Kernel support not available, missing opcontrol --init as root ?


Step5:重新在/etc/目录下创建mtab并添加“nodev /dev/oprofile oprofilefs rw 0 0”
         touch /etc/mtab
         Vi /etc/mtab

         Insert  "nodev /dev/oprofile oprofilefs rw 0 0"   --->
mtab中添加的内容


Step6:执行# ./opcontrol –init

Kernel support not available, missing opcontrol --init as root ?
         ok

 

Q8: “Kernel support not available, missing opcontrol --init as root ?

为啥还出现“Kernel support not available, missing opcontrol --init as root ?”这个东西呢??

今天中午吃完中饭又去找了一遍,总算知道原因了:

check_version()

{

       OPROFILE_AVAILABLE=no

       grep oprofilefs /etc/mtab >/dev/null

       if test "$?" -eq 0; then

              # need to have oprofilefs mounted for this to work on 2.6

              KERNEL_SUPPORT=yes

              OPROFILE_AVAILABLE=yes

              return

       fi

}

原来是在opcontrol这个脚本的1790行判断“$?”这个shell变量出问题了,这个变量是判断上次操作时的退出符的,我打印出$?一看发现是‘1’,看来真的是上句出问题了,那它的上句就是grep oprofilefs /etc/mtab >/dev/null 了,这说明grep没有查询到任何一行合适的语句,看来是/etc/mtab文件出问题了,这个文件是我手动敲进去的,看来肯定是这个出问题了,一看果然出问题了,应该是

nodev /dev/oprofile oprofilefs rw 0 0

而我写的是nodev /dev/oprofile oprofile rw 0 0自己真是太粗心了!!!

 

 

Q9:再次编译binutils工具集时发现./configure无法生效

[fpmystar@SEP4020 binutils-2.19.51.0.12]$ make -j8

make[1]: Entering directory `/home/fpmystar/oprofile/binutils-2.19.51.0.12'

make[1]: Nothing to be done for `all-target'.

Configuring in ./intl

Configuring in ./libiberty

Configuring in ./etc

configure: loading cache ./config.cache

checking for a BSD-compatible install... configure: loading cache ./config.cache

configure: loading cache ./config.cache

/usr/bin/install -c

configure: error: `CFLAGS' has changed since the previous run:

configure:   former value:  `-g -O2'

configure:   current value: `-march=armv4t'

configure: error: in `/home/fpmystar/oprofile/binutils-2.19.51.0.12/intl':

configure: error: changes in the environment can compromise the build

configure: error: run `make distclean' and/or `rm ./config.cache' and start over

configure: error: `CFLAGS' has changed since the previous run:

configure:   former value:  `-g -O2'

configure:   current value: `-march=armv4t'

configure: error: in `/home/fpmystar/oprofile/binutils-2.19.51.0.12/libiberty':

configure: error: changes in the environment can compromise the build

configure: error: run `make distclean' and/or `rm ./config.cache' and start over

configure: creating ./config.status

make[1]: *** [configure-intl] 错误 1

make[1]: *** %3

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值