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