Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp249668lqp; Mon, 10 Jun 2024 02:56:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW2e2KJfJGQMNndZNbXNAp6F15ZUKqfkwtjaTdTriqItnRB1rzuOpg4RIXQYouvW3t/gXLbtsB0k8EuG4kIO4sVzuQJiyK6shhGyyCj2g== X-Google-Smtp-Source: AGHT+IGi2H4OhUOXvs8ZHDltwXTkup+qCxVIwmv9dzjBiZmt4iAY/83qO0ZiWyjd0JJYtY8fMCIZ X-Received: by 2002:a17:907:3fa3:b0:a6f:1d4e:734f with SMTP id a640c23a62f3a-a6f1d4e75a1mr199551666b.36.1718013391009; Mon, 10 Jun 2024 02:56:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718013390; cv=pass; d=google.com; s=arc-20160816; b=NW6ZcszR7rKSXid2iQARyia7vzBoSKoMkj0mMuctNf5CWn4u3LDrhBbv4pDcKVthAN SdnWoYgIoc2mAS1pmgkz4atnACfooVq8GVx0C4Gq99RaeVFp24Y7lcc+KAcE+S0vFozt IYUzFSQXjGDZfGjo5AP6Pn+ktMX3X8ZY5QFm6lRC6wMQj1gvDIGMUDlK2CLsbdyE+13w F0l820FX3I0KumqyIOfMeWI4ivWCUczCV7SjwRs2kRaksdHY603tVbBZiEFUAer79BH/ AsJxUeYG0KIrhcQmons+5nAzZRMhpgjuZU1a2BUB7BvJC6wFDdcgZyM5fUOhk4FyU98G xYCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=MSvjm1bV+5pbEsj9stP58rg+sbqgwBFQOl1E7vAV5KI=; fh=HpB/ghQ4qY+yqVacJINdcRXrsaCBAaUbGMhHL4opc+o=; b=mkqu4AMMPELEdy5eaQcpnYyVj8TgbBqGbAAg0tr4SYeWG0ciLjjNCZJKXcBKj/FKLg lwNIUEQgrmmbrUMMLKCQqDS+mQWN/2eCKaQ0OLfCLuWtZ4ve/jD9vKCGgplYf41rbpXC /GBTuQis1niwcl8O6hfYkfezlJuRJXcC6j4C/YvFFG6OHWSDzdma0GsjmKt4xBSQ97EM gCovr9OLuc5Ay9FPGkfeH/KTVVTK6ep/Wa1+LyAZg/FnK4TC1IpXCuNDFfFa4Hzb+CNw HVtTbm1Ww9lmAy4Sz/PwmkBITOeNf4PqgCiP/t0lSg7NqFBlLBphdVrEn3UklZZ86Lnv 4dkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-207974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207974-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6efbd429b6si250184466b.810.2024.06.10.02.56.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 02:56:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-207974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207974-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B8FFB1F24394 for ; Mon, 10 Jun 2024 09:56:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60AD07D3E0; Mon, 10 Jun 2024 09:55:22 +0000 (UTC) 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: 8bit 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 programs at runtime. $ UBSAN_OPTIONS=print_stacktrace=1 ./perf record -a If UBSan detects any problem at runtime, it outputs a “runtime error:” message. + +4) Cross compilation +==================== +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-compile +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 compile +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=arm64 CROSS_COMPILE=aarch64-linux-gnu- -C tools/perf + +For static linking, the option `LDFLAGS="-static"` is required. + + $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \ + LDFLAGS="-static" -C tools/perf + +In the embedded system world, a use case is to explicitly specify the package +configuration paths for cross building: + + $ PKG_CONFIG_SYSROOT_DIR="/path/to/cross/build/sysroot" \ + PKG_CONFIG_LIBDIR="/usr/lib/:/usr/local/lib" \ + make ARCH=arm64 CROSS_COMPILE=aarch64-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. -- 2.34.1