Skip to content

Commit a530337

Browse files
Yang Jihongacmel
authored andcommitted
perf build: Fix build feature-dwarf_getlocations fail for old libdw
For libdw versions below 0.177, need to link libdl.a in addition to libbebl.a during static compilation, otherwise feature-dwarf_getlocations compilation will fail. Before: $ make LDFLAGS=-static BUILD: Doing 'make -j20' parallel build <SNIP> Makefile.config:483: Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157 <SNIP> $ cat ../build/feature/test-dwarf_getlocations.make.output /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libebl.a(eblclosebackend.o): in function `ebl_closebackend': (.text+0x20): undefined reference to `dlclose' collect2: error: ld returned 1 exit status After: $ make LDFLAGS=-static <SNIP> Auto-detecting system features: ... dwarf: [ on ] <SNIP> $ ./perf probe Usage: perf probe [<options>] 'PROBEDEF' ['PROBEDEF' ...] or: perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...] or: perf probe [<options>] --del '[GROUP:]EVENT' ... or: perf probe --list [GROUP:]EVENT ... <SNIP> Fixes: 536661d ("perf: build: Only link libebl.a for old libdw") Reviewed-by: Leo Yan <leo.yan@arm.com> Signed-off-by: Yang Jihong <yangjihong@bytedance.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Leo Yan <leo.yan@arm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://lore.kernel.org/r/20240919013513.118527-3-yangjihong@bytedance.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 43f6564 commit a530337

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

tools/build/feature/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ ifeq ($(findstring -static,${LDFLAGS}),-static)
181181
ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
182182
DWARFLIBS += -lebl
183183
endif
184+
185+
# Must put -ldl after -lebl for dependency
186+
DWARFLIBS += -ldl
184187
endif
185188

186189
$(OUTPUT)test-dwarf.bin:

tools/perf/Makefile.config

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ ifdef LIBDW_DIR
147147
endif
148148
DWARFLIBS := -ldw
149149
ifeq ($(findstring -static,${LDFLAGS}),-static)
150-
DWARFLIBS += -lelf -ldl -lz -llzma -lbz2 -lzstd
150+
DWARFLIBS += -lelf -lz -llzma -lbz2 -lzstd
151151

152152
LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw).0.0
153153
LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
@@ -158,6 +158,9 @@ ifeq ($(findstring -static,${LDFLAGS}),-static)
158158
ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
159159
DWARFLIBS += -lebl
160160
endif
161+
162+
# Must put -ldl after -lebl for dependency
163+
DWARFLIBS += -ldl
161164
endif
162165
FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
163166
FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS)

0 commit comments

Comments
 (0)