Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp249460lqp; Mon, 10 Jun 2024 02:55:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXEkePn0G8DOl67tXbquVO4ux56kW/uRKDwi+c3HUpjRWpGdUdaIMHhwPeNzLMgzzF2vIFNY5dn7se9vFiWHcbuJnbEmRwJpYDgUQEg6Q== X-Google-Smtp-Source: AGHT+IF4YqsWQJ4Ku+QWEmxpuvZrN1i3XEenMsX/LgCQKYEzGwZtMzYK9R87TlABzZLu44pAn72A X-Received: by 2002:a17:907:86a4:b0:a6f:1727:cf4b with SMTP id a640c23a62f3a-a6f1727d4dbmr243306966b.23.1718013352552; Mon, 10 Jun 2024 02:55:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718013352; cv=pass; d=google.com; s=arc-20160816; b=Tg03s1fa3DHLff7ApR2vGF82VIMCg4I2yqSpUUF8egbApogqt9//0wrKiApFna8W0N +RoLh4idkp6pYpXSmEQ119ozA3ikDzLrwnzyU9CR6baANnKQFzvcML8M5u0lF8nhAbpN M4P+o6+FurTzeNlQx963lt63RyVjOBYFvZOjmpghz73tdpwz8texSghD+fm90w4oIIJQ 8r4TS5A03OIza6yj524vIA+GCu72iNnH/60YFzoOJIitxnJnQmW48bAl0FKEFSPEj4kN w19/ceCcW0tXB3pNhSeqqjOaMSc0kPZWaEXxCjvtvZjLVdStYNZe2Hwr3Pe5lN++Bl1E SU0A== 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=w52uBEbdVa/LsrD549tvX5/mT7pleBPk44cFiQTW1tU=; fh=HpB/ghQ4qY+yqVacJINdcRXrsaCBAaUbGMhHL4opc+o=; b=pvS4/J68E+/GK3cqxhQKdz9k6RLiutfTpSWmZ/Td2bl6sHlxu9OSITwyjJwsxcGrNs iaMHZJbdRrYrTXusEPGKWZ9NtE+6gqxCy2C5QuQOvb+exDDXv7FlkFrSKOvq5dMu+zcf rzghdEijL+Pi8ikM7rh5467RsoU0vaG5Y7Cp2zbhqiW4iyD0ojmEvttPdcNmEnOkxxzA 90JtbYxKcY658B60Ofq55w2T0ncvrgcf0NWWz1b99CaH+0C2+IUwdSv0Spnddqmy1gS+ 8qzOU9uUttfcEU7UaQCxlsGa6gLqFqPxmQ7ZBbC/ebc9xrs12ytH3Aaqw3hsFs4+A4YP JB6Q==; 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-207971-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207971-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-a6f0de9f27asi201829866b.940.2024.06.10.02.55.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 02:55:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207971-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-207971-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207971-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 45B321F23E18 for ; Mon, 10 Jun 2024 09:55:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C3C27757EF; Mon, 10 Jun 2024 09:55:14 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E55537711F; Mon, 10 Jun 2024 09:55:12 +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=1718013314; cv=none; b=YVuwC+1OyKs5ujpEnCwdg00fZAJFMgMdl8MbqKHFGCNS5MJ/uN6tRUEIafLqljIBb1ugPpHWWlak0YwLM9xlinXo6BWeECY9xhk5ZSqmgzskaqoF1Z6OKQjs/HAne+Jf4B4cszwm0Qno+LcLgclm8xaMQ6fZOOqS30jbY86MvY8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718013314; c=relaxed/simple; bh=dNQ/CAzEs4rD+yEYfDKzk8slZO10VImKzEI6shNAwNo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=k2ysCCxC66uF9bq2WlMm6XujPIvavg3H1hRYFiIb1qvTnSMLe9bu9efos6/6sRaVOpQ8wCcxIhr+fImXzr7cwLQajdTw6xnFl7gUV2doezpzVIP5Amn1XE7+Ayjc7jhke9WA33mmv7i9bVgojLpXg4j8lkDpqgnSGg2APEI2764= 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 A1508169C; Mon, 10 Jun 2024 02:55:36 -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 C76E73F73B; Mon, 10 Jun 2024 02:55:09 -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 3/6] perf: build: Only link libebl.a for old libdw Date: Mon, 10 Jun 2024 10:54:30 +0100 Message-Id: <20240610095433.336295-4-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 Since libdw version 0.177, elfutils has merged libebl.a into libdw (see the commit "libebl: Don't install libebl.a, libebl.h and remove backends from spec." in the elfutils repository). As a result, libebl.a does not exist on Debian Bullseye and newer releases, causing static perf builds to fail on these distributions. This commit checks the libdw version and only links libebl.a if it detects that the libdw version is older than 0.177. Signed-off-by: Leo Yan --- tools/build/feature/Makefile | 12 +++++++++++- tools/perf/Makefile.config | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index 084f803093c3..b23b3e8ad5e4 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -171,7 +171,17 @@ $(OUTPUT)test-libopencsd.bin: DWARFLIBS := -ldw ifeq ($(findstring -static,${LDFLAGS}),-static) -DWARFLIBS += -lelf -lebl -lz -llzma -lbz2 + DWARFLIBS += -lelf -lz -llzma -lbz2 + + LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw) + LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION))) + LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION))) + + # Elfutils merged libebl.a into libdw.a starting from version 0.177, + # Link libebl.a only if libdw is older than this version. + ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0) + DWARFLIBS += -lebl + endif endif $(OUTPUT)test-dwarf.bin: diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 755fb78be76a..db3bc460d4c2 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -152,7 +152,17 @@ ifdef LIBDW_DIR endif DWARFLIBS := -ldw ifeq ($(findstring -static,${LDFLAGS}),-static) - DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2 + DWARFLIBS += -lelf -ldl -lz -llzma -lbz2 + + LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw) + LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION))) + LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION))) + + # Elfutils merged libebl.a into libdw.a starting from version 0.177, + # Link libebl.a only if libdw is older than this version. + ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0) + DWARFLIBS += -lebl + endif endif FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS) FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS) -- 2.34.1