[compiler-rt] r248542 - [CMake] [darwin] [builtins] Refactoring code to filter builtin lists out into a function. NFC.

Chris Bieneman via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 14:40:07 PDT 2015


Author: cbieneman
Date: Thu Sep 24 16:40:06 2015
New Revision: 248542

URL: http://llvm.org/viewvc/llvm-project?rev=248542&view=rev
Log:
[CMake] [darwin] [builtins] Refactoring code to filter builtin lists out into a function. NFC.

Modified:
    compiler-rt/trunk/cmake/Modules/CompilerRTDarwinUtils.cmake

Modified: compiler-rt/trunk/cmake/Modules/CompilerRTDarwinUtils.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/Modules/CompilerRTDarwinUtils.cmake?rev=248542&r1=248541&r2=248542&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/Modules/CompilerRTDarwinUtils.cmake (original)
+++ compiler-rt/trunk/cmake/Modules/CompilerRTDarwinUtils.cmake Thu Sep 24 16:40:06 2015
@@ -184,6 +184,25 @@ function(darwin_lipo_libs name)
   add_dependencies(${LIB_PARENT_TARGET} ${name})
 endfunction()
 
+# Filter out generic versions of routines that are re-implemented in
+# architecture specific manner.  This prevents multiple definitions of the
+# same symbols, making the symbol selection non-deterministic.
+function(darwin_filter_builtin_sources output_var excluded_list)
+  set(intermediate ${ARGN})
+  foreach (_file ${intermediate})
+    get_filename_component(_name_we ${_file} NAME_WE)
+    list(FIND ${excluded_list} ${_name_we} _found)
+    if(_found GREATER -1)
+      list(REMOVE_ITEM intermediate ${_file})
+    elseif(${_file} MATCHES ".*/.*\\.S")
+      get_filename_component(_name ${_file} NAME)
+      string(REPLACE ".S" ".c" _cname "${_name}")
+      list(REMOVE_ITEM intermediate ${_cname})
+    endif ()
+  endforeach ()
+  set(${output_var} ${intermediate} PARENT_SCOPE)
+endfunction()
+
 # Generates builtin libraries for all operating systems specified in ARGN. Each
 # OS library is constructed by lipo-ing together single-architecture libraries.
 macro(darwin_add_builtin_libraries)
@@ -213,25 +232,13 @@ macro(darwin_add_builtin_libraries)
 
 
       darwin_find_excluded_builtins_list(${os} ${arch} ${DARWIN_${os}_BUILTIN_MIN_VER})
-      # Filter out generic versions of routines that are re-implemented in
-      # architecture specific manner.  This prevents multiple definitions of the
-      # same symbols, making the symbol selection non-deterministic.
-      foreach (_file ${${arch}_SOURCES})
-        get_filename_component(_name_we ${_file} NAME_WE)
-        list(FIND ${arch}_${os}_EXCLUDED_BUILTINS ${_name_we} _found)
-        if(_found GREATER -1)
-          list(REMOVE_ITEM ${arch}_SOURCES ${_file})
-        elseif(${_file} MATCHES ${arch}/*)
-          get_filename_component(_name ${_file} NAME)
-          string(REPLACE ".S" ".c" _cname "${_name}")
-          list(REMOVE_ITEM ${arch}_SOURCES ${_cname})
-        endif ()
-      endforeach ()
+      
+      darwin_filter_builtin_sources(filtered_sources ${arch}_${os}_EXCLUDED_BUILTINS ${${arch}_SOURCES})
 
       darwin_add_builtin_library(clang_rt builtins
                               OS ${os}
                               ARCH ${arch}
-                              SOURCES ${${arch}_SOURCES}
+                              SOURCES ${filtered_sources}
                               CFLAGS -arch ${arch}
                               PARENT_TARGET builtins)
     endforeach()




More information about the llvm-commits mailing list