From patchwork Fri Jan 6 14:25:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 40146 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp853841wrt; Fri, 6 Jan 2023 06:31:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXvZts/91J6Nuad2wNq/elpGbsfP2qaFLyY92gxCfqFrYx6velkaAo5R9ZFjg3oFGKQ26JOh X-Received: by 2002:a05:6a20:4d9e:b0:af:91a1:94a0 with SMTP id gj30-20020a056a204d9e00b000af91a194a0mr55899704pzb.32.1673015480251; Fri, 06 Jan 2023 06:31:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673015480; cv=none; d=google.com; s=arc-20160816; b=fvsSIdULuj/tuENZ+btIqtyR/3AD5h5MuLV9G7Bv/sZ1YxGvulQ2DwcexgVVOyjD7E YGc7wD9DucTn8dFAOHrNDI7zL/ZNFFeQsJY/PQpRhDLkqE5Wgr5FHYe5rHGD/AtNReeF srY6H3XZ9Uxnn7wCKfiEi0be2rN2BXTyoqS+kns/iHuIJPlzy0xbAJEx+XaZURIABI4N c/JqeACSAlkSRTIwqroBzuxi8n1R+CqhNK5v5gmTS819t2E1POK8pzlY9r7j/D7Ak66i tRNKndSSXvssHQEakbQBL+l7CPv7fG+anh7c88GIkT2kpf6iZyVTiyES6f/CFD+tWVcS 17kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:mime-version:message-id:date :dkim-signature; bh=kC1oBRAXE838EyqcFtArpyyQWxtXQZCkq8gbe8hpVg4=; b=l1Bv7iz8919nsTFKb1nm4xM7+baTThM7U+N8vH27bsjFRky9KQPvwiMPtng2QNShNl 5rfn6gkPF/Uapv0hILFpxqHv0IiY8wVpgSJ9J0Qkym3u569gaskZDB9UEekv667OXFbU 6B/SCWASf4u0f6gzriPRrlN0LJsNBK1UphbycUG7W4wquhuIRFu0B5UyvZ5shzRsywpQ Ny1E9gFIhmpFFRkdN7UANRPZSVE8JVpY/kCr0oKEv7Quf1s2L37nBoAYae8NHZahEj3o JeDGeVmNa6X+AnYd432RPhNZu6dm9L4lFWkZUCMEN81lXpfTBbXGtWvbwVKbhjN9ngxJ Ox5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=DQbR51Bi; 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 p1-20020a056a000a0100b005768619bd8esi1720856pfh.177.2023.01.06.06.31.05; Fri, 06 Jan 2023 06:31:20 -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=DQbR51Bi; 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 S234950AbjAFO0D (ORCPT + 99 others); Fri, 6 Jan 2023 09:26:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234867AbjAFOZw (ORCPT ); Fri, 6 Jan 2023 09:25:52 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3C503D5E3 for ; Fri, 6 Jan 2023 06:25:50 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-46eb8a5a713so19509547b3.1 for ; Fri, 06 Jan 2023 06:25:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=kC1oBRAXE838EyqcFtArpyyQWxtXQZCkq8gbe8hpVg4=; b=DQbR51Biav8RW8cOre9crR/Cih3nKjqFKDEeGB3Vzb6WLdeL6VgDdEY0m9IzEDCgrN cpAKhqH/MyXqYXG58AMkrIMXmqOH9z1eFuRMnCKzMvISBKAJH+V9UESk4I5TAuvNYXEk 0vHO4JLod2K+wj6DvdrtkZcdxfMvdsDMRzYMnpqZ98BOvclvUDCDI4bh72+5iOY4O+DX R1cMezttAzMW0x/PXmONyk0cmTVL7Ohf+gaRYzCZRwWjzu9ZtuYYU+cHiv/EHb/6fL7D lREvj57YppLZcivTMT7ICPNvpU2ba2yERIkGPY2Vq1wbOYbveGs+I2+CJBR7QrAOINNZ fIrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=kC1oBRAXE838EyqcFtArpyyQWxtXQZCkq8gbe8hpVg4=; b=evqYmfqLOMLky0hbp/3NR35ZNUDX+WiLrBzKUMRP3NW4ge3nE3DHIlizONcTm6G0nm bLfv2koNBHEvjiaJcHvyz0bL992WMYvkKp2e+xeNIgueaLyJc2ijOHt1ka062hJPxWyc OGMKxdDb0lT1Q+Gs3hJVPYM30HpGk71WUVq3zrWI628ZDtg+Vdoh3go8pW4UplPtNw+r OmvxCxR3xSg9Vx2P9l9ijSueF1VH5WujaZByFsppExg2EUWHjIilnkNliPTOZlZ0DJVU QE6AIzyXaK3xliaCvOy8oKdugpCLs23FpmO+ZAXQSOY5+4TKu7wT4GXKLAx7M+tQDGX5 +FDA== X-Gm-Message-State: AFqh2kpX3/VqmS7lRqmRqtDr+ATcD3PrIeI2vRxLRKrqgYdMaTCcRofM cbfljC0GilI0xdjrUJVbEa/Rtn7hMxSO X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:b317:a30:653a:18e5]) (user=irogers job=sendgmr) by 2002:a81:9281:0:b0:391:ea94:ec9b with SMTP id j123-20020a819281000000b00391ea94ec9bmr149767ywg.57.1673015149991; Fri, 06 Jan 2023 06:25:49 -0800 (PST) Date: Fri, 6 Jan 2023 06:25:36 -0800 Message-Id: <20230106142537.607399-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Subject: [PATCH v2 1/2] perf build: Properly guard libbpf includes 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?1754283880275363243?= X-GMAIL-MSGID: =?utf-8?q?1754283880275363243?= Including libbpf header files should be guarded by HAVE_LIBBPF_SUPPORT. In bpf_counter.h, move the skeleton utilities under HAVE_BPF_SKEL. Fixes: d6a735ef3277 ("perf bpf_counter: Move common functions to bpf_counter.h") Reported-by: Mike Leach Signed-off-by: Ian Rogers Tested-by: Mike Leach --- tools/perf/builtin-trace.c | 2 + tools/perf/util/bpf_counter.h | 85 ++++++++++++++++++----------------- 2 files changed, 46 insertions(+), 41 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 86e06f136f40..d21fe0f32a6d 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -16,7 +16,9 @@ #include "util/record.h" #include +#ifdef HAVE_LIBBPF_SUPPORT #include +#endif #include "util/bpf_map.h" #include "util/rlimit.h" #include "builtin.h" diff --git a/tools/perf/util/bpf_counter.h b/tools/perf/util/bpf_counter.h index 4dbf26408b69..9113c8bf5cb0 100644 --- a/tools/perf/util/bpf_counter.h +++ b/tools/perf/util/bpf_counter.h @@ -4,9 +4,12 @@ #include #include + +#ifdef HAVE_LIBBPF_SUPPORT #include #include #include +#endif struct evsel; struct target; @@ -42,6 +45,47 @@ int bpf_counter__read(struct evsel *evsel); void bpf_counter__destroy(struct evsel *evsel); int bpf_counter__install_pe(struct evsel *evsel, int cpu_map_idx, int fd); +static inline __u32 bpf_link_get_id(int fd) +{ + struct bpf_link_info link_info = { .id = 0, }; + __u32 link_info_len = sizeof(link_info); + + bpf_obj_get_info_by_fd(fd, &link_info, &link_info_len); + return link_info.id; +} + +static inline __u32 bpf_link_get_prog_id(int fd) +{ + struct bpf_link_info link_info = { .id = 0, }; + __u32 link_info_len = sizeof(link_info); + + bpf_obj_get_info_by_fd(fd, &link_info, &link_info_len); + return link_info.prog_id; +} + +static inline __u32 bpf_map_get_id(int fd) +{ + struct bpf_map_info map_info = { .id = 0, }; + __u32 map_info_len = sizeof(map_info); + + bpf_obj_get_info_by_fd(fd, &map_info, &map_info_len); + return map_info.id; +} + +/* trigger the leader program on a cpu */ +static inline int bperf_trigger_reading(int prog_fd, int cpu) +{ + DECLARE_LIBBPF_OPTS(bpf_test_run_opts, opts, + .ctx_in = NULL, + .ctx_size_in = 0, + .flags = BPF_F_TEST_RUN_ON_CPU, + .cpu = cpu, + .retval = 0, + ); + + return bpf_prog_test_run_opts(prog_fd, &opts); +} + #else /* HAVE_BPF_SKEL */ #include @@ -87,45 +131,4 @@ static inline void set_max_rlimit(void) setrlimit(RLIMIT_MEMLOCK, &rinf); } -static inline __u32 bpf_link_get_id(int fd) -{ - struct bpf_link_info link_info = { .id = 0, }; - __u32 link_info_len = sizeof(link_info); - - bpf_obj_get_info_by_fd(fd, &link_info, &link_info_len); - return link_info.id; -} - -static inline __u32 bpf_link_get_prog_id(int fd) -{ - struct bpf_link_info link_info = { .id = 0, }; - __u32 link_info_len = sizeof(link_info); - - bpf_obj_get_info_by_fd(fd, &link_info, &link_info_len); - return link_info.prog_id; -} - -static inline __u32 bpf_map_get_id(int fd) -{ - struct bpf_map_info map_info = { .id = 0, }; - __u32 map_info_len = sizeof(map_info); - - bpf_obj_get_info_by_fd(fd, &map_info, &map_info_len); - return map_info.id; -} - -/* trigger the leader program on a cpu */ -static inline int bperf_trigger_reading(int prog_fd, int cpu) -{ - DECLARE_LIBBPF_OPTS(bpf_test_run_opts, opts, - .ctx_in = NULL, - .ctx_size_in = 0, - .flags = BPF_F_TEST_RUN_ON_CPU, - .cpu = cpu, - .retval = 0, - ); - - return bpf_prog_test_run_opts(prog_fd, &opts); -} - #endif /* __PERF_BPF_COUNTER_H */ 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) $@