From patchwork Thu Aug 29 10:56:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 1155185 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="VUdh0b9J"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46K01F13nNz9sMr for ; Thu, 29 Aug 2019 20:57:05 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727866AbfH2K5E (ORCPT ); Thu, 29 Aug 2019 06:57:04 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35134 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727120AbfH2K5D (ORCPT ); Thu, 29 Aug 2019 06:57:03 -0400 Received: by mail-wr1-f66.google.com with SMTP id g7so2973001wrx.2 for ; Thu, 29 Aug 2019 03:57:02 -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=HKngvou9PTiEySa5fxRXC+r6OGUa9j6poOx1wOazin8=; b=VUdh0b9J1kPYrn231R1DeFnsGsrc8wIoW/ULI1erpzMlfMjSjBwrWiCQ3r28eiRhh+ HyZEBxhl9uWV5TxNSlgjeoUCWXv+xR+hV285D6M5iKC/vRyzb88NXxYepymDRWS5LX1X bVAnwtGNXPCmvhnv3qlr3xF0WJ4D9qqt21NJKQMIxLZ4DMqyhgJ2l9TzmTBmShHEkZKF WBOkGpVSdn3oloet7sBG23+xeIE/670bVKa3JKxvEkeAY1tI2swqbInckRXWntStXrNh 8fPNvukXoU6zhdxaBA21vTCn2UWDeUFCMKHLS5r3wFk/d/T3Svt1eM77mUp2lzTVpJRm hP1g== 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=HKngvou9PTiEySa5fxRXC+r6OGUa9j6poOx1wOazin8=; b=LILvmvTyVx7OzgKj2PIL3rGiushPvgW/Kq1gsle30PJ3qbe7S+jZYnLmqcvVX8WeO+ VZV4Ik/de6lKLg5fCYMDawb23K1Cy3vpienarwKX/YuA/lyPlGyJ5Xat7FasTLyxOzih GxokKkfeUTzA6oXpz6GMWZKkfYU5Yww1zAMgfpXNJuTQ3u5AE2ZvOfUsiQRn94s8TFDk o5JZB7w5CrR45BqEns7c0ZNi+xahzNp32eeomsOsig8dXYeSoo9XiS/Mf5bqcTkjSbJ9 AL/Eews108dEggbJRgURa92+Ty1Zlx7Xqrlug4J6lLQnIgloRq3EKb+t/I96a5tyCBKV B9AQ== X-Gm-Message-State: APjAAAVAF4n3KLDqWvuwiN3nbp21LF+c7YzZ7vYpGDRgMFQ9e+fjeh4z 4sjZGVGlLzhvnCSpaxA3Yip23zOh0X4= X-Google-Smtp-Source: APXvYqyEo1n1o7xcGcvE+PiGOi6It4KCuv4fEy3D/JhdLjGRArCkCd0FldCMjXdDxDz6Ar3TgmVzNw== X-Received: by 2002:a5d:5112:: with SMTP id s18mr11274370wrt.34.1567076221444; Thu, 29 Aug 2019 03:57:01 -0700 (PDT) Received: from cbtest32.netronome.com ([217.38.71.146]) by smtp.gmail.com with ESMTPSA id j18sm2091938wrr.20.2019.08.29.03.57.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 03:57:00 -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 1/3] tools: bpftool: ignore make built-in rules for getting kernel version Date: Thu, 29 Aug 2019 11:56:43 +0100 Message-Id: <20190829105645.12285-2-quentin.monnet@netronome.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190829105645.12285-1-quentin.monnet@netronome.com> References: <20190829105645.12285-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 --- 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 Thu Aug 29 10:56:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 1155187 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="H6BNnL4r"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46K01G17Knz9sPS for ; Thu, 29 Aug 2019 20:57:06 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727888AbfH2K5F (ORCPT ); Thu, 29 Aug 2019 06:57:05 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:52871 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727123AbfH2K5E (ORCPT ); Thu, 29 Aug 2019 06:57:04 -0400 Received: by mail-wm1-f68.google.com with SMTP id t17so3237223wmi.2 for ; Thu, 29 Aug 2019 03:57:03 -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=ot8jB+CSJxQ+ZYUPnQZRW6Tx5ySR7IASwY4oH0PhbjE=; b=H6BNnL4r80mp4XnaYpzO8PjFAaw+1rNGd3OT4yg+whE8FJqeOXntl9cD/zH67nBfsE FHAKgl6m6DUYtgZt1rc3fxeF5eZahW+hTNLeGW5W9H/1ivuv7GqVe7ApvI9bAoFdxV64 OwZgX3qMDFQEBT4smlBOildVdAT6MdVC5e6oPkMwRRUHzyKbgml57SWX8ADcU1gVOf1D ATi4S3C3fAI2VWLhVNHb+lYlV4MTcNdbik1Dxp0XyE1vFVHyqeZjeFWB7ygo7F6499Wi FyHdS6NHmG6Y9zK5yjxTyMBQANtk0hl3zUiCKSLUe/2CESIMdWpFDzaUh0I0inszAQKc +onQ== 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=ot8jB+CSJxQ+ZYUPnQZRW6Tx5ySR7IASwY4oH0PhbjE=; b=UgKc+YPYw0Yu6vPcpDaVNvFREr/5rRD8rfEUuEu2O6/EOH1pPipSy94xpfUuwsnARc rKe3WpLLA2GIFhbwVbyaLrajbfcYSpzHn25XgAg/CfJtqQ6hcOMMIFQTeMkbFVNi9QcW tlDh1X/J1FUtfhYLgfQ4x4jDMlAcamLkTbQNmVYJV+SiT231+j6Lb1icz1o1O1QX5YcU VJcw88Em8fiaPT+SjFGn3JseUlPr7mrl8JOCyLKFwKfxGNVqr68l/IU/TjCa8PIJgr8T JsWjcRifZe26YI0zfvL5lvo79p7hvRpo37nMIJA9rLqBr4DJYMRJ04ITdeFJKRHtD9Ox VRlA== X-Gm-Message-State: APjAAAVrV2T91vL3YQukhcyzHsU3kBXV5eFYTN9C/gm/hZQuGRXsQJLE B4fBwzQKLpp1/CWbysIhmIPKfA== X-Google-Smtp-Source: APXvYqz+4IsYS+CTpOqDQI9L50u3NKklxi5ICqUFaJ+chy1EbUaID3NmlPe1O5KAGf+6zIoMq2SoOA== X-Received: by 2002:a7b:c198:: with SMTP id y24mr10685317wmi.131.1567076222567; Thu, 29 Aug 2019 03:57:02 -0700 (PDT) Received: from cbtest32.netronome.com ([217.38.71.146]) by smtp.gmail.com with ESMTPSA id j18sm2091938wrr.20.2019.08.29.03.57.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 03:57:02 -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 2/3] tools: bpftool: improve and check builds for different make invocations Date: Thu, 29 Aug 2019 11:56:44 +0100 Message-Id: <20190829105645.12285-3-quentin.monnet@netronome.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190829105645.12285-1-quentin.monnet@netronome.com> References: <20190829105645.12285-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. Reported-by: Lorenz Bauer Signed-off-by: Quentin Monnet --- tools/bpf/bpftool/Makefile | 12 +- tools/testing/selftests/bpf/Makefile | 3 +- .../selftests/bpf/test_bpftool_build.sh | 137 ++++++++++++++++++ 3 files changed, 146 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..15dbea809a38 --- /dev/null +++ b/tools/testing/selftests/bpf/test_bpftool_build.sh @@ -0,0 +1,137 @@ +#!/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 [ $# -ge 1 ] ; then + check ${@: -1} + else + check . + fi + ( + if [ $# -eq 1 ] ; then + cd ${@: -1}/bpftool + 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 + 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 Thu Aug 29 10:56:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 1155189 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="BBvuGNw5"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46K01H5MWqz9sDB for ; Thu, 29 Aug 2019 20:57:07 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727889AbfH2K5F (ORCPT ); Thu, 29 Aug 2019 06:57:05 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:40958 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727120AbfH2K5F (ORCPT ); Thu, 29 Aug 2019 06:57:05 -0400 Received: by mail-wr1-f65.google.com with SMTP id c3so2942876wrd.7 for ; Thu, 29 Aug 2019 03:57:04 -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=qo+jIlzTdRjj5XqbIhGgOupgZtD97wKDakusyLmwdK0=; b=BBvuGNw5ClkOpjUSYE/0x2LneTUCMC0fLn/Dz48gLNnMTa7OKEIk4BSx29+yThPQX/ wIDBJ6W1ev1YXhGV9vMnnR1v539s3lDCapCAWuwXs8AM25c5hnF6C5AHYjuXlFrw0q4x 5C7w9c8tJXtj//ua6JogNjVz7QTnhpywiuXcsB/3aZ1nytygekH6FNlWsmrLuq+0Frtx DE08G6zFzxubbuzdBkNxB1CyS3DDW/qoRDLuTMxMQQTmzUvM0Z8EX6cJiXNm1vkpf4iB 22t4t5eW1HOF3pZcRvi1AYN5Kx53NV5rJYBd7wlGc0t1TfOvgifGoKP8KLdQJMTfd6Va lTrA== 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=qo+jIlzTdRjj5XqbIhGgOupgZtD97wKDakusyLmwdK0=; b=JecMMeSvZIXkdhuD2gyyWCCjnf/A7hBKyWxo7dHEuE2pYS5DkSsaaKURV+z8fn6C+X 5ggiQoe668ai0MluKDlnY7Zydliwn295geAFcJvZvoYb+C9m6H3fWNBRnc+kXZfX/s83 YRyeJByQCkPMNDbIbaCYLYu5V80DAgpQYZyYTLC3K9wkInzVR/eV1fUzDLAJWdrWb2V4 9/1PNe5jhcg7t7Q+uklFvewkuKTEXKun6KiIVuGf0B4gnMnauBwaJ06gUV9FqMEVXN57 BgGuSUHqCHExCjVJ1QzCDCzSxTll35I5ZGNHqrlvZbBdn/U8w4CuC658XE7AHKOAueiI aSSw== X-Gm-Message-State: APjAAAWTq9kXIWIPQoO7Z/YhtK/jJkGG3tajW/Wb/FwrhAP2ZtavLO3S NfsAVSNMfpEYrM548M+3+B2hfQ== X-Google-Smtp-Source: APXvYqzC42eL+icqpZ9RvKAbHLc2ziGgDSxjZd1mGXZt1UPmohmCRi9OvHzk01jPMNZosga5kefTog== X-Received: by 2002:a5d:658d:: with SMTP id q13mr3251729wru.78.1567076223889; Thu, 29 Aug 2019 03:57:03 -0700 (PDT) Received: from cbtest32.netronome.com ([217.38.71.146]) by smtp.gmail.com with ESMTPSA id j18sm2091938wrr.20.2019.08.29.03.57.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 03:57:02 -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 3/3] tools: bpftool: do not link twice against libbpf.a in Makefile Date: Thu, 29 Aug 2019 11:56:45 +0100 Message-Id: <20190829105645.12285-4-quentin.monnet@netronome.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190829105645.12285-1-quentin.monnet@netronome.com> References: <20190829105645.12285-1-quentin.monnet@netronome.com> Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@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 --- 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 3fc82ff9b52c..22b5a8f2c53d 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 $@ $<