This patch introduces target_link_libraries(INTERFACE|PRIVATE) to parallelize
building libraries.
With this on manycore host, built time from clean could be reduced much.
This requires the feature in CMake-2.8.12.
For example on Opteron 4x16 cores 2.5GHz (6380) to build clang,
$ time ninja clang
trunk (r201978)
real 2m20.779s
user 63m8.007s
sys 3m2.697s
This patch
real 1m27.150s
user 68m56.874s
sys 2m28.777s
40% reduced.
This requires dependencies for generated headers of each library should be
up-to-date.
This is one of reasons why I once removed dependencies in clang libraries.
(I am working for another patch to evolve handling dependencies)
Changes to compiler-rt and lld are minimal. I could improve them if this were
landed.
This is also available from
https://github.com/chapuni/llvm-project/commits/cmake/cmp0023
http://llvm-reviews.chandlerc.com/D2864
Files:
clang-tools-extra/clang-apply-replacements/CMakeLists.txt
clang-tools-extra/clang-modernize/Core/CMakeLists.txt
clang-tools-extra/clang-query/CMakeLists.txt
clang-tools-extra/clang-tidy/CMakeLists.txt
clang-tools-extra/clang-tidy/google/CMakeLists.txt
clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
clang/CMakeLists.txt
clang/lib/ARCMigrate/CMakeLists.txt
clang/lib/AST/CMakeLists.txt
clang/lib/ASTMatchers/CMakeLists.txt
clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
clang/lib/Analysis/CMakeLists.txt
clang/lib/CodeGen/CMakeLists.txt
clang/lib/Driver/CMakeLists.txt
clang/lib/Edit/CMakeLists.txt
clang/lib/Format/CMakeLists.txt
clang/lib/Frontend/CMakeLists.txt
clang/lib/FrontendTool/CMakeLists.txt
clang/lib/Index/CMakeLists.txt
clang/lib/Lex/CMakeLists.txt
clang/lib/Parse/CMakeLists.txt
clang/lib/Rewrite/Core/CMakeLists.txt
clang/lib/Rewrite/Frontend/CMakeLists.txt
clang/lib/Sema/CMakeLists.txt
clang/lib/Serialization/CMakeLists.txt
clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
clang/lib/StaticAnalyzer/Core/CMakeLists.txt
clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
clang/lib/Tooling/CMakeLists.txt
compiler-rt/CMakeLists.txt
lld/lib/Core/CMakeLists.txt
lld/lib/ReaderWriter/CMakeLists.txt
llvm/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/LLVM-Config.cmake
llvm/lib/LineEditor/CMakeLists.txt
llvm/lib/Support/CMakeLists.txt
llvm/utils/unittest/CMakeLists.txt
llvm/utils/unittest/UnitTestMain/CMakeLists.txt
Index: clang-tools-extra/clang-apply-replacements/CMakeLists.txt
===================================================================
--- clang-tools-extra/clang-apply-replacements/CMakeLists.txt
+++ clang-tools-extra/clang-apply-replacements/CMakeLists.txt
@@ -4,8 +4,8 @@
add_clang_library(clangApplyReplacements
lib/Tooling/ApplyReplacements.cpp
- )
-target_link_libraries(clangApplyReplacements
+
+ LINK_LIBS
clangBasic
clangRewriteCore
clangTooling
Index: clang-tools-extra/clang-modernize/Core/CMakeLists.txt
===================================================================
--- clang-tools-extra/clang-modernize/Core/CMakeLists.txt
+++ clang-tools-extra/clang-modernize/Core/CMakeLists.txt
@@ -7,8 +7,8 @@
IncludeExcludeInfo.cpp
PerfSupport.cpp
IncludeDirectives.cpp
- )
-target_link_libraries(modernizeCore
+
+ LINK_LIBS
clangAST
clangASTMatchers
clangBasic
Index: clang-tools-extra/clang-query/CMakeLists.txt
===================================================================
--- clang-tools-extra/clang-query/CMakeLists.txt
+++ clang-tools-extra/clang-query/CMakeLists.txt
@@ -6,8 +6,8 @@
add_clang_library(clangQuery
Query.cpp
QueryParser.cpp
- )
-target_link_libraries(clangQuery
+
+ LINK_LIBS
clangAST
clangASTMatchers
clangBasic
Index: clang-tools-extra/clang-tidy/CMakeLists.txt
===================================================================
--- clang-tools-extra/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/CMakeLists.txt
@@ -9,8 +9,8 @@
DEPENDS
ClangSACheckers
- )
-target_link_libraries(clangTidy
+
+ LINK_LIBS
clangAST
clangASTMatchers
clangBasic
Index: clang-tools-extra/clang-tidy/google/CMakeLists.txt
===================================================================
--- clang-tools-extra/clang-tidy/google/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/google/CMakeLists.txt
@@ -2,8 +2,8 @@
add_clang_library(clangTidyGoogleModule
GoogleTidyModule.cpp
- )
-target_link_libraries(clangTidyGoogleModule
+
+ LINK_LIBS
clangAST
clangASTMatchers
clangBasic
Index: clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
===================================================================
--- clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
@@ -2,8 +2,8 @@
add_clang_library(clangTidyLLVMModule
LLVMTidyModule.cpp
- )
-target_link_libraries(clangTidyLLVMModule
+
+ LINK_LIBS
clangAST
clangASTMatchers
clangBasic
Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.8.8)
+cmake_minimum_required(VERSION 2.8.12)
# If we are not building as a part of LLVM, build Clang as an
# standalone project, using LLVM as an external library:
@@ -312,7 +312,7 @@
llvm_add_library(${name} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
if(TARGET ${name})
- target_link_libraries( ${name} ${LLVM_COMMON_LIBS} )
+ target_link_libraries(${name} INTERFACE ${LLVM_COMMON_LIBS})
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libclang")
install(TARGETS ${name}
Index: clang/lib/ARCMigrate/CMakeLists.txt
===================================================================
--- clang/lib/ARCMigrate/CMakeLists.txt
+++ clang/lib/ARCMigrate/CMakeLists.txt
@@ -23,9 +23,8 @@
TransZeroOutPropsInDealloc.cpp
TransformActions.cpp
Transforms.cpp
- )
-target_link_libraries(clangARCMigrate
+ LINK_LIBS
clangAST
clangAnalysis
clangBasic
Index: clang/lib/AST/CMakeLists.txt
===================================================================
--- clang/lib/AST/CMakeLists.txt
+++ clang/lib/AST/CMakeLists.txt
@@ -57,9 +57,8 @@
TypePrinter.cpp
VTableBuilder.cpp
VTTBuilder.cpp
- )
-target_link_libraries(clangAST
+ LINK_LIBS
clangBasic
clangLex
)
Index: clang/lib/ASTMatchers/CMakeLists.txt
===================================================================
--- clang/lib/ASTMatchers/CMakeLists.txt
+++ clang/lib/ASTMatchers/CMakeLists.txt
@@ -5,8 +5,7 @@
add_clang_library(clangASTMatchers
ASTMatchFinder.cpp
ASTMatchersInternal.cpp
- )
-target_link_libraries(clangASTMatchers
+ LINK_LIBS
clangAST
)
Index: clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
===================================================================
--- clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
+++ clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
@@ -5,9 +5,8 @@
VariantValue.cpp
Parser.cpp
Registry.cpp
- )
-target_link_libraries(clangDynamicASTMatchers
+ LINK_LIBS
clangAST
clangASTMatchers
clangBasic
Index: clang/lib/Analysis/CMakeLists.txt
===================================================================
--- clang/lib/Analysis/CMakeLists.txt
+++ clang/lib/Analysis/CMakeLists.txt
@@ -24,9 +24,8 @@
ScanfFormatString.cpp
ThreadSafety.cpp
UninitializedValues.cpp
- )
-target_link_libraries(clangAnalysis
+ LINK_LIBS
clangBasic
clangAST
)
Index: clang/lib/CodeGen/CMakeLists.txt
===================================================================
--- clang/lib/CodeGen/CMakeLists.txt
+++ clang/lib/CodeGen/CMakeLists.txt
@@ -58,9 +58,11 @@
MicrosoftCXXABI.cpp
ModuleBuilder.cpp
TargetInfo.cpp
- )
-target_link_libraries(clangCodeGen
+ DEPENDS
+ intrinsics_gen
+
+ LINK_LIBS
clangBasic
clangAST
clangFrontend
Index: clang/lib/Driver/CMakeLists.txt
===================================================================
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -24,8 +24,7 @@
DEPENDS
ClangCC1AsOptions
ClangDriverOptions
- )
-target_link_libraries(clangDriver
+ LINK_LIBS
clangBasic
)
Index: clang/lib/Edit/CMakeLists.txt
===================================================================
--- clang/lib/Edit/CMakeLists.txt
+++ clang/lib/Edit/CMakeLists.txt
@@ -6,9 +6,8 @@
Commit.cpp
EditedSource.cpp
RewriteObjCFoundationAPI.cpp
- )
-target_link_libraries(clangEdit
+ LINK_LIBS
clangBasic
clangAST
clangLex
Index: clang/lib/Format/CMakeLists.txt
===================================================================
--- clang/lib/Format/CMakeLists.txt
+++ clang/lib/Format/CMakeLists.txt
@@ -8,9 +8,8 @@
TokenAnnotator.cpp
UnwrappedLineParser.cpp
WhitespaceManager.cpp
- )
-target_link_libraries(clangFormat
+ LINK_LIBS
clangBasic
clangLex
clangTooling
Index: clang/lib/Frontend/CMakeLists.txt
===================================================================
--- clang/lib/Frontend/CMakeLists.txt
+++ clang/lib/Frontend/CMakeLists.txt
@@ -36,9 +36,8 @@
DEPENDS
ClangDriverOptions
- )
-target_link_libraries(clangFrontend
+ LINK_LIBS
clangAST
clangBasic
clangDriver
Index: clang/lib/FrontendTool/CMakeLists.txt
===================================================================
--- clang/lib/FrontendTool/CMakeLists.txt
+++ clang/lib/FrontendTool/CMakeLists.txt
@@ -3,29 +3,32 @@
Support
)
-add_clang_library(clangFrontendTool
- ExecuteCompilerInvocation.cpp
-
- DEPENDS
- ClangDriverOptions
- )
-
-target_link_libraries(clangFrontendTool
+set(link_libs
clangBasic
clangCodeGen
clangDriver
clangFrontend
clangRewriteFrontend
)
if(CLANG_ENABLE_ARCMT)
- target_link_libraries(clangFrontendTool
+ list(APPEND link_libs
clangARCMigrate
)
endif()
if(CLANG_ENABLE_STATIC_ANALYZER)
- target_link_libraries(clangFrontendTool
+ list(APPEND link_libs
clangStaticAnalyzerFrontend
)
endif()
+
+add_clang_library(clangFrontendTool
+ ExecuteCompilerInvocation.cpp
+
+ DEPENDS
+ ClangDriverOptions
+
+ LINK_LIBS
+ ${link_libs}
+ )
Index: clang/lib/Index/CMakeLists.txt
===================================================================
--- clang/lib/Index/CMakeLists.txt
+++ clang/lib/Index/CMakeLists.txt
@@ -8,9 +8,8 @@
ADDITIONAL_HEADERS
SimpleFormatContext.h
- )
-target_link_libraries(clangIndex
+ LINK_LIBS
clangAST
clangBasic
clangFormat
Index: clang/lib/Lex/CMakeLists.txt
===================================================================
--- clang/lib/Lex/CMakeLists.txt
+++ clang/lib/Lex/CMakeLists.txt
@@ -25,8 +25,7 @@
ScratchBuffer.cpp
TokenConcatenation.cpp
TokenLexer.cpp
- )
-target_link_libraries(clangLex
+ LINK_LIBS
clangBasic
)
Index: clang/lib/Parse/CMakeLists.txt
===================================================================
--- clang/lib/Parse/CMakeLists.txt
+++ clang/lib/Parse/CMakeLists.txt
@@ -19,9 +19,8 @@
ParseTemplate.cpp
ParseTentative.cpp
Parser.cpp
- )
-target_link_libraries(clangParse
+ LINK_LIBS
clangBasic
clangAST
clangLex
Index: clang/lib/Rewrite/Core/CMakeLists.txt
===================================================================
--- clang/lib/Rewrite/Core/CMakeLists.txt
+++ clang/lib/Rewrite/Core/CMakeLists.txt
@@ -8,9 +8,8 @@
RewriteRope.cpp
Rewriter.cpp
TokenRewriter.cpp
- )
-target_link_libraries(clangRewriteCore
+ LINK_LIBS
clangAST
clangBasic
clangLex
Index: clang/lib/Rewrite/Frontend/CMakeLists.txt
===================================================================
--- clang/lib/Rewrite/Frontend/CMakeLists.txt
+++ clang/lib/Rewrite/Frontend/CMakeLists.txt
@@ -11,9 +11,8 @@
RewriteModernObjC.cpp
RewriteObjC.cpp
RewriteTest.cpp
- )
-target_link_libraries(clangRewriteFrontend
+ LINK_LIBS
clangAST
clangBasic
clangEdit
Index: clang/lib/Sema/CMakeLists.txt
===================================================================
--- clang/lib/Sema/CMakeLists.txt
+++ clang/lib/Sema/CMakeLists.txt
@@ -48,9 +48,8 @@
SemaTemplateVariadic.cpp
SemaType.cpp
TypeLocBuilder.cpp
- )
-target_link_libraries(clangSema
+ LINK_LIBS
clangAST
clangAnalysis
clangBasic
Index: clang/lib/Serialization/CMakeLists.txt
===================================================================
--- clang/lib/Serialization/CMakeLists.txt
+++ clang/lib/Serialization/CMakeLists.txt
@@ -20,9 +20,8 @@
ADDITIONAL_HEADERS
ASTCommon.h
ASTReaderInternals.h
- )
-target_link_libraries(clangSerialization
+ LINK_LIBS
clangAST
clangBasic
clangLex
Index: clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -77,9 +77,8 @@
DEPENDS
ClangSACheckers
- )
-target_link_libraries(clangStaticAnalyzerCheckers
+ LINK_LIBS
clangAST
clangAnalysis
clangBasic
Index: clang/lib/StaticAnalyzer/Core/CMakeLists.txt
===================================================================
--- clang/lib/StaticAnalyzer/Core/CMakeLists.txt
+++ clang/lib/StaticAnalyzer/Core/CMakeLists.txt
@@ -39,9 +39,8 @@
Store.cpp
SubEngine.cpp
SymbolManager.cpp
- )
-target_link_libraries(clangStaticAnalyzerCore
+ LINK_LIBS
clangAST
clangAnalysis
clangBasic
Index: clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
===================================================================
--- clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
+++ clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
@@ -8,9 +8,8 @@
AnalysisConsumer.cpp
CheckerRegistration.cpp
FrontendActions.cpp
- )
-target_link_libraries(clangStaticAnalyzerFrontend
+ LINK_LIBS
clangAST
clangAnalysis
clangBasic
Index: clang/lib/Tooling/CMakeLists.txt
===================================================================
--- clang/lib/Tooling/CMakeLists.txt
+++ clang/lib/Tooling/CMakeLists.txt
@@ -9,9 +9,8 @@
Refactoring.cpp
RefactoringCallbacks.cpp
Tooling.cpp
- )
-target_link_libraries(clangTooling
+ LINK_LIBS
clangAST
clangASTMatchers
clangBasic
Index: compiler-rt/CMakeLists.txt
===================================================================
--- compiler-rt/CMakeLists.txt
+++ compiler-rt/CMakeLists.txt
@@ -20,7 +20,7 @@
# .o files. This is particularly useful in producing larger, more complex
# runtime libraries.
if (NOT MSVC)
- cmake_minimum_required(VERSION 2.8.8)
+ cmake_minimum_required(VERSION 2.8.12)
else()
# Version 2.8.12.1 is required to build with Visual Studion 2013.
cmake_minimum_required(VERSION 2.8.12.1)
Index: lld/lib/Core/CMakeLists.txt
===================================================================
--- lld/lib/Core/CMakeLists.txt
+++ lld/lib/Core/CMakeLists.txt
@@ -11,7 +11,7 @@
SymbolTable.cpp
)
-target_link_libraries(lldCore
+target_link_libraries(lldCore INTERFACE
lldNative
lldYAML
)
Index: lld/lib/ReaderWriter/CMakeLists.txt
===================================================================
--- lld/lib/ReaderWriter/CMakeLists.txt
+++ lld/lib/ReaderWriter/CMakeLists.txt
@@ -1,10 +1,11 @@
-set(LLVM_LINK_COMPONENTS object)
-
add_subdirectory(ELF)
add_subdirectory(MachO)
add_subdirectory(Native)
add_subdirectory(PECOFF)
add_subdirectory(YAML)
+
+set(LLVM_LINK_COMPONENTS object)
+
add_lld_library(lldReaderWriter
CoreLinkingContext.cpp
FileArchive.cpp
@@ -14,7 +15,7 @@
FileArchive.cpp
)
-target_link_libraries(lldReaderWriter
+target_link_libraries(lldReaderWriter INTERFACE
lldCore
lldPasses
)
Index: llvm/CMakeLists.txt
===================================================================
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -1,6 +1,6 @@
# See docs/CMake.html for instructions about how to build LLVM with CMake.
-cmake_minimum_required(VERSION 2.8.8)
+cmake_minimum_required(VERSION 2.8.12)
project(LLVM)
# Add path for custom modules
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -289,7 +289,12 @@
endif()
endif()
- target_link_libraries(${name} ${ARG_LINK_LIBS})
+ if(ARG_STATIC)
+ target_link_libraries(${name} INTERFACE ${ARG_LINK_LIBS})
+ else()
+ # MODULE|SHARED
+ target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})
+ endif()
llvm_config(${name} ${ARG_LINK_COMPONENTS} ${LLVM_LINK_COMPONENTS})
@@ -330,7 +335,7 @@
# name, but using get_property(... SET) doesn't suffice to determine if a
# property has been set to an empty value.
get_property(lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${name})
- target_link_libraries(${name} ${lib_deps})
+ target_link_libraries(${name} INTERFACE ${lib_deps})
endmacro(add_llvm_library name)
macro(add_llvm_loadable_module name)
Index: llvm/cmake/modules/LLVM-Config.cmake
===================================================================
--- llvm/cmake/modules/LLVM-Config.cmake
+++ llvm/cmake/modules/LLVM-Config.cmake
@@ -39,7 +39,15 @@
set( link_components ${ARGN} )
llvm_map_components_to_libnames(LIBRARIES ${link_components})
- target_link_libraries(${executable} ${LIBRARIES})
+ get_target_property(t ${executable} TYPE)
+ if("${t}" STREQUAL "STATIC_LIBRARY")
+ target_link_libraries(${executable} INTERFACE ${LIBRARIES})
+ elseif("${t}" STREQUAL "SHARED_LIBRARY" OR "${t}" STREQUAL "MODULE_LIBRARY")
+ target_link_libraries(${executable} PRIVATE ${LIBRARIES})
+ else()
+ # Use plain form for legacy user.
+ target_link_libraries(${executable} ${LIBRARIES})
+ endif()
endfunction(explicit_llvm_config)
Index: llvm/lib/LineEditor/CMakeLists.txt
===================================================================
--- llvm/lib/LineEditor/CMakeLists.txt
+++ llvm/lib/LineEditor/CMakeLists.txt
@@ -1,7 +1,11 @@
+if(HAVE_LIBEDIT)
+ set(link_libs edit)
+endif()
+
add_llvm_library(LLVMLineEditor
LineEditor.cpp
- )
-if(HAVE_LIBEDIT)
- target_link_libraries(LLVMLineEditor edit)
-endif()
+ LINK_LIBS
+ LLVMSupport
+ ${link_libs}
+)
Index: llvm/lib/Support/CMakeLists.txt
===================================================================
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -142,5 +142,5 @@
endif()
endif( MINGW )
endif( NOT MSVC )
-target_link_libraries(LLVMSupport ${system_libs})
+target_link_libraries(LLVMSupport INTERFACE ${system_libs})
set_property(TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS "${system_libs}")
Index: llvm/utils/unittest/CMakeLists.txt
===================================================================
--- llvm/utils/unittest/CMakeLists.txt
+++ llvm/utils/unittest/CMakeLists.txt
@@ -40,11 +40,9 @@
add_llvm_library(gtest
googletest/src/gtest-all.cc
- )
-# Depends on llvm::raw_ostream
-target_link_libraries(gtest
- LLVMSupport
+ LINK_LIBS
+ LLVMSupport # Depends on llvm::raw_ostream
)
add_subdirectory(UnitTestMain)
Index: llvm/utils/unittest/UnitTestMain/CMakeLists.txt
===================================================================
--- llvm/utils/unittest/UnitTestMain/CMakeLists.txt
+++ llvm/utils/unittest/UnitTestMain/CMakeLists.txt
@@ -1,9 +1,7 @@
add_llvm_library(gtest_main
TestMain.cpp
- )
-# Depends on llvm::cl
-target_link_libraries(gtest_main
+ LINK_LIBS
gtest
- LLVMSupport
+ LLVMSupport # Depends on llvm::cl
)
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits