Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools build: Add feature detection for LLVM

Check if basic LLVM compiling environment is ready.

Use llvm-config to detect include and library directories. Avoid using
'llvm-config --cxxflags' because its result contain some unwanted flags
like --sysroot (if LLVM is built by yocto).

Use '?=' to set LLVM_CONFIG, so explicitly passing LLVM_CONFIG to make
would override it.

Use 'llvm-config --libs BPF' to check if BPF backend is compiled in.
Since now BPF bytecode is the only required backend, no need to waste
time linking llvm and clang if BPF backend is missing. This also
introduce an implicit requirement that LLVM should be new enough. Old
LLVM doesn't support BPF backend.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Joe Stringer <joe@ovn.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/20161126070354.141764-8-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Wang Nan and committed by
Arnaldo Carvalho de Melo
cb40d55b 2bd42de0

+16
+8
tools/build/feature/Makefile
··· 55 55 CC := $(CROSS_COMPILE)gcc -MD 56 56 CXX := $(CROSS_COMPILE)g++ -MD 57 57 PKG_CONFIG := $(CROSS_COMPILE)pkg-config 58 + LLVM_CONFIG ?= llvm-config 58 59 59 60 all: $(FILES) 60 61 ··· 229 228 230 229 $(OUTPUT)test-jvmti.bin: 231 230 $(BUILD) 231 + 232 + $(OUTPUT)test-llvm.bin: 233 + $(BUILDXX) -std=gnu++11 \ 234 + -I$(shell $(LLVM_CONFIG) --includedir) \ 235 + -L$(shell $(LLVM_CONFIG) --libdir) \ 236 + $(shell $(LLVM_CONFIG) --libs Core BPF) \ 237 + $(shell $(LLVM_CONFIG) --system-libs) 232 238 233 239 -include $(OUTPUT)*.d 234 240
+8
tools/build/feature/test-llvm.cpp
··· 1 + #include "llvm/Support/ManagedStatic.h" 2 + #include "llvm/Support/raw_ostream.h" 3 + int main() 4 + { 5 + llvm::errs() << "Hello World!\n"; 6 + llvm::llvm_shutdown(); 7 + return 0; 8 + }