0001
0002 1) perf build
0003 =============
0004 The perf build process consists of several separated building blocks,
0005 which are linked together to form the perf binary:
0006 - libperf library (static)
0007 - perf builtin commands
0008 - traceevent library (static)
0009 - GTK ui library
0010
0011 Several makefiles govern the perf build:
0012
0013 - Makefile
0014 top level Makefile working as a wrapper that calls the main
0015 Makefile.perf with a -j option to do parallel builds.
0016
0017 - Makefile.perf
0018 main makefile that triggers build of all perf objects including
0019 installation and documentation processing.
0020
0021 - tools/build/Makefile.build
0022 main makefile of the build framework
0023
0024 - tools/build/Build.include
0025 build framework generic definitions
0026
0027 - Build makefiles
0028 makefiles that defines build objects
0029
0030 Please refer to tools/build/Documentation/Build.txt for more
0031 information about build framework.
0032
0033
0034 2) perf build
0035 =============
0036 The Makefile.perf triggers the build framework for build objects:
0037 perf, libperf, gtk
0038
0039 resulting in following objects:
0040 $ ls *-in.o
0041 gtk-in.o libperf-in.o perf-in.o
0042
0043 Those objects are then used in final linking:
0044 libperf-gtk.so <- gtk-in.o libperf-in.o
0045 perf <- perf-in.o libperf-in.o
0046
0047
0048 NOTE this description is omitting other libraries involved, only
0049 focusing on build framework outcomes
0050
0051 3) Build with ASan or UBSan
0052 ==========================
0053 $ cd tools/perf
0054 $ make DESTDIR=/usr
0055 $ make DESTDIR=/usr install
0056
0057 AddressSanitizer (or ASan) is a GCC feature that detects memory corruption bugs
0058 such as buffer overflows and memory leaks.
0059
0060 $ cd tools/perf
0061 $ make DEBUG=1 EXTRA_CFLAGS='-fno-omit-frame-pointer -fsanitize=address'
0062 $ ASAN_OPTIONS=log_path=asan.log ./perf record -a
0063
0064 ASan outputs all detected issues into a log file named 'asan.log.<pid>'.
0065
0066 UndefinedBehaviorSanitizer (or UBSan) is a fast undefined behavior detector
0067 supported by GCC. UBSan detects undefined behaviors of programs at runtime.
0068
0069 $ cd tools/perf
0070 $ make DEBUG=1 EXTRA_CFLAGS='-fno-omit-frame-pointer -fsanitize=undefined'
0071 $ UBSAN_OPTIONS=print_stacktrace=1 ./perf record -a
0072
0073 If UBSan detects any problem at runtime, it outputs a “runtime error:” message.