From nobody Thu Dec 18 09:57:45 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 --- 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