From patchwork Sun Oct 3 19:21:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12533013 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2A3AC433FE for ; Sun, 3 Oct 2021 19:22:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84244611CB for ; Sun, 3 Oct 2021 19:22:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231334AbhJCTYJ (ORCPT ); Sun, 3 Oct 2021 15:24:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231484AbhJCTYI (ORCPT ); Sun, 3 Oct 2021 15:24:08 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11FDDC061780 for ; Sun, 3 Oct 2021 12:22:21 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id s21so26298320wra.7 for ; Sun, 03 Oct 2021 12:22:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C6sdHrUdi9BDM1rYxYocEEgrTC9SSamTyBYNfJp2XuY=; b=17QgwXsEgUib0iUwtVD1HzJ5lK0MncYQOh/snOkZX1ALHJ4aHPz9eYSYjnf1swtE1U VOpnxqVo9hT9YDoOC+Dg5jX/qe2AePrbaQAngACdn4AEDEY16oAq7OGHzr+xEQlZgjHL NfyY5Z94qGnW3mF0aMrzchCtqPKseeqwWw2DI8+WH1466bqvU0w70REfVXjwSKnEcHcF XIN5oe7SLCVCFMIyaUTiphC8mg+e4rOZjCxlG//reedC6CUNMkF6saSR32K5ROzodMzB KotyzHIlV8kEtQpoH0GJT/W6IZvj8jIWHqQVBH3BaibGs7xHVO/Ic/BOHk+MfgJkyk1C 8Yow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C6sdHrUdi9BDM1rYxYocEEgrTC9SSamTyBYNfJp2XuY=; b=dfggeiiel2Mw+5lMa/X3tt1wvVd4JwIg7ACVXh755Qt8jDDGWXX+E2DRmmoKGwCBO2 3FUMu55M3UkXKxoQQfrfoEHRvcGGGCP/ypxNpunh3Z3mi6FPTk6fVXepldUaUFQzhE9B h4COydwUI7hI29T5KWFLH2XD9BuNniPM/uE8BpH3faQjhP7BA63SaglX+YRv7WXoZ018 oH2SEI+0yQv/MUAfeFM+KiVpxld9lQR75ed1g/ny63/Zyrh5qV2m+cNrYUEOszuPNH/W BE5RryzPtuqHJHSCpS5iAU4vk3eyHCgTJuYJJKV6a66WV6os7s6QgVytD7Pp1JN3lMZ7 sK/A== X-Gm-Message-State: AOAM532VgXUSdu9wVKOAG9Z99KYBr3PmoAkwPXL+0GHmfPWOI6o10JPc ObDJ6GkSciC+R7JoEzpGEsKe3w== X-Google-Smtp-Source: ABdhPJywRrUo+T1Rjsp9/FrEmgfy3oEm1JvV76AlHEcy7m+4a0GMbHZHdEBvVk7QwUFLFlnxvWch2Q== X-Received: by 2002:adf:f4ca:: with SMTP id h10mr9952771wrp.159.1633288939602; Sun, 03 Oct 2021 12:22:19 -0700 (PDT) Received: from localhost.localdomain ([149.86.88.77]) by smtp.gmail.com with ESMTPSA id d3sm14124642wrb.36.2021.10.03.12.22.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 12:22:19 -0700 (PDT) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Quentin Monnet Subject: [PATCH bpf-next v3 01/10] tools: bpftool: remove unused includes to Date: Sun, 3 Oct 2021 20:21:59 +0100 Message-Id: <20211003192208.6297-2-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211003192208.6297-1-quentin@isovalent.com> References: <20211003192208.6297-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net It seems that the header file was never necessary to compile bpftool, and it is not part of the headers exported from libbpf. Let's remove the includes from prog.c and gen.c. Fixes: d510296d331a ("bpftool: Use syscall/loader program in "prog load" and "gen skeleton" command.") Signed-off-by: Quentin Monnet --- tools/bpf/bpftool/gen.c | 1 - tools/bpf/bpftool/prog.c | 1 - 2 files changed, 2 deletions(-) diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c index cc835859465b..b2ffc18eafc1 100644 --- a/tools/bpf/bpftool/gen.c +++ b/tools/bpf/bpftool/gen.c @@ -18,7 +18,6 @@ #include #include #include -#include #include "json_writer.h" #include "main.h" diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index 9c3e343b7d87..7323dd490873 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include "cfg.h" From patchwork Sun Oct 3 19:22:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12533017 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C416C433F5 for ; Sun, 3 Oct 2021 19:22:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21A10611CB for ; Sun, 3 Oct 2021 19:22:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231609AbhJCTYN (ORCPT ); Sun, 3 Oct 2021 15:24:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231580AbhJCTYK (ORCPT ); Sun, 3 Oct 2021 15:24:10 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40F3BC061780 for ; Sun, 3 Oct 2021 12:22:22 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id k7so26221827wrd.13 for ; Sun, 03 Oct 2021 12:22:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F+eDIzEajIHNPrpBckDVUcZ6GfeTxtcft4jDlPKe6jw=; b=E0Iwd6T6L4LdUmdVFF9sCqNj9E45EUHHvXmULJyEW9pXEeslIi5ZqhHrHn0uAzaeUG fqszde80curm5O02ePqubTy9re719YzwcGij1/C3HFCtLZfKYAlHLVpSSelhaKt2KLmN 76vp0vLJ+LvMS1VBDJ8aoXn5f7q/6FJTdO4HfbBssMFv/OOEe1tXHR2NR/BuFZeX/cq9 JWWMQmkC8RbMUSv1nwURPZKeH3y8JrYdNTWRyOYn8xuo0PIEZ7QdO73LPHmX/c3wt4LZ yO9tzVd+uLJY/PynNjojW5Phuun44g/KmZzLK7HaofpSEfqlIpiPROukeufzr3zMuM8F pUPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F+eDIzEajIHNPrpBckDVUcZ6GfeTxtcft4jDlPKe6jw=; b=q6nVLRnVJ2EMV0+EhD06J+6HflTg5QDXeZtJVBT+iUWLkijunMR1x6GnyrNyzcIP+C kUrrckOQ5mHPO8LKyqCGu7U+/6+y5f6nzBMP83vJvBnCURKxENdf0LoVpXVu+yecqNRY qSWHllvODJRnAFJVkiu8I1YzrM6TVYQheuoepfW9NFk0xgbekzerQKJDIpYV78vy56Zv N9TFK6Fxh/oEbmiHHRPk9XGGjfYuH2O6mdIiGZm/bTDL3UZ1CIID8MEtPS6aBsKDMZfj 06v46EDCwYCwsAq0Dych4ua3EkDIyQa+zrVvApycRlTtogcwBI5uNJraMtMWlp8yYI0V MpAA== X-Gm-Message-State: AOAM530dplfVU04mlWHsdzEHXWigRz31tf8OxqdpMzrXb080t0QcSBB3 Rmb6YZqlpHh3A+ulARFO7DYxEw== X-Google-Smtp-Source: ABdhPJzedE5stWqeSXaLh38lK73QksnPp8gbXU6Axw8FoeshUoB2hXXqAKkKuE0yiAlxXAop+s+UMQ== X-Received: by 2002:adf:a4ca:: with SMTP id h10mr10085549wrb.28.1633288940729; Sun, 03 Oct 2021 12:22:20 -0700 (PDT) Received: from localhost.localdomain ([149.86.88.77]) by smtp.gmail.com with ESMTPSA id d3sm14124642wrb.36.2021.10.03.12.22.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 12:22:20 -0700 (PDT) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Quentin Monnet Subject: [PATCH bpf-next v3 02/10] tools: bpftool: install libbpf headers instead of including the dir Date: Sun, 3 Oct 2021 20:22:00 +0100 Message-Id: <20211003192208.6297-3-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211003192208.6297-1-quentin@isovalent.com> References: <20211003192208.6297-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Bpftool relies on libbpf, therefore it relies on a number of headers from the library and must be linked against the library. The Makefile for bpftool exposes these objects by adding tools/lib as an include directory ("-I$(srctree)/tools/lib"). This is a working solution, but this is not the cleanest one. The risk is to involuntarily include objects that are not intended to be exposed by the libbpf. The headers needed to compile bpftool should in fact be "installed" from libbpf, with its "install_headers" Makefile target. In addition, there is one header which is internal to the library and not supposed to be used by external applications, but that bpftool uses anyway. Adjust the Makefile in order to install the header files properly before compiling bpftool. Also copy the additional internal header file (nlattr.h), but call it out explicitly. Build (and install headers) in a subdirectory under bpftool/ instead of tools/lib/bpf/. When descending from a parent Makefile, this is configurable by setting the OUTPUT, LIBBPF_OUTPUT and LIBBPF_DESTDIR variables. Also adjust the Makefile for BPF selftests, so as to reuse the (host) libbpf compiled earlier and to avoid compiling a separate version of the library just for bpftool. Signed-off-by: Quentin Monnet Acked-by: Andrii Nakryiko --- tools/bpf/bpftool/Makefile | 26 +++++++++++++++----------- tools/testing/selftests/bpf/Makefile | 2 ++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 1fcf5b01a193..ef5219e0e233 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -17,16 +17,16 @@ endif BPF_DIR = $(srctree)/tools/lib/bpf/ ifneq ($(OUTPUT),) - LIBBPF_OUTPUT = $(OUTPUT)/libbpf/ - LIBBPF_PATH = $(LIBBPF_OUTPUT) - BOOTSTRAP_OUTPUT = $(OUTPUT)/bootstrap/ + _OUTPUT := $(OUTPUT) else - LIBBPF_OUTPUT = - LIBBPF_PATH = $(BPF_DIR) - BOOTSTRAP_OUTPUT = $(CURDIR)/bootstrap/ + _OUTPUT := $(CURDIR) endif +BOOTSTRAP_OUTPUT := $(_OUTPUT)/bootstrap/ +LIBBPF_OUTPUT := $(_OUTPUT)/libbpf/ +LIBBPF_DESTDIR := $(LIBBPF_OUTPUT) +LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)/include -LIBBPF = $(LIBBPF_PATH)libbpf.a +LIBBPF = $(LIBBPF_OUTPUT)libbpf.a LIBBPF_BOOTSTRAP_OUTPUT = $(BOOTSTRAP_OUTPUT)libbpf/ LIBBPF_BOOTSTRAP = $(LIBBPF_BOOTSTRAP_OUTPUT)libbpf.a @@ -37,8 +37,13 @@ endif $(LIBBPF_OUTPUT) $(BOOTSTRAP_OUTPUT) $(LIBBPF_BOOTSTRAP_OUTPUT): $(QUIET_MKDIR)mkdir -p $@ +# We need to copy nlattr.h which is not otherwise exported by libbpf, but still +# required by bpftool. $(LIBBPF): FORCE | $(LIBBPF_OUTPUT) - $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_OUTPUT) $(LIBBPF_OUTPUT)libbpf.a + $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_OUTPUT) \ + DESTDIR=$(LIBBPF_DESTDIR) prefix= $(LIBBPF) install_headers + $(call QUIET_INSTALL, bpf/nlattr.h) + $(Q)install -m 644 -t $(LIBBPF_INCLUDE)/bpf/ $(BPF_DIR)nlattr.h $(LIBBPF_BOOTSTRAP): FORCE | $(LIBBPF_BOOTSTRAP_OUTPUT) $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_BOOTSTRAP_OUTPUT) \ @@ -60,10 +65,10 @@ CFLAGS += -W -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers CFLAGS += $(filter-out -Wswitch-enum -Wnested-externs,$(EXTRA_WARNINGS)) CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ \ -I$(if $(OUTPUT),$(OUTPUT),.) \ + -I$(LIBBPF_INCLUDE) \ -I$(srctree)/kernel/bpf/ \ -I$(srctree)/tools/include \ -I$(srctree)/tools/include/uapi \ - -I$(srctree)/tools/lib \ -I$(srctree)/tools/perf CFLAGS += -DBPFTOOL_VERSION='"$(BPFTOOL_VERSION)"' ifneq ($(EXTRA_CFLAGS),) @@ -167,8 +172,7 @@ $(OUTPUT)%.bpf.o: skeleton/%.bpf.c $(OUTPUT)vmlinux.h $(LIBBPF) $(QUIET_CLANG)$(CLANG) \ -I$(if $(OUTPUT),$(OUTPUT),.) \ -I$(srctree)/tools/include/uapi/ \ - -I$(LIBBPF_PATH) \ - -I$(srctree)/tools/lib \ + -I$(LIBBPF_INCLUDE) \ -g -O2 -Wall -target bpf -c $< -o $@ && $(LLVM_STRIP) -g $@ $(OUTPUT)%.skel.h: $(OUTPUT)%.bpf.o $(BPFTOOL_BOOTSTRAP) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 326ea75ce99e..5432bfc99740 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -209,6 +209,8 @@ $(DEFAULT_BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) \ CC=$(HOSTCC) LD=$(HOSTLD) \ EXTRA_CFLAGS='-g -O0' \ OUTPUT=$(HOST_BUILD_DIR)/bpftool/ \ + LIBBPF_OUTPUT=$(HOST_BUILD_DIR)/libbpf/ \ + LIBBPF_DESTDIR=$(HOST_SCRATCH_DIR)/ \ prefix= DESTDIR=$(HOST_SCRATCH_DIR)/ install all: docs From patchwork Sun Oct 3 19:22:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12533015 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE410C433EF for ; Sun, 3 Oct 2021 19:22:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ABA7361244 for ; Sun, 3 Oct 2021 19:22:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231598AbhJCTYM (ORCPT ); Sun, 3 Oct 2021 15:24:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231510AbhJCTYL (ORCPT ); Sun, 3 Oct 2021 15:24:11 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30AEAC061781 for ; Sun, 3 Oct 2021 12:22:23 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id v17so26337925wrv.9 for ; Sun, 03 Oct 2021 12:22:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NFw6vBNrAsZQkWmoKzmF9vOaMGDod9dzq2elbrAe3vk=; b=g0vEkC6gqADSXcQR0dz8jCqMnKlihD4QEtLJwHBXYAI4t4LuXy210XlxHxsEirNUpu 8j1bP7upeF8kFDpBoCsHD/52BPCGtZeO161k8oDReSVJae7pZlzePBlpq91kM4jJEqoy 8RpYJPkPLtxis61EKJQ5abmeVlVPogY+kvoRNIZ5GYk/HlzKYHJg2p68DUEOucCI9k/E 7sEIOQSvhm1GEjPu8tKm5lweQ3y1sfQG757lMwuMPOkyVCXhrHQxxLuZInF1OkODXQ6A xYRLgPvMCnsxNnsrrIpF5C7cNHRkwD2uLWGY2ero1/bFsuDJhyBbU50YKdWVa4pNIz+V Y00A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NFw6vBNrAsZQkWmoKzmF9vOaMGDod9dzq2elbrAe3vk=; b=JKs9gW64phfxKAR+PSOId5Txn51RomIvTr/oi1lF0XICKm5Um/M7crjVG1yiTPn5VI 2qZ+0nXztcz1C3375hF0PClQr+pRfx89vdjiNlS2q6tzdhxOrzU6W8QI049ZsKBmjubO JY8vfmk0yHrmjuGKFcqH6rlgRjhNsfdk9SokedlMnAYRr7BezjoF7kF0fVZFN6pV8H1p hVJCUK7Jsp22a9m1GQ8dZGvscTAr5EdDCs9FF7LGIqvj966Y2OakoOPFpf5hUxm/Ej5B 6K/YHjqE4Qnikg7lXZg11Ol04vshBal40iLEVp3/23hZj0Z4wileF4/GcjTFX1YiFzky Ef2Q== X-Gm-Message-State: AOAM532m7rIKS+m4azOJ/BXLsyykc/tqwtzC+AjQOkkxKWEgmQxUL0li 4enrMOpnQ2bUuCG5nm1/OJe1Lw== X-Google-Smtp-Source: ABdhPJyUVlHrm48D7TTifsvdRgLC9RApZ7Pjdz2FZKutnogz7CknaWc1qf92t+ZGUBdyIswCIbV8Hw== X-Received: by 2002:adf:a154:: with SMTP id r20mr10263598wrr.326.1633288941775; Sun, 03 Oct 2021 12:22:21 -0700 (PDT) Received: from localhost.localdomain ([149.86.88.77]) by smtp.gmail.com with ESMTPSA id d3sm14124642wrb.36.2021.10.03.12.22.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 12:22:21 -0700 (PDT) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Quentin Monnet Subject: [PATCH bpf-next v3 03/10] tools: resolve_btfids: install libbpf headers when building Date: Sun, 3 Oct 2021 20:22:01 +0100 Message-Id: <20211003192208.6297-4-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211003192208.6297-1-quentin@isovalent.com> References: <20211003192208.6297-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net API headers from libbpf should not be accessed directly from the library's source directory. Instead, they should be exported with "make install_headers". Let's make sure that resolve_btfids installs the headers properly when building. When descending from a parent Makefile, the specific output directories for building the library and exporting the headers are configurable with LIBBPF_OUT and LIBBPF_DESTDIR, respectively. This is in addition to OUTPUT, on top of which those variables are constructed by default. Also adjust the Makefile for the BPF selftests in order to point to the (target) libbpf shared with other tools, instead of building a version specific to resolve_btfids. Remove libbpf's order-only dependencies on the include directories (they are created by libbpf and don't need to exist beforehand). Signed-off-by: Quentin Monnet Acked-by: Andrii Nakryiko --- tools/bpf/resolve_btfids/Makefile | 17 ++++++++++++----- tools/bpf/resolve_btfids/main.c | 4 ++-- tools/testing/selftests/bpf/Makefile | 7 +++++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile index 08b75e314ae7..4eb74c7e65c4 100644 --- a/tools/bpf/resolve_btfids/Makefile +++ b/tools/bpf/resolve_btfids/Makefile @@ -29,25 +29,31 @@ BPFOBJ := $(OUTPUT)/libbpf/libbpf.a LIBBPF_OUT := $(abspath $(dir $(BPFOBJ)))/ SUBCMDOBJ := $(OUTPUT)/libsubcmd/libsubcmd.a +LIBBPF_DESTDIR := $(LIBBPF_OUT) +LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)include + BINARY := $(OUTPUT)/resolve_btfids BINARY_IN := $(BINARY)-in.o all: $(BINARY) -$(OUTPUT) $(OUTPUT)/libbpf $(OUTPUT)/libsubcmd: +$(OUTPUT) $(OUTPUT)/libsubcmd $(LIBBPF_OUT): $(call msg,MKDIR,,$@) $(Q)mkdir -p $(@) $(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@) -$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)/libbpf - $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT) $(abspath $@) +$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) \ + | $(LIBBPF_OUT) + $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT) \ + DESTDIR=$(LIBBPF_DESTDIR) prefix= \ + $(abspath $@) install_headers CFLAGS := -g \ -I$(srctree)/tools/include \ -I$(srctree)/tools/include/uapi \ - -I$(LIBBPF_SRC) \ + -I$(LIBBPF_INCLUDE) \ -I$(SUBCMD_SRC) LIBS = -lelf -lz @@ -65,7 +71,8 @@ $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN) clean_objects := $(wildcard $(OUTPUT)/*.o \ $(OUTPUT)/.*.o.cmd \ $(OUTPUT)/.*.o.d \ - $(OUTPUT)/libbpf \ + $(LIBBPF_OUT) \ + $(LIBBPF_DESTDIR) \ $(OUTPUT)/libsubcmd \ $(OUTPUT)/resolve_btfids) diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c index de6365b53c9c..91af785e6de5 100644 --- a/tools/bpf/resolve_btfids/main.c +++ b/tools/bpf/resolve_btfids/main.c @@ -60,8 +60,8 @@ #include #include #include -#include -#include +#include +#include #include #define BTF_IDS_SECTION ".BTF_ids" diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 5432bfc99740..9c6045261806 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -122,9 +122,11 @@ BPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a ifneq ($(CROSS_COMPILE),) HOST_BUILD_DIR := $(BUILD_DIR)/host HOST_SCRATCH_DIR := $(OUTPUT)/host-tools +HOST_INCLUDE_DIR := $(HOST_SCRATCH_DIR)/include else HOST_BUILD_DIR := $(BUILD_DIR) HOST_SCRATCH_DIR := $(SCRATCH_DIR) +HOST_INCLUDE_DIR := $(INCLUDE_DIR) endif HOST_BPFOBJ := $(HOST_BUILD_DIR)/libbpf/libbpf.a RESOLVE_BTFIDS := $(HOST_BUILD_DIR)/resolve_btfids/resolve_btfids @@ -227,7 +229,7 @@ docs-clean: $(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \ ../../../include/uapi/linux/bpf.h \ - | $(INCLUDE_DIR) $(BUILD_DIR)/libbpf + | $(BUILD_DIR)/libbpf $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) OUTPUT=$(BUILD_DIR)/libbpf/ \ EXTRA_CFLAGS='-g -O0' \ DESTDIR=$(SCRATCH_DIR) prefix= all install_headers @@ -235,7 +237,7 @@ $(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \ ifneq ($(BPFOBJ),$(HOST_BPFOBJ)) $(HOST_BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \ ../../../include/uapi/linux/bpf.h \ - | $(INCLUDE_DIR) $(HOST_BUILD_DIR)/libbpf + | $(HOST_BUILD_DIR)/libbpf $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) \ EXTRA_CFLAGS='-g -O0' \ OUTPUT=$(HOST_BUILD_DIR)/libbpf/ CC=$(HOSTCC) LD=$(HOSTLD) \ @@ -260,6 +262,7 @@ $(RESOLVE_BTFIDS): $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/resolve_btfids \ $(TOOLSDIR)/lib/str_error_r.c $(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/resolve_btfids \ CC=$(HOSTCC) LD=$(HOSTLD) AR=$(HOSTAR) \ + LIBBPF_INCLUDE=$(HOST_INCLUDE_DIR) \ OUTPUT=$(HOST_BUILD_DIR)/resolve_btfids/ BPFOBJ=$(HOST_BPFOBJ) # Get Clang's default includes on this system, as opposed to those seen by From patchwork Sun Oct 3 19:22:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12533019 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 463B0C433FE for ; Sun, 3 Oct 2021 19:22:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 251FE6120F for ; Sun, 3 Oct 2021 19:22:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231631AbhJCTYT (ORCPT ); Sun, 3 Oct 2021 15:24:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231591AbhJCTYM (ORCPT ); Sun, 3 Oct 2021 15:24:12 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CFB2C061786 for ; Sun, 3 Oct 2021 12:22:24 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id k21-20020a05600c0b5500b0030d6ac87a80so735857wmr.0 for ; Sun, 03 Oct 2021 12:22:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XgUYWJZuL/HwVLt6ttv8qOWLvVmOfG/Qt/Uz50IHV30=; b=OBnuWV6Bpvbn29ACjdTx7kRLWzSefsJ+OmeF8IcplYnercHWTzkrDGxPez7fXJxpDm WuIX7UFo7z/gRpdkt6InD/HL17wrnkndmoocWIjCWc1iuTdTettzBLaPUo2Du8LxLRrW eT1XZPJoYJK4COzSRrXkC4twKNJWwwnBCYEYIXTiRapeCMGlVs241bjk/Bqw83flvb+i QuHNMIfuyXvG+8AE9U8+PYbBFKQsIxLECr2aEcyCd1Xc0fn6XU4rP8hYXWQ5FVRILfqB qWDpJslMNZdNjH5jF4gqXPrHaz4yBizP+g7OuL7ZWe0PvJaMpo+3fxmmFjDQhqaeiikw WIQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XgUYWJZuL/HwVLt6ttv8qOWLvVmOfG/Qt/Uz50IHV30=; b=gxErZ73otgyq1lNfME674dBRDKO+dOzs4dEB3DVvmWsG4hOSV/2jUyHOvRkA88sqOw 5jR76CG6UnLFcTTwo1vWbJyu4ZGI7Sva2tKYpcG1t/YSupysHp21BabiIjWl5mDR2Sfx IGLxxB7+lGpMtJZp7z//aquDHs+K+AjC/lA7KhlrXsYDjgSDC+16m8z9hhtVLt/g8HTt UPRu0n6wow5vEkIE04mOJX+m77xim8oMjD+t3v6gcro/Kskb7+Y3Mb2hTcm/2JVszEhk UAF3QUyowIjaDDvzzJ57pntoZJtQoo8ioYLSpVL46kJtXu8W9SsWJCgtr3oB6J/H32NC d2Lw== X-Gm-Message-State: AOAM531GSpf9KyexRzhgo/FVuLmp6QrwijHfKBMBmg98yAjVBwFNwNll 8BCTNyhcdFGWXinbW2kMZb68toprE6eeNHq+ X-Google-Smtp-Source: ABdhPJz4YtIVsH13i44+O1OyJSIZRf2C2PE1ZjEvQqN+iHRhouHY6B44Glk+Hx2BYFdNJRvFVGHLHw== X-Received: by 2002:a1c:1fd5:: with SMTP id f204mr4686629wmf.73.1633288942712; Sun, 03 Oct 2021 12:22:22 -0700 (PDT) Received: from localhost.localdomain ([149.86.88.77]) by smtp.gmail.com with ESMTPSA id d3sm14124642wrb.36.2021.10.03.12.22.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 12:22:22 -0700 (PDT) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Quentin Monnet Subject: [PATCH bpf-next v3 04/10] tools: runqslower: install libbpf headers when building Date: Sun, 3 Oct 2021 20:22:02 +0100 Message-Id: <20211003192208.6297-5-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211003192208.6297-1-quentin@isovalent.com> References: <20211003192208.6297-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net API headers from libbpf should not be accessed directly from the library's source directory. Instead, they should be exported with "make install_headers". Let's make sure that runqslower installs the headers properly when building. We use a libbpf_hdrs target to mark the logical dependency on libbpf's headers export for a number of object files, even though the headers should have been exported at this time (since bpftool needs them, and is required to generate the skeleton or the vmlinux.h). When descending from a parent Makefile, the specific output directories for building the library and exporting the headers are configurable with BPFOBJ_OUTPUT and BPF_DESTDIR, respectively. This is in addition to OUTPUT, on top of which those variables are constructed by default. Also adjust the Makefile for the BPF selftests. We pass a number of variables to the "make" invocation, because we want to point runqslower to the (target) libbpf shared with other tools, instead of building its own version. In addition, runqslower relies on (target) bpftool, and we also want to pass the proper variables to its Makefile so that bpftool itself reuses the same libbpf. Signed-off-by: Quentin Monnet --- tools/bpf/runqslower/Makefile | 22 +++++++++++++--------- tools/testing/selftests/bpf/Makefile | 15 +++++++++------ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/tools/bpf/runqslower/Makefile b/tools/bpf/runqslower/Makefile index 3818ec511fd2..049aef7e9a4c 100644 --- a/tools/bpf/runqslower/Makefile +++ b/tools/bpf/runqslower/Makefile @@ -9,9 +9,9 @@ BPFTOOL ?= $(DEFAULT_BPFTOOL) LIBBPF_SRC := $(abspath ../../lib/bpf) BPFOBJ_OUTPUT := $(OUTPUT)libbpf/ BPFOBJ := $(BPFOBJ_OUTPUT)libbpf.a -BPF_INCLUDE := $(BPFOBJ_OUTPUT) -INCLUDES := -I$(OUTPUT) -I$(BPF_INCLUDE) -I$(abspath ../../lib) \ - -I$(abspath ../../include/uapi) +BPF_DESTDIR := $(BPFOBJ_OUTPUT) +BPF_INCLUDE := $(BPF_DESTDIR)/include +INCLUDES := -I$(OUTPUT) -I$(BPF_INCLUDE) -I$(abspath ../../include/uapi) CFLAGS := -g -Wall # Try to detect best kernel BTF source @@ -33,7 +33,7 @@ endif .DELETE_ON_ERROR: -.PHONY: all clean runqslower +.PHONY: all clean runqslower libbpf_hdrs all: runqslower runqslower: $(OUTPUT)/runqslower @@ -46,13 +46,15 @@ clean: $(Q)$(RM) $(OUTPUT)runqslower $(Q)$(RM) -r .output +libbpf_hdrs: $(BPFOBJ) + $(OUTPUT)/runqslower: $(OUTPUT)/runqslower.o $(BPFOBJ) $(QUIET_LINK)$(CC) $(CFLAGS) $^ -lelf -lz -o $@ $(OUTPUT)/runqslower.o: runqslower.h $(OUTPUT)/runqslower.skel.h \ - $(OUTPUT)/runqslower.bpf.o + $(OUTPUT)/runqslower.bpf.o libbpf_hdrs -$(OUTPUT)/runqslower.bpf.o: $(OUTPUT)/vmlinux.h runqslower.h +$(OUTPUT)/runqslower.bpf.o: $(OUTPUT)/vmlinux.h runqslower.h libbpf_hdrs $(OUTPUT)/%.skel.h: $(OUTPUT)/%.bpf.o | $(BPFTOOL) $(QUIET_GEN)$(BPFTOOL) gen skeleton $< > $@ @@ -81,8 +83,10 @@ else endif $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(BPFOBJ_OUTPUT) - $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(BPFOBJ_OUTPUT) $@ + $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(BPFOBJ_OUTPUT) \ + DESTDIR=$(BPFOBJ_OUTPUT) prefix= $(abspath $@) install_headers -$(DEFAULT_BPFTOOL): | $(BPFTOOL_OUTPUT) +$(DEFAULT_BPFTOOL): $(BPFOBJ) | $(BPFTOOL_OUTPUT) $(Q)$(MAKE) $(submake_extras) -C ../bpftool OUTPUT=$(BPFTOOL_OUTPUT) \ - CC=$(HOSTCC) LD=$(HOSTLD) + LIBBPF_OUTPUT=$(BPFOBJ_OUTPUT) \ + LIBBPF_DESTDIR=$(BPF_DESTDIR) CC=$(HOSTCC) LD=$(HOSTLD) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 9c6045261806..ffe48b40d8fa 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -130,6 +130,7 @@ HOST_INCLUDE_DIR := $(INCLUDE_DIR) endif HOST_BPFOBJ := $(HOST_BUILD_DIR)/libbpf/libbpf.a RESOLVE_BTFIDS := $(HOST_BUILD_DIR)/resolve_btfids/resolve_btfids +RUNQSLOWER_OUTPUT := $(BUILD_DIR)/runqslower/ VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux) \ $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \ @@ -154,7 +155,7 @@ $(notdir $(TEST_GEN_PROGS) \ # sort removes libbpf duplicates when not cross-building MAKE_DIRS := $(sort $(BUILD_DIR)/libbpf $(HOST_BUILD_DIR)/libbpf \ $(HOST_BUILD_DIR)/bpftool $(HOST_BUILD_DIR)/resolve_btfids \ - $(INCLUDE_DIR)) + $(RUNQSLOWER_OUTPUT) $(INCLUDE_DIR)) $(MAKE_DIRS): $(call msg,MKDIR,,$@) $(Q)mkdir -p $@ @@ -183,11 +184,13 @@ $(OUTPUT)/test_stub.o: test_stub.c $(BPFOBJ) DEFAULT_BPFTOOL := $(HOST_SCRATCH_DIR)/sbin/bpftool -$(OUTPUT)/runqslower: $(BPFOBJ) | $(DEFAULT_BPFTOOL) - $(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/runqslower \ - OUTPUT=$(SCRATCH_DIR)/ VMLINUX_BTF=$(VMLINUX_BTF) \ - BPFOBJ=$(BPFOBJ) BPF_INCLUDE=$(INCLUDE_DIR) && \ - cp $(SCRATCH_DIR)/runqslower $@ +$(OUTPUT)/runqslower: $(BPFOBJ) | $(DEFAULT_BPFTOOL) $(RUNQSLOWER_OUTPUT) + $(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/runqslower \ + OUTPUT=$(RUNQSLOWER_OUTPUT) VMLINUX_BTF=$(VMLINUX_BTF) \ + BPFTOOL_OUTPUT=$(BUILD_DIR)/bpftool/ \ + BPFOBJ_OUTPUT=$(BUILD_DIR)/libbpf \ + BPFOBJ=$(BPFOBJ) BPF_INCLUDE=$(INCLUDE_DIR) && \ + cp $(RUNQSLOWER_OUTPUT)runqslower $@ TEST_GEN_PROGS_EXTENDED += $(DEFAULT_BPFTOOL) From patchwork Sun Oct 3 19:22:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12533021 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9513FC433EF for ; Sun, 3 Oct 2021 19:22:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BEC361359 for ; Sun, 3 Oct 2021 19:22:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231643AbhJCTYV (ORCPT ); Sun, 3 Oct 2021 15:24:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231603AbhJCTYN (ORCPT ); Sun, 3 Oct 2021 15:24:13 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58B01C0613EC for ; Sun, 3 Oct 2021 12:22:25 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id r7so10869429wrc.10 for ; Sun, 03 Oct 2021 12:22:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=evgkFwhvFSVV29jlx7/vaHeZoUosgpKpRXmwxiTaD3k=; b=iT/R2KGcGYE0s3qZZUBBk45Xl++27wr8ko/XRGVWsC15NaZnuW/qFzmqCjtWK3g9Fb iXWKQ1U+cczRcsTj3QpLjB9LugXaOG0pQTdkYpDw7WfcjHJAQPnjL60lV/RVZpgLaK9E ugzF6S48fQ9FpT9h4Hbgu+Wm9p5kA0E1eRnr2l5Sba/2aoY7Up3/SGUUkTR0+Xn/zjTw sLIQQsgqvKnsxOn/VgR/W3Se5pCgL8EO/YhcMpGuQwsP2K3oZMzyejLk7g/N2qLuBkGD PSpXucoHL+YRGmiQSsDNIxd00uPPmGD4sjdwo8oJdrYwaEbextF8INFrfvFlLMPteill 84xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=evgkFwhvFSVV29jlx7/vaHeZoUosgpKpRXmwxiTaD3k=; b=7Bi3yIgLk+jlqhDHJz4yH1CE1UVMRtjGKNn9k1KGoarpWNcDO2ikmoDo5iJDP7vwnl UW/pDrLeXOaEk4fMsDFvIvI4lT7UBETJ2fPOSeEJXH6JvsNZzwopI0VsDLHplh6g75fS xQbUUdDZ00NvOKkPVAWgCncLZAIVNHNQAfPGobIUVNvWzXljgqB1MDQ6QXkgBmDrZ3HE vnqh7bnlq4d9jDgtvAdT34dJdozBMBCwWMRTTVzDVQc3ceEGbxOJt4dbK6AwYcRieDdV L8/XzQHlLpr7HCERJETBLVLjlIpRS+683qDfXdTqnqWaa5EusGRbRIC6oDNf1PvK1Sfn 1zmQ== X-Gm-Message-State: AOAM533Sct+2jETV8sNxLZ+dUHsEeRZrteNFLGeBZWSr8kLirN9XQioZ JsRwIovbuz62zKRUjx/BCcLYug== X-Google-Smtp-Source: ABdhPJxkfHBPXFOiIPz+ZRvUBNgytyA9laAZs29RZUW+zLQ1XKNOyFVnEzzxXePI2xfYga4ImqKd2Q== X-Received: by 2002:a05:6000:1681:: with SMTP id y1mr4383947wrd.340.1633288943993; Sun, 03 Oct 2021 12:22:23 -0700 (PDT) Received: from localhost.localdomain ([149.86.88.77]) by smtp.gmail.com with ESMTPSA id d3sm14124642wrb.36.2021.10.03.12.22.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 12:22:23 -0700 (PDT) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Quentin Monnet Subject: [PATCH bpf-next v3 05/10] bpf: preload: install libbpf headers when building Date: Sun, 3 Oct 2021 20:22:03 +0100 Message-Id: <20211003192208.6297-6-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211003192208.6297-1-quentin@isovalent.com> References: <20211003192208.6297-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net API headers from libbpf should not be accessed directly from the library's source directory. Instead, they should be exported with "make install_headers". Let's make sure that bpf/preload/Makefile installs the headers properly when building. Note that we declare an additional dependency for iterators/iterators.o: having $(LIBBPF_A) as a dependency to "$(obj)/bpf_preload_umd" is not sufficient, as it makes it required only at the linking step. But we need libbpf to be compiled, and in particular its headers to be exported, before we attempt to compile iterators.o. The issue would not occur before this commit, because libbpf's headers were not exported and were always available under tools/lib/bpf. Signed-off-by: Quentin Monnet --- kernel/bpf/preload/Makefile | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/kernel/bpf/preload/Makefile b/kernel/bpf/preload/Makefile index 1951332dd15f..efccf857f7ed 100644 --- a/kernel/bpf/preload/Makefile +++ b/kernel/bpf/preload/Makefile @@ -1,21 +1,36 @@ # SPDX-License-Identifier: GPL-2.0 LIBBPF_SRCS = $(srctree)/tools/lib/bpf/ -LIBBPF_A = $(obj)/libbpf.a -LIBBPF_OUT = $(abspath $(obj)) +LIBBPF_OUT = $(abspath $(obj))/libbpf +LIBBPF_A = $(LIBBPF_OUT)/libbpf.a +LIBBPF_DESTDIR = $(LIBBPF_OUT) +LIBBPF_INCLUDE = $(LIBBPF_DESTDIR)/include # Although not in use by libbpf's Makefile, set $(O) so that the "dummy" test # in tools/scripts/Makefile.include always succeeds when building the kernel # with $(O) pointing to a relative path, as in "make O=build bindeb-pkg". -$(LIBBPF_A): - $(Q)$(MAKE) -C $(LIBBPF_SRCS) O=$(LIBBPF_OUT)/ OUTPUT=$(LIBBPF_OUT)/ $(LIBBPF_OUT)/libbpf.a +$(LIBBPF_A): | $(LIBBPF_OUT) + $(Q)$(MAKE) -C $(LIBBPF_SRCS) O=$(LIBBPF_OUT)/ OUTPUT=$(LIBBPF_OUT)/ \ + DESTDIR=$(LIBBPF_DESTDIR) prefix= \ + $(LIBBPF_OUT)/libbpf.a install_headers + +libbpf_hdrs: $(LIBBPF_A) + +.PHONY: libbpf_hdrs + +$(LIBBPF_OUT): + $(call msg,MKDIR,$@) + $(Q)mkdir -p $@ userccflags += -I $(srctree)/tools/include/ -I $(srctree)/tools/include/uapi \ - -I $(srctree)/tools/lib/ -Wno-unused-result + -I $(LIBBPF_INCLUDE) -Wno-unused-result userprogs := bpf_preload_umd clean-files := $(userprogs) bpf_helper_defs.h FEATURE-DUMP.libbpf staticobjs/ feature/ +clean-files += $(LIBBPF_OUT) $(LIBBPF_DESTDIR) + +$(obj)/iterators/iterators.o: libbpf_hdrs bpf_preload_umd-objs := iterators/iterators.o bpf_preload_umd-userldlibs := $(LIBBPF_A) -lelf -lz From patchwork Sun Oct 3 19:22:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12533023 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 721D1C4332F for ; Sun, 3 Oct 2021 19:22:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D4226124D for ; Sun, 3 Oct 2021 19:22:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231649AbhJCTYW (ORCPT ); Sun, 3 Oct 2021 15:24:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231580AbhJCTYQ (ORCPT ); Sun, 3 Oct 2021 15:24:16 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30288C061787 for ; Sun, 3 Oct 2021 12:22:26 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id t8so26437829wri.1 for ; Sun, 03 Oct 2021 12:22:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vEX+HUR72ahF32WavI8A1JXem/G4/Ffc2RuIMJIPcLY=; b=hDyAkLX0Sl1tgYsPTIN5XiOT1eh63RkG478Hmm50kyHWFNeuLkQzOAGLmt1dVaY9cq IHrqkIFJQjaDCc8KtmipXYIg5x9BRVURHO/qO0QgO43sNY1q1fzOKyBhmm04ucE59Awb dPtG+cOvbkRbqOmWjVO6V5Qi3lg1gKZwqf1Wyb9zqnbFJdNK6pFwJDfqt+0cx2QK6A+s lkh44W/+jLOxTD/vfzXHeVuENmfOP+dCpI3dGDYE4tNp4Sn/Sq0YQL3k33OOo6LelOd1 ZHYdFiPUCTn9qEDfHr6iIE0d+diGWrAun9gtVsNihU+g+tCfkbeSG4HFuXAWtgv7uyKd sxqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vEX+HUR72ahF32WavI8A1JXem/G4/Ffc2RuIMJIPcLY=; b=Y/xVUO5TCrBkHE7zw4Fc9g+F4gge/ztfF1k3NPiJdhcpVJNKmluJS0Ky3jocOv4kv6 PKepR/OBRoABUk6SThvzp8rnRwhbP+DOUfYmpAt3luVO8iqwHQiv1Q69JyEKof48IJaT YWqdkkCn0qw/lRLsJVFNyecz5FJc03fBXoz64wzWVuFI2rH6tlJ2URO8cZggwKeFYZBv Sp8AJneRb+tcjGes6noM7mTn6HkGAW7ujHl1B+0clJgpDUX4w6fjpUnyyqsYVwXnBdTO +Mcb851QxsWvBfV2m5srEbeTUF+A2r/DMqacvYku6X/hlSM4afI5fP6DKsuO+UHdJvhm W4wA== X-Gm-Message-State: AOAM533CyaG2JZP3t60MSEuTtP/wpa+aXAocXz/mqBDa27onLJnbbVKo g6hldChV3vfZvBnPHB4XbhnRYA== X-Google-Smtp-Source: ABdhPJz17Olw6AQuf7WMrMuQQ49/fd3yr76Lg7377laLO+A2sTDBxFCYUb3kca4nEav1PatsPP+YPA== X-Received: by 2002:adf:a2d8:: with SMTP id t24mr9907628wra.30.1633288944818; Sun, 03 Oct 2021 12:22:24 -0700 (PDT) Received: from localhost.localdomain ([149.86.88.77]) by smtp.gmail.com with ESMTPSA id d3sm14124642wrb.36.2021.10.03.12.22.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 12:22:24 -0700 (PDT) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Quentin Monnet Subject: [PATCH bpf-next v3 06/10] bpf: iterators: install libbpf headers when building Date: Sun, 3 Oct 2021 20:22:04 +0100 Message-Id: <20211003192208.6297-7-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211003192208.6297-1-quentin@isovalent.com> References: <20211003192208.6297-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net API headers from libbpf should not be accessed directly from the library's source directory. Instead, they should be exported with "make install_headers". Let's make sure that bpf/preload/iterators/Makefile installs the headers properly when building. Signed-off-by: Quentin Monnet --- kernel/bpf/preload/iterators/Makefile | 39 ++++++++++++++++++--------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/kernel/bpf/preload/iterators/Makefile b/kernel/bpf/preload/iterators/Makefile index 28fa8c1440f4..ec39ccc71b8e 100644 --- a/kernel/bpf/preload/iterators/Makefile +++ b/kernel/bpf/preload/iterators/Makefile @@ -1,18 +1,26 @@ # SPDX-License-Identifier: GPL-2.0 OUTPUT := .output +abs_out := $(abspath $(OUTPUT)) + CLANG ?= clang LLC ?= llc LLVM_STRIP ?= llvm-strip + +TOOLS_PATH := $(abspath ../../../../tools) +BPFTOOL_SRC := $(TOOLS_PATH)/bpf/bpftool +BPFTOOL_OUTPUT := $(abs_out)/bpftool DEFAULT_BPFTOOL := $(OUTPUT)/sbin/bpftool BPFTOOL ?= $(DEFAULT_BPFTOOL) -LIBBPF_SRC := $(abspath ../../../../tools/lib/bpf) -BPFOBJ := $(OUTPUT)/libbpf.a -BPF_INCLUDE := $(OUTPUT) -INCLUDES := -I$(OUTPUT) -I$(BPF_INCLUDE) -I$(abspath ../../../../tools/lib) \ - -I$(abspath ../../../../tools/include/uapi) + +LIBBPF_SRC := $(TOOLS_PATH)/lib/bpf +LIBBPF_OUTPUT := $(abs_out)/libbpf +LIBBPF_DESTDIR := $(LIBBPF_OUTPUT) +LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)/include +BPFOBJ := $(LIBBPF_OUTPUT)/libbpf.a + +INCLUDES := -I$(OUTPUT) -I$(LIBBPF_INCLUDE) -I$(TOOLS_PATH)/include/uapi CFLAGS := -g -Wall -abs_out := $(abspath $(OUTPUT)) ifeq ($(V),1) Q = msg = @@ -44,14 +52,19 @@ $(OUTPUT)/iterators.bpf.o: iterators.bpf.c $(BPFOBJ) | $(OUTPUT) -c $(filter %.c,$^) -o $@ && \ $(LLVM_STRIP) -g $@ -$(OUTPUT): +$(OUTPUT) $(LIBBPF_OUTPUT) $(BPFTOOL_OUTPUT): $(call msg,MKDIR,$@) - $(Q)mkdir -p $(OUTPUT) + $(Q)mkdir -p $@ -$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT) +$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) \ + | $(LIBBPF_OUTPUT) $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) \ - OUTPUT=$(abspath $(dir $@))/ $(abspath $@) + OUTPUT=$(abspath $(dir $@))/ prefix= \ + DESTDIR=$(LIBBPF_DESTDIR) $(abspath $@) install_headers -$(DEFAULT_BPFTOOL): - $(Q)$(MAKE) $(submake_extras) -C ../../../../tools/bpf/bpftool \ - prefix= OUTPUT=$(abs_out)/ DESTDIR=$(abs_out) install +$(DEFAULT_BPFTOOL): $(BPFOBJ) | $(BPFTOOL_OUTPUT) + $(Q)$(MAKE) $(submake_extras) -C $(BPFTOOL_SRC) \ + OUTPUT=$(BPFTOOL_OUTPUT)/ \ + LIBBPF_OUTPUT=$(LIBBPF_OUTPUT)/ \ + LIBBPF_DESTDIR=$(LIBBPF_DESTDIR)/ \ + prefix= DESTDIR=$(abs_out)/ install From patchwork Sun Oct 3 19:22:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12533031 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F7C5C4332F for ; Sun, 3 Oct 2021 19:22:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2536D61359 for ; Sun, 3 Oct 2021 19:22:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231641AbhJCTYZ (ORCPT ); Sun, 3 Oct 2021 15:24:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231592AbhJCTYV (ORCPT ); Sun, 3 Oct 2021 15:24:21 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1802AC06178C for ; Sun, 3 Oct 2021 12:22:27 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id s24so11641925wmh.4 for ; Sun, 03 Oct 2021 12:22:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PA0i/EWwJwh7+reEqVeD2J7wmdkqQ95NhaVeS0zBeog=; b=0R6Iuol4Fwq/n1XZasMMQyznY0SFEY8VkqquoZCK0wjsLs/mG92kd3100/N8+4TpBV WWjgsgaDwJ5uPr9Du/ouJzN1cqvSjLAHpVjRGYJtrZ4UF9yUo+hssAIOgMppxVkvhprE bcg3BhKoFWcSoy2tuI5qsa3XaILWy8KtKiiajV5cSs0R/snc7yo7EcvGzAhB0hR/K/JD obUjS5HUeaWgw+gbNTpXmTLQ5EF4/8S3dV+reTbf+OaG8vYW7kCIFI9kdvQsqHXYPoZl 36lHMBmGOHV5bYsQCZaAjziA9wB9FoT9wecDl3ZszAVKl/psxLZLpjqOKyznn6iQqf6F vWLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PA0i/EWwJwh7+reEqVeD2J7wmdkqQ95NhaVeS0zBeog=; b=fZol9JVNFJrpP1BSbNuic48QWcBEX6nbPAOpCocG/Ibh+ST99dF5ZoQs9DYRcbsWDC nJcjhZIdN/i26wcF5wIZNChL1C14j7dL+2WmaOKA6hEzOAA8arcfh3ZBgpc9atHFfLly 6g+c5AJydKm5jbwO75Fb1V2h1JveXZRWACv3YWD829xICExv2XgMxRT5t4PoAhcZfDqV KuRpFx5KbMF8rtxGDCVGomsK3lPj+1F/HezdjjXzi80XvXFU8c+rV5v+rDFCDrA3XB72 O1p58xZzMMvium6sfiBdKOZr1HRIbp1Ac85IyC5nuwe+8IDT00KnH9bUaq8XGtORJVzI Y4+A== X-Gm-Message-State: AOAM530X/DQkwBtXZxumNMNPmIZpMWirfQYIbXrHv7b3V90v3JmdAZON w65vJrBsN6EWZ4YpLbEN7PSDRw== X-Google-Smtp-Source: ABdhPJw9WVzu/MVXgYizR19j/KlOGlVbUDgPvTF07y19xxZUN4PcyRR/SxBBBJjJ3anl0lV2ACkbLg== X-Received: by 2002:a05:600c:2193:: with SMTP id e19mr15219521wme.38.1633288945690; Sun, 03 Oct 2021 12:22:25 -0700 (PDT) Received: from localhost.localdomain ([149.86.88.77]) by smtp.gmail.com with ESMTPSA id d3sm14124642wrb.36.2021.10.03.12.22.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 12:22:25 -0700 (PDT) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Quentin Monnet Subject: [PATCH bpf-next v3 07/10] samples/bpf: install libbpf headers when building Date: Sun, 3 Oct 2021 20:22:05 +0100 Message-Id: <20211003192208.6297-8-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211003192208.6297-1-quentin@isovalent.com> References: <20211003192208.6297-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net API headers from libbpf should not be accessed directly from the source directory. Instead, they should be exported with "make install_headers". Make sure that samples/bpf/Makefile installs the headers properly when building. The object compiled from and exported by libbpf are now placed into a subdirectory of sample/bpf/ instead of remaining in tools/lib/bpf/. We attempt to remove this directory on "make clean". However, the "clean" target re-enters the samples/bpf/ directory from the root of the repository ("$(MAKE) -C ../../ M=$(CURDIR) clean"), in such a way that $(srctree) and $(src) are not defined, making it impossible to use $(LIBBPF_OUTPUT) and $(LIBBPF_DESTDIR) in the recipe. So we only attempt to clean $(CURDIR)/libbpf, which is the default value. Add a dependency on libbpf's headers for the $(TRACE_HELPERS). We also change the output directory for bpftool, to place the generated objects under samples/bpf/bpftool/ instead of building in bpftool's directory directly. Doing so, we make sure bpftool reuses the libbpf library previously compiled and installed. Signed-off-by: Quentin Monnet --- samples/bpf/Makefile | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index 4dc20be5fb96..d5566c9e0c69 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -59,7 +59,11 @@ tprogs-y += xdp_redirect tprogs-y += xdp_monitor # Libbpf dependencies -LIBBPF = $(TOOLS_PATH)/lib/bpf/libbpf.a +LIBBPF_SRC = $(TOOLS_PATH)/lib/bpf +LIBBPF_OUTPUT = $(abspath $(BPF_SAMPLES_PATH))/libbpf +LIBBPF_DESTDIR = $(LIBBPF_OUTPUT) +LIBBPF_INCLUDE = $(LIBBPF_DESTDIR)/include +LIBBPF = $(LIBBPF_OUTPUT)/libbpf.a CGROUP_HELPERS := ../../tools/testing/selftests/bpf/cgroup_helpers.o TRACE_HELPERS := ../../tools/testing/selftests/bpf/trace_helpers.o @@ -198,7 +202,7 @@ TPROGS_CFLAGS += -Wstrict-prototypes TPROGS_CFLAGS += -I$(objtree)/usr/include TPROGS_CFLAGS += -I$(srctree)/tools/testing/selftests/bpf/ -TPROGS_CFLAGS += -I$(srctree)/tools/lib/ +TPROGS_CFLAGS += -I$(LIBBPF_INCLUDE) TPROGS_CFLAGS += -I$(srctree)/tools/include TPROGS_CFLAGS += -I$(srctree)/tools/perf TPROGS_CFLAGS += -DHAVE_ATTR_TEST=0 @@ -268,16 +272,28 @@ all: clean: $(MAKE) -C ../../ M=$(CURDIR) clean @find $(CURDIR) -type f -name '*~' -delete + @$(RM) -r $(CURDIR)/libbpf $(CURDIR)/bpftool -$(LIBBPF): FORCE +$(LIBBPF): FORCE | $(LIBBPF_OUTPUT) # Fix up variables inherited from Kbuild that tools/ build system won't like - $(MAKE) -C $(dir $@) RM='rm -rf' EXTRA_CFLAGS="$(TPROGS_CFLAGS)" \ - LDFLAGS=$(TPROGS_LDFLAGS) srctree=$(BPF_SAMPLES_PATH)/../../ O= + $(MAKE) -C $(LIBBPF_SRC) RM='rm -rf' EXTRA_CFLAGS="$(TPROGS_CFLAGS)" \ + LDFLAGS=$(TPROGS_LDFLAGS) srctree=$(BPF_SAMPLES_PATH)/../../ \ + O= OUTPUT=$(LIBBPF_OUTPUT)/ DESTDIR=$(LIBBPF_DESTDIR) prefix= \ + $@ install_headers BPFTOOLDIR := $(TOOLS_PATH)/bpf/bpftool -BPFTOOL := $(BPFTOOLDIR)/bpftool -$(BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) - $(MAKE) -C $(BPFTOOLDIR) srctree=$(BPF_SAMPLES_PATH)/../../ +BPFTOOL_OUTPUT := $(abspath $(BPF_SAMPLES_PATH))/bpftool +BPFTOOL := $(BPFTOOL_OUTPUT)/bpftool +$(BPFTOOL): $(LIBBPF) $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) \ + | $(BPFTOOL_OUTPUT) + $(MAKE) -C $(BPFTOOLDIR) srctree=$(BPF_SAMPLES_PATH)/../../ \ + OUTPUT=$(BPFTOOL_OUTPUT)/ \ + LIBBPF_OUTPUT=$(LIBBPF_OUTPUT)/ \ + LIBBPF_DESTDIR=$(LIBBPF_DESTDIR)/ + +$(LIBBPF_OUTPUT) $(BPFTOOL_OUTPUT): + $(call msg,MKDIR,$@) + $(Q)mkdir -p $@ $(obj)/syscall_nrs.h: $(obj)/syscall_nrs.s FORCE $(call filechk,offsets,__SYSCALL_NRS_H__) @@ -309,6 +325,11 @@ verify_target_bpf: verify_cmds $(BPF_SAMPLES_PATH)/*.c: verify_target_bpf $(LIBBPF) $(src)/*.c: verify_target_bpf $(LIBBPF) +libbpf_hdrs: $(LIBBPF) +$(obj)/$(TRACE_HELPERS): libbpf_hdrs + +.PHONY: libbpf_hdrs + $(obj)/xdp_redirect_cpu_user.o: $(obj)/xdp_redirect_cpu.skel.h $(obj)/xdp_redirect_map_multi_user.o: $(obj)/xdp_redirect_map_multi.skel.h $(obj)/xdp_redirect_map_user.o: $(obj)/xdp_redirect_map.skel.h @@ -367,7 +388,7 @@ $(obj)/%.bpf.o: $(src)/%.bpf.c $(obj)/vmlinux.h $(src)/xdp_sample.bpf.h $(src)/x $(Q)$(CLANG) -g -O2 -target bpf -D__TARGET_ARCH_$(SRCARCH) \ -Wno-compare-distinct-pointer-types -I$(srctree)/include \ -I$(srctree)/samples/bpf -I$(srctree)/tools/include \ - -I$(srctree)/tools/lib $(CLANG_SYS_INCLUDES) \ + -I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES) \ -c $(filter %.bpf.c,$^) -o $@ LINKED_SKELS := xdp_redirect_cpu.skel.h xdp_redirect_map_multi.skel.h \ @@ -404,7 +425,7 @@ $(obj)/%.o: $(src)/%.c @echo " CLANG-bpf " $@ $(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(BPF_EXTRA_CFLAGS) \ -I$(obj) -I$(srctree)/tools/testing/selftests/bpf/ \ - -I$(srctree)/tools/lib/ \ + -I$(LIBBPF_INCLUDE) \ -D__KERNEL__ -D__BPF_TRACING__ -Wno-unused-value -Wno-pointer-sign \ -D__TARGET_ARCH_$(SRCARCH) -Wno-compare-distinct-pointer-types \ -Wno-gnu-variable-sized-type-not-at-end \ From patchwork Sun Oct 3 19:22:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12533025 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A57AC433FE for ; Sun, 3 Oct 2021 19:22:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03D31611CB for ; Sun, 3 Oct 2021 19:22:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231667AbhJCTYX (ORCPT ); Sun, 3 Oct 2021 15:24:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231640AbhJCTYV (ORCPT ); Sun, 3 Oct 2021 15:24:21 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05CCCC061797 for ; Sun, 3 Oct 2021 12:22:27 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id l18-20020a05600c4f1200b002f8cf606262so17206464wmq.1 for ; Sun, 03 Oct 2021 12:22:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PNpnL8ZQsgPH+z/F1sT0I4BRmDeqtk9e85L/4fLHn7U=; b=qHk0pFUmQaua9Z6qCkrmlYzQsSD1RtUmCaQ2wYUEv0R94CAABxOlNnaM/S4Lc2Boll R0Nr9qFIQRSrU0veduqtWRy8S/SxNHEzAHMizBbuHysz2YAZZkUtAQQJ/4cCegyYwuyF iMuDuwKQm4MyR9YtHYSRAwwZftV6+jFXY9eRd/vOHHlzQc2ZBHQVLiAiEVGO3nnc3Kax rBGwy7/t+7n9IkgQ/jfJlIA+woTMnsVGc2cAO6txXdjem9/KO3En+KzMmAn/ojWTYIDa WW8z0kCHVIdT21TBsTM2XhebY23GZEitRXLJ8CmYd72rUdwbE4NnkkMCPsrgPFDdSsMP vhQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PNpnL8ZQsgPH+z/F1sT0I4BRmDeqtk9e85L/4fLHn7U=; b=hWAZ/EG4piLJeu4TjXY2a8+fKBtaXjBNA6gBHct/JpFFC2+FZJhHeKday301OhXxlf AUcb0W24gu9FjJPszVxtTeum7A5lZMzLtteyzSeB5wcxjgTZm+/1UZIMQlxg4vpR4ZAb LPA0fAZ3R6gItsliE+1qhR0ruNf7Vz0bP4n1GY2JLpJA7AI2Vk70SPyTVb8MjOOiEm+h YQnWRrynns7Xb/LExmVI6Cm+FWJXhvGRb/3t6cr6egJnKyedZCIH2vdtE0cFhMFclx73 +QV5qzsMm9YfKi2YlnrtXj5CedEJOW3tyZedtTsxCPdTAx0C+d1vljL3j1aD4vMx6NfC iSQA== X-Gm-Message-State: AOAM532cj4vZz2DG7TALuilKcSbPrxIr4Dz+S0xhTpyY53mQl+0QSA9L xI4ywXGnn6DSlJgElpaDyI7bOA== X-Google-Smtp-Source: ABdhPJzvY4ZHRSimMrDe1tSIQAGyULfdDHglxmmujPfI+cMx5/fKYCELvzLpHfL4QTRb0agzGoVtJA== X-Received: by 2002:a05:600c:210d:: with SMTP id u13mr5374985wml.146.1633288946586; Sun, 03 Oct 2021 12:22:26 -0700 (PDT) Received: from localhost.localdomain ([149.86.88.77]) by smtp.gmail.com with ESMTPSA id d3sm14124642wrb.36.2021.10.03.12.22.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 12:22:26 -0700 (PDT) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Quentin Monnet Subject: [PATCH bpf-next v3 08/10] samples/bpf: update .gitignore Date: Sun, 3 Oct 2021 20:22:06 +0100 Message-Id: <20211003192208.6297-9-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211003192208.6297-1-quentin@isovalent.com> References: <20211003192208.6297-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Update samples/bpf/.gitignore to ignore files generated when building the samples. Add: - vmlinux.h - the generated skeleton files (*.skel.h) - the samples/bpf/libbpf/ and .../bpftool/ directories, recently introduced as an output directory for building libbpf and bpftool. Signed-off-by: Quentin Monnet --- samples/bpf/.gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samples/bpf/.gitignore b/samples/bpf/.gitignore index fcba217f0ae2..09a091b8a4f3 100644 --- a/samples/bpf/.gitignore +++ b/samples/bpf/.gitignore @@ -57,3 +57,7 @@ testfile.img hbm_out.log iperf.* *.out +*.skel.h +vmlinux.h +bpftool/ +libbpf/ From patchwork Sun Oct 3 19:22:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12533027 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AEBFC433F5 for ; Sun, 3 Oct 2021 19:22:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E71A46124D for ; Sun, 3 Oct 2021 19:22:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231610AbhJCTYY (ORCPT ); Sun, 3 Oct 2021 15:24:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231641AbhJCTYV (ORCPT ); Sun, 3 Oct 2021 15:24:21 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD06BC061798 for ; Sun, 3 Oct 2021 12:22:28 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id l18-20020a05600c4f1200b002f8cf606262so17206505wmq.1 for ; Sun, 03 Oct 2021 12:22:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6qPlM6MAUchBkbCWCD/H91DQxecPf+FzubhRu6ucuSs=; b=JzLgue6VTP/8H6wnhXA7pOgI6vuWWCcHDEe2O2SAqEHI67lRMcZvxR6eCVzkUghmsD ZEbp0J97ousKvr3bdTc/f1kAjwQKmPJj1kwCrd6yrOANRhEAxh9wZXH7PwXaPrQ/jmlk jMMC5Ls3ejUqG6EyO+KkPtRigtuzqr06NvXN2uMxY7lF9EpPtDwvwjUIprbaJxENOs3B TGY6YhqjgjYS709dr2kntVswYdFKzsQS+3V08trhh13RRx90Ag3hl7icV9NRiJ8hqjIG HMhQmvBbW0BVCzIIRYGMePVBfSdrfCmOTpiNKWo1toxVlQ+ZxNRzCIfBkJ/YHWDHKCqk uQiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6qPlM6MAUchBkbCWCD/H91DQxecPf+FzubhRu6ucuSs=; b=JuJkmWwBuly5GIPnK7nRDABvjGahyRX88g8aXJ637vgGUo2hG8vEkJmXZ4kHvFMrS9 CafQ3YFnpjhWmIUw7CT3OsNv9NYW1NorhTbvcIPJ0wd9AMGPIpn7PPaIFUhreNL6gA8P /AYzZQskk/CmgZDb8AUlfQKj89OFGW2xaIrEVXPpI0yALyTXNznOgNb4/vKAn7LZeoWV nB1g0WTtNRW5nIMjTKtR0yAOU2avo/R8FQu7ytvqUIG9WqzH5BO6EWzYiBQWaQRDwwKz ELah/Lb4FBY/1xgcX0W7qxZ249yImD4ydR1yak3CJz/RHEZeH7nrZcvGiFz+TUtBK/xM EEdg== X-Gm-Message-State: AOAM533yPpn58Snx/G1IHGWvv3JCajz+rL+hXrSkjMroby/FnnyxB8fv 0dF/Dap4WYEFt14WfdzkGnfR2w== X-Google-Smtp-Source: ABdhPJx+xW/iFnEmz526jnqKOBhDKHPGkVElpt95MJBSlFuMp1iCwteFzsttq9RK88kCs20SsSj+lQ== X-Received: by 2002:a1c:7706:: with SMTP id t6mr3472713wmi.134.1633288947389; Sun, 03 Oct 2021 12:22:27 -0700 (PDT) Received: from localhost.localdomain ([149.86.88.77]) by smtp.gmail.com with ESMTPSA id d3sm14124642wrb.36.2021.10.03.12.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 12:22:27 -0700 (PDT) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Quentin Monnet Subject: [PATCH bpf-next v3 09/10] selftests/bpf: better clean up for runqslower in test_bpftool_build.sh Date: Sun, 3 Oct 2021 20:22:07 +0100 Message-Id: <20211003192208.6297-10-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211003192208.6297-1-quentin@isovalent.com> References: <20211003192208.6297-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net The script test_bpftool_build.sh attempts to build bpftool in the various supported ways, to make sure nothing breaks. One of those ways is to run "make tools/bpf" from the root of the kernel repository. This command builds bpftool, along with the other tools under tools/bpf, and runqslower in particular. After running the command and upon a successful bpftool build, the script attempts to cleanup the generated objects. However, after building with this target and in the case of runqslower, the files are not cleaned up as expected. This is because the "tools/bpf" target sets $(OUTPUT) to .../tools/bpf/runqslower/ when building the tool, causing the object files to be placed directly under the runqslower directory. But when running "cd tools/bpf; make clean", the value for $(OUTPUT) is set to ".output" (relative to the runqslower directory) by runqslower's Makefile, and this is where the Makefile looks for files to clean up. We cannot easily fix in the root Makefile (where "tools/bpf" is defined) or in tools/scripts/Makefile.include (setting $(OUTPUT)), where changing the way the output variables are passed would likely have consequences elsewhere. We could change runqslower's Makefile to build in the repository instead of in a dedicated ".output/", but doing so just to accommodate a test script doesn't sound great. Instead, let's just make sure that we clean up runqslower properly by adding the correct command to the script. This will attempt to clean runqslower twice: the first try with command "cd tools/bpf; make clean" will search for tools/bpf/runqslower/.output and fail to clean it (but will still clean the other tools, in particular bpftool), the second one (added in this commit) sets the $(OUTPUT) variable like for building with the "tool/bpf" target and should succeed. Signed-off-by: Quentin Monnet --- tools/testing/selftests/bpf/test_bpftool_build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/bpf/test_bpftool_build.sh b/tools/testing/selftests/bpf/test_bpftool_build.sh index b03a87571592..1453a53ed547 100755 --- a/tools/testing/selftests/bpf/test_bpftool_build.sh +++ b/tools/testing/selftests/bpf/test_bpftool_build.sh @@ -90,6 +90,10 @@ echo -e "... through kbuild\n" if [ -f ".config" ] ; then make_and_clean tools/bpf + ## "make tools/bpf" sets $(OUTPUT) to ...tools/bpf/runqslower for + ## runqslower, but the default (used for the "clean" target) is .output. + ## Let's make sure we clean runqslower's directory properly. + make -C tools/bpf/runqslower OUTPUT=${KDIR_ROOT_DIR}/tools/bpf/runqslower/ clean ## $OUTPUT is overwritten in kbuild Makefile, and thus cannot be passed ## down from toplevel Makefile to bpftool's Makefile. From patchwork Sun Oct 3 19:22:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12533029 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D4ECC433FE for ; Sun, 3 Oct 2021 19:22:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56E5261244 for ; Sun, 3 Oct 2021 19:22:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231684AbhJCTY1 (ORCPT ); Sun, 3 Oct 2021 15:24:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231597AbhJCTYV (ORCPT ); Sun, 3 Oct 2021 15:24:21 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3D86C0617A3 for ; Sun, 3 Oct 2021 12:22:29 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id o20so8360323wro.3 for ; Sun, 03 Oct 2021 12:22:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BDlgUQirZcOt1FAHvZmZNmvLlnlW8XrgUiUQXaZEUJM=; b=HPYUUXZZm3+OB8e2U+Z2KPrnDJKdj/A0fXhGS8POpGD8+7WDr8LtyrMuS6RzCHevkI ri92xvsl6tiEmbhQN0dgEuY16lMcI0WarLqxg2ox8SMyDGshIB7rg3+7Bf1puF5/zh6z Cf1oRmb5h9qVTm7BD02J1y2coIogbvhbj/5l7kO2JDeiZLh6VKq6Et6j0lHeqIWiNTOU p7rUmuY1APtvgYLRKM8V0lY99uog9E416RMaOyPRWVEMRGCMBsr//S9k4mk35PKXvGuh lqE9Td9LNZ6CHnl9y73BnJjG/PogKL6qc1xcOcIqdbFsFl+KWzoe1NDoY+gfYj0peFt5 /Smg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BDlgUQirZcOt1FAHvZmZNmvLlnlW8XrgUiUQXaZEUJM=; b=aTlDAZoUNBZLvNnT31k24jOIPqa8KTwhE2qrLGxBDkbDNaAmUdTJ8WdDmiYdqkas+O qvkUWE5/WeUkX+dehCiZIA8O4HSESBp+bnL9JUDiISlRB2w9hp8LoDHm6HtSuH5yj4G6 DIDeq2warMKW3T8WSqqe5/1F0LjLs32UliZ5J3lIkaefhuZ5SiHkaezz6EYP1ekSnWUt eRNeD3j4iaKt4EY8VYWbu/D2OSCrq+TfovfZASQq5f2MGaWWRCHwvuOkRhahtqC2G8gz zhOCkDoazbRGIVixZwiEHsKginNC/g2inmQpCV4Jj4ROTA5wkRq0u1/VWqh93weR3U+Y RjtA== X-Gm-Message-State: AOAM530R4l/q+Cf8WNJ+bmJOjLS4g0TV8prE4+E7gsVhboV/p0FmcNWp 2U7EtKWadYHI0W7QfH9QGpNi7A== X-Google-Smtp-Source: ABdhPJzb/u4TIo3KgzbBwfzILlctGJx1H2U1FHbUrzIhlv1OBw3jUKwvwzKt2EAwW6e0QOEXLjZfAg== X-Received: by 2002:a5d:4911:: with SMTP id x17mr6955157wrq.173.1633288948218; Sun, 03 Oct 2021 12:22:28 -0700 (PDT) Received: from localhost.localdomain ([149.86.88.77]) by smtp.gmail.com with ESMTPSA id d3sm14124642wrb.36.2021.10.03.12.22.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 12:22:27 -0700 (PDT) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Quentin Monnet Subject: [PATCH bpf-next v3 10/10] tools: bpftool: add install-bin target to install binary only Date: Sun, 3 Oct 2021 20:22:08 +0100 Message-Id: <20211003192208.6297-11-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211003192208.6297-1-quentin@isovalent.com> References: <20211003192208.6297-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net With "make install", bpftool installs its binary and its bash completion file. Usually, this is what we want. But a few components in the kernel repository (namely, BPF iterators and selftests) also install bpftool locally before using it. In such a case, bash completion is not necessary and is just a useless build artifact. Let's add an "install-bin" target to bpftool, to offer a way to install the binary only. Signed-off-by: Quentin Monnet --- kernel/bpf/preload/iterators/Makefile | 2 +- tools/bpf/bpftool/Makefile | 6 ++++-- tools/testing/selftests/bpf/Makefile | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/bpf/preload/iterators/Makefile b/kernel/bpf/preload/iterators/Makefile index ec39ccc71b8e..616a7ec0232c 100644 --- a/kernel/bpf/preload/iterators/Makefile +++ b/kernel/bpf/preload/iterators/Makefile @@ -67,4 +67,4 @@ $(DEFAULT_BPFTOOL): $(BPFOBJ) | $(BPFTOOL_OUTPUT) OUTPUT=$(BPFTOOL_OUTPUT)/ \ LIBBPF_OUTPUT=$(LIBBPF_OUTPUT)/ \ LIBBPF_DESTDIR=$(LIBBPF_DESTDIR)/ \ - prefix= DESTDIR=$(abs_out)/ install + prefix= DESTDIR=$(abs_out)/ install-bin diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index ef5219e0e233..eaa38d27194d 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -221,10 +221,12 @@ clean: $(LIBBPF)-clean $(LIBBPF_BOOTSTRAP)-clean feature-detect-clean $(Q)$(RM) -- $(OUTPUT)FEATURE-DUMP.bpftool $(Q)$(RM) -r -- $(OUTPUT)feature/ -install: $(OUTPUT)bpftool +install-bin: $(OUTPUT)bpftool $(call QUIET_INSTALL, bpftool) $(Q)$(INSTALL) -m 0755 -d $(DESTDIR)$(prefix)/sbin $(Q)$(INSTALL) $(OUTPUT)bpftool $(DESTDIR)$(prefix)/sbin/bpftool + +install: install-bin $(Q)$(INSTALL) -m 0755 -d $(DESTDIR)$(bash_compdir) $(Q)$(INSTALL) -m 0644 bash-completion/bpftool $(DESTDIR)$(bash_compdir) @@ -251,6 +253,6 @@ zdep: @if [ "$(feature-zlib)" != "1" ]; then echo "No zlib found"; exit 1 ; fi .SECONDARY: -.PHONY: all FORCE clean install uninstall zdep +.PHONY: all FORCE clean install-bin install uninstall zdep .PHONY: doc doc-clean doc-install doc-uninstall .DEFAULT_GOAL := all diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index ffe48b40d8fa..f1cb55c0c37e 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -216,7 +216,7 @@ $(DEFAULT_BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) \ OUTPUT=$(HOST_BUILD_DIR)/bpftool/ \ LIBBPF_OUTPUT=$(HOST_BUILD_DIR)/libbpf/ \ LIBBPF_DESTDIR=$(HOST_SCRATCH_DIR)/ \ - prefix= DESTDIR=$(HOST_SCRATCH_DIR)/ install + prefix= DESTDIR=$(HOST_SCRATCH_DIR)/ install-bin all: docs