Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752589AbcLFIWt (ORCPT ); Tue, 6 Dec 2016 03:22:49 -0500 Received: from terminus.zytor.com ([198.137.202.10]:42080 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751427AbcLFIWs (ORCPT ); Tue, 6 Dec 2016 03:22:48 -0500 Date: Tue, 6 Dec 2016 00:22:28 -0800 From: tip-bot for Wang Nan Message-ID: Cc: wangnan0@huawei.com, lizefan@huawei.com, jolsa@kernel.org, tglx@linutronix.de, ast@fb.com, linux-kernel@vger.kernel.org, hpa@zytor.com, joe@ovn.org, mingo@kernel.org, acme@redhat.com, hekuang@huawei.com Reply-To: tglx@linutronix.de, ast@fb.com, lizefan@huawei.com, wangnan0@huawei.com, jolsa@kernel.org, hekuang@huawei.com, mingo@kernel.org, acme@redhat.com, linux-kernel@vger.kernel.org, hpa@zytor.com, joe@ovn.org In-Reply-To: <20161126070354.141764-8-wangnan0@huawei.com> References: <20161126070354.141764-8-wangnan0@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] tools build: Add feature detection for LLVM Git-Commit-ID: cb40d55b595cd117ef7c1880247605875b2115e8 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2636 Lines: 78 Commit-ID: cb40d55b595cd117ef7c1880247605875b2115e8 Gitweb: http://git.kernel.org/tip/cb40d55b595cd117ef7c1880247605875b2115e8 Author: Wang Nan AuthorDate: Sat, 26 Nov 2016 07:03:31 +0000 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 5 Dec 2016 15:51:42 -0300 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 Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa Cc: Joe Stringer Cc: Zefan Li Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/20161126070354.141764-8-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/build/feature/Makefile | 8 ++++++++ tools/build/feature/test-llvm.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index 8f668bc..c09de59 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -55,6 +55,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) @@ -229,6 +230,13 @@ $(OUTPUT)test-cxx.bin: $(OUTPUT)test-jvmti.bin: $(BUILD) +$(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; +}