From nobody Mon Feb 9 01:20:34 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 85E8F18C33E; Mon, 15 Jul 2024 14:29:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721053780; cv=none; b=tmDKQn0iTMPnKHne08gifUF2mtDHj3hqvJ44pq4m/XHl24m/7oR1cCr7er813qB9P0p+RbJqlrkrdO9bMjESzeztZmiWAwqHRzPpqAEG0K7Kq9jCtlrPCUpiqJGZbCWt2KBMMLJRhGFBlO5ZkLnDd748IxIcTtODVn/vyLJXbQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721053780; c=relaxed/simple; bh=YZKkOo2iIN7sg6inRV92qD4tbNh1Uovs6wd5L8+CTEk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UjV0j2Goe+FWrjUvK0hUNwhvXtud32k0yrhQlR2Dj518CjAPcnXZ8j0er442YeD4HP35R67Cbnyzavssroy1zD3SUNrg1vEPkpO9YeZ0yGFD6DGxXgAI4O8tx1Yn6n7SwP8sIad/pmnqy0Q8fxCdX2m2LF8wHkpRvWvvFls7nK4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 26033FEC; Mon, 15 Jul 2024 07:30:03 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 469053F766; Mon, 15 Jul 2024 07:29:36 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Nick Terrell , Thomas Richter , amadio@gentoo.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Leo Yan Subject: [PATCH v4 1/6] perf: build: Setup PKG_CONFIG_LIBDIR for cross compilation Date: Mon, 15 Jul 2024 15:29:16 +0100 Message-Id: <20240715142921.51881-2-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240715142921.51881-1-leo.yan@arm.com> References: <20240715142921.51881-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. When a build passes the environment variables PKG_CONFIG_LIBDIR or PKG_CONFIG_PATH, like a user uses make command or a build system (like Yocto, Buildroot, etc) prepares the variables and passes to the Perf's Makefile, the commit keeps these variables for package configuration. Otherwise, this commit sets the PKG_CONFIG_LIBDIR variable to use the Multiarch libs for the cross compilation. Signed-off-by: Leo Yan --- tools/build/feature/Makefile | 25 ++++++++++++++++++++++++- tools/perf/Makefile.perf | 27 ++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index ed54cef450f5..dff65d03d30d 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -82,7 +82,30 @@ FILES=3D \ =20 FILES :=3D $(addprefix $(OUTPUT),$(FILES)) =20 -PKG_CONFIG ?=3D $(CROSS_COMPILE)pkg-config +# Some distros provide the command $(CROSS_COMPILE)pkg-config for +# searching packges installed with Multiarch. Use it for cross +# compilation if it is existed. +ifneq (, $(shell which $(CROSS_COMPILE)pkg-config)) + PKG_CONFIG ?=3D $(CROSS_COMPILE)pkg-config +else + PKG_CONFIG ?=3D pkg-config + + # PKG_CONFIG_PATH or PKG_CONFIG_LIBDIR, alongside PKG_CONFIG_SYSROOT_DIR + # for modified system root, are required for the cross compilation. + # If these PKG_CONFIG environment variables are not set, Multiarch libra= ry + # paths are used instead. + ifdef CROSS_COMPILE + ifeq ($(PKG_CONFIG_LIBDIR)$(PKG_CONFIG_PATH)$(PKG_CONFIG_SYSROOT_DIR),) + CROSS_ARCH =3D $(shell $(CC) -dumpmachine) + PKG_CONFIG_LIBDIR :=3D /usr/local/$(CROSS_ARCH)/lib/pkgconfig/ + PKG_CONFIG_LIBDIR :=3D $(PKG_CONFIG_LIBDIR):/usr/local/lib/$(CROSS_A= RCH)/pkgconfig/ + PKG_CONFIG_LIBDIR :=3D $(PKG_CONFIG_LIBDIR):/usr/lib/$(CROSS_ARCH)/p= kgconfig/ + PKG_CONFIG_LIBDIR :=3D $(PKG_CONFIG_LIBDIR):/usr/local/share/pkgconf= ig/ + PKG_CONFIG_LIBDIR :=3D $(PKG_CONFIG_LIBDIR):/usr/share/pkgconfig/ + export PKG_CONFIG_LIBDIR + endif + endif +endif =20 all: $(FILES) =20 diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 5c35c0d89306..a4a3dca2033a 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -193,7 +193,32 @@ HOSTLD ?=3D ld HOSTAR ?=3D ar CLANG ?=3D clang =20 -PKG_CONFIG =3D $(CROSS_COMPILE)pkg-config +# Some distros provide the command $(CROSS_COMPILE)pkg-config for +# searching packges installed with Multiarch. Use it for cross +# compilation if it is existed. +ifneq (, $(shell which $(CROSS_COMPILE)pkg-config)) + PKG_CONFIG ?=3D $(CROSS_COMPILE)pkg-config +else + PKG_CONFIG ?=3D pkg-config + + # PKG_CONFIG_PATH or PKG_CONFIG_LIBDIR, alongside PKG_CONFIG_SYSROOT_DIR + # for modified system root, is required for the cross compilation. + # If these PKG_CONFIG environment variables are not set, Multiarch libra= ry + # paths are used instead. + ifdef CROSS_COMPILE + ifeq ($(PKG_CONFIG_LIBDIR)$(PKG_CONFIG_PATH)$(PKG_CONFIG_SYSROOT_DIR),) + CROSS_ARCH =3D $(shell $(CC) -dumpmachine) + PKG_CONFIG_LIBDIR :=3D /usr/local/$(CROSS_ARCH)/lib/pkgconfig/ + PKG_CONFIG_LIBDIR :=3D $(PKG_CONFIG_LIBDIR):/usr/local/lib/$(CROSS_A= RCH)/pkgconfig/ + PKG_CONFIG_LIBDIR :=3D $(PKG_CONFIG_LIBDIR):/usr/lib/$(CROSS_ARCH)/p= kgconfig/ + PKG_CONFIG_LIBDIR :=3D $(PKG_CONFIG_LIBDIR):/usr/local/share/pkgconf= ig/ + PKG_CONFIG_LIBDIR :=3D $(PKG_CONFIG_LIBDIR):/usr/share/pkgconfig/ + export PKG_CONFIG_LIBDIR + $(warning Missing PKG_CONFIG_LIBDIR, PKG_CONFIG_PATH and PKG_CONFIG_= SYSROOT_DIR for cross compilation,) + $(warning set PKG_CONFIG_LIBDIR for using Multiarch libs.) + endif + endif +endif =20 RM =3D rm -f LN =3D ln -f --=20 2.34.1 From nobody Mon Feb 9 01:20:34 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3501818EA91; Mon, 15 Jul 2024 14:29:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721053782; cv=none; b=GdQiGk2P0UH5DuLlECPjRuqSTJ2KGQgbK3S2jdNkXS3aITkUklqs3EBKL+Pz1mgVfCK0B5L91k1g3wclpFX8uSQrofDTSNBs9vnkRMqib3M+tBhaYS0Atnux/kDdktvUyIVEouUo7wXoOOWAoAtzPW9/sjLVTej6rcswd36JD0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721053782; c=relaxed/simple; bh=fc88uOJRhVMj3xvkGkwo8FFwVo0Vrw2VDh0HPHWQs4M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BXWZzAooJJJhYD08cvVuynxQhJsTVqBxuYkVCfM6wRP1SwyNRpirlIy1UFLIcwXbb/GR8btlpT3fwRi0yH+dssBA4JYhcrjXYA3L+CORWcMH8N739KAdQQqk2Rn9ncLuhA+ytoARNUICw4w4guMLqJ3BmEv6v7ctv3nIMTWnC+I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EBC7D1007; Mon, 15 Jul 2024 07:30:04 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 185493F766; Mon, 15 Jul 2024 07:29:37 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Nick Terrell , Thomas Richter , amadio@gentoo.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Leo Yan Subject: [PATCH v4 2/6] perf: build: Set Python configuration for cross compilation Date: Mon, 15 Jul 2024 15:29:17 +0100 Message-Id: <20240715142921.51881-3-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240715142921.51881-1-leo.yan@arm.com> References: <20240715142921.51881-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Leo Yan --- tools/perf/Makefile.config | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 7f1e016a9253..755fb78be76a 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -303,6 +303,11 @@ endif =20 ifdef PYTHON_CONFIG PYTHON_EMBED_LDOPTS :=3D $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDF= LAGS) 2>/dev/null) + # Update the python flags for cross compilation + ifdef CROSS_COMPILE + PYTHON_NATIVE :=3D $(shell echo $(PYTHON_EMBED_LDOPTS) | sed 's/\(-L.*= \/\)\(.*-linux-gnu\).*/\2/') + PYTHON_EMBED_LDOPTS :=3D $(subst $(PYTHON_NATIVE),$(shell $(CC) -dumpm= achine),$(PYTHON_EMBED_LDOPTS)) + endif PYTHON_EMBED_LDFLAGS :=3D $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) PYTHON_EMBED_LIBADD :=3D $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil PYTHON_EMBED_CCOPTS :=3D $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/n= ull) @@ -904,6 +909,9 @@ else PYTHON_SETUPTOOLS_INSTALLED :=3D $(shell $(PYTHON) -c 'import set= uptools;' 2> /dev/null && echo "yes" || echo "no") ifeq ($(PYTHON_SETUPTOOLS_INSTALLED), yes) PYTHON_EXTENSION_SUFFIX :=3D $(shell $(PYTHON) -c 'from importl= ib import machinery; print(machinery.EXTENSION_SUFFIXES[0])') + ifdef CROSS_COMPILE + PYTHON_EXTENSION_SUFFIX :=3D $(subst $(PYTHON_NATIVE),$(shell= $(CC) -dumpmachine),$(PYTHON_EXTENSION_SUFFIX)) + endif LANG_BINDINGS +=3D $(obj-perf)python/perf$(PYTHON_EXTENSION_SUF= FIX) else $(warning Missing python setuptools, the python binding won't b= e built, please install python3-setuptools or equivalent) --=20 2.34.1 From nobody Mon Feb 9 01:20:34 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F4BA18F2F1; Mon, 15 Jul 2024 14:29:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721053784; cv=none; b=AxCIGhWueNRFbZ5fYD4YV6xspDz93xye3VKIoOQhwFFUf90gm+mdht4gAy1VMsrNeIKs/t2LEvxFkkUoDvQjy+7qom2zsMQVsXr1/8GOl6lrNioAmu0S0SyogWiXjEp/Z3+vccSowtc/LwFXorK3Wwu9ftx6L+70u8C0SvCHO6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721053784; c=relaxed/simple; bh=YWIe5v99t0UfaTAte/zzxMcuCF5wPTe2Vrv7++kRpco=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=unY2WqvvpkuhXvI3kgtH1EmdmvZHPMaJMNSmMEkJ6hy1ovLiPBlDhnp+cnWRUEgbhFYlv91iNqHIBsnbPhKVEuE8qXDRoZDBHWvQOJAUeV86bNrfcVZQDIZvv9ituqsqWvfnXBSJaUZ+DZSu/41nZOtncZrPmRwx6EjXvscmT6s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BDD0A1042; Mon, 15 Jul 2024 07:30:06 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DE18D3F766; Mon, 15 Jul 2024 07:29:39 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Nick Terrell , Thomas Richter , amadio@gentoo.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Leo Yan Subject: [PATCH v4 3/6] perf: build: Only link libebl.a for old libdw Date: Mon, 15 Jul 2024 15:29:18 +0100 Message-Id: <20240715142921.51881-4-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240715142921.51881-1-leo.yan@arm.com> References: <20240715142921.51881-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- tools/build/feature/Makefile | 12 +++++++++++- tools/perf/Makefile.config | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index dff65d03d30d..08b2be257639 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -170,7 +170,17 @@ $(OUTPUT)test-libopencsd.bin: =20 DWARFLIBS :=3D -ldw ifeq ($(findstring -static,${LDFLAGS}),-static) -DWARFLIBS +=3D -lelf -lebl -lz -llzma -lbz2 + DWARFLIBS +=3D -lelf -lz -llzma -lbz2 + + LIBDW_VERSION :=3D $(shell $(PKG_CONFIG) --modversion libdw) + LIBDW_VERSION_1 :=3D $(word 1, $(subst ., ,$(LIBDW_VERSION))) + LIBDW_VERSION_2 :=3D $(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 +=3D -lebl + endif endif =20 $(OUTPUT)test-dwarf.bin: diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 755fb78be76a..db3bc460d4c2 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -152,7 +152,17 @@ ifdef LIBDW_DIR endif DWARFLIBS :=3D -ldw ifeq ($(findstring -static,${LDFLAGS}),-static) - DWARFLIBS +=3D -lelf -lebl -ldl -lz -llzma -lbz2 + DWARFLIBS +=3D -lelf -ldl -lz -llzma -lbz2 + + LIBDW_VERSION :=3D $(shell $(PKG_CONFIG) --modversion libdw) + LIBDW_VERSION_1 :=3D $(word 1, $(subst ., ,$(LIBDW_VERSION))) + LIBDW_VERSION_2 :=3D $(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 +=3D -lebl + endif endif FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind :=3D $(LIBDW_CFLAGS) FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind :=3D $(LIBDW_LDFLAGS) $(DWARFLIBS) --=20 2.34.1 From nobody Mon Feb 9 01:20:34 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CABE118FC91; Mon, 15 Jul 2024 14:29:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721053786; cv=none; b=WQrDgjjt9Lz0sgiJxQZeov/IXzI360TPn09cR8tXzJs+FLj/h+EsYDm7RhHesNWbTutWt/v+yyfTA9YisO/Y+LizuQI2VTqHe4yiQ+dak9SotVVqdI8y4PIfR7U9EfoOCeEVBuADSuHxKCRNLiRHcVe63bnhlvtBEWUdsqTk7j0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721053786; c=relaxed/simple; bh=wo7GIUvNuBV/NXXAqy2+mHPHpop6wUNXRasu8vnTEfA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ePcWWZ4Kv/vXQVEDt+G9clMzaqU1r4t1Br73kznlLyAxyOi8WqDAQW4GX00SCjKbBUETDJt4zd2DUdudAWQfZzNlCe8+1oAe1E+LKVcRqHePx8DnaIXKczUJQtfLzSnQt/SEzqAjPntUzv5HBqs1sYn1bhEhpfcGQ/RkCsEI27Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8F71EDA7; Mon, 15 Jul 2024 07:30:08 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B02C93F766; Mon, 15 Jul 2024 07:29:41 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Nick Terrell , Thomas Richter , amadio@gentoo.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Leo Yan Subject: [PATCH v4 4/6] perf: build: Link lib 'lzma' for static build Date: Mon, 15 Jul 2024 15:29:19 +0100 Message-Id: <20240715142921.51881-5-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240715142921.51881-1-leo.yan@arm.com> References: <20240715142921.51881-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Leo Yan --- tools/build/feature/Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index 08b2be257639..2d5be5c17d65 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -211,27 +211,27 @@ $(OUTPUT)test-numa_num_possible_cpus.bin: $(BUILD) -lnuma =20 $(OUTPUT)test-libunwind.bin: - $(BUILD) -lelf + $(BUILD) -lelf -llzma =20 $(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 =20 $(OUTPUT)test-libunwind-x86_64.bin: - $(BUILD) -lelf -lunwind-x86_64 + $(BUILD) -lelf -llzma -lunwind-x86_64 =20 $(OUTPUT)test-libunwind-arm.bin: - $(BUILD) -lelf -lunwind-arm + $(BUILD) -lelf -llzma -lunwind-arm =20 $(OUTPUT)test-libunwind-aarch64.bin: - $(BUILD) -lelf -lunwind-aarch64 + $(BUILD) -lelf -llzma -lunwind-aarch64 =20 $(OUTPUT)test-libunwind-debug-frame-arm.bin: - $(BUILD) -lelf -lunwind-arm + $(BUILD) -lelf -llzma -lunwind-arm =20 $(OUTPUT)test-libunwind-debug-frame-aarch64.bin: - $(BUILD) -lelf -lunwind-aarch64 + $(BUILD) -lelf -llzma -lunwind-aarch64 =20 $(OUTPUT)test-libaudit.bin: $(BUILD) -laudit --=20 2.34.1 From nobody Mon Feb 9 01:20:34 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 41C9E190042; Mon, 15 Jul 2024 14:29:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721053786; cv=none; b=ldzxw6telHNflGsHvpL3PFUy32oMOJiUNVUqtKr2AvN4gsTIQCfSEIDA2XqCKgkGWeWV63gxDKCOUkoonT0J/3Dxkv9Mxl+VxgM/+cGn/bcZKiHhmn8gcpWsPwsL5ICPMuteJmxyarYg7y+Si8kmHDP9rs9XiPd1UnYjMCIy5DE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721053786; c=relaxed/simple; bh=DoyIJN76g9VcxfuI6ysiAakjqN6ECMALbr8DTSj3FO8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LhgX9x7UlUE+gf5CGAePClQpbmRtiBtBvVbsjVjCuf5WL1Za9/uJly70PJelqITIKaFD4HFcK2ddN5z/8PHFgBhGJFCsGN8yUO0jsYED//6oIhifFGVf3QHGnjNocPZ1xFQiHe/q5gg6o7zuP+N7ZvuqT8KjZoHIsFi7j4mJ494= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6138CFEC; Mon, 15 Jul 2024 07:30:10 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 81EC93F766; Mon, 15 Jul 2024 07:29:43 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Nick Terrell , Thomas Richter , amadio@gentoo.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Leo Yan Subject: [PATCH v4 5/6] perf: build: Link lib 'zstd' for static build Date: Mon, 15 Jul 2024 15:29:20 +0100 Message-Id: <20240715142921.51881-6-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240715142921.51881-1-leo.yan@arm.com> References: <20240715142921.51881-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When build static perf, Makefile reports the error: Makefile.config:480: No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >=3D 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. Signed-off-by: Leo Yan --- tools/build/feature/Makefile | 2 +- tools/perf/Makefile.config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index 2d5be5c17d65..4af6a9582f15 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -170,7 +170,7 @@ $(OUTPUT)test-libopencsd.bin: =20 DWARFLIBS :=3D -ldw ifeq ($(findstring -static,${LDFLAGS}),-static) - DWARFLIBS +=3D -lelf -lz -llzma -lbz2 + DWARFLIBS +=3D -lelf -lz -llzma -lbz2 -lzstd =20 LIBDW_VERSION :=3D $(shell $(PKG_CONFIG) --modversion libdw) LIBDW_VERSION_1 :=3D $(word 1, $(subst ., ,$(LIBDW_VERSION))) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index db3bc460d4c2..0f918475d7b6 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -152,7 +152,7 @@ ifdef LIBDW_DIR endif DWARFLIBS :=3D -ldw ifeq ($(findstring -static,${LDFLAGS}),-static) - DWARFLIBS +=3D -lelf -ldl -lz -llzma -lbz2 + DWARFLIBS +=3D -lelf -ldl -lz -llzma -lbz2 -lzstd =20 LIBDW_VERSION :=3D $(shell $(PKG_CONFIG) --modversion libdw) LIBDW_VERSION_1 :=3D $(word 1, $(subst ., ,$(LIBDW_VERSION))) --=20 2.34.1 From nobody Mon Feb 9 01:20:34 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 88DA1191F6F; Mon, 15 Jul 2024 14:29:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721053789; cv=none; b=M3OmI+x0yi1RIgX1bPy2nBGS6AA4Vv8RmOaaPPoYeZGcb/6uaCIaSF/UoafoeskNtS4Cv6klrMuzRPRVwgL8FxsDTteDHVE/jgA0QiLxrb5BEHoVHIqFV1uRp+XVBzdkZk5lWYavmLobPMdzxZqGEOjlWOfyFvw2wtR1JqregMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721053789; c=relaxed/simple; bh=THN5rLNVvIjNeAoyxyQQ+pJ8hTn9svBd8fM+nE5JKas=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=iRgzgmfpnDpVI6+wXW+IEHcorgWx6S2hAinnRICUJgwUbKZLXJikHrg4lX2CM8sQlVBqNLnBgQuARqEmY+eXb5cT8WDvB+lMR09KMwPVxC/kSY6U3dbqmzTK+zdzvoTAnFxsOVPum3q2sI8lyIbHMaN/COiEVsqcb32ncfoBd94= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4D683DA7; Mon, 15 Jul 2024 07:30:12 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 53E143F766; Mon, 15 Jul 2024 07:29:45 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Nick Terrell , Thomas Richter , amadio@gentoo.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Leo Yan , James Clark Subject: [PATCH v4 6/6] perf docs: Document cross compilation Date: Mon, 15 Jul 2024 15:29:21 +0100 Message-Id: <20240715142921.51881-7-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240715142921.51881-1-leo.yan@arm.com> References: <20240715142921.51881-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Records the commands for cross compilation with two methods. The first method relies on Multiarch. The second approach is to explicitly specify the PKG_CONFIG variables, which is widely used in build system (like Buildroot, Yocto, etc). Co-developed-by: James Clark Signed-off-by: James Clark Signed-off-by: Leo Yan --- tools/perf/Documentation/Build.txt | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tools/perf/Documentation/Build.txt b/tools/perf/Documentation/= Build.txt index 3766886c4bca..2237ceee74ba 100644 --- a/tools/perf/Documentation/Build.txt +++ b/tools/perf/Documentation/Build.txt @@ -71,3 +71,40 @@ supported by GCC. UBSan detects undefined behaviors of p= rograms at runtime. $ UBSAN_OPTIONS=3Dprint_stacktrace=3D1 ./perf record -a =20 If UBSan detects any problem at runtime, it outputs a =E2=80=9Cruntime err= or:=E2=80=9D message. + +4) Cross compilation +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +The perf tool can be cross compiled in below methods. + +As Multiarch is commonly supported in Linux distributions, we can install +libraries for multiple architectures on the same system and then cross-com= pile +Linux perf. For example, Aarch64 libraries and toolchains can be installed= on +an x86_64 machine, allowing us to compile perf for an Aarch64 target. + +Below is the command for building perf with dynamic linking: +As Multiarch is commonly supported in Linux distros, therefore, we can +install multiple architectures libs in the same system and then cross comp= ile +the Linux perf. For example, the Aarch64 libraries and toolchain can be +installed on the x86_64 machine, based on it we can compile the perf for +Aarch64 target. + +Below is the command for building the perf with dynamic linking. + + $ cd /path/to/Linux + $ make ARCH=3Darm64 CROSS_COMPILE=3Daarch64-linux-gnu- -C tools/perf + +For static linking, the option `LDFLAGS=3D"-static"` is required. + + $ make ARCH=3Darm64 CROSS_COMPILE=3Daarch64-linux-gnu- \ + LDFLAGS=3D"-static" -C tools/perf + +In the embedded system world, a use case is to explicitly specify the pack= age +configuration paths for cross building: + + $ PKG_CONFIG_SYSROOT_DIR=3D"/path/to/cross/build/sysroot" \ + PKG_CONFIG_LIBDIR=3D"/usr/lib/:/usr/local/lib" \ + make ARCH=3Darm64 CROSS_COMPILE=3Daarch64-linux-gnu- -C tools/perf + +In this case, the variable PKG_CONFIG_SYSROOT_DIR can be used alongside the +variable PKG_CONFIG_LIBDIR or PKG_CONFIG_PATH to prepend the sysroot path = to +the library paths for cross compilation. --=20 2.34.1