xref: /OK3568_Linux_fs/kernel/tools/perf/Documentation/Build.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun
2*4882a593Smuzhiyun1) perf build
3*4882a593Smuzhiyun=============
4*4882a593SmuzhiyunThe perf build process consists of several separated building blocks,
5*4882a593Smuzhiyunwhich are linked together to form the perf binary:
6*4882a593Smuzhiyun  - libperf library (static)
7*4882a593Smuzhiyun  - perf builtin commands
8*4882a593Smuzhiyun  - traceevent library (static)
9*4882a593Smuzhiyun  - GTK ui library
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunSeveral makefiles govern the perf build:
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun  - Makefile
14*4882a593Smuzhiyun    top level Makefile working as a wrapper that calls the main
15*4882a593Smuzhiyun    Makefile.perf with a -j option to do parallel builds.
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun  - Makefile.perf
18*4882a593Smuzhiyun    main makefile that triggers build of all perf objects including
19*4882a593Smuzhiyun    installation and documentation processing.
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun  - tools/build/Makefile.build
22*4882a593Smuzhiyun    main makefile of the build framework
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun  - tools/build/Build.include
25*4882a593Smuzhiyun    build framework generic definitions
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun  - Build makefiles
28*4882a593Smuzhiyun    makefiles that defines build objects
29*4882a593Smuzhiyun
30*4882a593SmuzhiyunPlease refer to tools/build/Documentation/Build.txt for more
31*4882a593Smuzhiyuninformation about build framework.
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun2) perf build
35*4882a593Smuzhiyun=============
36*4882a593SmuzhiyunThe Makefile.perf triggers the build framework for build objects:
37*4882a593Smuzhiyun   perf, libperf, gtk
38*4882a593Smuzhiyun
39*4882a593Smuzhiyunresulting in following objects:
40*4882a593Smuzhiyun  $ ls  *-in.o
41*4882a593Smuzhiyun  gtk-in.o  libperf-in.o  perf-in.o
42*4882a593Smuzhiyun
43*4882a593SmuzhiyunThose objects are then used in final linking:
44*4882a593Smuzhiyun  libperf-gtk.so <- gtk-in.o  libperf-in.o
45*4882a593Smuzhiyun  perf           <- perf-in.o libperf-in.o
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun
48*4882a593SmuzhiyunNOTE this description is omitting other libraries involved, only
49*4882a593Smuzhiyun     focusing on build framework outcomes
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun3) Build with ASan or UBSan
52*4882a593Smuzhiyun==========================
53*4882a593Smuzhiyun  $ cd tools/perf
54*4882a593Smuzhiyun  $ make DESTDIR=/usr
55*4882a593Smuzhiyun  $ make DESTDIR=/usr install
56*4882a593Smuzhiyun
57*4882a593SmuzhiyunAddressSanitizer (or ASan) is a GCC feature that detects memory corruption bugs
58*4882a593Smuzhiyunsuch as buffer overflows and memory leaks.
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun  $ cd tools/perf
61*4882a593Smuzhiyun  $ make DEBUG=1 EXTRA_CFLAGS='-fno-omit-frame-pointer -fsanitize=address'
62*4882a593Smuzhiyun  $ ASAN_OPTIONS=log_path=asan.log ./perf record -a
63*4882a593Smuzhiyun
64*4882a593SmuzhiyunASan outputs all detected issues into a log file named 'asan.log.<pid>'.
65*4882a593Smuzhiyun
66*4882a593SmuzhiyunUndefinedBehaviorSanitizer (or UBSan) is a fast undefined behavior detector
67*4882a593Smuzhiyunsupported by GCC. UBSan detects undefined behaviors of programs at runtime.
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun  $ cd tools/perf
70*4882a593Smuzhiyun  $ make DEBUG=1 EXTRA_CFLAGS='-fno-omit-frame-pointer -fsanitize=undefined'
71*4882a593Smuzhiyun  $ UBSAN_OPTIONS=print_stacktrace=1 ./perf record -a
72*4882a593Smuzhiyun
73*4882a593SmuzhiyunIf UBSan detects any problem at runtime, it outputs a “runtime error:” message.
74