From patchwork Fri Jan 6 14:25:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 40147 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp854029wrt; Fri, 6 Jan 2023 06:31:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXv57JY7fO9o4BFXvnxGJWLmgFoSrcPAQd1KAtr2qqxgk5DmGUukpAORq0DLsWcsdBmBOyet X-Received: by 2002:a17:90a:1345:b0:226:1495:3dca with SMTP id y5-20020a17090a134500b0022614953dcamr33354609pjf.45.1673015499253; Fri, 06 Jan 2023 06:31:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673015499; cv=none; d=google.com; s=arc-20160816; b=B6ZGyUDEk8h8mXDe8Z26NXJbxIs7w3o2Ps4DUPFkbNMzEUn3ldxlRrrDlLOmqy7qCq DbCO+0ivDDQCFcyPYFTvTZOIhIQNkXgrjLUTnTix89UOeAyddhj93TvzfCDWx/ZwdSGd vysIrj8hp/YKJqN1rw40i1tN8f+8QPE+HGLLPDMncKANpwgm0ciwjEXNtc4iTWfAnlx5 zOjjzNbsrR4GSjT51UrMKbeghgKDIIyqjsC7CC3RWoNFAqcfKZ+W042MDobmlIhyCLbo UN+hNlUgNfvsg8C8P82EBCh/ehdgciKAlE08uYIYxXZJbPK+3xvvTrNs5F5j6DomSWtE DTBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=1ELKsvqp/CVQlQh6V4i31lh01VunlKiC/zGB5BPQtSo=; b=v22RICVz4XlR6r/j7IFZe3naVKxLOnEvg64ASlyjH0RpX/nKAjpAThUtpMWVtjJ55d 8R6P/NjaNp2XllFPbKwXyg5YcXWZPqQvIUIQnQ0NmIFOUSHkvOxjOgAUC9d6dXryhgRk VBqpe/tv+irzYxqY17Qzphl7J5zsx0suObQq/voUhcFGgmCsDMMdgAP9z83tpDRN/eog s/7cfyuC9JaTgJk6s688dn1nmLaevS9/2Xybv0hhb6/aLOtg3GW4B1FE5xdf8Y99q5tC s/gHHVccAWpxQatplmTNANE1zXLyiBHPsRJZBdwqeAb85FXKO6MZ19b18VucFX5pPLLQ IZTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=jQ7TMfZ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g1-20020a636b01000000b0049b926fa4basi1474921pgc.345.2023.01.06.06.31.26; Fri, 06 Jan 2023 06:31:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=jQ7TMfZ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234982AbjAFO0H (ORCPT + 99 others); Fri, 6 Jan 2023 09:26:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234964AbjAFO0A (ORCPT ); Fri, 6 Jan 2023 09:26:00 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E57E76819 for ; Fri, 6 Jan 2023 06:25:58 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id r7-20020a25c107000000b006ff55ac0ee7so1965545ybf.15 for ; Fri, 06 Jan 2023 06:25:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=1ELKsvqp/CVQlQh6V4i31lh01VunlKiC/zGB5BPQtSo=; b=jQ7TMfZ6mTKGiYxELU7dPBP6UAmUuxQp12nnyfHvFquXR1IyQZKdRmpS0Mhza56NGT gQ08Oxc+jxPERM20WK5uePhumjytu8aVvUWqGlG8xyTv+AnKtbcwzRo7ATc7veAstRKp xUrc0+WMAqnkom2fm8sUbpFm7WuL507emRZnu0m8hxc0UPEyoy9zOtexa4OSlwheSULE vbMc+5aOZIHbgp+1muwMCZlRZ8gM8s8nGj7OOpcMveq5PvDGsLv3W+usV70sASV4hunN rPM3O2XE2CuozWbLAzgiNvdJb7Ksxapkyt2zhPjW1cHo8PGqXBuFvCsP9NnMwMp1qQsE pgkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1ELKsvqp/CVQlQh6V4i31lh01VunlKiC/zGB5BPQtSo=; b=boMQ0TbYKrtjaaC1Fo/B2WY16IACavDBQnsLtyoIbYqktJBxt+9CAGysLONLTrfczr gQNoKeReDx0ItuFvyB0ndiyUPcHba/tc0B8FaF8906bVKPj5qTq2z/roe689+64lJ0QM +YhV2NtpWA7rohxRFVoSJkKnQRmyoOUGVtKLV2NVZTt2n4+Ek5fPv9ZXuIuxY5xxGTbU 7jl7ntKrOp8Y2WhPNutCTMj/naBCzanFtopd06ELObYoFfx9+PiTTbBUbQD3ss2q6G40 NrShbbbLzSD2BSY4VgZWxTHSXueoNw9imCzILAziFw0T6JN5NnCY73iyDSRbXje7/upk uHBQ== X-Gm-Message-State: AFqh2krqVuHbquNCGmnTLz1ykjWOsybM2/Q2/t70bn3SznVAhsCR5ZyT rIOx1YxLlG0v8Biu6ATvIdy4mFdQsCJ/ X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:b317:a30:653a:18e5]) (user=irogers job=sendgmr) by 2002:a81:748a:0:b0:38f:abc4:fd47 with SMTP id p132-20020a81748a000000b0038fabc4fd47mr5945038ywc.170.1673015157713; Fri, 06 Jan 2023 06:25:57 -0800 (PST) Date: Fri, 6 Jan 2023 06:25:37 -0800 In-Reply-To: <20230106142537.607399-1-irogers@google.com> Message-Id: <20230106142537.607399-2-irogers@google.com> Mime-Version: 1.0 References: <20230106142537.607399-1-irogers@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Subject: [PATCH v2 2/2] perf build: Fix build error when NO_LIBBPF=1 From: Ian Rogers To: Mike Leach , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, acme@kernel.org, irogers@google.com, peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754283899939016573?= X-GMAIL-MSGID: =?utf-8?q?1754283899939016573?= The $(LIBBPF) target should only be a dependency of prepare if the static version of libbpf is needed. Add a new LIBBPF_STATIC variable that is set by Makefile.config. Use LIBBPF_STATIC to determine whether the CFLAGS, etc. need updating and for adding $(LIBBPF) as a prepare dependency. As Makefile.config isn't loaded for "clean" as a target, always set LIBBPF_OUTPUT regardless of whether it is needed for $(LIBBPF). This is done to minimize conditional logic for $(LIBBPF)-clean. This issue and an original fix was reported by Mike Leach in: https://lore.kernel.org/lkml/20230105172243.7238-1-mike.leach@linaro.org/ Fixes: 746bd29e348f ("perf build: Use tools/lib headers from install path") Reported-by: Mike Leach Signed-off-by: Ian Rogers Tested-by: Mike Leach --- tools/perf/Makefile.config | 2 ++ tools/perf/Makefile.perf | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index c2504c39bdcb..7c00ce0a7464 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -602,6 +602,8 @@ ifndef NO_LIBELF dummy := $(error Error: No libbpf devel library found, please install libbpf-devel); endif else + # Libbpf will be built as a static library from tools/lib/bpf. + LIBBPF_STATIC := 1 CFLAGS += -DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID CFLAGS += -DHAVE_LIBBPF_BPF_PROG_LOAD CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 13e7d26e77f0..4e370462e7e1 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -303,10 +303,12 @@ ifneq ($(OUTPUT),) else LIBBPF_OUTPUT = $(CURDIR)/libbpf endif -LIBBPF_DESTDIR = $(LIBBPF_OUTPUT) -LIBBPF_INCLUDE = $(LIBBPF_DESTDIR)/include -LIBBPF = $(LIBBPF_OUTPUT)/libbpf.a -CFLAGS += -I$(LIBBPF_OUTPUT)/include +ifdef LIBBPF_STATIC + LIBBPF_DESTDIR = $(LIBBPF_OUTPUT) + LIBBPF_INCLUDE = $(LIBBPF_DESTDIR)/include + LIBBPF = $(LIBBPF_OUTPUT)/libbpf.a + CFLAGS += -I$(LIBBPF_OUTPUT)/include +endif ifneq ($(OUTPUT),) LIBSUBCMD_OUTPUT = $(abspath $(OUTPUT))/libsubcmd @@ -393,10 +395,8 @@ endif export PERL_PATH PERFLIBS = $(LIBAPI) $(LIBPERF) $(LIBSUBCMD) $(LIBSYMBOL) -ifndef NO_LIBBPF - ifndef LIBBPF_DYNAMIC - PERFLIBS += $(LIBBPF) - endif +ifdef LIBBPF_STATIC + PERFLIBS += $(LIBBPF) endif # We choose to avoid "if .. else if .. else .. endif endif" @@ -756,12 +756,15 @@ prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioc $(arch_errno_name_array) \ $(sync_file_range_arrays) \ $(LIBAPI) \ - $(LIBBPF) \ $(LIBPERF) \ $(LIBSUBCMD) \ $(LIBSYMBOL) \ bpf-skel +ifdef LIBBPF_STATIC +prepare: $(LIBBPF) +endif + $(OUTPUT)%.o: %.c prepare FORCE $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@