From patchwork Sat Oct 9 21:03:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12548085 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 088F3C433F5 for ; Sat, 9 Oct 2021 21:03:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0A8260FC3 for ; Sat, 9 Oct 2021 21:03:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231139AbhJIVFw (ORCPT ); Sat, 9 Oct 2021 17:05:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230342AbhJIVFu (ORCPT ); Sat, 9 Oct 2021 17:05:50 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9411C061764 for ; Sat, 9 Oct 2021 14:03:52 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id r18so41392439wrg.6 for ; Sat, 09 Oct 2021 14:03:52 -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=vxhL1cLX+WJUmiozIOS0qjqujZU09pMwQ+UT7XVfvGQ=; b=MouNxQEfindL7mty3cVeBaUdO2AJ6dMnjo7zKqt5iWpoRiHACjYdIcjSeO99POLtco k7j2GIfwQX+Bsr9I7nEmrPVFFSQcsBQrfz/8jhZ6VzJTn5npFqSwWhWcRw75hGu3NGD3 EM2siFNuduR7MOyo/UTm39CSSRKoeiM9BR1slj+4N+A5GRqcJIxrxuScemiHOjk2wS9b KU2d21rCCvfIF/SyewHaKsrnSa8wtMrf9QlDiSjQkzpZE8CX9mGnNT7dvi5dDM5Wez82 fjmITVsQx/I+Pi+jBCKw2gvJUQw08oJJUBlLEBgQBNp5w/rPLi5ciUe3lrasGhxUhu4z Vvkg== 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=vxhL1cLX+WJUmiozIOS0qjqujZU09pMwQ+UT7XVfvGQ=; b=GS4qdF5vvY7mu5hef2vcRsspbippIAHqPE4G2vHYKDh7C27mOanPgpMvEvYMzoGt2k WFNjlbENIkNkVBAtvOsL6TLXGuZ9fpUk90f0D7M9Bnvxi7+NVWw4IDLgEakfVUdbdLlp oxGxMPJU3YH0eKxskrrjlEYsFSI37NX33DpZzWkzoo4jx7gbakQnwvquVRJFdmDSapBR k8SDPSTQCX+zm0nGemQnwrDeEjkNdT76pSIXWa07tHQpJcCHiWO8gwhD+sOc1kySmUpi Lfm/Fg7rh1oh4rqE93jXqypcXpI8Bha//UEmJVjPgJEIyAKDxR9aqPbGXKfCjbc/5Xxt iamw== X-Gm-Message-State: AOAM530H/eqC91iQ/vdt4/3bOGDDxHW9NBGdUg1sPv4JccDSYyDwyebZ BsXaoP+FlEPXiC71SyElp8DX9A== X-Google-Smtp-Source: ABdhPJy+16M6bYoUpeKjkYq1a2kb32QKXs7FbbMGTfP9dvD9JA8t2jvRPs6tPW+1dLJujsEXQBlHXQ== X-Received: by 2002:a05:600c:214:: with SMTP id 20mr11762643wmi.190.1633813431377; Sat, 09 Oct 2021 14:03:51 -0700 (PDT) Received: from localhost.localdomain ([149.86.83.130]) by smtp.gmail.com with ESMTPSA id k128sm3102516wme.41.2021.10.09.14.03.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Oct 2021 14:03:51 -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 1/3] bpftool: fix install for libbpf's internal header(s) Date: Sat, 9 Oct 2021 22:03:39 +0100 Message-Id: <20211009210341.6291-2-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211009210341.6291-1-quentin@isovalent.com> References: <20211009210341.6291-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net We recently updated bpftool's Makefile to make it install the headers from libbpf, instead of pulling them directly from libbpf's directory. There is also an additional header, internal to libbpf, that needs be installed. The way that bpftool's Makefile installs that particular header is currently correct, but would break if we were to modify $(LIBBPF_INTERNAL_HDRS) to make it point to more than one header. Use a static pattern rule instead, so that the Makefile can withstand the addition of other headers to install. The objective is simply to make the Makefile more robust. It should _not_ be read as an invitation to import more internal headers from libbpf into bpftool. Fixes: f012ade10b34 ("bpftool: Install libbpf headers instead of including the dir") Reported-by: Andrii Nakryiko Signed-off-by: Quentin Monnet --- tools/bpf/bpftool/Makefile | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 9c2d13c513f0..2c510293f32b 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -14,7 +14,7 @@ else Q = @ endif -BPF_DIR = $(srctree)/tools/lib/bpf/ +BPF_DIR = $(srctree)/tools/lib/bpf ifneq ($(OUTPUT),) _OUTPUT := $(OUTPUT) @@ -25,6 +25,7 @@ BOOTSTRAP_OUTPUT := $(_OUTPUT)/bootstrap/ LIBBPF_OUTPUT := $(_OUTPUT)/libbpf/ LIBBPF_DESTDIR := $(LIBBPF_OUTPUT) LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)/include +LIBBPF_HDRS_DIR := $(LIBBPF_INCLUDE)/bpf LIBBPF = $(LIBBPF_OUTPUT)libbpf.a LIBBPF_BOOTSTRAP_OUTPUT = $(BOOTSTRAP_OUTPUT)libbpf/ @@ -32,7 +33,8 @@ LIBBPF_BOOTSTRAP = $(LIBBPF_BOOTSTRAP_OUTPUT)libbpf.a # We need to copy nlattr.h which is not otherwise exported by libbpf, but still # required by bpftool. -LIBBPF_INTERNAL_HDRS := nlattr.h +_LIBBPF_INTERNAL_HDRS := nlattr.h +LIBBPF_INTERNAL_HDRS := $(addprefix $(LIBBPF_HDRS_DIR)/,$(_LIBBPF_INTERNAL_HDRS)) ifeq ($(BPFTOOL_VERSION),) BPFTOOL_VERSION := $(shell make -rR --no-print-directory -sC ../../.. kernelversion) @@ -45,10 +47,9 @@ $(LIBBPF): FORCE | $(LIBBPF_OUTPUT) $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_OUTPUT) \ DESTDIR=$(LIBBPF_DESTDIR) prefix= $(LIBBPF) install_headers -$(LIBBPF_INCLUDE)/bpf/$(LIBBPF_INTERNAL_HDRS): \ - $(addprefix $(BPF_DIR),$(LIBBPF_INTERNAL_HDRS)) $(LIBBPF) - $(call QUIET_INSTALL, bpf/$(notdir $@)) - $(Q)install -m 644 -t $(LIBBPF_INCLUDE)/bpf/ $(BPF_DIR)$(notdir $@) +$(LIBBPF_INTERNAL_HDRS): $(LIBBPF_HDRS_DIR)/%.h: $(BPF_DIR)/%.h $(LIBBPF) + $(call QUIET_INSTALL, $@) + $(Q)install -m 644 -t $(LIBBPF_HDRS_DIR) $< $(LIBBPF_BOOTSTRAP): FORCE | $(LIBBPF_BOOTSTRAP_OUTPUT) $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_BOOTSTRAP_OUTPUT) \ @@ -150,7 +151,7 @@ BOOTSTRAP_OBJS = $(addprefix $(BOOTSTRAP_OUTPUT),main.o common.o json_writer.o g $(BOOTSTRAP_OBJS): $(LIBBPF_BOOTSTRAP) OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o -$(OBJS): $(LIBBPF) $(LIBBPF_INCLUDE)/bpf/$(LIBBPF_INTERNAL_HDRS) +$(OBJS): $(LIBBPF) $(LIBBPF_INTERNAL_HDRS) VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux) \ $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \ From patchwork Sat Oct 9 21:03:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12548087 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 B011AC433F5 for ; Sat, 9 Oct 2021 21:03:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 973C860D42 for ; Sat, 9 Oct 2021 21:03:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231167AbhJIVFy (ORCPT ); Sat, 9 Oct 2021 17:05:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230456AbhJIVFv (ORCPT ); Sat, 9 Oct 2021 17:05:51 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96687C061762 for ; Sat, 9 Oct 2021 14:03:53 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id e12so41342658wra.4 for ; Sat, 09 Oct 2021 14:03:53 -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=tIexbe7G0YKMe1CwdKXK5X9VCycFErTnEJUFWFOr7tk=; b=29JsiVqzyMgyMHqnJIHvomcrEghh6Xp0mZP92qjUUz1tBZNvdHvJ4IvK7ev0T1OdON Rqsl+BUkAok2GsYh6gxtRE3PBsAE6ACvdNZRTTNlCSjiH0NNqZqsmDrwvoSKtdGRxbm6 hbSoFC+1SM7POJMkp/CL3sVdQSUUc0c1+9Al4Hn7Xfxg4wx9U839AlQYdgg02CdzXAQy 3MCB6QtWWE1MKxPmvi2fVfE6BNuu83B4q5i5p5fUQUUKmJJOIfL4t2wCwIP0MZA7gKXj bd9BxcI+3Y7V6ArNfF8g1OOM8CzOBRwDndEUflHrExcoXLk0lgMZAn1rCjNT3GTAYadT CEVQ== 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=tIexbe7G0YKMe1CwdKXK5X9VCycFErTnEJUFWFOr7tk=; b=btshQ2ITzxiAqrqCaio2S/UAOo18HfLuh2eA3i07s0R2AGa+eOON0aEjRyatlMso9Y uIGqBmN0wvqbbCIkiLzTTuQI7114ed7Onl1MUceBroAxD2hokeFVV0C/c1q2k4JsN2Gb HWVsTVBEMaDsM5xcZoIbUWuUblMLZCBApxFhDCTlYBVZDRyrecZYyRi70kzM5VJ5+S/G vD8tKviuj8Md/iufewlVl9DOWIYuAiQiqFgYro1jPbv+s2RFWkWiYydlo+fq56g1lWWR m4I8PAWa/9/YerKGfHdSjJageU4fktGXjYwNZmt0443gFDy7VR4lI2ksZFPXP4wb5NGP s3Qw== X-Gm-Message-State: AOAM531W7WrpNY92H7Ja7KoaivB+aGfIkQj80l6kxBqtE/8TDkUl6pAK LD1XG+4HthO7wagZ+6imq1nA3A== X-Google-Smtp-Source: ABdhPJzLAeAwCpeyveL4h9rYhm3L3FXh7tJgRLbN63rKGYYBLuslUuzV8reb4oYn8Tv+4sGmY1YZEA== X-Received: by 2002:a7b:c441:: with SMTP id l1mr11373264wmi.69.1633813432190; Sat, 09 Oct 2021 14:03:52 -0700 (PDT) Received: from localhost.localdomain ([149.86.83.130]) by smtp.gmail.com with ESMTPSA id k128sm3102516wme.41.2021.10.09.14.03.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Oct 2021 14:03:51 -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 2/3] bpftool: do not FORCE-build libbpf Date: Sat, 9 Oct 2021 22:03:40 +0100 Message-Id: <20211009210341.6291-3-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211009210341.6291-1-quentin@isovalent.com> References: <20211009210341.6291-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net In bpftool's Makefile, libbpf has a FORCE dependency, to make sure we rebuild it in case its source files changed. Let's instead make the rebuild depend on the source files directly, through a call to the "$(wildcard ...)" function. This avoids descending into libbpf's directory if there is nothing to update. Do the same for the bootstrap libbpf version. This results in a slightly faster operation and less verbose output when running make a second time in bpftool's directory. Before: Auto-detecting system features: ... libbfd: [ on ] ... disassembler-four-args: [ on ] ... zlib: [ on ] ... libcap: [ on ] ... clang-bpf-co-re: [ on ] make[1]: Entering directory '/root/dev/linux/tools/lib/bpf' make[1]: Entering directory '/root/dev/linux/tools/lib/bpf' make[1]: Nothing to be done for 'install_headers'. make[1]: Leaving directory '/root/dev/linux/tools/lib/bpf' make[1]: Leaving directory '/root/dev/linux/tools/lib/bpf' After: Auto-detecting system features: ... libbfd: [ on ] ... disassembler-four-args: [ on ] ... zlib: [ on ] ... libcap: [ on ] ... clang-bpf-co-re: [ on ] Other ways to clean up the output could be to pass the "-s" option, or to redirect the output to >/dev/null, when calling make recursively to descend into libbpf's directory. However, this would suppress some useful output if something goes wrong during the build. A better alternative would be to pass "--no-print-directory" to the recursive make, but that would still leave us with some noise for "install_headers". Skipping the descent into libbpf's directory if no source file has changed works best, and seems the most logical option overall. Reported-by: Andrii Nakryiko Signed-off-by: Quentin Monnet --- tools/bpf/bpftool/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 2c510293f32b..4acec74f459b 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -43,7 +43,7 @@ endif $(LIBBPF_OUTPUT) $(BOOTSTRAP_OUTPUT) $(LIBBPF_BOOTSTRAP_OUTPUT): $(QUIET_MKDIR)mkdir -p $@ -$(LIBBPF): FORCE | $(LIBBPF_OUTPUT) +$(LIBBPF): $(wildcard $(BPF_DIR)/*.[ch] $(BPF_DIR)/Makefile) | $(LIBBPF_OUTPUT) $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_OUTPUT) \ DESTDIR=$(LIBBPF_DESTDIR) prefix= $(LIBBPF) install_headers @@ -51,7 +51,7 @@ $(LIBBPF_INTERNAL_HDRS): $(LIBBPF_HDRS_DIR)/%.h: $(BPF_DIR)/%.h $(LIBBPF) $(call QUIET_INSTALL, $@) $(Q)install -m 644 -t $(LIBBPF_HDRS_DIR) $< -$(LIBBPF_BOOTSTRAP): FORCE | $(LIBBPF_BOOTSTRAP_OUTPUT) +$(LIBBPF_BOOTSTRAP): $(wildcard $(BPF_DIR)/*.[ch] $(BPF_DIR)/Makefile) | $(LIBBPF_BOOTSTRAP_OUTPUT) $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_BOOTSTRAP_OUTPUT) \ ARCH= CC=$(HOSTCC) LD=$(HOSTLD) $@ From patchwork Sat Oct 9 21:03:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12548089 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 14F0DC433F5 for ; Sat, 9 Oct 2021 21:04:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F28FE60F9C for ; Sat, 9 Oct 2021 21:04:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230520AbhJIVF4 (ORCPT ); Sat, 9 Oct 2021 17:05:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230327AbhJIVFv (ORCPT ); Sat, 9 Oct 2021 17:05:51 -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 69E9AC061762 for ; Sat, 9 Oct 2021 14:03:54 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id r7so41304263wrc.10 for ; Sat, 09 Oct 2021 14:03:54 -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=ctY+yofXF/zlJ0MXeGIFlVWxptmFvqmULcdipUPLWuE=; b=VYOkRzyceu8W7fkPjPVmT8TrIJC4m4iBYOlyYd3MHaeF0v2tgZIgtrw89kN63OxtPF vWEp84ENlhmyGJYV5ejgNFtEKTiCG7o2/BENzj8w0YHEsVJD3fKOX6U7iHc7w5DPAH9D y10CfMK2HU/sZLs+6LtTKJeYdwizD9UsfXBvG7pJbJuaLtV2lg2fI8RvzGrXctREimlU 458XBVssAVJ04kY3O1KTaT/mCHkPdiVlcMdx8GOK+bAsWtRV5RH1QC020Xmix3R+PwMg nPpfulfQOIlxH9LJnNk64xt7g1Yx7MJdUy9BFZ3PvtINRRLk0LiN1UiNREss42F0H4cn Oixw== 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=ctY+yofXF/zlJ0MXeGIFlVWxptmFvqmULcdipUPLWuE=; b=7lFIOjdVYtX7XXpwV6HRbt9R+k5BfBllVspeQWISqwn4n4AM/7TW5hw1aGj0ZScIlg U9EOWSssq9v+FhNvqvSS/i9ZNSWLrhp/THyV5TKWsGE31ZRmXgbxJIWYgjwR8DFxxXA3 6h020OFS8mWi1oAt7qj050nSuN93WZQ9VN6W1Kk6j8ptGa7Nw/ulKuk6KYckxiVFT42t +xZoYD9VfpRum/ZhKOTgNFQHBMOYZ4jqI6f/aVAv0joT3OhrI4fGSTB7b09JMiWGZWJ2 Q64KbhxkgjOclGfxKLaAfy+O4in594Bc/t9NwH1VOEUiBfE+71lDFHA8NFC8waxZDDr8 C5cA== X-Gm-Message-State: AOAM530NA5HmJu1VlHU1UoXZZffdtmkW2C9FfExfLLjn6eExJW8k/afv xv9C6PdAPgfC5jVCXnoCgdROfA== X-Google-Smtp-Source: ABdhPJzrF5HgIrfkd8iqvhuZD9Hs0omTZKPedqCb15KPZ2mCLTW74DaZ4j1ZGTil3q7nIXXCMxKhXQ== X-Received: by 2002:a1c:7f56:: with SMTP id a83mr12241308wmd.20.1633813433041; Sat, 09 Oct 2021 14:03:53 -0700 (PDT) Received: from localhost.localdomain ([149.86.83.130]) by smtp.gmail.com with ESMTPSA id k128sm3102516wme.41.2021.10.09.14.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Oct 2021 14:03:52 -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 3/3] bpftool: turn check on zlib from a phony target into a conditional error Date: Sat, 9 Oct 2021 22:03:41 +0100 Message-Id: <20211009210341.6291-4-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211009210341.6291-1-quentin@isovalent.com> References: <20211009210341.6291-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net One of bpftool's object files depends on zlib. To make sure we do not attempt to build that object when the library is not available, commit d66fa3c70e59 ("tools: bpftool: add feature check for zlib") introduced a feature check to detect whether zlib is present. This check comes as a rule for which the target ("zdep") is a nonexistent file (phony target), which means that the Makefile always attempts to rebuild it. It is mostly harmless. However, one side effect is that, on running again once bpftool is already built, make considers that "something" (the recipe for zdep) was executed, and does not print the usual message "make: Nothing to be done for 'all'", which is a user-friendly indicator that the build went fine. Before, with some level of debugging information: $ make --debug=m [...] Reading makefiles... Auto-detecting system features: ... libbfd: [ on ] ... disassembler-four-args: [ on ] ... zlib: [ on ] ... libcap: [ on ] ... clang-bpf-co-re: [ on ] Updating makefiles.... Updating goal targets.... File 'all' does not exist. File 'zdep' does not exist. Must remake target 'zdep'. File 'all' does not exist. Must remake target 'all'. Successfully remade target file 'all'. After the patch: $ make --debug=m [...] Auto-detecting system features: ... libbfd: [ on ] ... disassembler-four-args: [ on ] ... zlib: [ on ] ... libcap: [ on ] ... clang-bpf-co-re: [ on ] Updating makefiles.... Updating goal targets.... File 'all' does not exist. Must remake target 'all'. Successfully remade target file 'all'. make: Nothing to be done for 'all'. (Note the last line, which is not part of make's debug information.) Signed-off-by: Quentin Monnet --- tools/bpf/bpftool/Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 4acec74f459b..2174e21aa57b 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -199,7 +199,10 @@ $(BOOTSTRAP_OUTPUT)disasm.o: $(srctree)/kernel/bpf/disasm.c $(OUTPUT)disasm.o: $(srctree)/kernel/bpf/disasm.c $(QUIET_CC)$(CC) $(CFLAGS) -c -MMD -o $@ $< -$(OUTPUT)feature.o: | zdep +$(OUTPUT)feature.o: +ifneq ($(feature-zlib), 1) + $(error "No zlib found") +endif $(BPFTOOL_BOOTSTRAP): $(BOOTSTRAP_OBJS) $(LIBBPF_BOOTSTRAP) $(QUIET_LINK)$(HOSTCC) $(CFLAGS) $(LDFLAGS) -o $@ $(BOOTSTRAP_OBJS) \ @@ -255,10 +258,7 @@ doc-uninstall: FORCE: -zdep: - @if [ "$(feature-zlib)" != "1" ]; then echo "No zlib found"; exit 1 ; fi - .SECONDARY: -.PHONY: all FORCE clean install-bin install uninstall zdep +.PHONY: all FORCE clean install-bin install uninstall .PHONY: doc doc-clean doc-install doc-uninstall .DEFAULT_GOAL := all