Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp249372lqp; Mon, 10 Jun 2024 02:55:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX6vYLSxXiBre12tqZ2dd3qdHuodS3LlkFpj6Xmo/2Mv+u295LH1tPdhNEuX052N2b9hfWXw1nN9AY6h4vOJwgh9gmR1hIogjxudxZmaw== X-Google-Smtp-Source: AGHT+IFTTDZlSkmNEHi2CL/fM7ufPdBbz8ckTPKScp3SvXxbfX3xA1Ugpx9V5NJQMkDkRkbH/dAA X-Received: by 2002:a05:620a:414b:b0:797:a8cf:67de with SMTP id af79cd13be357-797a8cf6bbamr43185785a.19.1718013339051; Mon, 10 Jun 2024 02:55:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718013339; cv=pass; d=google.com; s=arc-20160816; b=a9VRFRnW7wd5Qo7XzLL9ZAzulFW8PCT9jTUjhM7wl57MLqnJK8BLDyYTRJk29MB17I nWNFYPo3ADQ3vhRHRvDjV7J8CUw8zLH4uJ8c982/LCY83JuocYDCyN5l92wpidsZtzzu EPUZo8KBCStLpLZJx0Zjqap1YRdLQwdGTzhB+YJQPS0st+Z2oz/C1sjMg9eH6d8EVFrv KzMcuLU7XCpjGykG6mhPCA6EFucCB3/YUw5N57vWYqJrbbQ8S1SeViRSR9GSmfQ3tvEi /xGWbP/Quwx8TdtrQ25BXC25TKAJ742ALHwyKhba/fs0eHbtrjwRVyGnj2KcpXjdjLzt IQZg== 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=TWPlA2KQi/ecdmoF3ZX5JgjBqkcCnReKLmceBe1Obp8=; fh=HpB/ghQ4qY+yqVacJINdcRXrsaCBAaUbGMhHL4opc+o=; b=S6sntiOs1vGmg68ORdBBVl1ad1/pal/PfiyHgtSM9IHQTF78PyX7AprVcg+vq/Mr/b EAxVWmi+yUgU9N9Hi16G4HZHDsZYkfUizA1Dh41U9SU1LvNgWuO3M2FJwngpKfL7kTC6 5Z1t3IA469lLOMa6e4yxkwCUlWGRFbqDVl600brr50uX7WnapNnPLYAOVsLrTDgOXobV 6MfWSHjwCVzOC6RqrfBlixFrbFrJd9SpLWmtFkUmM5/8JTkJTp6vSsseI3Fxvc88IgsD yzMEC1C/q/YaFkE15aw1VyYiVvmTElaFSqsVDzTVLv03m7EWJTvQ02h0TyClPJP59Zl5 TUyw==; 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-207970-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207970-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-7955036f556si618303385a.691.2024.06.10.02.55.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 02:55:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207970-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; 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-207970-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207970-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C1E341C21456 for ; Mon, 10 Jun 2024 09:55:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B32B77111; Mon, 10 Jun 2024 09:55:12 +0000 (UTC) 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: 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 7f1e016a9253..755fb78be76a 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