From patchwork Thu Apr 28 12:21:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Dangaard Brouer X-Patchwork-Id: 8969491 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 22187BF29F for ; Thu, 28 Apr 2016 12:21:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 323DF202BE for ; Thu, 28 Apr 2016 12:21:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 45861202B8 for ; Thu, 28 Apr 2016 12:21:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753179AbcD1MVR (ORCPT ); Thu, 28 Apr 2016 08:21:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36607 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752751AbcD1MVQ (ORCPT ); Thu, 28 Apr 2016 08:21:16 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D42076F669; Thu, 28 Apr 2016 12:21:15 +0000 (UTC) Received: from firesoul.localdomain (ovpn-200-34.brq.redhat.com [10.40.200.34]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3SCLEit005395; Thu, 28 Apr 2016 08:21:15 -0400 Received: from [192.168.42.3] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id 4310630746076; Thu, 28 Apr 2016 14:21:14 +0200 (CEST) Subject: [net-next PATCH V4 5/5] samples/bpf: like LLC also verify and allow redefining CLANG command From: Jesper Dangaard Brouer To: netdev@vger.kernel.org Cc: linux-kbuild@vger.kernel.org, bblanco@plumgrid.com, Jesper Dangaard Brouer , naveen.n.rao@linux.vnet.ibm.com, borkmann@iogearbox.net, alexei.starovoitov@gmail.com Date: Thu, 28 Apr 2016 14:21:14 +0200 Message-ID: <20160428122114.16807.10131.stgit@firesoul> In-Reply-To: <20160428121949.16807.84828.stgit@firesoul> References: <20160428121949.16807.84828.stgit@firesoul> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Users are likely to manually compile both LLVM 'llc' and 'clang' tools. Thus, also allow redefining CLANG and verify command exist. Makefile implementation wise, the target that verify the command have been generalized. Signed-off-by: Jesper Dangaard Brouer Acked-by: Alexei Starovoitov --- samples/bpf/Makefile | 25 ++++++++++++++----------- samples/bpf/README.rst | 6 +++--- 2 files changed, 17 insertions(+), 14 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index dd63521832d8..66897e61232c 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -81,9 +81,10 @@ HOSTLOADLIBES_spintest += -lelf HOSTLOADLIBES_map_perf_test += -lelf -lrt HOSTLOADLIBES_test_overhead += -lelf -lrt -# Allows pointing LLC to a LLVM backend with bpf support, redefine on cmdline: -# make samples/bpf/ LLC=~/git/llvm/build/bin/llc +# Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline: +# make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang LLC ?= llc +CLANG ?= clang # Trick to allow make to be run from this directory all: @@ -93,16 +94,18 @@ clean: $(MAKE) -C ../../ M=$$PWD clean @rm -f *~ -# Verify LLVM compiler is available and bpf target is supported -.PHONY: verify_cmd_llc verify_target_bpf +# Verify LLVM compiler tools are available and bpf target is supported by llc +.PHONY: verify_cmds verify_target_bpf $(CLANG) $(LLC) -verify_cmd_llc: - @if ! (which "${LLC}" > /dev/null 2>&1); then \ - echo "*** ERROR: Cannot find LLVM tool 'llc' (${LLC})" ;\ - exit 1; \ - else true; fi +verify_cmds: $(CLANG) $(LLC) + @for TOOL in $^ ; do \ + if ! (which -- "$${TOOL}" > /dev/null 2>&1); then \ + echo "*** ERROR: Cannot find LLVM tool $${TOOL}" ;\ + exit 1; \ + else true; fi; \ + done -verify_target_bpf: verify_cmd_llc +verify_target_bpf: verify_cmds @if ! (${LLC} -march=bpf -mattr=help > /dev/null 2>&1); then \ echo "*** ERROR: LLVM (${LLC}) does not support 'bpf' target" ;\ echo " NOTICE: LLVM version >= 3.7.1 required" ;\ @@ -115,6 +118,6 @@ $(src)/*.c: verify_target_bpf # But, there is no easy way to fix it, so just exclude it since it is # useless for BPF samples. $(obj)/%.o: $(src)/%.c - clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \ + $(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \ -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \ -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@ diff --git a/samples/bpf/README.rst b/samples/bpf/README.rst index 0da069ffa434..d60d50d94640 100644 --- a/samples/bpf/README.rst +++ b/samples/bpf/README.rst @@ -60,8 +60,8 @@ Quick sniplet for manually compiling LLVM and clang $ cmake .. -DLLVM_TARGETS_TO_BUILD="BPF;X86" $ make -j $(getconf _NPROCESSORS_ONLN) -It is also possible to point make to the newly compiled 'llc' command -via redefining LLC on the make command line:: +It is also possible to point make to the newly compiled 'llc' or +'clang' command via redefining LLC or CLANG on the make command line:: - make samples/bpf/ LLC=~/git/llvm/build/bin/llc + make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang