From patchwork Tue Apr 26 16:27:32 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: 8940811 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 66688BF29F for ; Tue, 26 Apr 2016 16:28:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 76ABE20121 for ; Tue, 26 Apr 2016 16:27:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 51DA020138 for ; Tue, 26 Apr 2016 16:27:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752614AbcDZQ1f (ORCPT ); Tue, 26 Apr 2016 12:27:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53675 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752149AbcDZQ1e (ORCPT ); Tue, 26 Apr 2016 12:27:34 -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 738A97F6A8; Tue, 26 Apr 2016 16:27:33 +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 u3QGRWiH022793; Tue, 26 Apr 2016 12:27:33 -0400 Received: from [192.168.42.3] (localhost [IPv6:::1]) by firesoul.localdomain (Postfix) with ESMTP id 2CE5430065C64; Tue, 26 Apr 2016 18:27:32 +0200 (CEST) Subject: [net-next PATCH V2 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: Tue, 26 Apr 2016 18:27:32 +0200 Message-ID: <20160426162732.22962.73140.stgit@firesoul> In-Reply-To: <20160426162650.22962.20516.stgit@firesoul> References: <20160426162650.22962.20516.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 | 23 +++++++++++++---------- samples/bpf/README.rst | 6 +++--- 2 files changed, 16 insertions(+), 13 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..c02ea9d2a248 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: @@ -94,15 +95,17 @@ clean: @rm -f *~ # Verify LLVM compiler is available and bpf target is supported -.PHONY: verify_cmd_llc verify_target_bpf +.PHONY: verify_cmd_llc 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 1ec4b08a7b40..74897dbe6458 100644 --- a/samples/bpf/README.rst +++ b/samples/bpf/README.rst @@ -73,8 +73,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 compile 'llc' command -via redefining LLC on the make command line:: +It is also possible to point make to the newly compile '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