From patchwork Fri Aug 30 11:00:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 1155866 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="xWDfxIOI"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46Kc3K3Q9wz9sN6 for ; Fri, 30 Aug 2019 21:01:01 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727751AbfH3LAz (ORCPT ); Fri, 30 Aug 2019 07:00:55 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36375 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727105AbfH3LAx (ORCPT ); Fri, 30 Aug 2019 07:00:53 -0400 Received: by mail-wr1-f65.google.com with SMTP id y19so6547513wrd.3 for ; Fri, 30 Aug 2019 04:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5KBK1cGSBEAbGEvyJtoTJ6fJ17kKSEVR9EUqVztgDKw=; b=xWDfxIOIYjzAbGRzXVhrfSAcx5KGF/2WAhU5H2OqBZ48pYok+kyM+p1t5Gnaek9CzD sXL5M2u80CQUo6GQqdbNNVgybgyl2KdMhvdwY+N4glLtQM2PsCvKZzGDdYvBUuR6Hfeq 7iSQcGIGm0iopgQyc0B1lyRdp41mPv0wliTg40bx8gR45HfejzIK/qxOmsp47KUsCLJz uExjGUBtpeNHZ9Jl+MTMPx/4idDSCToZS8lHY0StfvpVeHdn34J7+GJIJl0eI05m0pVA F7XrCLUH1P+budt/kfxmrGDR1fCpT6hUiEzFb1PShYlKaim0uGVgBMl//kEXOyy4JKTM Ptxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5KBK1cGSBEAbGEvyJtoTJ6fJ17kKSEVR9EUqVztgDKw=; b=Lj+1HJk9lWu96DSSxxNFaUZb8kOFyoxz2AldMdLuuMcawP6ZYcg4A4i/k5bZe8WeJx hFhKiKMiO3WUQIewqHTQds8dYtLLwaLZ86UYIXQMTFYbZ+NEJLjmLny+P32hSi2tN6ok KZL8thKn+ZoTVM2t77AXuU70p/bU7/hc04JRoj8FRqonCueZ4DeQwJkW4mLjlCWwFIi7 H2uClNSXm1+HqMqdEtVsFziLjtW6wr/Fki4JKptyuB1aUU7EaMEgJnLci5BdlC2DSq24 +2iv8Ft/PtmPmNCOh4qHbB7MI1L+LM/rAI5j1fw+kAcb2IJLhpW98B5MdDWA3T3mPU4p jArw== X-Gm-Message-State: APjAAAWeEr8583c9+WTQYdFkius1Q22QHBd1rziqaGu41NLhp9EtIFE+ baPcy9haCDBp8ywmngkt6UxFOg== X-Google-Smtp-Source: APXvYqyE5c88n/jExRazKL6s6y59bE1sgrEtKT0LVIyquRCbXmYNa+x6ZT6pa22w1q290hg4aQq0zw== X-Received: by 2002:adf:eac5:: with SMTP id o5mr18636189wrn.140.1567162851509; Fri, 30 Aug 2019 04:00:51 -0700 (PDT) Received: from cbtest32.netronome.com ([217.38.71.146]) by smtp.gmail.com with ESMTPSA id t198sm7848083wmt.39.2019.08.30.04.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2019 04:00:50 -0700 (PDT) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@netronome.com, Quentin Monnet , Lorenz Bauer , Ilya Leoshkevich , Jakub Kicinski Subject: [PATCH bpf-next v2 1/4] tools: bpftool: ignore make built-in rules for getting kernel version Date: Fri, 30 Aug 2019 12:00:37 +0100 Message-Id: <20190830110040.31257-2-quentin.monnet@netronome.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190830110040.31257-1-quentin.monnet@netronome.com> References: <20190830110040.31257-1-quentin.monnet@netronome.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Bpftool calls the toplevel Makefile to get the kernel version for the sources it is built from. But when the utility is built from the top of the kernel repository, it may dump the following error message for certain architectures (including x86): $ make tools/bpf [...] make[3]: *** [checkbin] Error 1 [...] This does not prevent bpftool compilation, but may feel disconcerting. The "checkbin" arch-dependent target is not supposed to be called for target "kernelversion", which is a simple "echo" of the version number. It turns out this is caused by the make invocation in tools/bpf/bpftool, which attempts to find implicit rules to apply. Extract from debug output: Reading makefiles... Reading makefile 'Makefile'... Reading makefile 'scripts/Kbuild.include' (search path) (no ~ expansion)... Reading makefile 'scripts/subarch.include' (search path) (no ~ expansion)... Reading makefile 'arch/x86/Makefile' (search path) (no ~ expansion)... Reading makefile 'scripts/Makefile.kcov' (search path) (no ~ expansion)... Reading makefile 'scripts/Makefile.gcc-plugins' (search path) (no ~ expansion)... Reading makefile 'scripts/Makefile.kasan' (search path) (no ~ expansion)... Reading makefile 'scripts/Makefile.extrawarn' (search path) (no ~ expansion)... Reading makefile 'scripts/Makefile.ubsan' (search path) (no ~ expansion)... Updating makefiles.... Considering target file 'scripts/Makefile.ubsan'. Looking for an implicit rule for 'scripts/Makefile.ubsan'. Trying pattern rule with stem 'Makefile.ubsan'. [...] Trying pattern rule with stem 'Makefile.ubsan'. Trying implicit prerequisite 'scripts/Makefile.ubsan.o'. Looking for a rule with intermediate file 'scripts/Makefile.ubsan.o'. Avoiding implicit rule recursion. Trying pattern rule with stem 'Makefile.ubsan'. Trying rule prerequisite 'prepare'. Trying rule prerequisite 'FORCE'. Found an implicit rule for 'scripts/Makefile.ubsan'. Considering target file 'prepare'. File 'prepare' does not exist. Considering target file 'prepare0'. File 'prepare0' does not exist. Considering target file 'archprepare'. File 'archprepare' does not exist. Considering target file 'archheaders'. File 'archheaders' does not exist. Finished prerequisites of target file 'archheaders'. Must remake target 'archheaders'. Putting child 0x55976f4f6980 (archheaders) PID 31743 on the chain. To avoid that, pass the -r and -R flags to eliminate the use of make built-in rules (and while at it, built-in variables) when running command "make kernelversion" from bpftool's Makefile. Signed-off-by: Quentin Monnet Reviewed-by: Jakub Kicinski --- tools/bpf/bpftool/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index f284c207765a..cd0fc05464e7 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -24,7 +24,7 @@ endif LIBBPF = $(BPF_PATH)libbpf.a -BPFTOOL_VERSION := $(shell make --no-print-directory -sC ../../.. kernelversion) +BPFTOOL_VERSION := $(shell make -rR --no-print-directory -sC ../../.. kernelversion) $(LIBBPF): FORCE $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) $(OUTPUT)libbpf.a From patchwork Fri Aug 30 11:00:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 1155860 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: incoming-bpf@patchwork.ozlabs.org Delivered-To: patchwork-incoming-bpf@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=bpf-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="wNpGCBFS"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46Kc3C4TBlz9sML for ; Fri, 30 Aug 2019 21:00:55 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726969AbfH3LAz (ORCPT ); Fri, 30 Aug 2019 07:00:55 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:41884 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727066AbfH3LAz (ORCPT ); Fri, 30 Aug 2019 07:00:55 -0400 Received: by mail-wr1-f67.google.com with SMTP id j16so6518313wrr.8 for ; Fri, 30 Aug 2019 04:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oHkWOIUKneM96Wyt7o1Cc9RvWciYrEm0JcdszF+su8k=; b=wNpGCBFSgHwPPyZqz/ha0sptmoyhxwuxQd6ZaM8KQiSBCv4LwgV3w17X0/E9JHeBgU CZVnD4CB3HcraJT7o8v89LEUgGUXmecbazqXsiExShF5vGp3JJ5Dsodg0pkbzqiZvtVD uMCIDBIvhoEtGSAbVpxKNtk0SLUABEcBTcjQ/jmRwo5CkPIjvQy4EvMMC46rhCDkgrFl J/j+4IeTRvYLU7Vb3bWg5Q7g1KQu+t3zBulhkma4XTPDUkpILOjgGi6rg88N3HAhqosA 7ETj6mkk42sT94iGqTTVEkoe6BIACbjaVM5iy6d2WvYtA26gIF+rCATBceEUDNTVEOvp B4CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oHkWOIUKneM96Wyt7o1Cc9RvWciYrEm0JcdszF+su8k=; b=LRz/fAsqpgLEh8NO41E8D/ZMtabGFvYWPVyirVCbump8ySevnHc8XIum/QqDqmf1pE SeYxciTGpwVTWa2/Y3NH3E7m0rXlfi/ZKobIeayjY2V26CUbzubdD1/SS/wKpL2FM90A MXsmAr0CJfBBbofPu+vyAtO5gXXeioWziqE3riE0q3Xum5fD60y7Z1X0NEGejPHKv/AC BgMSV2yIjkgtlgZG549AsXKXdbIiIt+fGPuodfA3hLO5BbW3X/sU6fvbHLNPrTVdZ9aK bFvmeoHsQ6PDzbJRcxnAJ2cxnhKdDqEUY2T9iMdxOKzGZvBNgY3r9x+UuJDA0B/QPrQ8 FH/w== X-Gm-Message-State: APjAAAUk/Yfsjp/UWWS2Dy2LoGKIZYuxbeFdPXiiQwsVLjMPwNHVZsju Moe5+v78XBgznZihi3tLQMSIaw== X-Google-Smtp-Source: APXvYqzQaKljQj1oVj+cwHiLS/PzbI7pmdiGYRHhTn1lCvZsh/587HgXPW/pDBFc9a91Kjn2uprYgA== X-Received: by 2002:a5d:4582:: with SMTP id p2mr5524924wrq.305.1567162852657; Fri, 30 Aug 2019 04:00:52 -0700 (PDT) Received: from cbtest32.netronome.com ([217.38.71.146]) by smtp.gmail.com with ESMTPSA id t198sm7848083wmt.39.2019.08.30.04.00.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2019 04:00:51 -0700 (PDT) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@netronome.com, Quentin Monnet , Lorenz Bauer , Ilya Leoshkevich , Jakub Kicinski Subject: [PATCH bpf-next v2 2/4] tools: bpftool: improve and check builds for different make invocations Date: Fri, 30 Aug 2019 12:00:38 +0100 Message-Id: <20190830110040.31257-3-quentin.monnet@netronome.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190830110040.31257-1-quentin.monnet@netronome.com> References: <20190830110040.31257-1-quentin.monnet@netronome.com> Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org There are a number of alternative "make" invocations that can be used to compile bpftool. The following invocations are expected to work: - through the kbuild system, from the top of the repository (make tools/bpf) - by telling make to change to the bpftool directory (make -C tools/bpf/bpftool) - by building the BPF tools from tools/ (cd tools && make bpf) - by running make from bpftool directory (cd tools/bpf/bpftool && make) Additionally, setting the O or OUTPUT variables should tell the build system to use a custom output path, for each of these alternatives. The following patch fixes the following invocations: $ make tools/bpf $ make tools/bpf O= $ make -C tools/bpf/bpftool OUTPUT= $ make -C tools/bpf/bpftool O= $ cd tools/ && make bpf O= $ cd tools/bpf/bpftool && make OUTPUT= $ cd tools/bpf/bpftool && make O= After this commit, the build still fails for two variants when passing the OUTPUT variable: $ make tools/bpf OUTPUT= $ cd tools/ && make bpf OUTPUT= In order to remember and check what make invocations are supposed to work, and to document the ones which do not, a new script is added to the BPF selftests. Note that some invocations require the kernel to be configured, so the script skips them if no .config file is found. v2: - In make_and_clean(), set $ERROR to 1 when "make" returns non-zero, even if the binary was produced. - Run "make clean" from the correct directory (bpf/ instead of bpftool/, when relevant). Reported-by: Lorenz Bauer Signed-off-by: Quentin Monnet Reviewed-by: Jakub Kicinski --- tools/bpf/bpftool/Makefile | 12 +- tools/testing/selftests/bpf/Makefile | 3 +- .../selftests/bpf/test_bpftool_build.sh | 143 ++++++++++++++++++ 3 files changed, 152 insertions(+), 6 deletions(-) create mode 100755 tools/testing/selftests/bpf/test_bpftool_build.sh diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index cd0fc05464e7..3fc82ff9b52c 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -17,21 +17,23 @@ endif BPF_DIR = $(srctree)/tools/lib/bpf/ ifneq ($(OUTPUT),) - BPF_PATH = $(OUTPUT) + LIBBPF_OUTPUT = $(OUTPUT)/libbpf/ + LIBBPF_PATH = $(LIBBPF_OUTPUT) else - BPF_PATH = $(BPF_DIR) + LIBBPF_PATH = $(BPF_DIR) endif -LIBBPF = $(BPF_PATH)libbpf.a +LIBBPF = $(LIBBPF_PATH)libbpf.a BPFTOOL_VERSION := $(shell make -rR --no-print-directory -sC ../../.. kernelversion) $(LIBBPF): FORCE - $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) $(OUTPUT)libbpf.a + $(if $(LIBBPF_OUTPUT),@mkdir -p $(LIBBPF_OUTPUT)) + $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_OUTPUT) $(LIBBPF_OUTPUT)libbpf.a $(LIBBPF)-clean: $(call QUIET_CLEAN, libbpf) - $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) clean >/dev/null + $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_OUTPUT) clean >/dev/null prefix ?= /usr/local bash_compdir ?= /usr/share/bash-completion/completions diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 1faad0c3c3c9..c7595b4ed55d 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -63,7 +63,8 @@ TEST_PROGS := test_kmod.sh \ test_tcp_check_syncookie.sh \ test_tc_tunnel.sh \ test_tc_edt.sh \ - test_xdping.sh + test_xdping.sh \ + test_bpftool_build.sh TEST_PROGS_EXTENDED := with_addr.sh \ with_tunnels.sh \ diff --git a/tools/testing/selftests/bpf/test_bpftool_build.sh b/tools/testing/selftests/bpf/test_bpftool_build.sh new file mode 100755 index 000000000000..4ba5a34bff56 --- /dev/null +++ b/tools/testing/selftests/bpf/test_bpftool_build.sh @@ -0,0 +1,143 @@ +#!/bin/bash +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) + +ERROR=0 +TMPDIR= + +# If one build fails, continue but return non-0 on exit. +return_value() { + if [ -d "$TMPDIR" ] ; then + rm -rf -- $TMPDIR + fi + exit $ERROR +} +trap return_value EXIT + +case $1 in + -h|--help) + echo -e "$0 [-j ]" + echo -e "\tTest the different ways of building bpftool." + echo -e "" + echo -e "\tOptions:" + echo -e "\t\t-j :\tPass -j flag to 'make'." + exit + ;; +esac + +J=$* + +# Assume script is located under tools/testing/selftests/bpf/. We want to start +# build attempts from the top of kernel repository. +SCRIPT_REL_PATH=$(realpath --relative-to=$PWD $0) +SCRIPT_REL_DIR=$(dirname $SCRIPT_REL_PATH) +KDIR_ROOT_DIR=$(realpath $PWD/$SCRIPT_REL_DIR/../../../../) +cd $KDIR_ROOT_DIR + +check() { + local dir=$(realpath $1) + + echo -n "binary: " + # Returns non-null if file is found (and "false" is run) + find $dir -type f -executable -name bpftool -print -exec false {} + && \ + ERROR=1 && printf "FAILURE: Did not find bpftool\n" +} + +make_and_clean() { + echo -e "\$PWD: $PWD" + echo -e "command: make -s $* >/dev/null" + make $J -s $* >/dev/null + if [ $? -ne 0 ] ; then + ERROR=1 + fi + if [ $# -ge 1 ] ; then + check ${@: -1} + else + check . + fi + ( + if [ $# -ge 1 ] ; then + cd ${@: -1} + fi + make -s clean + ) + echo +} + +make_with_tmpdir() { + local ARGS + + TMPDIR=$(mktemp -d) + if [ $# -ge 2 ] ; then + ARGS=${@:1:(($# - 1))} + fi + echo -e "\$PWD: $PWD" + echo -e "command: make -s $ARGS ${@: -1}=$TMPDIR/ >/dev/null" + make $J -s $ARGS ${@: -1}=$TMPDIR/ >/dev/null + if [ $? -ne 0 ] ; then + ERROR=1 + fi + check $TMPDIR + rm -rf -- $TMPDIR + echo +} + +echo "Trying to build bpftool" +echo -e "... through kbuild\n" + +if [ -f ".config" ] ; then + make_and_clean tools/bpf + + ## $OUTPUT is overwritten in kbuild Makefile, and thus cannot be passed + ## down from toplevel Makefile to bpftool's Makefile. + + # make_with_tmpdir tools/bpf OUTPUT + echo -e "skip: make tools/bpf OUTPUT= (not supported)\n" + + make_with_tmpdir tools/bpf O +else + echo -e "skip: make tools/bpf (no .config found)\n" + echo -e "skip: make tools/bpf OUTPUT= (not supported)\n" + echo -e "skip: make tools/bpf O= (no .config found)\n" +fi + +echo -e "... from kernel source tree\n" + +make_and_clean -C tools/bpf/bpftool + +make_with_tmpdir -C tools/bpf/bpftool OUTPUT + +make_with_tmpdir -C tools/bpf/bpftool O + +echo -e "... from tools/\n" +cd tools/ + +make_and_clean bpf + +## In tools/bpf/Makefile, function "descend" is called and passes $(O) and +## $(OUTPUT). We would like $(OUTPUT) to have "bpf/bpftool/" appended before +## calling bpftool's Makefile, but this is not the case as the "descend" +## function focuses on $(O)/$(subdir). However, in the present case, updating +## $(O) to have $(OUTPUT) recomputed from it in bpftool's Makefile does not +## work, because $(O) is not defined from command line and $(OUTPUT) is not +## updated in tools/scripts/Makefile.include. +## +## Workarounds would require to a) edit "descend" or use an alternative way to +## call bpftool's Makefile, b) modify the conditions to update $(OUTPUT) and +## other variables in tools/scripts/Makefile.include (at the risk of breaking +## the build of other tools), or c) append manually the "bpf/bpftool" suffix to +## $(OUTPUT) in bpf's Makefile, which may break if targets for other directories +## use "descend" in the future. + +# make_with_tmpdir bpf OUTPUT +echo -e "skip: make bpf OUTPUT= (not supported)\n" + +make_with_tmpdir bpf O + +echo -e "... from bpftool's dir\n" +cd bpf/bpftool + +make_and_clean + +make_with_tmpdir OUTPUT + +make_with_tmpdir O From patchwork Fri Aug 30 11:00:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 1155862 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="A5JOyQXU"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46Kc3G30Mfz9sMr for ; Fri, 30 Aug 2019 21:00:58 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727976AbfH3LA5 (ORCPT ); Fri, 30 Aug 2019 07:00:57 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:55833 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727639AbfH3LA4 (ORCPT ); Fri, 30 Aug 2019 07:00:56 -0400 Received: by mail-wm1-f65.google.com with SMTP id g207so2865755wmg.5 for ; Fri, 30 Aug 2019 04:00:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KL1UUCGXI64uWslAiK52D0uTNplrjm12P0PBpcTxduQ=; b=A5JOyQXUmrXOa9XrpuUkzBZHbsCqNyTN/N28VZhycpC5dwkz0wlr6BHHXNaPBrXFkt XyOxjlyA5eJ65Os4+1TTKWk4jq2K6e4R0jgTELGMZYLr7OcnNZyBNFxggRtvN4L3qw8C B0hhwFunCAxYwinBobKRXJhAxir3URiOPlC9Ij4Agijbj3c1Wd2Al2t3vMHI6a/r0p8e kEyKjQvH3RrKC/ZQoIlxyx0ie0p/EIYp3Vco6m1loNchMVeQXTKZJnchp3plHznp6C6E 9LFAyYsSh9ukkR5I+hSjJiTjxLbApCdRny9CL04hQXlgdcfkBrnlXL9eIWZHtolpH453 zV0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KL1UUCGXI64uWslAiK52D0uTNplrjm12P0PBpcTxduQ=; b=qvalOHw+PqRYWbjUSMr8GKItJNqq+TLVSBfdWwdn9JJtUaAGzJxFh5K9yfctOnMIDa z/Sp6DDPL765dkDjsvqVZfYbBygzn+ZY19mzE8+UBPykv8K81zEsUJhP+Sx6xIP/Gtu2 VBcdkC1RgJWLSkQ3GkoY8NT6twJpMBppKzdFzhPa2+OEZq5wMPC+XQrv1GC4Vl+75ER8 0i9Pg4MVdpWOLmtwmgbsPiM8KWwWNJREghQD8bVYp1VoAh7d6Lu5FnBojXOwhCfFK4Bt j+OZ7hmiolZnJECRQimfZ18smqIkSErzysuHoJLzX/a0apjJ2Oxou+gyBVpyvD+/leIv W6Lw== X-Gm-Message-State: APjAAAXQgA1+kRoQ0xnQtgHIGZSxNXtFD8i8PHjKV5p4HKvFHmajnQZt FaOhqqSPS9MM84b1ecEU8qp+ww== X-Google-Smtp-Source: APXvYqybUDqMj3+qDn7pN1ui2OC5ROaGKJF4ajASppOEZEpghSkKJXV4Lm7d5GrhOc6jiRK2Qd9JYg== X-Received: by 2002:a7b:c758:: with SMTP id w24mr7177541wmk.143.1567162854234; Fri, 30 Aug 2019 04:00:54 -0700 (PDT) Received: from cbtest32.netronome.com ([217.38.71.146]) by smtp.gmail.com with ESMTPSA id t198sm7848083wmt.39.2019.08.30.04.00.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2019 04:00:53 -0700 (PDT) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@netronome.com, Quentin Monnet , Lorenz Bauer , Ilya Leoshkevich , Jakub Kicinski Subject: [PATCH bpf-next v2 3/4] tools: bpf: account for generated feature/ and libbpf/ directories Date: Fri, 30 Aug 2019 12:00:39 +0100 Message-Id: <20190830110040.31257-4-quentin.monnet@netronome.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190830110040.31257-1-quentin.monnet@netronome.com> References: <20190830110040.31257-1-quentin.monnet@netronome.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When building "tools/bpf" from the top of the Linux repository, the build system passes a value for the $(OUTPUT) Makefile variable to tools/bpf/Makefile and tools/bpf/bpftool/Makefile, which results in generating "libbpf/" (for bpftool) and "feature/" (bpf and bpftool) directories inside the tree. This commit adds such directories to the relevant .gitignore files, and edits the Makefiles to ensure they are removed on "make clean". The use of "rm" is also made consistent throughout those Makefiles (relies on the $(RM) variable, use "--" to prevent interpreting $(OUTPUT)/$(DESTDIR) as options. v2: - New patch. Signed-off-by: Quentin Monnet --- tools/bpf/.gitignore | 1 + tools/bpf/Makefile | 5 +++-- tools/bpf/bpftool/.gitignore | 2 ++ tools/bpf/bpftool/Makefile | 10 ++++++---- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tools/bpf/.gitignore b/tools/bpf/.gitignore index dfe2bd5a4b95..59024197e71d 100644 --- a/tools/bpf/.gitignore +++ b/tools/bpf/.gitignore @@ -1,4 +1,5 @@ FEATURE-DUMP.bpf +feature bpf_asm bpf_dbg bpf_exp.yacc.* diff --git a/tools/bpf/Makefile b/tools/bpf/Makefile index 53b60ad452f5..fbf5e4a0cb9c 100644 --- a/tools/bpf/Makefile +++ b/tools/bpf/Makefile @@ -81,10 +81,11 @@ $(OUTPUT)bpf_exp.lex.o: $(OUTPUT)bpf_exp.lex.c clean: bpftool_clean $(call QUIET_CLEAN, bpf-progs) - $(Q)rm -rf $(OUTPUT)*.o $(OUTPUT)bpf_jit_disasm $(OUTPUT)bpf_dbg \ + $(Q)$(RM) -r -- $(OUTPUT)*.o $(OUTPUT)bpf_jit_disasm $(OUTPUT)bpf_dbg \ $(OUTPUT)bpf_asm $(OUTPUT)bpf_exp.yacc.* $(OUTPUT)bpf_exp.lex.* $(call QUIET_CLEAN, core-gen) - $(Q)rm -f $(OUTPUT)FEATURE-DUMP.bpf + $(Q)$(RM) -- $(OUTPUT)FEATURE-DUMP.bpf + $(Q)$(RM) -r -- $(OUTPUT)feature install: $(PROGS) bpftool_install $(call QUIET_INSTALL, bpf_jit_disasm) diff --git a/tools/bpf/bpftool/.gitignore b/tools/bpf/bpftool/.gitignore index 8248b8dd89d4..b13926432b84 100644 --- a/tools/bpf/bpftool/.gitignore +++ b/tools/bpf/bpftool/.gitignore @@ -3,3 +3,5 @@ bpftool*.8 bpf-helpers.* FEATURE-DUMP.bpftool +feature +libbpf diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 3fc82ff9b52c..b0c5a369f54a 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -124,9 +124,11 @@ $(OUTPUT)%.o: %.c clean: $(LIBBPF)-clean $(call QUIET_CLEAN, bpftool) - $(Q)$(RM) $(OUTPUT)bpftool $(OUTPUT)*.o $(OUTPUT)*.d + $(Q)$(RM) -- $(OUTPUT)bpftool $(OUTPUT)*.o $(OUTPUT)*.d + $(Q)$(RM) -r -- $(OUTPUT)libbpf/ $(call QUIET_CLEAN, core-gen) - $(Q)$(RM) $(OUTPUT)FEATURE-DUMP.bpftool + $(Q)$(RM) -- $(OUTPUT)FEATURE-DUMP.bpftool + $(Q)$(RM) -r -- $(OUTPUT)feature/ install: $(OUTPUT)bpftool $(call QUIET_INSTALL, bpftool) @@ -137,8 +139,8 @@ install: $(OUTPUT)bpftool uninstall: $(call QUIET_UNINST, bpftool) - $(Q)$(RM) $(DESTDIR)$(prefix)/sbin/bpftool - $(Q)$(RM) $(DESTDIR)$(bash_compdir)/bpftool + $(Q)$(RM) -- $(DESTDIR)$(prefix)/sbin/bpftool + $(Q)$(RM) -- $(DESTDIR)$(bash_compdir)/bpftool doc: $(call descend,Documentation) From patchwork Fri Aug 30 11:00:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 1155863 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="oSAv+pXh"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46Kc3J1XdPz9sML for ; Fri, 30 Aug 2019 21:01:00 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728031AbfH3LA7 (ORCPT ); Fri, 30 Aug 2019 07:00:59 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:46607 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727883AbfH3LA5 (ORCPT ); Fri, 30 Aug 2019 07:00:57 -0400 Received: by mail-wr1-f65.google.com with SMTP id h7so5192474wrt.13 for ; Fri, 30 Aug 2019 04:00:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EIr8AwOPiNckdVBY6i7n8z6ctI1h3TpypkoOttv24nk=; b=oSAv+pXhnO/OYle9E3G8UH8llVneQ8uAsk1pihGWX5uwFjBzjBvufEYuUW3XNJ+FwR 1uMAbLiY0F0IQqWGFq0xXf0KzPnHnE5sSLjUr8vYZcWSzcLFRtM9GLhWt3gH83w7Vmdn JLne9RTU5uS4fIdoyxr/MeN8hdYAiwqewYTBbaelPwdf4jS2ab4OD+cp9aOtn7ge4tfi ff54s2BQt/r5mlQS3I0fuBOl2jnxS/gjZbPuTiD36z9+MmaNlnXkxcYPtMMfYLP+8McT x/8aYFRbCTpejazxRia4jk756TuqqvI3+eQ4/bdS5cRQRKDKOM1u37kLN4OLAnxumEOH BNMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EIr8AwOPiNckdVBY6i7n8z6ctI1h3TpypkoOttv24nk=; b=HSXD1pDNj1yUpWfPZvBOAKyQo0mtjRgLDoEitXU6MkWbqAuV66GRX3u73jpgqeXnmV u9u1HCkAKxyoSyHamxYmLjGeGjHb9vXdAnhniqpX7vtaOtFVpsMzeb2UaQYgJ3ST0AwX kSPkmocY37e8Lg0rJKU1jNocWsM7tujLoJShXup5qNd6PMhdfE1cq0C9DC68J75Q37GB /ryHlgzapbyhMpwQVczeYC6bp1IZh2RBj6/rj1q/bemXXiOv6UzKhnBA/xV74jTAQwaR F7WsYhCXRBMbNqwD8UlHIBOLK+5gFCLuy1Ot/+fYQRsYD16pd019mEB6G1YRE5f7Bxd0 iHzA== X-Gm-Message-State: APjAAAXxA37fLkQqzH299J8L+Lpw2jUsRWGMJHvs51GQCruQ8eMuZRR5 bPxw7gaCqfw6JeCskh3Iaj3Cvw== X-Google-Smtp-Source: APXvYqyePid31/mbtw+pMW7sS/tQSrLG35ES5azqMPRTxsFSVhfSNMx5hJEJYbWfW+gUlX4Ug80n1A== X-Received: by 2002:adf:dc03:: with SMTP id t3mr17323673wri.80.1567162855349; Fri, 30 Aug 2019 04:00:55 -0700 (PDT) Received: from cbtest32.netronome.com ([217.38.71.146]) by smtp.gmail.com with ESMTPSA id t198sm7848083wmt.39.2019.08.30.04.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2019 04:00:54 -0700 (PDT) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@netronome.com, Quentin Monnet , Lorenz Bauer , Ilya Leoshkevich , Jakub Kicinski Subject: [PATCH bpf-next v2 4/4] tools: bpftool: do not link twice against libbpf.a in Makefile Date: Fri, 30 Aug 2019 12:00:40 +0100 Message-Id: <20190830110040.31257-5-quentin.monnet@netronome.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190830110040.31257-1-quentin.monnet@netronome.com> References: <20190830110040.31257-1-quentin.monnet@netronome.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In bpftool's Makefile, $(LIBS) includes $(LIBBPF), therefore the library is used twice in the linking command. No need to have $(LIBBPF) (from $^) on that command, let's do with "$(OBJS) $(LIBS)" (but move $(LIBBPF) _before_ the -l flags in $(LIBS)). Signed-off-by: Ilya Leoshkevich Signed-off-by: Quentin Monnet Reviewed-by: Jakub Kicinski --- 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 b0c5a369f54a..39bc6f0f4f0b 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -55,7 +55,7 @@ ifneq ($(EXTRA_LDFLAGS),) LDFLAGS += $(EXTRA_LDFLAGS) endif -LIBS = -lelf -lz $(LIBBPF) +LIBS = $(LIBBPF) -lelf -lz INSTALL ?= install RM ?= rm -f @@ -117,7 +117,7 @@ $(OUTPUT)disasm.o: $(srctree)/kernel/bpf/disasm.c $(OUTPUT)feature.o: | zdep $(OUTPUT)bpftool: $(OBJS) $(LIBBPF) - $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) + $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) $(OUTPUT)%.o: %.c $(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<