Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751576AbcLFIXR (ORCPT ); Tue, 6 Dec 2016 03:23:17 -0500 Received: from terminus.zytor.com ([198.137.202.10]:42106 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750825AbcLFIXP (ORCPT ); Tue, 6 Dec 2016 03:23:15 -0500 Date: Tue, 6 Dec 2016 00:22:58 -0800 From: tip-bot for Wang Nan Message-ID: Cc: ast@fb.com, acme@redhat.com, hpa@zytor.com, wangnan0@huawei.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, hekuang@huawei.com, jolsa@kernel.org, joe@ovn.org, lizefan@huawei.com, mingo@kernel.org Reply-To: linux-kernel@vger.kernel.org, tglx@linutronix.de, wangnan0@huawei.com, hpa@zytor.com, acme@redhat.com, ast@fb.com, mingo@kernel.org, lizefan@huawei.com, joe@ovn.org, jolsa@kernel.org, hekuang@huawei.com In-Reply-To: <20161126070354.141764-9-wangnan0@huawei.com> References: <20161126070354.141764-9-wangnan0@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] tools build: Add feature detection for clang Git-Commit-ID: c7fb4f62e2a97bd25d555263ef501fe053edcbb6 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: 2983 Lines: 82 Commit-ID: c7fb4f62e2a97bd25d555263ef501fe053edcbb6 Gitweb: http://git.kernel.org/tip/c7fb4f62e2a97bd25d555263ef501fe053edcbb6 Author: Wang Nan AuthorDate: Sat, 26 Nov 2016 07:03:32 +0000 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 5 Dec 2016 15:51:43 -0300 tools build: Add feature detection for clang Check if basic clang compiling environment is ready. Doesn't like 'llvm-config --libs' which can returns llvm libraries in right order and duplicates some libraries if necessary, there's no correspondence for clang libraries (-lclangxxx). to avoid extra complexity and to avoid new clang breaking libraries ordering, use --start-group and --end-group. In this test case, manually identify required clang libs and hope it to be stable. Putting all clang libraries here is possible (use make's wildcard), but then feature checking becomes very slow. 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-9-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/build/feature/Makefile | 10 ++++++++++ tools/build/feature/test-clang.cpp | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index c09de59..871d553 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -237,6 +237,16 @@ $(OUTPUT)test-llvm.bin: $(shell $(LLVM_CONFIG) --libs Core BPF) \ $(shell $(LLVM_CONFIG) --system-libs) +$(OUTPUT)test-clang.bin: + $(BUILDXX) -std=gnu++11 \ + -I$(shell $(LLVM_CONFIG) --includedir) \ + -L$(shell $(LLVM_CONFIG) --libdir) \ + -Wl,--start-group -lclangBasic -lclangDriver \ + -lclangFrontend -lclangEdit -lclangLex \ + -lclangAST -Wl,--end-group \ + $(shell $(LLVM_CONFIG) --libs Core option) \ + $(shell $(LLVM_CONFIG) --system-libs) + -include $(OUTPUT)*.d ############################### diff --git a/tools/build/feature/test-clang.cpp b/tools/build/feature/test-clang.cpp new file mode 100644 index 0000000..e23c1b1 --- /dev/null +++ b/tools/build/feature/test-clang.cpp @@ -0,0 +1,21 @@ +#include "clang/Basic/VirtualFileSystem.h" +#include "clang/Driver/Driver.h" +#include "clang/Frontend/TextDiagnosticPrinter.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/raw_ostream.h" + +using namespace clang; +using namespace clang::driver; + +int main() +{ + IntrusiveRefCntPtr DiagID(new DiagnosticIDs()); + IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions(); + + DiagnosticsEngine Diags(DiagID, &*DiagOpts); + Driver TheDriver("test", "bpf-pc-linux", Diags); + + llvm::llvm_shutdown(); + return 0; +}