[PATCH] D109611: Fix CLANG_ENABLE_STATIC_ANALYZER=OFF building all analyzer source
Alexander Richardson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 20 04:56:32 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6d7b3d6b3a8d: Fix CLANG_ENABLE_STATIC_ANALYZER=OFF building all analyzer source (authored by arichardson).
Changed prior to commit:
https://reviews.llvm.org/D109611?vs=371944&id=373554#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109611/new/
https://reviews.llvm.org/D109611
Files:
clang/cmake/modules/AddClang.cmake
clang/lib/StaticAnalyzer/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -429,10 +429,13 @@
# This is used to specify that this is a component library of
# LLVM which means that the source resides in llvm/lib/ and it is a
# candidate for inclusion into libLLVM.so.
+# EXCLUDE_FROM_ALL
+# Do not build this library as part of the default target, only
+# if explicitly requested or when linked against.
# )
function(llvm_add_library name)
cmake_parse_arguments(ARG
- "MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH;COMPONENT_LIB"
+ "MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH;COMPONENT_LIB;EXCLUDE_FROM_ALL"
"OUTPUT_NAME;PLUGIN_TOOL;ENTITLEMENTS;BUNDLE_PATH"
"ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS"
${ARGN})
@@ -535,6 +538,9 @@
# FIXME: Add name_static to anywhere in TARGET ${name}'s PROPERTY.
set(ARG_STATIC)
+ if(ARG_EXCLUDE_FROM_ALL OR EXCLUDE_FROM_ALL)
+ set_target_properties(${name_static} PROPERTIES EXCLUDE_FROM_ALL ON)
+ endif()
endif()
if(ARG_MODULE)
@@ -546,6 +552,10 @@
add_library(${name} STATIC ${ALL_FILES})
endif()
+ if(ARG_EXCLUDE_FROM_ALL OR EXCLUDE_FROM_ALL)
+ set_target_properties(${name} PROPERTIES EXCLUDE_FROM_ALL ON)
+ endif()
+
if(ARG_COMPONENT_LIB)
set_target_properties(${name} PROPERTIES LLVM_COMPONENT TRUE)
set_property(GLOBAL APPEND PROPERTY LLVM_COMPONENT_LIBS ${name})
Index: clang/lib/StaticAnalyzer/CMakeLists.txt
===================================================================
--- clang/lib/StaticAnalyzer/CMakeLists.txt
+++ clang/lib/StaticAnalyzer/CMakeLists.txt
@@ -1,3 +1,10 @@
+# These directories can significantly impact build time, only build
+# them if anything depends on the clangStaticAnalyzer* libraries.
+if(NOT CLANG_ENABLE_STATIC_ANALYZER)
+ set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL ON)
+ set(EXCLUDE_FROM_ALL ON)
+endif()
+
add_subdirectory(Core)
add_subdirectory(Checkers)
add_subdirectory(Frontend)
Index: clang/cmake/modules/AddClang.cmake
===================================================================
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -100,7 +100,12 @@
# The Xcode generator doesn't handle object libraries correctly.
list(APPEND LIBTYPE OBJECT)
endif()
- set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
+ if (NOT EXCLUDE_FROM_ALL)
+ # Only include libraries that don't have EXCLUDE_FROM_ALL set. This
+ # ensure that the clang static analyzer libraries are not compiled
+ # as part of clang-shlib if CLANG_ENABLE_STATIC_ANALYZER=OFF.
+ set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
+ endif()
endif()
llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
@@ -110,8 +115,11 @@
endif()
foreach(lib ${libs})
- if(TARGET ${lib})
+ if(TARGET ${lib})
target_link_libraries(${lib} INTERFACE ${LLVM_COMMON_LIBS})
+ if (EXCLUDE_FROM_ALL)
+ continue()
+ endif()
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)
get_target_export_arg(${name} Clang export_to_clangtargets UMBRELLA clang-libraries)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109611.373554.patch
Type: text/x-patch
Size: 3415 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210920/51046227/attachment.bin>
More information about the llvm-commits
mailing list