diff mbox

[net-next,V2,2/5] samples/bpf: Makefile verify LLVM compiler avail and bpf target is supported

Message ID 20160426162716.22962.36473.stgit@firesoul (mailing list archive)
State New, archived
Headers show

Commit Message

Jesper Dangaard Brouer April 26, 2016, 4:27 p.m. UTC
Make compiling samples/bpf more user friendly, by detecting if LLVM
compiler tool 'llc' is available, and also detect if the 'bpf' target
is available in this version of LLVM.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
 samples/bpf/Makefile |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)


--
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

Comments

Alexei Starovoitov April 26, 2016, 5:28 p.m. UTC | #1
On Tue, Apr 26, 2016 at 06:27:16PM +0200, Jesper Dangaard Brouer wrote:
> Make compiling samples/bpf more user friendly, by detecting if LLVM
> compiler tool 'llc' is available, and also detect if the 'bpf' target
> is available in this version of LLVM.
> 
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>

Acked-by: Alexei Starovoitov <ast@kernel.org>
--
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
David Laight April 27, 2016, 1:52 p.m. UTC | #2
RnJvbTogSmVzcGVyIERhbmdhYXJkIEJyb3Vlcg0KPiBTZW50OiAyNiBBcHJpbCAyMDE2IDE3OjI3
DQo+IE1ha2UgY29tcGlsaW5nIHNhbXBsZXMvYnBmIG1vcmUgdXNlciBmcmllbmRseSwgYnkgZGV0
ZWN0aW5nIGlmIExMVk0NCj4gY29tcGlsZXIgdG9vbCAnbGxjJyBpcyBhdmFpbGFibGUsIGFuZCBh
bHNvIGRldGVjdCBpZiB0aGUgJ2JwZicgdGFyZ2V0DQo+IGlzIGF2YWlsYWJsZSBpbiB0aGlzIHZl
cnNpb24gb2YgTExWTS4NCi4uLg0KPiBkaWZmIC0t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iAgICBMTEM9Ii9wYXRoX3RvX2xsYy9sbGMgLWV4dHJhX2FyZyIgbWFrZSBmdWJhcg0K
DQoJRGF2aWQNCg0K
--
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 mbox

Patch

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 5bae9536f100..45859c99f573 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -85,6 +85,24 @@  HOSTLOADLIBES_test_overhead += -lelf -lrt
 #  make samples/bpf/ LLC=~/git/llvm/build/bin/llc
 LLC ?= llc
 
+# Verify LLVM compiler is available and bpf target is supported
+.PHONY: verify_cmd_llc verify_target_bpf
+
+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_target_bpf: verify_cmd_llc
+	@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" ;\
+		exit 2; \
+	else true; fi
+
+$(src)/*.c: verify_target_bpf
+
 # asm/sysreg.h - inline assembly used by it is incompatible with llvm.
 # But, there is no easy way to fix it, so just exclude it since it is
 # useless for BPF samples.