Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1476058lqj; Tue, 4 Jun 2024 02:44:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWHL1vkcNgQEAEgX5kRvlaVEKdZl+aX8Tgtz3ZRgH5nFQfT+ji/3v9K7R7BVlsMph3xU5Cyq6/y8OuV5OwzR8EQO/GfoDLuzyGbHfLHKA== X-Google-Smtp-Source: AGHT+IEw4FY4xXa70OdU1z3gJg7A/YRBqo7SyrhlFE3bz15Lo3mkxM74z7hpXu8Viqqri3foWoUD X-Received: by 2002:a17:906:a1c4:b0:a64:722f:5a2f with SMTP id a640c23a62f3a-a6820902268mr700005966b.42.1717494266057; Tue, 04 Jun 2024 02:44:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717494266; cv=pass; d=google.com; s=arc-20160816; b=sD4CwY2XYPumSP7EdZZMouvAgjG3Q046Y+1UbjIg2130V0D5eC79aO9OmFSJNeAHEc KxdoBLteYHY7tBCwAao7P4RYACn1vOCYWGaxciytvbW8g6dT1vk6OTGjc0psjnG8bosW OR/t3FXiRDwxhDkWe6e2fjV8hVIkWUkgoHrqg5MZbBTP3a30jpgiP/Hu7HYoEgTjnujz vvzjChcTOPA8CgVENxe16JxBghkeOE/KXAtJWA34No+2ogD2FTjtdHiSus59mXaehass z2eyiX2NiLr+jQKXxJel0CdKtCWUlK0XptPbHYv69PnWidxaN3sEXXAESAw0z13oG8gy dcCw== 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=4zQ+bG9EPSnYVjZjfpMLJAxPQLJtfkVHeR8ak/FCiBw=; fh=KSiWrCR7xjqa6nMnB8EyauKJbY8zFKZ3kSm6JhLxeok=; b=nt+CYvCnCpHtcHtpbzVN1b42r21NwsqqsbOV3mccpsFVog+erMfPsNI+ZzSvMO5xZw n9aBj2pA+1aGnF6zTOzGG034P1rsv3BYH1jEJBgPquPK8kXoJeGkQFjIssIvRqyBptTY OPIlxNmPqPNUbA+WUFsZFjfFmyhB2027wXzscUk8qyoRpHpEN8z1w/wUdicZP5Mgvjql Wl7pocEHfLVoSv35SfDtT1rYFl9EfJrk5lGcyok8YRuysWgISEla1LZF6v7+xWLruDz7 vH8hM0l0unG0MDbSA55x5jQXg1Rg73KgFoPFE0CXTiYYKlI1lLML3xbQyM7kFaVX8Gq9 I6aw==; 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-200358-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200358-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-a67ea38dd4fsi473905466b.375.2024.06.04.02.44.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:44:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200358-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-200358-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200358-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 5D28A1F24649 for ; Tue, 4 Jun 2024 09:33:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9364B145326; Tue, 4 Jun 2024 09:32:47 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C429B144D24; Tue, 4 Jun 2024 09:32: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=1717493567; cv=none; b=B1u7XnkZqhLewd+L4TN08Oqd9nXa8J6AQzo5PHnoO51bC3dxMgLfbd7TDt+v0zErEepSFi8H/JA2QNPC7RVgywehSAGEoLinVLNfOHA30CnYj1OJsPuq/wsAGegMlQD65vGieKHTwVG5KvJgJxEUo59itrng1FgBjyCHfmhMUOE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717493567; c=relaxed/simple; bh=v6eX51MtO/kHVdP5FiWoLf+U6ElkFVAWKVYKBl9e4Hg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NRHusfMH5eUXNZnaX1HeYfSyNOjltbBmLI7carsmE6Ommu23+6lR/vcAGl+9pNa8lIlVUtHpnP2ORkf6drJ3KCGSiS82Vf54oeYB2CXuT0qxXk7PDXlhNpAc0+NxGGDLBgZiOMqNsGk1Jjvn20oTWWehz59Y0IVGt51D8agGqJ4= 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 87BAF1515; Tue, 4 Jun 2024 02:33:09 -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 7AE6A3F762; Tue, 4 Jun 2024 02:32:43 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , James Clark , Ian Rogers , "Liang, Kan" , Nick Terrell , Thomas Richter , Changbin Du , Fangrui Song , "Mateusz Kowalczyk" , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Leo Yan Subject: [PATCH v1 3/6] perf: build: Set Python configuration for cross compilation Date: Tue, 4 Jun 2024 10:32:20 +0100 Message-Id: <20240604093223.1934236-4-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240604093223.1934236-1-leo.yan@arm.com> References: <20240604093223.1934236-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: 8bit 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 f545e0c3c176..646e5af0ed51 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -303,6 +303,11 @@ endif ifdef PYTHON_CONFIG PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null) + # Update the python flags for cross compilation + ifdef CROSS_COMPILE + PYTHON_NATIVE := $(shell echo $(PYTHON_EMBED_LDOPTS) | sed 's/\(-L.*\/\)\(.*-linux-gnu\).*/\2/') + PYTHON_EMBED_LDOPTS := $(subst $(PYTHON_NATIVE),$(shell $(CC) -dumpmachine),$(PYTHON_EMBED_LDOPTS)) + endif PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null) @@ -904,6 +909,9 @@ else PYTHON_SETUPTOOLS_INSTALLED := $(shell $(PYTHON) -c 'import setuptools;' 2> /dev/null && echo "yes" || echo "no") ifeq ($(PYTHON_SETUPTOOLS_INSTALLED), yes) PYTHON_EXTENSION_SUFFIX := $(shell $(PYTHON) -c 'from importlib import machinery; print(machinery.EXTENSION_SUFFIXES[0])') + ifdef CROSS_COMPILE + PYTHON_EXTENSION_SUFFIX := $(subst $(PYTHON_NATIVE),$(shell $(CC) -dumpmachine),$(PYTHON_EXTENSION_SUFFIX)) + endif LANG_BINDINGS += $(obj-perf)python/perf$(PYTHON_EXTENSION_SUFFIX) else $(warning Missing python setuptools, the python binding won't be built, please install python3-setuptools or equivalent) -- 2.34.1