Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'perf-tools-fixes-for-v6.11-2024-07-30' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools

Pull perf tools fixes from Namhyung Kim:
"Some more build fixes and a random crash fix:

- Fix cross-build by setting pkg-config env according to the arch

- Fix static build for missing library dependencies

- Fix Segfault when callchain has no symbols"

* tag 'perf-tools-fixes-for-v6.11-2024-07-30' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools:
perf docs: Document cross compilation
perf: build: Link lib 'zstd' for static build
perf: build: Link lib 'lzma' for static build
perf: build: Only link libebl.a for old libdw
perf: build: Set Python configuration for cross compilation
perf: build: Setup PKG_CONFIG_LIBDIR for cross compilation
perf tool: fix dereferencing NULL al->maps

+117 -13
+43 -10
tools/build/feature/Makefile
··· 82 82 83 83 FILES := $(addprefix $(OUTPUT),$(FILES)) 84 84 85 - PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config 85 + # Some distros provide the command $(CROSS_COMPILE)pkg-config for 86 + # searching packges installed with Multiarch. Use it for cross 87 + # compilation if it is existed. 88 + ifneq (, $(shell which $(CROSS_COMPILE)pkg-config)) 89 + PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config 90 + else 91 + PKG_CONFIG ?= pkg-config 92 + 93 + # PKG_CONFIG_PATH or PKG_CONFIG_LIBDIR, alongside PKG_CONFIG_SYSROOT_DIR 94 + # for modified system root, are required for the cross compilation. 95 + # If these PKG_CONFIG environment variables are not set, Multiarch library 96 + # paths are used instead. 97 + ifdef CROSS_COMPILE 98 + ifeq ($(PKG_CONFIG_LIBDIR)$(PKG_CONFIG_PATH)$(PKG_CONFIG_SYSROOT_DIR),) 99 + CROSS_ARCH = $(shell $(CC) -dumpmachine) 100 + PKG_CONFIG_LIBDIR := /usr/local/$(CROSS_ARCH)/lib/pkgconfig/ 101 + PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/lib/$(CROSS_ARCH)/pkgconfig/ 102 + PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/lib/$(CROSS_ARCH)/pkgconfig/ 103 + PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/share/pkgconfig/ 104 + PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/share/pkgconfig/ 105 + export PKG_CONFIG_LIBDIR 106 + endif 107 + endif 108 + endif 86 109 87 110 all: $(FILES) 88 111 ··· 170 147 171 148 DWARFLIBS := -ldw 172 149 ifeq ($(findstring -static,${LDFLAGS}),-static) 173 - DWARFLIBS += -lelf -lebl -lz -llzma -lbz2 150 + DWARFLIBS += -lelf -lz -llzma -lbz2 -lzstd 151 + 152 + LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw) 153 + LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION))) 154 + LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION))) 155 + 156 + # Elfutils merged libebl.a into libdw.a starting from version 0.177, 157 + # Link libebl.a only if libdw is older than this version. 158 + ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0) 159 + DWARFLIBS += -lebl 160 + endif 174 161 endif 175 162 176 163 $(OUTPUT)test-dwarf.bin: ··· 211 178 $(BUILD) -lnuma 212 179 213 180 $(OUTPUT)test-libunwind.bin: 214 - $(BUILD) -lelf 181 + $(BUILD) -lelf -llzma 215 182 216 183 $(OUTPUT)test-libunwind-debug-frame.bin: 217 - $(BUILD) -lelf 184 + $(BUILD) -lelf -llzma 218 185 $(OUTPUT)test-libunwind-x86.bin: 219 - $(BUILD) -lelf -lunwind-x86 186 + $(BUILD) -lelf -llzma -lunwind-x86 220 187 221 188 $(OUTPUT)test-libunwind-x86_64.bin: 222 - $(BUILD) -lelf -lunwind-x86_64 189 + $(BUILD) -lelf -llzma -lunwind-x86_64 223 190 224 191 $(OUTPUT)test-libunwind-arm.bin: 225 - $(BUILD) -lelf -lunwind-arm 192 + $(BUILD) -lelf -llzma -lunwind-arm 226 193 227 194 $(OUTPUT)test-libunwind-aarch64.bin: 228 - $(BUILD) -lelf -lunwind-aarch64 195 + $(BUILD) -lelf -llzma -lunwind-aarch64 229 196 230 197 $(OUTPUT)test-libunwind-debug-frame-arm.bin: 231 - $(BUILD) -lelf -lunwind-arm 198 + $(BUILD) -lelf -llzma -lunwind-arm 232 199 233 200 $(OUTPUT)test-libunwind-debug-frame-aarch64.bin: 234 - $(BUILD) -lelf -lunwind-aarch64 201 + $(BUILD) -lelf -llzma -lunwind-aarch64 235 202 236 203 $(OUTPUT)test-libaudit.bin: 237 204 $(BUILD) -laudit
+28
tools/perf/Documentation/Build.txt
··· 71 71 $ UBSAN_OPTIONS=print_stacktrace=1 ./perf record -a 72 72 73 73 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.
+19 -1
tools/perf/Makefile.config
··· 152 152 endif 153 153 DWARFLIBS := -ldw 154 154 ifeq ($(findstring -static,${LDFLAGS}),-static) 155 - DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2 155 + DWARFLIBS += -lelf -ldl -lz -llzma -lbz2 -lzstd 156 + 157 + LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw) 158 + LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION))) 159 + LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION))) 160 + 161 + # Elfutils merged libebl.a into libdw.a starting from version 0.177, 162 + # Link libebl.a only if libdw is older than this version. 163 + ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0) 164 + DWARFLIBS += -lebl 165 + endif 156 166 endif 157 167 FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS) 158 168 FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS) ··· 306 296 307 297 ifdef PYTHON_CONFIG 308 298 PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null) 299 + # Update the python flags for cross compilation 300 + ifdef CROSS_COMPILE 301 + PYTHON_NATIVE := $(shell echo $(PYTHON_EMBED_LDOPTS) | sed 's/\(-L.*\/\)\(.*-linux-gnu\).*/\2/') 302 + PYTHON_EMBED_LDOPTS := $(subst $(PYTHON_NATIVE),$(shell $(CC) -dumpmachine),$(PYTHON_EMBED_LDOPTS)) 303 + endif 309 304 PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) 310 305 PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil 311 306 PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null) ··· 912 897 PYTHON_SETUPTOOLS_INSTALLED := $(shell $(PYTHON) -c 'import setuptools;' 2> /dev/null && echo "yes" || echo "no") 913 898 ifeq ($(PYTHON_SETUPTOOLS_INSTALLED), yes) 914 899 PYTHON_EXTENSION_SUFFIX := $(shell $(PYTHON) -c 'from importlib import machinery; print(machinery.EXTENSION_SUFFIXES[0])') 900 + ifdef CROSS_COMPILE 901 + PYTHON_EXTENSION_SUFFIX := $(subst $(PYTHON_NATIVE),$(shell $(CC) -dumpmachine),$(PYTHON_EXTENSION_SUFFIX)) 902 + endif 915 903 LANG_BINDINGS += $(obj-perf)python/perf$(PYTHON_EXTENSION_SUFFIX) 916 904 else 917 905 $(warning Missing python setuptools, the python binding won't be built, please install python3-setuptools or equivalent)
+26 -1
tools/perf/Makefile.perf
··· 193 193 HOSTAR ?= ar 194 194 CLANG ?= clang 195 195 196 - PKG_CONFIG = $(CROSS_COMPILE)pkg-config 196 + # Some distros provide the command $(CROSS_COMPILE)pkg-config for 197 + # searching packges installed with Multiarch. Use it for cross 198 + # compilation if it is existed. 199 + ifneq (, $(shell which $(CROSS_COMPILE)pkg-config)) 200 + PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config 201 + else 202 + PKG_CONFIG ?= pkg-config 203 + 204 + # PKG_CONFIG_PATH or PKG_CONFIG_LIBDIR, alongside PKG_CONFIG_SYSROOT_DIR 205 + # for modified system root, is required for the cross compilation. 206 + # If these PKG_CONFIG environment variables are not set, Multiarch library 207 + # paths are used instead. 208 + ifdef CROSS_COMPILE 209 + ifeq ($(PKG_CONFIG_LIBDIR)$(PKG_CONFIG_PATH)$(PKG_CONFIG_SYSROOT_DIR),) 210 + CROSS_ARCH = $(shell $(CC) -dumpmachine) 211 + PKG_CONFIG_LIBDIR := /usr/local/$(CROSS_ARCH)/lib/pkgconfig/ 212 + PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/lib/$(CROSS_ARCH)/pkgconfig/ 213 + PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/lib/$(CROSS_ARCH)/pkgconfig/ 214 + PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/share/pkgconfig/ 215 + PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/share/pkgconfig/ 216 + export PKG_CONFIG_LIBDIR 217 + $(warning Missing PKG_CONFIG_LIBDIR, PKG_CONFIG_PATH and PKG_CONFIG_SYSROOT_DIR for cross compilation,) 218 + $(warning set PKG_CONFIG_LIBDIR for using Multiarch libs.) 219 + endif 220 + endif 221 + endif 197 222 198 223 RM = rm -f 199 224 LN = ln -f
+1 -1
tools/perf/util/callchain.c
··· 1141 1141 int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node *node, 1142 1142 bool hide_unresolved) 1143 1143 { 1144 - struct machine *machine = maps__machine(node->ms.maps); 1144 + struct machine *machine = node->ms.maps ? maps__machine(node->ms.maps) : NULL; 1145 1145 1146 1146 maps__put(al->maps); 1147 1147 al->maps = maps__get(node->ms.maps);