This has similar effect as simply deleting the static libraries which we don't
want after installation. By not copying them in the first place we reduce the
disk usage during installation.

Index: llvm-6.0.0.src/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm-6.0.0.src.orig/cmake/modules/AddLLVM.cmake
+++ llvm-6.0.0.src/cmake/modules/AddLLVM.cmake
@@ -639,10 +639,19 @@ macro(add_llvm_library name)
         set_property(GLOBAL PROPERTY LLVM_HAS_EXPORTS True)
       endif()
 
-      install(TARGETS ${name}
-              ${export_to_llvmexports}
-              ${install_type} DESTINATION ${install_dir}
-              COMPONENT ${name})
+      if(ARG_SHARED)
+        install(TARGETS ${name}
+                ${export_to_llvmexports}
+                ${install_type} DESTINATION ${install_dir}
+                COMPONENT ${name})
+      else()
+        if(NOT LLVM_BUILD_LLVM_DYLIB)
+          install(TARGETS ${name}
+                  ${export_to_llvmexports}
+                  ${install_type} DESTINATION ${install_dir}
+                  COMPONENT ${name})
+        endif()
+      endif()
 
       if (NOT CMAKE_CONFIGURATION_TYPES)
         add_llvm_install_targets(install-${name}
Index: llvm-6.0.0.src/lld-6.0.0.src/cmake/modules/AddLLD.cmake
===================================================================
--- llvm-6.0.0.src.orig/lld-6.0.0.src/cmake/modules/AddLLD.cmake
+++ llvm-6.0.0.src/lld-6.0.0.src/cmake/modules/AddLLD.cmake
@@ -17,13 +17,6 @@ macro(add_lld_library name)
       set_property(GLOBAL PROPERTY LLD_HAS_EXPORTS True)
     endif()
 
-    install(TARGETS ${name}
-      COMPONENT ${name}
-      ${export_to_lldtargets}
-      LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-      ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-      RUNTIME DESTINATION bin)
-
     if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
       add_llvm_install_targets(install-${name}
         DEPENDS ${name}
Index: llvm-6.0.0.src/lldb-6.0.0.src/cmake/modules/AddLLDB.cmake
===================================================================
--- llvm-6.0.0.src.orig/lldb-6.0.0.src/cmake/modules/AddLLDB.cmake
+++ llvm-6.0.0.src/lldb-6.0.0.src/cmake/modules/AddLLDB.cmake
@@ -60,10 +60,12 @@ function(add_lldb_library name)
           LIBRARY DESTINATION ${out_dir}
           ARCHIVE DESTINATION ${out_dir})
       else()
-        install(TARGETS ${name}
-          COMPONENT ${name}
-          LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-          ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
+        if(NOT LLVM_BUILD_LLVM_DYLIB)
+          install(TARGETS ${name}
+            COMPONENT ${name}
+            LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+            ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
+        endif()
       endif()
       if (NOT CMAKE_CONFIGURATION_TYPES)
         add_llvm_install_targets(install-${name}
Index: llvm-6.0.0.src/polly-6.0.0.src/cmake/polly_macros.cmake
===================================================================
--- llvm-6.0.0.src.orig/polly-6.0.0.src/cmake/polly_macros.cmake
+++ llvm-6.0.0.src/polly-6.0.0.src/cmake/polly_macros.cmake
@@ -42,12 +42,22 @@ macro(add_polly_library name)
     llvm_config(${name} ${LLVM_LINK_COMPONENTS})
   endif( LLVM_LINK_COMPONENTS )
   if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LLVMPolly")
-    install(TARGETS ${name}
-      EXPORT LLVMExports
-      LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-      ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
+    if (MODULE OR SHARED_LIBRARY)
+      install(TARGETS ${name}
+        EXPORT LLVMExports
+        LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+        ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
+      set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
+    else()
+      if(NOT LLVM_BUILD_LLVM_DYLIB)
+        install(TARGETS ${name}
+          EXPORT LLVMExports
+          LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+          ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
+        set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
+      endif()
+    endif()
   endif()
-  set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
 endmacro(add_polly_library)
 
 macro(add_polly_loadable_module name)
Index: llvm-6.0.0.src/polly-6.0.0.src/lib/CMakeLists.txt
===================================================================
--- llvm-6.0.0.src.orig/polly-6.0.0.src/lib/CMakeLists.txt
+++ llvm-6.0.0.src/polly-6.0.0.src/lib/CMakeLists.txt
@@ -145,7 +145,7 @@ else ()
   # hosts. This is not the case for bugpoint. Use LLVM_POLLY_LINK_INTO_TOOLS=ON
   # instead which will automatically resolve the additional dependencies by
   # Polly.
-  target_link_libraries(LLVMPolly ${ISL_TARGET} ${JSONCPP_LIBRARIES})
+  target_link_libraries(LLVMPolly PRIVATE ${ISL_TARGET} ${JSONCPP_LIBRARIES})
   if (GPU_CODEGEN)
     target_link_libraries(LLVMPolly PollyPPCG)
   endif ()
