Skip to contentSkip to conversation

perf: build: Fix cross compilation

PATCH Superseded Leo Yan 2 participants 11 messages Jun 4, 2024 – Jun 7, 2024 perf events

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Leo Yan

author
#0 lore raw

cover perf: build: Fix cross compilation

This patch series fixes cross compilation issues.

The first two patches address the package configuration issue. It sets the package path so the compiler can find the architecture's package. The patch 03 sets the Python configuration path and renames the .so to reflect the build target.

The last three patches fix the static build failures. Patch 04 is to fix the issue caused by newer version's elfutils, and the last patches fix the building failure for feature detecting binaries.

This patch series is tested for building perf on x86_64 host for Arm64 target.

Leo Yan (6):
perf: build: Setup PKG_CONFIG_LIBDIR for cross compilation
perf: build: Append libtraceevent path in PKG_CONFIG_LIBDIR
perf: build: Set Python configuration for cross compilation
perf: build: Only link libebl.a for old libdw
perf: build: Link lib 'lzma' for static build
perf: build: Link lib 'zstd' for static build

 tools/build/feature/Makefile | 42 +++++++++++++++++++++++++++---------
 tools/perf/Makefile.config   | 25 +++++++++++++++++++--
 tools/perf/Makefile.perf     | 15 ++++++++++++-
 3 files changed, 69 insertions(+), 13 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/6 perf: build: Setup PKG_CONFIG_LIBDIR for cross compilation

On recent Linux distros like Ubuntu Noble and Debian Bookworm, the 'pkg-config-aarch64-linux-gnu' package is missing. As a result, the aarch64-linux-gnu-pkg-config command is not available, which causes build failures.

Alternatively, this commit sets the PKG_CONFIG_LIBDIR environment variable dynamically based on the cross compiler to ensure the correct package configurations.

---
 tools/build/feature/Makefile | 14 +++++++++++++-
 tools/perf/Makefile.perf     | 15 ++++++++++++++-
 2 files changed, 27 insertions(+), 2 deletions(-)
tools/build/feature/Makefile +13 -1
index ed54cef450f5..6f52f892f9a3 100644
@@ -82,7 +82,19 @@ FILES=                                          \
 
 FILES := $(addprefix $(OUTPUT),$(FILES))
 
-PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
+PKG_CONFIG ?= pkg-config
+
+ifdef CROSS_COMPILE
+  ifndef PKG_CONFIG_LIBDIR
+    CROSS_ARCH = $(shell $(CC) -dumpmachine)
+    PKG_CONFIG_LIBDIR := /usr/local/$(CROSS_ARCH)/lib/pkgconfig/
+    PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/share/pkgconfig/
+    PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/lib/$(CROSS_ARCH)/pkgconfig/
+    PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/lib/$(CROSS_ARCH)/pkgconfig/
+    PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/share/pkgconfig/
+    export PKG_CONFIG_LIBDIR
+  endif
+endif
 
 all: $(FILES)
 
tools/perf/Makefile.perf +14 -1
index 5c35c0d89306..c1553a546a4f 100644
@@ -193,7 +193,20 @@ HOSTLD  ?= ld
 HOSTAR  ?= ar
 CLANG   ?= clang
 
-PKG_CONFIG = $(CROSS_COMPILE)pkg-config
+PKG_CONFIG ?= pkg-config
+
+# Set the PKG_CONFIG_LIBDIR for cross compilation.
+ifdef CROSS_COMPILE
+  ifndef PKG_CONFIG_LIBDIR
+    CROSS_ARCH = $(shell $(CC) -dumpmachine)
+    PKG_CONFIG_LIBDIR := /usr/local/$(CROSS_ARCH)/lib/pkgconfig/
+    PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/share/pkgconfig/
+    PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/lib/$(CROSS_ARCH)/pkgconfig/
+    PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/lib/$(CROSS_ARCH)/pkgconfig/
+    PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/share/pkgconfig/
+    export PKG_CONFIG_LIBDIR
+  endif
+endif
 
 RM      = rm -f
 LN      = ln -f
Signature · 1 line
2.34.1
maintainer
#2 lore raw

Re: [PATCH v1 1/6] perf: build: Setup PKG_CONFIG_LIBDIR for cross compilation

Hi Leo,

Quoted 20 lines · Leo Yan

On recent Linux distros like Ubuntu Noble and Debian Bookworm, the 'pkg-config-aarch64-linux-gnu' package is missing. As a result, the aarch64-linux-gnu-pkg-config command is not available, which causes build failures.

Alternatively, this commit sets the PKG_CONFIG_LIBDIR environment variable dynamically based on the cross compiler to ensure the correct package configurations.

---
 tools/build/feature/Makefile | 14 +++++++++++++-
 tools/perf/Makefile.perf     | 15 ++++++++++++++-
 2 files changed, 27 insertions(+), 2 deletions(-)
tools/build/feature/Makefile +0 -0
index ed54cef450f5..6f52f892f9a3 100644

tools/build/feature/Makefile FILES= \ · line 88

Quoted 8 lines
tools/build/feature/Makefile +4 -1
@@ -82,7 +82,19 @@ FILES=                                          \
 
 FILES := $(addprefix $(OUTPUT),$(FILES))
 
-PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
+PKG_CONFIG ?= pkg-config
+
+ifdef CROSS_COMPILE
+  ifndef PKG_CONFIG_LIBDIR

Can we do that only if the cross-compile-pkg-config is not available?

Thanks,
Namhyung

Quoted 41 lines
tools/build/feature/Makefile +9 -0
+    CROSS_ARCH = $(shell $(CC) -dumpmachine)
+    PKG_CONFIG_LIBDIR := /usr/local/$(CROSS_ARCH)/lib/pkgconfig/
+    PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/share/pkgconfig/
+    PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/lib/$(CROSS_ARCH)/pkgconfig/
+    PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/lib/$(CROSS_ARCH)/pkgconfig/
+    PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/share/pkgconfig/
+    export PKG_CONFIG_LIBDIR
+  endif
+endif
 
 all: $(FILES)
 
tools/perf/Makefile.perf +14 -1
index 5c35c0d89306..c1553a546a4f 100644
@@ -193,7 +193,20 @@ HOSTLD  ?= ld
 HOSTAR  ?= ar
 CLANG   ?= clang
 
-PKG_CONFIG = $(CROSS_COMPILE)pkg-config
+PKG_CONFIG ?= pkg-config
+
+# Set the PKG_CONFIG_LIBDIR for cross compilation.
+ifdef CROSS_COMPILE
+  ifndef PKG_CONFIG_LIBDIR
+    CROSS_ARCH = $(shell $(CC) -dumpmachine)
+    PKG_CONFIG_LIBDIR := /usr/local/$(CROSS_ARCH)/lib/pkgconfig/
+    PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/share/pkgconfig/
+    PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/lib/$(CROSS_ARCH)/pkgconfig/
+    PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/lib/$(CROSS_ARCH)/pkgconfig/
+    PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/share/pkgconfig/
+    export PKG_CONFIG_LIBDIR
+  endif
+endif
 
 RM      = rm -f
 LN      = ln -f
Signature · 1 line
2.34.1
author
#3 lore raw

Re: [PATCH v1 1/6] perf: build: Setup PKG_CONFIG_LIBDIR for cross compilation

Hi Namhyung,

Quoted 6 lines · Namhyung Kim
Quoted 6 lines
tools/build/feature/Makefile +0 -0
@@ -82,7 +82,19 @@ FILES=                                          \
 
  FILES := $(addprefix $(OUTPUT),$(FILES))
 
Quoted 7 lines

tools/build/feature/Makefile FILES= \ · line 88

Quoted 5 lines
tools/build/feature/Makefile +4 -1
-PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
+PKG_CONFIG ?= pkg-config
+
+ifdef CROSS_COMPILE
+  ifndef PKG_CONFIG_LIBDIR

Can we do that only if the cross-compile-pkg-config is not available?

Makes sense for me. I will update for this.

Thanks,
Leo

author
#4 lore raw

PATCH 2/6 perf: build: Append libtraceevent path in PKG_CONFIG_LIBDIR

In reply to Leo Yan

When a user specifies the path for libtraceevent, it means a self-built package is being used instead of the distro package. This commit appends the specified path in the variable 'PKG_CONFIG_LIBDIR', so that later pkg-config can retrieve version info from the self-built folder.

---
 tools/perf/Makefile.config | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/Makefile.config +4 -1
index 7f1e016a9253..f545e0c3c176 100644
@@ -1181,7 +1181,10 @@ ifneq ($(NO_LIBTRACEEVENT),1)
     CFLAGS += -DHAVE_LIBTRACEEVENT $(LIBTRACEEVENT_CFLAGS)
     LDFLAGS += $(LIBTRACEEVENT_LDFLAGS)
     EXTLIBS += ${TRACEEVENTLIBS}
-    LIBTRACEEVENT_VERSION := $(shell PKG_CONFIG_PATH=$(LIBTRACEEVENT_DIR) $(PKG_CONFIG) --modversion libtraceevent)
+    ifdef LIBTRACEEVENT_DIR
+      PKG_CONFIG_LIBDIR := $(LIBTRACEEVENT_DIR):$(PKG_CONFIG_LIBDIR)
+    endif
+    LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent)
     LIBTRACEEVENT_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
     LIBTRACEEVENT_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
     LIBTRACEEVENT_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
Signature · 1 line
2.34.1
author
#5 lore raw

PATCH 3/6 perf: build: Set Python configuration for cross compilation

In reply to Leo Yan

Python configuration has dedicated folders for different architectures. For example, Python 3.11 has two folders as shown below, one for Arm64 and another for x86_64:

/usr/lib/python3.11/config-3.11-aarch64-linux-gnu/ /usr/lib/python3.11/config-3.11-x86_64-linux-gnu/

This commit updates the Python configuration path based on the compiler's machine type, guiding the compiler to find the correct path for Python libraries. It also renames the generated .so file name to match the machine name.

---
 tools/perf/Makefile.config | 8 ++++++++
 1 file changed, 8 insertions(+)
tools/perf/Makefile.config +8 -0
index f545e0c3c176..646e5af0ed51 100644
@@ -303,6 +303,11 @@ endif
 
 ifdef PYTHON_CONFIG
   PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)
+  # Update the python flags for cross compilation
+  ifdef CROSS_COMPILE
+    PYTHON_NATIVE := $(shell echo $(PYTHON_EMBED_LDOPTS) | sed 's/\(-L.*\/\)\(.*-linux-gnu\).*/\2/')
+    PYTHON_EMBED_LDOPTS := $(subst $(PYTHON_NATIVE),$(shell $(CC) -dumpmachine),$(PYTHON_EMBED_LDOPTS))
+  endif
   PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
   PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
   PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)
@@ -904,6 +909,9 @@ else
          PYTHON_SETUPTOOLS_INSTALLED := $(shell $(PYTHON) -c 'import setuptools;' 2> /dev/null && echo "yes" || echo "no")
          ifeq ($(PYTHON_SETUPTOOLS_INSTALLED), yes)
            PYTHON_EXTENSION_SUFFIX := $(shell $(PYTHON) -c 'from importlib import machinery; print(machinery.EXTENSION_SUFFIXES[0])')
+           ifdef CROSS_COMPILE
+             PYTHON_EXTENSION_SUFFIX := $(subst $(PYTHON_NATIVE),$(shell $(CC) -dumpmachine),$(PYTHON_EXTENSION_SUFFIX))
+           endif
            LANG_BINDINGS += $(obj-perf)python/perf$(PYTHON_EXTENSION_SUFFIX)
 	 else
            $(warning Missing python setuptools, the python binding won't be built, please install python3-setuptools or equivalent)
Signature · 1 line
2.34.1
author
#6 lore raw

PATCH 4/6 perf: build: Only link libebl.a for old libdw

In reply to Leo Yan

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.

---
 tools/build/feature/Makefile | 12 +++++++++++-
 tools/perf/Makefile.config   | 12 +++++++++++-
 2 files changed, 22 insertions(+), 2 deletions(-)
tools/build/feature/Makefile +11 -1
index 6f52f892f9a3..2f4cfb7b8c14 100644
@@ -159,7 +159,17 @@ $(OUTPUT)test-libopencsd.bin:
 
 DWARFLIBS := -ldw
 ifeq ($(findstring -static,${LDFLAGS}),-static)
-DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
+  DWARFLIBS += -lelf -lz -llzma -lbz2
+
+  LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw)
+  LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
+  LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION)))
+
+  # Elfutils merged libebl.a into libdw.a starting from version 0.177,
+  # Link libebl.a only if libdw is older than this version.
+  ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
+    DWARFLIBS += -lebl
+  endif
 endif
 
 $(OUTPUT)test-dwarf.bin:
tools/perf/Makefile.config +11 -1
index 646e5af0ed51..e8d3713b081c 100644
@@ -152,7 +152,17 @@ ifdef LIBDW_DIR
 endif
 DWARFLIBS := -ldw
 ifeq ($(findstring -static,${LDFLAGS}),-static)
-  DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2
+  DWARFLIBS += -lelf -ldl -lz -llzma -lbz2
+
+  LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw)
+  LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
+  LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION)))
+
+  # Elfutils merged libebl.a into libdw.a starting from version 0.177,
+  # Link libebl.a only if libdw is older than this version.
+  ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
+    DWARFLIBS += -lebl
+  endif
 endif
 FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
 FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS)
Signature · 1 line
2.34.1
maintainer
#7 lore raw

Re: [PATCH v1 4/6] perf: build: Only link libebl.a for old libdw

Quoted 27 lines · Leo Yan

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.

---
 tools/build/feature/Makefile | 12 +++++++++++-
 tools/perf/Makefile.config   | 12 +++++++++++-
 2 files changed, 22 insertions(+), 2 deletions(-)
tools/build/feature/Makefile +2 -1
index 6f52f892f9a3..2f4cfb7b8c14 100644
@@ -159,7 +159,17 @@ $(OUTPUT)test-libopencsd.bin:
 
 DWARFLIBS := -ldw
 ifeq ($(findstring -static,${LDFLAGS}),-static)
-DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
+  DWARFLIBS += -lelf -lz -llzma -lbz2
+

tools/build/feature/Makefile $(OUTPUT)test-libopencsd.bin: · line 173

Quoted 10 lines
tools/build/feature/Makefile +9 -0
+  LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw)
+  LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
+  LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION)))
+
+  # Elfutils merged libebl.a into libdw.a starting from version 0.177,
+  # Link libebl.a only if libdw is older than this version.
+  ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
+    DWARFLIBS += -lebl
+  endif
 endif

Is there a better way to collect required libraries using pkg-config? I guess that's what we want to with the pkg-config in the first place. Maybe pkg-config --print-requires-private libdw ?

Thanks,
Namhyung

Quoted 28 lines
tools/build/feature/Makefile +0 -0
 $(OUTPUT)test-dwarf.bin:
tools/perf/Makefile.config +11 -1
index 646e5af0ed51..e8d3713b081c 100644
@@ -152,7 +152,17 @@ ifdef LIBDW_DIR
 endif
 DWARFLIBS := -ldw
 ifeq ($(findstring -static,${LDFLAGS}),-static)
-  DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2
+  DWARFLIBS += -lelf -ldl -lz -llzma -lbz2
+
+  LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw)
+  LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
+  LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION)))
+
+  # Elfutils merged libebl.a into libdw.a starting from version 0.177,
+  # Link libebl.a only if libdw is older than this version.
+  ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
+    DWARFLIBS += -lebl
+  endif
 endif
 FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
 FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS)
Signature · 1 line
2.34.1
author
#8 lore raw

Re: [PATCH v1 4/6] perf: build: Only link libebl.a for old libdw

On 6/6/24 18:40, Namhyung Kim wrote:

[...]

Quoted 17 lines
Quoted 17 lines
tools/build/feature/Makefile +8 -1
index 6f52f892f9a3..2f4cfb7b8c14 100644
@@ -159,7 +159,17 @@ $(OUTPUT)test-libopencsd.bin:
 
  DWARFLIBS := -ldw
  ifeq ($(findstring -static,${LDFLAGS}),-static)
-DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
+  DWARFLIBS += -lelf -lz -llzma -lbz2
+
+  LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw)
+  LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
+  LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION)))
+
+  # Elfutils merged libebl.a into libdw.a starting from version 0.177,
+  # Link libebl.a only if libdw is older than this version.
Quoted 8 lines

tools/build/feature/Makefile $(OUTPUT)test-libopencsd.bin: · line 173

Quoted 4 lines
tools/build/feature/Makefile +3 -0
+  ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
+    DWARFLIBS += -lebl
+  endif
  endif

Is there a better way to collect required libraries using pkg-config? I guess that's what we want to with the pkg-config in the first place. Maybe pkg-config --print-requires-private libdw ?

Unfortunately, pkg-config --print-requires-private libdw does not work for the libebl.a after checked on Debian:buster.

  # pkg-config --modversion libdw
  0.176
  # pkg-config --print-requires-private libdw
  zlib
  liblzma
  # pkg-config --libs-only-l libdw
  -ldw -lelf
  # ldd /usr/lib/x86_64-linux-gnu/libdw.so
	linux-vdso.so.1 (0x00007fff733e3000)
	libelf.so.1 => /usr/lib/x86_64-linux-gnu/libelf.so.1 (0x0000702e24ec6000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x0000702e24ec1000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x0000702e24ea3000)
	liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x0000702e24e7b000)
	libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x0000702e24e68000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x0000702e24ca8000)
	/lib64/ld-linux-x86-64.so.2 (0x0000702e24f3e000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 
(0x0000702e24c85000)

I think libdw.pc cannot reflect the required dependencies, we still need to use a way liked in this patch (it is a bit ugly :) to link '-lebl'.

Thanks,
Leo

author
#9 lore raw

PATCH 5/6 perf: build: Link lib 'lzma' for static build

In reply to Leo Yan

The libunwind feature test failed with the static linkage. This is due to the 'lzma' lib is missed, so link it to dismiss building failure.

---
 tools/build/feature/Makefile | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
tools/build/feature/Makefile +8 -8
index 2f4cfb7b8c14..18aa6e654804 100644
@@ -200,27 +200,27 @@ $(OUTPUT)test-numa_num_possible_cpus.bin:
 	$(BUILD) -lnuma
 
 $(OUTPUT)test-libunwind.bin:
-	$(BUILD) -lelf
+	$(BUILD) -lelf -llzma
 
 $(OUTPUT)test-libunwind-debug-frame.bin:
-	$(BUILD) -lelf
+	$(BUILD) -lelf -llzma
 $(OUTPUT)test-libunwind-x86.bin:
-	$(BUILD) -lelf -lunwind-x86
+	$(BUILD) -lelf -llzma -lunwind-x86
 
 $(OUTPUT)test-libunwind-x86_64.bin:
-	$(BUILD) -lelf -lunwind-x86_64
+	$(BUILD) -lelf -llzma -lunwind-x86_64
 
 $(OUTPUT)test-libunwind-arm.bin:
-	$(BUILD) -lelf -lunwind-arm
+	$(BUILD) -lelf -llzma -lunwind-arm
 
 $(OUTPUT)test-libunwind-aarch64.bin:
-	$(BUILD) -lelf -lunwind-aarch64
+	$(BUILD) -lelf -llzma -lunwind-aarch64
 
 $(OUTPUT)test-libunwind-debug-frame-arm.bin:
-	$(BUILD) -lelf -lunwind-arm
+	$(BUILD) -lelf -llzma -lunwind-arm
 
 $(OUTPUT)test-libunwind-debug-frame-aarch64.bin:
-	$(BUILD) -lelf -lunwind-aarch64
+	$(BUILD) -lelf -llzma -lunwind-aarch64
 
 $(OUTPUT)test-libaudit.bin:
 	$(BUILD) -laudit
Signature · 1 line
2.34.1
author
#10 lore raw

PATCH 6/6 perf: build: Link lib 'zstd' for static build

In reply to Leo Yan

When build static perf, Makefile reports the error:

Makefile.config:480: No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR

The libdw has been installed on the system, but the build system fails to build the feature detecting binary 'test-libdw-dwarf-unwind'. The failure is caused by missing to link the lib 'zstd'.

Link lib 'zstd' for the static build, in the end, the dwarf feature can be enabled in the static perf.

---
 tools/build/feature/Makefile | 2 +-
 tools/perf/Makefile.config   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tools/build/feature/Makefile +1 -1
index 18aa6e654804..80c237890a06 100644
@@ -159,7 +159,7 @@ $(OUTPUT)test-libopencsd.bin:
 
 DWARFLIBS := -ldw
 ifeq ($(findstring -static,${LDFLAGS}),-static)
-  DWARFLIBS += -lelf -lz -llzma -lbz2
+  DWARFLIBS += -lelf -lz -llzma -lbz2 -lzstd
 
   LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw)
   LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
tools/perf/Makefile.config +1 -1
index e8d3713b081c..acd405bc46de 100644
@@ -152,7 +152,7 @@ ifdef LIBDW_DIR
 endif
 DWARFLIBS := -ldw
 ifeq ($(findstring -static,${LDFLAGS}),-static)
-  DWARFLIBS += -lelf -ldl -lz -llzma -lbz2
+  DWARFLIBS += -lelf -ldl -lz -llzma -lbz2 -lzstd
 
   LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw)
   LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
Signature · 1 line
2.34.1