From nobody Thu Dec 18 08:35:44 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6ABE71BF2A; Wed, 17 Jul 2024 08:23:00 +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=1721204582; cv=none; b=Yq249bc7J/YJ0JVaXC6728memw2QbHB35fGZ6VqMvCIXp08fLQklBo3poVxp1FYK+bOatbv2tCMinRle6XCkwXprX8W2qZJjxYbBX/bdCr7KtnsH2CS4Ra4TyfRPKLIXDQhuAlyUWxe5PGxIRbUmkaSISOsINmrxMjJz4pEEemU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721204582; c=relaxed/simple; bh=YZKkOo2iIN7sg6inRV92qD4tbNh1Uovs6wd5L8+CTEk=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=S3PbsOD8/xRVrEGCk5UDjGD1i1//Cvyg9jZ+Cxy1t5Wcw8YhW56UL7BpRE8iGxopj3pWrN7TpQ3u2BK7iCF1CVJ7bq2e7t4+mFe6N867WtFVEflAwl8wwAXhb6jJQfDZDSvYWkJ8jJCEPy2AdxMuCdd6vCM8NIGJ6dBnOmufxdE= 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 D6DD7106F; Wed, 17 Jul 2024 01:23:24 -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 AF5763F762; Wed, 17 Jul 2024 01:22:57 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Leo Yan , Thomas Richter , James Clark , amadio@gentoo.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH v5 1/6] perf: build: Setup PKG_CONFIG_LIBDIR for cross compilation Date: Wed, 17 Jul 2024 09:22:06 +0100 Message-Id: <20240717082211.524826-2-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240717082211.524826-1-leo.yan@arm.com> References: <20240717082211.524826-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 Tested-by: Ian Rogers --- 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 Thu Dec 18 08:35:44 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 833313839C; Wed, 17 Jul 2024 08:23:02 +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=1721204584; cv=none; b=N758Op1oQNY4s5tIfvQPdy6AAe+KMjO+cTz36a7CtXpEf08xU/3nD6gcX0yqCy8zHi3/wdcG6cT0UH4uJD69R84ksLqSGTAhvxg+8nqXPKkSTXhbThkrHk5v5THbeSHM+uViyakYcEbt4MuCU83n12jDF/snTQkSqVqxGSt6gyk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721204584; c=relaxed/simple; bh=fc88uOJRhVMj3xvkGkwo8FFwVo0Vrw2VDh0HPHWQs4M=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Psbxam6YU8sP8iLBkSswuKD8qB720Ap93DsJUA75O8lQj/EFdj7sww8XoibPCnouDvd3jZm/CpHfcAuLMLokeFCGjdUxqyI9tyj+m8ODSv5GZT0xg62xpbUnIuWBVIiNXAItBKKDViMruT1EbD1M21AA46CNdm420rhKv+6c8B8= 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 004AC1480; Wed, 17 Jul 2024 01:23:27 -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 CCBF23F762; Wed, 17 Jul 2024 01:22:59 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Leo Yan , Thomas Richter , James Clark , amadio@gentoo.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH v5 2/6] perf: build: Set Python configuration for cross compilation Date: Wed, 17 Jul 2024 09:22:07 +0100 Message-Id: <20240717082211.524826-3-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240717082211.524826-1-leo.yan@arm.com> References: <20240717082211.524826-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 Tested-by: Ian Rogers --- 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 Thu Dec 18 08:35:44 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5DCA23BB22; Wed, 17 Jul 2024 08:23:04 +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=1721204585; cv=none; b=f8OKGY9FZfxsNh1tju0HlOScqeMPecfTY/4yB32L8cQ4PpX1YNoewWrXty7hevtjsZtpAtjWxz3DrjZEkYP7Vhv/lbyALaB0CMYctO9fJeXbFgD1gM3ZpInxgQuFMtv9RrR3/tEjaJ62BW/G6ykGmMI+6jQIiKWItdyOtqLIX48= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721204585; c=relaxed/simple; bh=YWIe5v99t0UfaTAte/zzxMcuCF5wPTe2Vrv7++kRpco=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JG0Mbl3vxNO8jMfIZfRVV0bIOUJ9V9OU71buROs/eF62TKPjFl0rwVI8pIiuMdVDlPqpMy+UZfR77teWNOEXW4nMM/0Sob+IG9rzNJqNYVJUOFd6LAg6MzK8aSt4dyardKRHcOyITFMuRN/7XEdx4SURp5uMr+x8HLTkDhq6tFU= 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 1DEEB1516; Wed, 17 Jul 2024 01:23:29 -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 EA6123F762; Wed, 17 Jul 2024 01:23:01 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Leo Yan , Thomas Richter , James Clark , amadio@gentoo.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH v5 3/6] perf: build: Only link libebl.a for old libdw Date: Wed, 17 Jul 2024 09:22:08 +0100 Message-Id: <20240717082211.524826-4-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240717082211.524826-1-leo.yan@arm.com> References: <20240717082211.524826-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 Tested-by: Ian Rogers --- 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 Thu Dec 18 08:35:44 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 433C1405E6; Wed, 17 Jul 2024 08:23:06 +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=1721204587; cv=none; b=oqMGsxqXLLv907aCpIozzik/MVwFoSJG3OP++8P+NoyIQIsfKUwv6S6wFCQqvnwtbHOPrJsDiBUkiMskatSK6AWCQwrcveSHTuSH15AMtFCLptn1RzX81HH3iieQsFi7E4RHYNVwEmoo/dik0EILRlTlKpHWhMP3JroLUNqLKN8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721204587; c=relaxed/simple; bh=wo7GIUvNuBV/NXXAqy2+mHPHpop6wUNXRasu8vnTEfA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=c050xIycbAJiR9ubil1eI22aybU+sFo2AlFi+qALKrk9uqBZsbCGuJC3xCoUSgrlwue33OUeJJPUUbd7Mwk9EClS+hcBcamjv322jdyXjsecqBfujoXc5YPvZ3C6tbhT18XPfh4OskYC/2x5TE8o5r6oS3/Nk3bPaDXPV+ptd+E= 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 3B3D41063; Wed, 17 Jul 2024 01:23:31 -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 13C523F762; Wed, 17 Jul 2024 01:23:03 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Leo Yan , Thomas Richter , James Clark , amadio@gentoo.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH v5 4/6] perf: build: Link lib 'lzma' for static build Date: Wed, 17 Jul 2024 09:22:09 +0100 Message-Id: <20240717082211.524826-5-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240717082211.524826-1-leo.yan@arm.com> References: <20240717082211.524826-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 Tested-by: Ian Rogers --- 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 Thu Dec 18 08:35:44 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F46447772; Wed, 17 Jul 2024 08:23:08 +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=1721204589; cv=none; b=fSF3B885GU4H23DX5XuXGCh7Qmd+B0yvYcw2yb96J7SYi9Rkv8KKI2BJE/qratLfSOdSsdiE+AtHCPe3mnThg/Lj6kl1cBbAJJkAiDDfIl9UYq62H7BbbzvlnVu1gFQ4kPEAHvqa1HZFZoq5G/qUk3lBCVum2KRmMepV/bNW9rY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721204589; c=relaxed/simple; bh=DoyIJN76g9VcxfuI6ysiAakjqN6ECMALbr8DTSj3FO8=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PB2iNlPqiAJlmSwmJW2sXR3o50/AvVbRcu8tsI2X0T8YnLZfuNU5Ao09h9dpQhw3zpwvR/UKphXCIpgaOtp5LZooSTeJDwQsIEmfDT0Wktn6G4ZAG46hpz/b5ymxI0xrvuHXi+evdCtMOfMeTWwXXtPmaYd5hYVUTJKEzy7tLKI= 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 58F2E1063; Wed, 17 Jul 2024 01:23:33 -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 316763F762; Wed, 17 Jul 2024 01:23:06 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Leo Yan , Thomas Richter , James Clark , amadio@gentoo.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH v5 5/6] perf: build: Link lib 'zstd' for static build Date: Wed, 17 Jul 2024 09:22:10 +0100 Message-Id: <20240717082211.524826-6-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240717082211.524826-1-leo.yan@arm.com> References: <20240717082211.524826-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 Tested-by: Ian Rogers --- 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 Thu Dec 18 08:35:44 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C1A04D8B6; Wed, 17 Jul 2024 08:23:10 +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=1721204592; cv=none; b=nw5QROMW77VaZiNzXkVXtRhSofZ/8+fwEdYdbrXxK+pYGIKy719+veSeGgHd0Z1m4yOYGfAztdoCd1pJJQkS0KIRzqbDTlD8jQGkx7saxxK4NFCMYw13mFzOtpesocp08w+8lBzE5+NAjN0JWv/7DlRPH8WW766yG/OEhOnQE/Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721204592; c=relaxed/simple; bh=7w8d4hF30cPl3B1WLOUMU9Qsqcr231BJGYZiaEO85Mk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=pUm2tQcBmCNgs88NafkcofdozyUo/+cFreVwvQbAcNjZC1g9G6bSt9Fdtiw+nRUfNz4U+3q0NmLlNMpxYCcVGKviowJB/ptYVXi7QfnIaEf4UEzVWAdqMVkGF7iYUtNLOKdZczrMzAvY+wfdXQ9OT8g7lfZfS9fASE7Wl3nZPHc= 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 97576106F; Wed, 17 Jul 2024 01:23:35 -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 4F42C3F762; Wed, 17 Jul 2024 01:23:08 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Leo Yan , Thomas Richter , James Clark , amadio@gentoo.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: James Clark Subject: [PATCH v5 6/6] perf docs: Document cross compilation Date: Wed, 17 Jul 2024 09:22:11 +0100 Message-Id: <20240717082211.524826-7-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240717082211.524826-1-leo.yan@arm.com> References: <20240717082211.524826-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 Tested-by: Ian Rogers --- tools/perf/Documentation/Build.txt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tools/perf/Documentation/Build.txt b/tools/perf/Documentation/= Build.txt index 3766886c4bca..83dc87c662b6 100644 --- a/tools/perf/Documentation/Build.txt +++ b/tools/perf/Documentation/Build.txt @@ -71,3 +71,31 @@ 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 +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 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