From 6c74a386ba460cb0e9a60c3d4dccdf65d68f9de5 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Wed, 28 Mar 2018 17:17:55 +0200 Subject: [PATCH] Enable ROOT to be built with prebuilt clang and llvm. To do so one needs to pass -Dbuiltin_llvm=Off -Dbuiltin_clang=Off and the PATH should contain the path to llvm-config. Note this is not enabling ROOT to work with vanilla clang! This patch allows ROOT to be built against a prebuilt clang and llvm from https://root.cern.ch/git/{llvm.git,clang.git}. It allows to reduce ROOT's build times (in cases when cmake decides to rebuild the in-tree llvm for no good reason). It moves the common denominator of different ROOT builds in one place to save space. It also allows easy switch between LLVM in debug and release mode. To build the external clang and llvm exactly in the same way as the in-tree builds use: CMAKE_FLAGS="\ -DLLVM_ENABLE_WARNINGS=OFF \ -DLLVM_INCLUDE_TESTS=OFF \ -DCLANG_INCLUDE_TESTS=OFF \ -DLLVM_INCLUDE_EXAMPLES=OFF \ -DCLANG_BUILD_TOOLS=OFF \ -DCLANG_TOOL_ARCMT_TEST_BUILD=OFF \ -DCLANG_TOOL_CLANG_CHECK_BUILD=OFF \ -DCLANG_TOOL_CLANG_FORMAT_BUILD=OFF \ -DCLANG_TOOL_CLANG_FORMAT_VS_BUILD=OFF \ -DCLANG_TOOL_CLANG_FUZZER_BUILD=OFF \ -DCLANG_TOOL_CLANG_IMPORT_TEST_BUILD=OFF \ -DCLANG_TOOL_CLANG_OFFLOAD_BUNDLER_BUILD=OFF \ -DCLANG_TOOL_CLANG_RENAME_BUILD=OFF \ -DCLANG_TOOL_C_ARCMT_TEST_BUILD=OFF \ -DCLANG_TOOL_C_INDEX_TEST_BUILD=OFF \ -DCLANG_TOOL_DIAGTOOL_BUILD=OFF \ -DCLANG_TOOL_LIBCLANG_BUILD=OFF \ -DCLANG_TOOL_SCAN_BUILD_BUILD=OFF \ -DCLANG_TOOL_SCAN_VIEW_BUILD=OFF \ -DLLVM_BUILD_TOOLS=OFF \ -DLLVM_TOOL_LLVM_AR_BUILD=OFF \ -DCLANG_TOOL_CLANG_OFFLOAD_BUNDLER_BUILD=OFF \ -DLLVM_FORCE_USE_OLD_TOOLCHAIN=ON \ -DCLANG_ENABLE_STATIC_ANALYZER=OFF \ -DCLANG_ENABLE_ARCMT=OFF \ -DCLANG_ENABLE_FORMAT=OFF \ -DLLVM_TARGETS_TO_BUILD=host \ -DLLVM_ABI_BREAKING_CHECKS=FORCE_OFF \ -DLLVM_ENABLE_ABI_BREAKING_CHECKS=OFF \ -DCMAKE_INSTALL_PREFIX=.. \ -DCMAKE_BUILD_TYPE=Debug" cmake "$CMAKE_FLAGS" ../../../sources/root-llvm/ --- CMakeLists.txt | 4 +++- lib/Interpreter/CMakeLists.txt | 14 +++++++------- lib/MetaProcessor/CMakeLists.txt | 3 --- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a018497b..8afad4d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -458,7 +458,9 @@ list(APPEND LLVM_COMMON_DEPENDS ${CLANG_TABLEGEN_TARGETS}) if (TARGET intrinsics_gen) list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen) endif() -list(APPEND LLVM_COMMON_DEPENDS clang-headers) +if (TARGET clang-headers) + list(APPEND LLVM_COMMON_DEPENDS clang-headers) +endif() add_subdirectory(lib) add_subdirectory(tools) diff --git a/lib/Interpreter/CMakeLists.txt b/lib/Interpreter/CMakeLists.txt index c5a45340..9e23efe4 100644 --- a/lib/Interpreter/CMakeLists.txt +++ b/lib/Interpreter/CMakeLists.txt @@ -7,15 +7,17 @@ #------------------------------------------------------------------------------ set(LIBS + clangAnalysis + clangAST + clangBasic + clangCodeGen clangDriver + clangEdit clangFrontend + clangLex clangParse clangSema - clangAST - clangLex clangSerialization - clangCodeGen - clangBasic clingUtils ) @@ -23,6 +25,7 @@ set(LIBS set( LLVM_LINK_COMPONENTS analysis core + coverage executionengine ipo mc @@ -73,9 +76,6 @@ add_cling_library(clingInterpreter OBJECT ValuePrinter.cpp ValuePrinterSynthesizer.cpp - DEPENDS - ClangDriverOptions - LINK_LIBS ${LIBS} ) diff --git a/lib/MetaProcessor/CMakeLists.txt b/lib/MetaProcessor/CMakeLists.txt index 35f67594..e753dca3 100644 --- a/lib/MetaProcessor/CMakeLists.txt +++ b/lib/MetaProcessor/CMakeLists.txt @@ -20,9 +20,6 @@ add_cling_library(clingMetaProcessor OBJECT MetaProcessor.cpp MetaSema.cpp - DEPENDS - ClangDriverOptions - LINK_LIBS clangLex clangAST