[CMake] [Darwin] [builtins] Apply OS and OS-arch filters to cc_kext builtin libraries.

We don't want to filter out the builtins that are present in libSystem like we do for the normal builtins because kexts can't link libSystem, but we should filter out all the builtins that are generally not supported on the OS and architecture.

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@248756 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/cmake/Modules/CompilerRTDarwinUtils.cmake b/cmake/Modules/CompilerRTDarwinUtils.cmake
index b09f367..1e017b8 100644
--- a/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ b/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -272,11 +272,22 @@
     # Don't build cc_kext libraries for simulator platforms
     if(NOT ${os} MATCHES ".*sim$")
       foreach (arch ${DARWIN_BUILTIN_ARCHS})
+        # By not specifying MIN_VERSION this only reads the OS and OS-arch lists.
+        # We don't want to filter out the builtins that are present in libSystem
+        # because kexts can't link libSystem.
+        darwin_find_excluded_builtins_list(${arch}_${os}_EXCLUDED_BUILTINS
+                              OS ${os}
+                              ARCH ${arch})
+
+        darwin_filter_builtin_sources(filtered_sources
+          EXCLUDE ${arch}_${os}_EXCLUDED_BUILTINS
+          ${${arch}_SOURCES})
+
         # In addition to the builtins cc_kext includes some profile sources
         darwin_add_builtin_library(clang_rt cc_kext
                                 OS ${os}
                                 ARCH ${arch}
-                                SOURCES ${${arch}_SOURCES} ${PROFILE_SOURCES}
+                                SOURCES ${filtered_sources} ${PROFILE_SOURCES}
                                 CFLAGS -arch ${arch} -mkernel
                                 DEFS KERNEL_USE
                                 PARENT_TARGET builtins)