Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp267065imm; Thu, 26 Jul 2018 03:15:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdsWqvV63tiqqZtoeIz3/fP1pF9tCvkMfqyRVmmh1nbEC+k24OzjxuEsCznm5dwaE9lwAO1 X-Received: by 2002:a63:fc44:: with SMTP id r4-v6mr1325487pgk.169.1532600137799; Thu, 26 Jul 2018 03:15:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532600137; cv=none; d=google.com; s=arc-20160816; b=kSLzJhHIau1NqKECWDTeUz4KZeoaBP5r3WyiBkoP9W4c8Ax2nNRZ1sgJvdQZo373DN lm9DZl7VbWumC9QBs498AAu1nW7EujS9dzrsOyvL0kbIggaSC+mQxUQzaZ7O2mfpydqW 3Q4PlyyyvjUkTQucvHflUpiwlK1FUT5HbgUkxSuH/+45RfSlokpp8xwJkBWFVDcf+t4n MH8v3iAQdwPGzf+2jur6h3veOsRNtnO+15NjuK3xkUf/+eGH8/4EBgPzCXrnAC88dwYM AxkmPpnYDh6iPM5I1nxveD8XiwQPGnWdT+0aW9KusdvDp65Bu272Rpir2a2RYwAHNlYE dXbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=OYy21Ub+xl0Zg1iW2ag5xZ5H/oK96Or3xHERkQ/dQuI=; b=0JYbe+v29dp+h3tlFkwisE4T0LDzNd/GezBxT90WC6NUAC25tHRDzjDB7S4qmzngFa 27/e3iS9xCPIRcJYz67dp1t67l9Mf+n3X7vbO7LLwn8zV3T4Dgjxgqr9Xu4LzAxqaled Iu8utSNwAgyg9CgvumV2FykIIZVP3dK2XPtURNI/dCcZSNfi8ppab5W8Fct/36LnOFEs 4V20VTypMzwgRKMyaC1MIPCPpvXs8oRptStH8spwuI/ZDPcO77wgMhhpYiDGryW76x60 z91lnvZXxWtKPOvEpiE2ZCTJ5oNbQXfGKuHpdEbrq2CGGu6nlgagDKnjoC8+2vHdAmMY 3Tlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hATYiuSJ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z21-v6si1018437pgn.365.2018.07.26.03.15.23; Thu, 26 Jul 2018 03:15:37 -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=@gmail.com header.s=20161025 header.b=hATYiuSJ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729352AbeGZLaD (ORCPT + 99 others); Thu, 26 Jul 2018 07:30:03 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45986 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728957AbeGZLaD (ORCPT ); Thu, 26 Jul 2018 07:30:03 -0400 Received: by mail-pf1-f196.google.com with SMTP id i26-v6so428855pfo.12; Thu, 26 Jul 2018 03:13:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=OYy21Ub+xl0Zg1iW2ag5xZ5H/oK96Or3xHERkQ/dQuI=; b=hATYiuSJrsLBlqvdOlPuxEfFIgTp9eUyp3b5Tdqbf3TzwAG0YULZAU752HwPi7/s+7 xqMtbM9LzJnciLKtYqfce4USmn3Js9yUZik0FIokbYZtgsTenxqXf0wZ6qaM9Cm5Ydpa 0Tu1PwW2pY6QjINwhyfPhUhMcJOR5JWf3zTCJzL6uwl6zKPIIpm3Fv/sFmxk/uXqUNzU bXPOwgDZ+fN+2UPccEXw9GYc+E9TtBswrxsIXQrJw9Ox6Nj9IYBoSsGhIdr+xUrJcJO0 G5j4/EMXoFy9qxopIZWtuFdH25WO6sbuiBWQj/qQYc6L7LRDeneH9OcdnVI6mAfoAlN/ VbIQ== 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; bh=OYy21Ub+xl0Zg1iW2ag5xZ5H/oK96Or3xHERkQ/dQuI=; b=By+8gojdeJbGjt1+ufeYwZXYq2nATRccS4WB52ZXcorp8cXoc7b1UMZfh3+iQhx7fc GRopX55G+tjMBLK0hL0EMRc+AS/qzEz5e2hd6uogP1BbnPh8eU1ACgAR3/g7v/ApNDi3 HVanSSoO7UckEVPlXGRTgpuIEg9UnL9dsDhgvo7gCLIzF0z1NHEK0vPdb3bi+0NFuade +gEXBvteYoC6pobMrKRwF1FNBgdyM7JAtQDmAkfu8W6XgqNFzP2RIiuLSC0tHoxeIdTZ pr1zSSLPHWU++9BCM1cXDrK0ja4rGYFJWSCQ1Lb8YC08nGNYgFnH+mKZBclm9K8UVGe1 x5Ww== X-Gm-Message-State: AOUpUlF78D0qMjRde5Pg/yAVS3ncnllNXELAgsGuncOQxPGYcMB21/hb i5cjaPR5lpMvBed4tmQFcoY= X-Received: by 2002:a63:5758:: with SMTP id h24-v6mr1330237pgm.432.1532600034210; Thu, 26 Jul 2018 03:13:54 -0700 (PDT) Received: from localhost.localdomain ([211.196.191.92]) by smtp.gmail.com with ESMTPSA id u11-v6sm3040068pfd.117.2018.07.26.03.13.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 03:13:53 -0700 (PDT) From: Taeung Song To: Daniel Borkmann , Alexei Starovoitov Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski Subject: [PATCH bpf-next v2] samples/bpf: Add BTF build flags to Makefile Date: Thu, 26 Jul 2018 19:13:44 +0900 Message-Id: <20180726101344.19351-1-treeze.taeung@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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") Acked-by: Martin KaFai Lau Reviewed-by: Jakub Kicinski Signed-off-by: Taeung Song --- samples/bpf/Makefile | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index 9ea2f7b64869..77f512625b8c 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -195,6 +195,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 @@ -202,6 +204,16 @@ 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 ($(and $(BTF_LLC_PROBE),$(BTF_PAHOLE_PROBE),$(BTF_OBJCOPY_PROBE)),) + EXTRA_CFLAGS += -g + LLC_FLAGS += -mattr=dwarfris + DWARF2BTF = y +endif + # Trick to allow make to be run from this directory all: $(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR) @@ -260,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 -- 2.17.1