Skip to content

Commit d27087c

Browse files
Leo-Yannamhyung
authored andcommitted
perf docs: Document cross compilation
Records the commands for cross compilation with two methods. The first method relies on Multiarch. The second approach is to explicitly specify the PKG_CONFIG variables, which is widely used in build system (like Buildroot, Yocto, etc). Co-developed-by: James Clark <[email protected]> Signed-off-by: James Clark <[email protected]> Signed-off-by: Leo Yan <[email protected]> Tested-by: Ian Rogers <[email protected]> Cc: [email protected] Cc: Thomas Richter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent f42596c commit d27087c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tools/perf/Documentation/Build.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,31 @@ supported by GCC. UBSan detects undefined behaviors of programs at runtime.
7171
$ UBSAN_OPTIONS=print_stacktrace=1 ./perf record -a
7272

7373
If UBSan detects any problem at runtime, it outputs a “runtime error:” message.
74+
75+
4) Cross compilation
76+
====================
77+
As Multiarch is commonly supported in Linux distributions, we can install
78+
libraries for multiple architectures on the same system and then cross-compile
79+
Linux perf. For example, Aarch64 libraries and toolchains can be installed on
80+
an x86_64 machine, allowing us to compile perf for an Aarch64 target.
81+
82+
Below is the command for building the perf with dynamic linking.
83+
84+
$ cd /path/to/Linux
85+
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -C tools/perf
86+
87+
For static linking, the option `LDFLAGS="-static"` is required.
88+
89+
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \
90+
LDFLAGS="-static" -C tools/perf
91+
92+
In the embedded system world, a use case is to explicitly specify the package
93+
configuration paths for cross building:
94+
95+
$ PKG_CONFIG_SYSROOT_DIR="/path/to/cross/build/sysroot" \
96+
PKG_CONFIG_LIBDIR="/usr/lib/:/usr/local/lib" \
97+
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -C tools/perf
98+
99+
In this case, the variable PKG_CONFIG_SYSROOT_DIR can be used alongside the
100+
variable PKG_CONFIG_LIBDIR or PKG_CONFIG_PATH to prepend the sysroot path to
101+
the library paths for cross compilation.

0 commit comments

Comments
 (0)