From nobody Thu Feb 12 17:28:59 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E9FB757F5; Mon, 10 Jun 2024 09:55:07 +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=1718013309; cv=none; b=ZPZqeWZRZN2dVecBUOqlbSrv6PvW5krx3QmxDcLShBEFmQQArlEJfy4RVyvFcrXujuBQYok3KOo7qQFuAh3Ri5VEuzeng9bSMVNMgAivdaEsNwMbkSbURBqtEqqh/grmFB1URZRW8A0R9gQcNrEl92i4r8ODyttEyohM/YqtcB8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718013309; c=relaxed/simple; bh=EJvYdtAU/vnXNiBRedH73QJqwaqsKTQoOOFCKDfrpyQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=T+sQpNMy9FYJL2411UOXitCJyKc1ax/YF0edUlCNNy5QlCatg+MA5pX2buIc549ZzvdIcetX7g+1T4c8ZTrZdr6yHkdHPhzsD4CDJF/554VKEFtREYRPiJbuPtBKCJ1peggS1Zl+VCcPyXmZi4mbJv2xaNVkTwdEz5Sv9YUu/D4= 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 7CBBF1688; Mon, 10 Jun 2024 02:55: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 A44063F73B; Mon, 10 Jun 2024 02:55:04 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Nick Terrell , Thomas Richter , Quentin Monnet , Changbin Du , Fangrui Song , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Guilherme Amadio Cc: Leo Yan Subject: [PATCH v2 1/6] perf: build: Setup PKG_CONFIG_LIBDIR for cross compilation Date: Mon, 10 Jun 2024 10:54:28 +0100 Message-Id: <20240610095433.336295-2-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610095433.336295-1-leo.yan@arm.com> References: <20240610095433.336295-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 | 26 +++++++++++++++++++++++++- tools/perf/Makefile.perf | 26 +++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index ed54cef450f5..084f803093c3 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -82,7 +82,31 @@ 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 is required for the cross + # compilation. If both is not set, try to set the lib paths installed + # by multiarch. + ifdef CROSS_COMPILE + ifeq ($(PKG_CONFIG_LIBDIR)$(PKG_CONFIG_PATH),) + 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/share/pkgconf= ig/ + 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/share/pkgconfig/ + export PKG_CONFIG_LIBDIR + $(warning Missing PKG_CONFIG_LIBDIR and PKG_CONFIG_PATH for cross co= mpilation,) + $(warning set PKG_CONFIG_LIBDIR=3D$(PKG_CONFIG_LIBDIR) for building = with Multiarch libs.) + endif + endif +endif =20 all: $(FILES) =20 diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 5c35c0d89306..2c9e89415e48 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -193,7 +193,31 @@ 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 is required for the cross + # compilation. If both is not set, try to set the lib paths installed + # by multiarch. + ifdef CROSS_COMPILE + ifeq ($(PKG_CONFIG_LIBDIR)$(PKG_CONFIG_PATH),) + 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/share/pkgconf= ig/ + 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/share/pkgconfig/ + export PKG_CONFIG_LIBDIR + $(warning Missing PKG_CONFIG_LIBDIR and PKG_CONFIG_PATH for cross co= mpilation,) + $(warning set PKG_CONFIG_LIBDIR to $(PKG_CONFIG_LIBDIR) for using li= bs with Multiarch.) + endif + endif +endif =20 RM =3D rm -f LN =3D ln -f --=20 2.34.1 From nobody Thu Feb 12 17:28:59 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 374DB770EF; Mon, 10 Jun 2024 09:55:09 +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=1718013311; cv=none; b=LVAxteIrasmLyCunO5bi2d7xluln5IThH1btVAi6LTYN2G//eGBKnKObFvBjdeRdSCqp/Gn8zE37VlxKURKcgTcltzuSV2B10Y0vDGvLtFaBR5sHuyl0NZb3eAMFbtH0K14ZvqNDMtub/2vWpw9L4LZZn+fWtJeNf/sZkRQ+Kqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718013311; c=relaxed/simple; bh=fc88uOJRhVMj3xvkGkwo8FFwVo0Vrw2VDh0HPHWQs4M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l/Fw15jMauLYD6nNE14XN4CrHl74GBzME4Doob7EkBYmM2OiPzGMhCSmAAqEj8XMwbnSf57wszXFsX8zvrjotY2+5deBpIvsId5uuP3E1c1PSLYQ6cNqBGksDPmodWFo70pojDhPjJEYm7QsmdKtpOQQmmJV0eIQjrQ3mITrzQw= 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 13B911692; Mon, 10 Jun 2024 02:55:34 -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 3C2F93F73B; Mon, 10 Jun 2024 02:55:07 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Nick Terrell , Thomas Richter , Quentin Monnet , Changbin Du , Fangrui Song , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Guilherme Amadio Cc: Leo Yan Subject: [PATCH v2 2/6] perf: build: Set Python configuration for cross compilation Date: Mon, 10 Jun 2024 10:54:29 +0100 Message-Id: <20240610095433.336295-3-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610095433.336295-1-leo.yan@arm.com> References: <20240610095433.336295-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 Thu Feb 12 17:28:59 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E55537711F; Mon, 10 Jun 2024 09:55:12 +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=1718013314; cv=none; b=YVuwC+1OyKs5ujpEnCwdg00fZAJFMgMdl8MbqKHFGCNS5MJ/uN6tRUEIafLqljIBb1ugPpHWWlak0YwLM9xlinXo6BWeECY9xhk5ZSqmgzskaqoF1Z6OKQjs/HAne+Jf4B4cszwm0Qno+LcLgclm8xaMQ6fZOOqS30jbY86MvY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718013314; c=relaxed/simple; bh=dNQ/CAzEs4rD+yEYfDKzk8slZO10VImKzEI6shNAwNo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=k2ysCCxC66uF9bq2WlMm6XujPIvavg3H1hRYFiIb1qvTnSMLe9bu9efos6/6sRaVOpQ8wCcxIhr+fImXzr7cwLQajdTw6xnFl7gUV2doezpzVIP5Amn1XE7+Ayjc7jhke9WA33mmv7i9bVgojLpXg4j8lkDpqgnSGg2APEI2764= 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 A1508169C; Mon, 10 Jun 2024 02:55:36 -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 C76E73F73B; Mon, 10 Jun 2024 02:55:09 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Nick Terrell , Thomas Richter , Quentin Monnet , Changbin Du , Fangrui Song , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Guilherme Amadio Cc: Leo Yan Subject: [PATCH v2 3/6] perf: build: Only link libebl.a for old libdw Date: Mon, 10 Jun 2024 10:54:30 +0100 Message-Id: <20240610095433.336295-4-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610095433.336295-1-leo.yan@arm.com> References: <20240610095433.336295-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 084f803093c3..b23b3e8ad5e4 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -171,7 +171,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 Feb 12 17:28:59 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BFB178C71; Mon, 10 Jun 2024 09:55:15 +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=1718013316; cv=none; b=Iaqn9DtF4VFlkR5wnR8y28k19R1yVqDjN10nntaBcgbCiJIUOJr4dQYrJtSZlgjKGe/6z0SVOOOAIesY+PByiN+h+xWAjE7AoKPCaJVZAt4G8K0pj22DlVMnpvIpUfaNFdlmpe6YPjRdaxKO3Z/QvHO1gpxkNcxc9hWS+6/h6M0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718013316; c=relaxed/simple; bh=66m4mWoqQDyTgo08cySdR6zX8px99PeFOWizcje8QwQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=A5pea64j3ZleezdDb/+0grRf9SA7tYs0NzVgBBBDja8L68udMmElH8QoIxtb6LR5nfML7QWPs75dBYqmSuXA7TFiCLiwLIg4sEYjtDL9WIHjA+8uzVFZ39aVh4XFHKufmQ/RH6bRd6cdPAMI5wCYMBqzPwUt5HQk9VRwyZHyWdk= 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 359FB12FC; Mon, 10 Jun 2024 02:55:39 -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 5E7353F73B; Mon, 10 Jun 2024 02:55:12 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Nick Terrell , Thomas Richter , Quentin Monnet , Changbin Du , Fangrui Song , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Guilherme Amadio Cc: Leo Yan Subject: [PATCH v2 4/6] perf: build: Link lib 'lzma' for static build Date: Mon, 10 Jun 2024 10:54:31 +0100 Message-Id: <20240610095433.336295-5-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610095433.336295-1-leo.yan@arm.com> References: <20240610095433.336295-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 b23b3e8ad5e4..9e5663eefc01 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -212,27 +212,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 Feb 12 17:28:59 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A421379DDB; Mon, 10 Jun 2024 09:55:17 +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=1718013318; cv=none; b=Mx6EWotU1a3cX7CmauiMvI/MuV1GtCpoo06HrTBvkwrNP+Zx0OwXYwDro3Vjev+4Zck0Y5Qj5pOK2/JMpwXNi8/sZDgNcBzTJaGvuyLotjYxbG3c9RG9B5XgJcDfiOr9k4UU+YsOvYJFjwH7lX3Re/XUhbgfl4EFK0Qd+OtPVnM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718013318; c=relaxed/simple; bh=TAI5MVvJ3quT5ll1LWwaXnbXGxwg9ZEetfoGD6HWeHs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Gxj1HoamVuMsxXwt9iTuyi5jj2rHQ6HZEVLq1IxRBY5pOLS7Ozs0N5qwM4uHlR+RB/GC6FJlyaZM7XwXmX1dwk8qypMh+/v44AmH2zKw+19u56vvCrnadr0+sOHcSDnQFRb3zi6lR76mcYGuaq85EgIrEX8DkMlK2oQ8kYT4O0o= 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 C1D4E1688; Mon, 10 Jun 2024 02:55:41 -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 E9EEC3F73B; Mon, 10 Jun 2024 02:55:14 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Nick Terrell , Thomas Richter , Quentin Monnet , Changbin Du , Fangrui Song , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Guilherme Amadio Cc: Leo Yan Subject: [PATCH v2 5/6] perf: build: Link lib 'zstd' for static build Date: Mon, 10 Jun 2024 10:54:32 +0100 Message-Id: <20240610095433.336295-6-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610095433.336295-1-leo.yan@arm.com> References: <20240610095433.336295-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 9e5663eefc01..991bb4fed774 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -171,7 +171,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 Feb 12 17:28:59 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7726F7C6D4; Mon, 10 Jun 2024 09:55:20 +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=1718013321; cv=none; b=h69W+kTlrB10/EYEKjafGbA0vqN69+GfL7Jm9Mo7zKK5K5s+qcPUaTy22riW0ohf81/jiV2guwSD1M1ouM8IbuyU+DFmkt6QV15/B1onvrhzBH1UDpe6eXkmtAPtZOlbR6j3/EmqM3wq/O/ObJaITwC3KqKJXQglT+h5Pp1WHQs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718013321; c=relaxed/simple; bh=THN5rLNVvIjNeAoyxyQQ+pJ8hTn9svBd8fM+nE5JKas=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=O+/TEcjmBV7aWa5rFVSSfc3kz33NybYt0apA2j+CVNrq0wrZxSl4tS6K+mfgbn8CXdcG5dUPATtiA1/rDcz163MTAvCbXCy6MjZisoOiqPQVJeDWmJPoysqxr/v+vEuAlo0+hZ4ZdDT+gdUX9x59sixYBT48uUeoxv9knle22U8= 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 650771688; Mon, 10 Jun 2024 02:55:44 -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 81DBB3F73B; Mon, 10 Jun 2024 02:55:17 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Nick Terrell , Thomas Richter , Quentin Monnet , Changbin Du , Fangrui Song , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Guilherme Amadio Cc: Leo Yan Subject: [PATCH v2 6/6] perf docs: Document cross compilation Date: Mon, 10 Jun 2024 10:54:33 +0100 Message-Id: <20240610095433.336295-7-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610095433.336295-1-leo.yan@arm.com> References: <20240610095433.336295-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