Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp249322lqp; Mon, 10 Jun 2024 02:55:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVttLUFE+ySAWm3OTXhERbZ5jCoQihDSHLzEIKzIvzS9WcJ/fFEYFymTLCMAtJTpfX6xveoCR93UYYPURy06LQsBd9u2y9yXA48TZOFGw== X-Google-Smtp-Source: AGHT+IGECQYSyuWAZ4WxnMhecOiJzXHR8xbS+S4zp/LOuH5NwH6MtwThBXo48bFQhEAsWB4uY/e6 X-Received: by 2002:a05:622a:1108:b0:43f:fa1e:c8e5 with SMTP id d75a77b69052e-4403621ffe1mr228632911cf.8.1718013326378; Mon, 10 Jun 2024 02:55:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718013326; cv=pass; d=google.com; s=arc-20160816; b=cwdd81trWkL+Pq4kJXFJtpJusk94ST3CztU0K1V4z1IW7XwYU2OT3wXffN65Z5KQRK 5eZKXQBXhaetm86BYYT2TiNv5kPdEM5+JMIcvdprkr9WQ+vgrXhr0QisjNMKlJX5O3xu BohzxK6rsKq1E7lJB8p9noZw4u+V2//dNRPYFquQfIcEXWpigWWcflGm4k6OfAxF0TJ1 bHXTLELd5jsdst96Z1PQJdpLLLByqQMVi0ZEKYzuxa67ItvfQBzlQVB5yqqXRwYwgbJs 896LuMVJ/hCcLJsXRVCJMYlE5EMUbdEH+dBV8CCA0uuercFSaQDD7QU+SAB7zOOdCWM6 26kQ== 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=tNA5c3JsKWIVS9EoeH5wsh7p5eNsygwcUYHMz3Uu1R0=; fh=HpB/ghQ4qY+yqVacJINdcRXrsaCBAaUbGMhHL4opc+o=; b=FflSs8iOH7ceXN/XrkbKqm5hxK6WDXK/+BRR+0DUWJYWGdxlmVqPRFfvOWiNC1lcv+ 1ZoZxgEVr9vic7+16MR5KUlS0w41NK6etrvxeS3/7LUluzNt8IDjwAk5j0Ks6b6TjtGz sL/2qloAOkphpKIO5fdRdyRL5BKtbYAE+xkjeTqjW2xs7iNowDhmjO0FzXJ/ZA6Jf0gu Os1RIFjitJC04v9cF4Q+zn2xGW+nT3LpJWxjZ1/8+THcK1tcLPvmW8guPAww2sa5gDVp unL9Hg0O+cv7qWkUdwwhyoqYrEKwrraPyZRefIjvWvRdn1qYvUEqmiNzTe9e6JyHZx74 W27w==; 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-207969-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207969-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. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-441031d65dcsi12077671cf.706.2024.06.10.02.55.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 02:55:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207969-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-207969-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207969-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 1041E1C21953 for ; Mon, 10 Jun 2024 09:55:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7DA7E768E7; Mon, 10 Jun 2024 09:55:09 +0000 (UTC) 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: 8bit 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= \ FILES := $(addprefix $(OUTPUT),$(FILES)) -PKG_CONFIG ?= $(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 ?= $(CROSS_COMPILE)pkg-config +else + PKG_CONFIG ?= 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 = $(shell $(CC) -dumpmachine) + PKG_CONFIG_LIBDIR := /usr/local/$(CROSS_ARCH)/lib/pkgconfig/ + PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/share/pkgconfig/ + PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/lib/$(CROSS_ARCH)/pkgconfig/ + PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/lib/$(CROSS_ARCH)/pkgconfig/ + PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/share/pkgconfig/ + export PKG_CONFIG_LIBDIR + $(warning Missing PKG_CONFIG_LIBDIR and PKG_CONFIG_PATH for cross compilation,) + $(warning set PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR) for building with Multiarch libs.) + endif + endif +endif all: $(FILES) 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 ?= ld HOSTAR ?= ar CLANG ?= clang -PKG_CONFIG = $(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 ?= $(CROSS_COMPILE)pkg-config +else + PKG_CONFIG ?= 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 = $(shell $(CC) -dumpmachine) + PKG_CONFIG_LIBDIR := /usr/local/$(CROSS_ARCH)/lib/pkgconfig/ + PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/share/pkgconfig/ + PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/lib/$(CROSS_ARCH)/pkgconfig/ + PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/lib/$(CROSS_ARCH)/pkgconfig/ + PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/share/pkgconfig/ + export PKG_CONFIG_LIBDIR + $(warning Missing PKG_CONFIG_LIBDIR and PKG_CONFIG_PATH for cross compilation,) + $(warning set PKG_CONFIG_LIBDIR to $(PKG_CONFIG_LIBDIR) for using libs with Multiarch.) + endif + endif +endif RM = rm -f LN = ln -f -- 2.34.1