Linux perf工具静态编译

在嵌入式环境中,有时候相关库比较少,所以需要单独编译静态版本的perf工具去定位问题,这里仅仅作为关键步骤记录,以备后续查阅

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 修改Makefile.config文件
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index a92f0f025ec7..87a6e97ff1f8 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -16,7 +16,7 @@ $(shell printf "" > $(OUTPUT).config-detected)
detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)
detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)

-CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
+CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS)) -static

include $(srctree)/tools/scripts/Makefile.arch

1
2
3
4
# 执行编译
cd tools/perf
make clean
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- perf V=1
作者

Markel

发布于

2025-04-25

更新于

2025-04-26

许可协议

评论