Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp2528507rwl; Fri, 6 Jan 2023 07:38:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXtS3kOYy8rLd6arNq/ewEPy9F8KsR+ZUi7Av9wCRwkGerKJ7asWgoNbRrfT0gx8ytR2uJbN X-Received: by 2002:a17:907:3e05:b0:84c:eca0:5f67 with SMTP id hp5-20020a1709073e0500b0084ceca05f67mr14432041ejc.54.1673019495890; Fri, 06 Jan 2023 07:38:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673019495; cv=none; d=google.com; s=arc-20160816; b=yoOaWXVtp+Li6FQ4JipkZ+vVsIUxetHOeG9fXIUzEaGIVj1ZZRGzIf79dSnK3nbTWE rriLbkLW34/vix9Etmi2pjVtfwCHxDD7EfNEVSQ5p2gpZurPTHX1+RkOJ/MMopDZdKqm Ah/ctXEltBtjOs50/s4sTBGol/zSNI3ytb3XVVmaOxEyPPt+BIVZ4n5DaOyxnJ3k3Mp9 ILDPQ9uOfyLuZCSn/WxH5NtNSSAivuDfy9vbRz5+7JVUNcHqYE4kS7xS9uChUYfWw2/v 5tKIe/f6qNRkklpxYxVwWgSjIlbaSXoxVma8xxGQFo4Oyxzl6XXyAECcWyPPRtv0KF45 DM9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=pOP2U/eNUNDM/BFzz41jwnvvD0q9z7KVLxoSLmeQ5Ik=; b=w+9cWJMKOJS5+Gu0Zsl0B/u7lwFqWYLQ5tp1nQ7aoqVlVcpgB9If8VPgBZvw/0Mwrb mbFfs0FS298WT1ZG6NjF0GEsdAq6BusmwoFjrqrmgy+GyXwKZ7FnpolFiMtLg3z+cUiS ydmfw5QwX6fOfVvVVCHTuuMCAIxEcCLfpsYyqmevNdOWFcy2Uh9m5jAIgM4Ay+8DzcwD 0kTNfRM6R1tmdmxbr5ImtIFfLVl2N5VNbkA0dEie1nB0dvPx7r5t9tQLpYYgL2SmGtZP K6EH+CK//0BspMs6+vVcmf/7I4gO1ysoUtuqpv3lRGcTH5sx5JL1dLsSrUKIKiVa5B5P N0vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iH0cdWoF; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xf7-20020a17090731c700b007825337afeesi1767782ejb.273.2023.01.06.07.38.01; Fri, 06 Jan 2023 07:38:15 -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=@linaro.org header.s=google header.b=iH0cdWoF; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233486AbjAFPMx (ORCPT + 55 others); Fri, 6 Jan 2023 10:12:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233697AbjAFPMt (ORCPT ); Fri, 6 Jan 2023 10:12:49 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E4D98111F for ; Fri, 6 Jan 2023 07:12:32 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id 17so1975325pll.0 for ; Fri, 06 Jan 2023 07:12:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=pOP2U/eNUNDM/BFzz41jwnvvD0q9z7KVLxoSLmeQ5Ik=; b=iH0cdWoF7hCqRCgId3gkeJ5nhxynIfZPsMSD7cym2axK6NGs4o3XgpHZjB5bWHlgqB AoNBsLh56wsCYg6PkC4kDVE/g+pjSg4Iw+mK0FMXtOl1gsPl4GvTVbS3VNycdNuFXEsn a4ag/t2nRyYJu1CAmTpOpFDGkipTZNQBIkkZLuxaR79XWunm9Cvw8rrVwYzSp6GR0DKj /LsAoDpBOGldlGPnbIe/ry6lRakkHOXvX2M1JpHsMsR0C35CWd7aLHINdBQl808CrHu9 uHxo+LDfuXIDogYoc+SbNNW8svMk8I1YLfI7Nz/PUkjiK/6uUmOXfisllo7wFfH+uXe1 QI0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pOP2U/eNUNDM/BFzz41jwnvvD0q9z7KVLxoSLmeQ5Ik=; b=DFqvKO32vq0/f4KVwlp3SZY2Y/exu5TFrGEXeaKgwHEgDTgTjMY0qzURKiGpBmxrx2 jwCoT4ZtRjdHfEViBjK2qSU5WWfoAEvrociUEe8Kz0ZSuGsV77PMfOLaOUBkr5oKAs7j Gwt52zBNLeKDlUZNqPyuzE42kqcLSo5mxNY4Y+6PwtCEfg8s/sq/QWlqoNEHcf5pYnT2 VL0DXCpAR9IELwh54zi61PrgRZWOFQb4dAwvd1BNPI+AHqf9Ga6k8im1t55/7qHOdHpG FqWAYUXk4HRnj8BCgMm93jCcQ3ZedL2aK2S44dDPKsJthzGKeSQ4wdVy/bP9BJs7Xd15 KDwQ== X-Gm-Message-State: AFqh2krYqnvKHhnWwwWgdo7l4ubPsIStDTTbJPAnhtMjpB5k1o0hFhfI ysNok8+zhsFTmXM4T8P2IeJGqyAc8bRyYJo6OZsuIQ== X-Received: by 2002:a17:90a:5d97:b0:226:c03e:23fc with SMTP id t23-20020a17090a5d9700b00226c03e23fcmr716787pji.6.1673017952133; Fri, 06 Jan 2023 07:12:32 -0800 (PST) MIME-Version: 1.0 References: <20230106142537.607399-1-irogers@google.com> <20230106142537.607399-2-irogers@google.com> In-Reply-To: <20230106142537.607399-2-irogers@google.com> From: Mike Leach Date: Fri, 6 Jan 2023 15:12:21 +0000 Message-ID: Subject: Re: [PATCH v2 2/2] perf build: Fix build error when NO_LIBBPF=1 To: Ian Rogers Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, acme@kernel.org, peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 On Fri, 6 Jan 2023 at 14:25, Ian Rogers wrote: > > 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 > --- > 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) $@ > > -- > 2.39.0.314.g84b9a713c41-goog > Tested-by: Mike Leach -- Mike Leach Principal Engineer, ARM Ltd. Manchester Design Centre. UK