[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1474635001-153850-4-git-send-email-wangnan0@huawei.com>
Date: Fri, 23 Sep 2016 12:49:50 +0000
From: Wang Nan <wangnan0@...wei.com>
To: <acme@...nel.org>, <ast@...com>
CC: <pi3orama@....com>, <linux-kernel@...r.kernel.org>,
<lizefan@...wei.com>, Wang Nan <wangnan0@...wei.com>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
He Kuang <hekuang@...wei.com>, Jiri Olsa <jolsa@...nel.org>
Subject: [PATCH 03/14] perf tools: 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@...wei.com>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Alexei Starovoitov <ast@...com>
Cc: He Kuang <hekuang@...wei.com>
Cc: Jiri Olsa <jolsa@...nel.org>
---
tools/build/feature/Makefile | 8 ++++++++
tools/build/feature/test-llvm.cpp | 8 ++++++++
2 files changed, 16 insertions(+)
create mode 100644 tools/build/feature/test-llvm.cpp
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index ac9c477..fd2f3e2 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -54,6 +54,7 @@ FILES := $(addprefix $(OUTPUT),$(FILES))
CC := $(CROSS_COMPILE)gcc -MD
CXX := $(CROSS_COMPILE)g++ -MD
PKG_CONFIG := $(CROSS_COMPILE)pkg-config
+LLVM_CONFIG ?= llvm-config
all: $(FILES)
@@ -225,6 +226,13 @@ $(OUTPUT)test-sdt.bin:
$(OUTPUT)test-cxx.bin:
$(BUILDXX) -std=gnu++11
+$(OUTPUT)test-llvm.bin:
+ $(BUILDXX) -std=gnu++11 \
+ -I$(shell $(LLVM_CONFIG) --includedir) \
+ -L$(shell $(LLVM_CONFIG) --libdir) \
+ $(shell $(LLVM_CONFIG) --libs Core BPF) \
+ $(shell $(LLVM_CONFIG) --system-libs)
+
-include $(OUTPUT)*.d
###############################
diff --git a/tools/build/feature/test-llvm.cpp b/tools/build/feature/test-llvm.cpp
new file mode 100644
index 0000000..d8d2cee
--- /dev/null
+++ b/tools/build/feature/test-llvm.cpp
@@ -0,0 +1,8 @@
+#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/raw_ostream.h"
+int main()
+{
+ llvm::errs() << "Hello World!\n";
+ llvm::llvm_shutdown();
+ return 0;
+}
--
1.8.3.4
Powered by blists - more mailing lists