From patchwork Wed Apr 27 07:30:33 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: 8953061 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 5193DBF29F for ; Wed, 27 Apr 2016 07:30:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 73D0520142 for ; Wed, 27 Apr 2016 07:30:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 63F7B201FE for ; Wed, 27 Apr 2016 07:30:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753250AbcD0Haj (ORCPT ); Wed, 27 Apr 2016 03:30:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53546 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753298AbcD0Haf (ORCPT ); Wed, 27 Apr 2016 03:30:35 -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 2158AC05E154; Wed, 27 Apr 2016 07:30:35 +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 u3R7UXl9002305; Wed, 27 Apr 2016 03:30:34 -0400 Received: from [192.168.42.3] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id 8B411327A1B06; Wed, 27 Apr 2016 09:30:33 +0200 (CEST) Subject: [net-next PATCH V3 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: Wed, 27 Apr 2016 09:30:33 +0200 Message-ID: <20160427073033.29959.70743.stgit@firesoul> In-Reply-To: <20160427072855.29959.70252.stgit@firesoul> References: <20160427072855.29959.70252.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..157d68d6eace 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 6bbc7958c305..d653548467a5 100644 --- a/samples/bpf/README.rst +++ b/samples/bpf/README.rst @@ -71,8 +71,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