Skip to content

Commit 536661d

Browse files
Leo-Yannamhyung
authored andcommitted
perf: build: Only link libebl.a for old libdw
Since libdw version 0.177, elfutils has merged libebl.a into libdw (see the commit "libebl: Don't install libebl.a, libebl.h and remove backends from spec." in the elfutils repository). As a result, libebl.a does not exist on Debian Bullseye and newer releases, causing static perf builds to fail on these distributions. This commit checks the libdw version and only links libebl.a if it detects that the libdw version is older than 0.177. Signed-off-by: Leo Yan <[email protected]> Tested-by: Ian Rogers <[email protected]> Cc: [email protected] Cc: James Clark <[email protected]> Cc: Thomas Richter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent cffe29d commit 536661d

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

tools/build/feature/Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,17 @@ $(OUTPUT)test-libopencsd.bin:
170170

171171
DWARFLIBS := -ldw
172172
ifeq ($(findstring -static,${LDFLAGS}),-static)
173-
DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
173+
DWARFLIBS += -lelf -lz -llzma -lbz2
174+
175+
LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw)
176+
LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
177+
LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION)))
178+
179+
# Elfutils merged libebl.a into libdw.a starting from version 0.177,
180+
# Link libebl.a only if libdw is older than this version.
181+
ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
182+
DWARFLIBS += -lebl
183+
endif
174184
endif
175185

176186
$(OUTPUT)test-dwarf.bin:

tools/perf/Makefile.config

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,17 @@ ifdef LIBDW_DIR
152152
endif
153153
DWARFLIBS := -ldw
154154
ifeq ($(findstring -static,${LDFLAGS}),-static)
155-
DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2
155+
DWARFLIBS += -lelf -ldl -lz -llzma -lbz2
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
156166
endif
157167
FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
158168
FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS)

0 commit comments

Comments
 (0)