[compiler-rt] r246487 - [CMake] Fix building builtins on Linux and Darwin.

Chris Bieneman via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 31 14:24:51 PDT 2015


Author: cbieneman
Date: Mon Aug 31 16:24:50 2015
New Revision: 246487

URL: http://llvm.org/viewvc/llvm-project?rev=246487&view=rev
Log:
[CMake] Fix building builtins on Linux and Darwin.

Summary:
I broke building the builtins with r245967. This fixes them on Linux and builds them properly for Darwin.

The old code could not be made to work on Darwin as a result of the refactoring of add_compiler_rt_runtime, so I had to rework the way they are built for Darwin. This solution is not ideal and will be fixed in subsequent commits. I just want to get this in so everything is working again.

Reviewers: samsonov, chh, compnerd, bogner

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12500

Modified:
    compiler-rt/trunk/cmake/config-ix.cmake
    compiler-rt/trunk/lib/builtins/CMakeLists.txt

Modified: compiler-rt/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=246487&r1=246486&r2=246487&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake (original)
+++ compiler-rt/trunk/cmake/config-ix.cmake Mon Aug 31 16:24:50 2015
@@ -258,6 +258,7 @@ if(APPLE)
   set(X86_64 x86_64 x86_64h)
 endif()
 
+set(ALL_BUILTIN_SUPPORTED_ARCH i386 i686 ${X86_64} ${ARM32} ${ARM64})
 set(ALL_SANITIZER_COMMON_SUPPORTED_ARCH ${X86_64} i386 i686 powerpc64
   powerpc64le ${ARM32} ${ARM64} mips mips64 mipsel mips64el)
 set(ALL_ASAN_SUPPORTED_ARCH ${X86_64} i386 i686 powerpc64 powerpc64le ${ARM32}
@@ -380,6 +381,8 @@ if(APPLE)
   # for list_union
   include(CompilerRTUtils)
 
+  list_union(BUILTIN_SUPPORTED_ARCH ALL_BUILTIN_SUPPORTED_ARCH toolchain_arches)
+
   list_union(SANITIZER_COMMON_SUPPORTED_ARCH
     ALL_SANITIZER_COMMON_SUPPORTED_ARCH
     COMPILER_RT_SUPPORTED_ARCH
@@ -413,6 +416,8 @@ if(APPLE)
     SANITIZER_COMMON_SUPPORTED_ARCH)
 else()
   # Architectures supported by compiler-rt libraries.
+  filter_available_targets(BUILTIN_SUPPORTED_ARCH
+    ${ALL_BUILTIN_SUPPORTED_ARCH})
   filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH
     ${ALL_SANITIZER_COMMON_SUPPORTED_ARCH})
   # LSan and UBSan common files should be available on all architectures

Modified: compiler-rt/trunk/lib/builtins/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/CMakeLists.txt?rev=246487&r1=246486&r2=246487&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/builtins/CMakeLists.txt Mon Aug 31 16:24:50 2015
@@ -159,6 +159,7 @@ set(x86_64_SOURCES
   x86_64/floatundisf.S
   x86_64/floatundixf.S
   ${GENERIC_SOURCES})
+set(x86_64h_SOURCES ${x86_64_SOURCES})
 
 if(WIN32)
   set(x86_64_SOURCES
@@ -301,14 +302,54 @@ set(aarch64_SOURCES
   trunctfsf2.c
   ${GENERIC_SOURCES})
 
+set(armv7_SOURCES ${arm_SOURCES})
+set(armv7s_SOURCES ${arm_SOURCES})
+set(arm64_SOURCES ${aarch64_SOURCES})
+
 add_custom_target(builtins)
 
-if(APPLE)
-  set(OS_OPTION OS osx)
-endif()
+if (APPLE)
+  foreach (os osx)
+    list_union(DARWIN_BUILTIN_ARCHS DARWIN_${os}_ARCHS BUILTIN_SUPPORTED_ARCH)
+    set(${os}_builtin_libs)
+    set(${os}_builtin_lipo_flags)
+    foreach (arch ${DARWIN_BUILTIN_ARCHS})
+      # 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})
+        if (${_file} MATCHES ${arch}/*)
+          get_filename_component(_name ${_file} NAME)
+          string(REPLACE ".S" ".c" _cname "${_name}")
+          list(REMOVE_ITEM ${arch}_SOURCES ${_cname})
+        endif ()
+      endforeach ()
 
-if (NOT WIN32 OR MINGW)
-  foreach (arch x86_64 i386 i686 arm aarch64)
+      add_compiler_rt_runtime(clang_rt.builtins_${arch} STATIC
+                              OS ${os}
+                              ARCHS ${arch}
+                              SOURCES ${${arch}_SOURCES}
+                              CFLAGS "-std=c99" ${DARWIN_${os}_CFLAGS} -arch ${arch}
+                              PARENT_TARGET builtins)
+      list(APPEND ${os}_builtin_libs clang_rt.builtins_${arch}_${os})
+      list(APPEND ${os}_builtin_lipo_flags -arch ${arch} 
+        ${COMPILER_RT_LIBRARY_OUTPUT_DIR}/libclang_rt.builtins_${arch}_${os}.a)
+    endforeach()
+
+    if(${os}_builtin_libs)
+      add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clang_rt.builtins_${os}.a
+        COMMAND lipo -output
+                ${COMPILER_RT_LIBRARY_OUTPUT_DIR}/clang_rt.builtins_${os}.a
+                -create ${${os}_builtin_lipo_flags}
+        DEPENDS ${${os}_builtin_libs}
+        )
+      add_custom_target(clang_rt.builtins_${os}
+        DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clang_rt.builtins_${os}.a)
+      add_dependencies(builtins clang_rt.builtins_${os})
+    endif()
+  endforeach()
+elseif (NOT WIN32 OR MINGW)
+  foreach (arch ${BUILTIN_SUPPORTED_ARCH})
     if (CAN_TARGET_${arch})
       # Filter out generic versions of routines that are re-implemented in
       # architecture specific manner.  This prevents multiple definitions of the
@@ -323,8 +364,7 @@ if (NOT WIN32 OR MINGW)
 
       add_compiler_rt_runtime(clang_rt.builtins
                               STATIC
-                              ARCH ${arch}
-                              ${OS_OPTION}
+                              ARCHS ${arch}
                               SOURCES ${${arch}_SOURCES}
                               CFLAGS "-std=c99"
                               PARENT_TARGET builtins)




More information about the llvm-commits mailing list