1

I am using linux perf tool for profiling shared library. Though it worked well on Ubuntu but now I want to run it on embedded linux and I cannot use apt-get to install linux perf tools on embedded linux. That's why I should have to compile everything from scratch.

Can anyone please guide how to compile linux perf tools and dependent kernel module from scratch/source.

Any help will be highly appreciated.

Thanks Arslan Ali

Arslan Ali
  • 63
  • 1
  • 12
  • 1
    "Can anyone please guide how to compile linux perf tools and dependent kernel module from scratch/source." - On Stack Overflow we don't write **guides** and other tutorials. **Try** to compile the tools, and if you have faced a concrete problem, then search for that problem, and if nothing helps, then ask on Stack Overflow. – Tsyvarev Apr 24 '20 at 19:17
  • @Tsyvarev thanks alot for your response and I will look for possible solution. Thanks – Arslan Ali Apr 24 '20 at 19:51

1 Answers1

2

Source code of perf is found in linux-kernel/tools/perf. So use the same kernel which use are using for your board.

For building the perf tools, go to the perf directory as told above. Then run the below command

These commands will change based on your cross toolchain

export CC=arm-linux-gnueabihf-gcc
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

After building is over copy the perf binary to your board /bin directory and add the execution permission to it. Then you can use this feature.

Community
  • 1
  • 1
Rahul Ravi
  • 819
  • 7
  • 5
  • Thanks so what I tried few days ago is to clone below repository git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git and then cd linux/tools/perf && make. And finally cp perf/usr/bin. But the issue the above link will clone the whole kernel and its files size are huge. – Arslan Ali Apr 30 '20 at 10:25
  • You just mentioned that you are using embedded linux. This means you will have linux kernel source code for your board. – Rahul Ravi Apr 30 '20 at 10:46
  • Yes this was ultimate requitment of the project but what I was trying first is to test how I can compile perf tools from source on my notebook with ubuntu. – Arslan Ali Apr 30 '20 at 10:54
  • 1
    For your testing you can download the tar file which will be shorter. For example , https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.9.97.tar.xz. Similarly the list of all the kernel is as below : https://mirrors.edge.kernel.org/pub/linux/kernel/ – Rahul Ravi Apr 30 '20 at 11:04
  • sound great. Thanks alot. Will be looking into those very shortly. – Arslan Ali Apr 30 '20 at 11:08
  • 1
    I tried with the above tar file and it work perfectly fine. The only thing which I want to ask is before doing make in linux/tools/perf it requires two additional dependencies i.e. flex and bison and I want to avoid installing them using apt-get – Arslan Ali Apr 30 '20 at 15:28