Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1416216imm; Wed, 25 Jul 2018 18:17:13 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc1vD5LxKp7PTZnDva078uthhfj8jJBWtBdDRuFYSFWPWoVBHzDfGbYu+4lMyE1IsZv0fT9 X-Received: by 2002:a62:4898:: with SMTP id q24-v6mr24096653pfi.58.1532567833807; Wed, 25 Jul 2018 18:17:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532567833; cv=none; d=google.com; s=arc-20160816; b=ZyqFSaJs9DcFHIjvcoYqDxrzKLYF2iaoPd5s/qZVoe5yTpw0JPDqOJAMdA81DNfUX8 3eeBaZuUMEs5UsmnHBy+ef2oO/jon8p8LB0ADK1G4xdlQfRna08iD/kuYeDmPoby5v7J V3mKTI+KFfRHXHW9YqFGO0cnYxfbGvMGlRrt9NorMBCGywA/sOXi206ZmPwbysvyKuxj M6d8B0CBe7rpS4MsITJ//+5t0RZ7FVYslPJn0OanmF5ODXPTcliRMn7aZculz24aehTy 9rw2Y5GGBWZG4G5yjEvRhcfN4F0qzlOTzuDVqfCBjnmzr3hnt2sXoxu0XKuDqecOU8QJ rG4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature:arc-authentication-results; bh=SDG1W7o/nFx5nqlG2/Pr5sAz7BUzYq+MCZUNcmT9HwQ=; b=KAK3A+bD8ERnuu4E/DlmxCL3uljYbLGUx85KUSjXQsd+e4DqRc9a+b5ZdaH6Zj+Skq wUekbQQJW062VxdeIWiqZO4aHyPh3FVUsZl8sF9sChKwNi2O7TWdEScJKU3oNUvBUQcS QJksmQ+SnhwhVp5Pe2xlPQKuNn3ySIbmFpcwXVY4oRpZdQm0zbf+IcJ1atPcC2tXMYvH PE3D4+NgjhOA+rA2b4vEJmU6V1+Ht5wZees2Ng/xKeCvAY0QEUSNSq5vj+3IiHsqdgpQ HA442hwgb/QZRaPaesZVbLnD3Np1z0+oTZRfj14UrFtyfp04HmVGIhAEaiwGbBxTopmz t+gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=DIXZ5REp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d11-v6si15255980pgm.556.2018.07.25.18.16.59; Wed, 25 Jul 2018 18:17:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=DIXZ5REp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728641AbeGZCa1 (ORCPT + 99 others); Wed, 25 Jul 2018 22:30:27 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:39849 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728407AbeGZCa0 (ORCPT ); Wed, 25 Jul 2018 22:30:26 -0400 Received: by mail-qk0-f193.google.com with SMTP id b5-v6so29061qkg.6 for ; Wed, 25 Jul 2018 18:16:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=SDG1W7o/nFx5nqlG2/Pr5sAz7BUzYq+MCZUNcmT9HwQ=; b=DIXZ5REpIQaLXY/gnXjXoZ8nbCdiY+3theini6yAvXEmBuG5P5ziE9EKKfVNDDAI79 DooitsylqNzJt87naqGM4jgM7vjpRnGmqF6ByKthgo8xDAk1Rqr7Q/IwRIPrtO9Z7jTc RI6dFsd8w1kV3yUaii6/lWWimCzc9YS4o5GsO6o+/2NNgGCAjPNdGBofUOUXyski3D61 /kKxqUGpgtXy1Gfa1hCxbw5XtfL1db1wXlN630cBHGrJ/O+CV6TE3xQP6uA2MHHG/XHF Jje7nzh/yfz+i3TkP8OEb8UK6t6+e4a0tjkzYKTJcL/l42q26lHk3eNQ0ds936mj4vWv yOeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=SDG1W7o/nFx5nqlG2/Pr5sAz7BUzYq+MCZUNcmT9HwQ=; b=kIOkoESI58Z+oGacPaH0cpeJ1sT5qx+ncRvt8kNxtemdwT5Ob9UxvtuczeyXoCD+/2 Ig309CrI3JgkbG1zMl0Nhlx/2wB0KFVjA1wCsX8qdMetebOawVBTuCcZf4UUD0UK8Jtr jWiYkck1ja+BZjzhLxCPGsnRJ5Bs2f8+RMhllu2AYpUaHZIrJudgjtUKrsAWEvcjBhqB Wr0LvBwrtX5qUbACWPZMs5NkGK/WbJglcTvMUK0E/jkX4IaG0WUDQe8vHZ78jrJYylQk H6ybVZMewO/OjVqOCwrBkyIZU8hppu+VwGfWVU4NOBUH2cLwv2J/okqp8pqKD7P8OBjZ yfWA== X-Gm-Message-State: AOUpUlHgUKGzXnuqB10GCmnvBGjiAZuujbXsCAYqtOQzdd3eo5OkC4xI TxbgcqgslpcfBp5zMthgCpzHgw== X-Received: by 2002:a37:a310:: with SMTP id m16-v6mr22430604qke.254.1532567767402; Wed, 25 Jul 2018 18:16:07 -0700 (PDT) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id l188-v6sm9834712qke.83.2018.07.25.18.16.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Jul 2018 18:16:07 -0700 (PDT) Date: Wed, 25 Jul 2018 18:16:03 -0700 From: Jakub Kicinski To: Taeung Song Cc: Daniel Borkmann , Alexei Starovoitov , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Martin KaFai Lau Subject: Re: [PATCH] samples/bpf: Add BTF build flags to Makefile Message-ID: <20180725181603.69289f5d@cakuba.netronome.com> In-Reply-To: <20180725163039.2838-1-treeze.taeung@gmail.com> References: <20180725163039.2838-1-treeze.taeung@gmail.com> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 26 Jul 2018 01:30:39 +0900, Taeung Song wrote: > To smoothly test BTF supported binary on samples/bpf, > let samples/bpf/Makefile probe llc, pahole and > llvm-objcopy for BPF support and use them > like tools/testing/selftests/bpf/Makefile > changed from the commit c0fa1b6c3efc ("bpf: btf: > Add BTF tests") > > Cc: Martin KaFai Lau > Signed-off-by: Taeung Song > --- > samples/bpf/Makefile | 21 ++++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) > > diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile > index 1303af10e54d..e079266360a3 100644 > --- a/samples/bpf/Makefile > +++ b/samples/bpf/Makefile > @@ -191,6 +191,8 @@ HOSTLOADLIBES_xdpsock += -pthread > # make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang > LLC ?= llc > CLANG ?= clang > +LLVM_OBJCOPY ?= llvm-objcopy > +BTF_PAHOLE ?= pahole > > # Detect that we're cross compiling and use the cross compiler > ifdef CROSS_COMPILE > @@ -198,6 +200,20 @@ HOSTCC = $(CROSS_COMPILE)gcc > CLANG_ARCH_ARGS = -target $(ARCH) > endif > > +BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris) > +BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF) > +BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm') > + > +ifneq ($(BTF_LLC_PROBE),) > +ifneq ($(BTF_PAHOLE_PROBE),) > +ifneq ($(BTF_OBJCOPY_PROBE),) Nice patch! FWIW you could consider using $(and ...) here: ifneq ($(and $(BTF_LLC_PROBE),$(BTF_PAHOLE_PROBE),$(BTF_OBJCOPY_PROBE)),) https://www.gnu.org/software/make/manual/html_node/Conditional-Functions.html#Conditional-Functions Not sure it's worth a respin.. > + EXTRA_CFLAGS += -g > + LLC_FLAGS += -mattr=dwarfris > + DWARF2BTF = y > +endif > +endif > +endif > + > # Trick to allow make to be run from this directory > all: > $(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR) > @@ -256,4 +272,7 @@ $(obj)/%.o: $(src)/%.c > -Wno-gnu-variable-sized-type-not-at-end \ > -Wno-address-of-packed-member -Wno-tautological-compare \ > -Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \ > - -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@ > + -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf $(LLC_FLAGS) -filetype=obj -o $@ > +ifeq ($(DWARF2BTF),y) > + $(BTF_PAHOLE) -J $@ > +endif