[compiler-rt] r248383 - [CMake] [Darwin] Bug 21562 - Add a CMake equivalent for make/platform/clang_darwin.mk in compiler_rt
Chris Bieneman via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 23 08:18:18 PDT 2015
Author: cbieneman
Date: Wed Sep 23 10:18:17 2015
New Revision: 248383
URL: http://llvm.org/viewvc/llvm-project?rev=248383&view=rev
Log:
[CMake] [Darwin] Bug 21562 - Add a CMake equivalent for make/platform/clang_darwin.mk in compiler_rt
Summary:
Building the builtins on Darwin platforms is a bit complicated. This is a first-pass implementation of the functionality from clang_darwin.mk into CMake.
When building the builtins on Darwin we have layers of blacklists that we apply based on platform, architecture, and minimum supported OS version.
Reviewers: bogner, filcab, bob.wilson, samsonov
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D13059
Added:
compiler-rt/trunk/lib/builtins/Darwin-excludes/
compiler-rt/trunk/lib/builtins/Darwin-excludes/README.TXT
compiler-rt/trunk/lib/builtins/Darwin-excludes/ios.txt
compiler-rt/trunk/lib/builtins/Darwin-excludes/ios6-armv7.txt
compiler-rt/trunk/lib/builtins/Darwin-excludes/ios6-armv7s.txt
compiler-rt/trunk/lib/builtins/Darwin-excludes/ios7-arm64.txt
Modified:
compiler-rt/trunk/cmake/Modules/CompilerRTDarwinUtils.cmake
compiler-rt/trunk/cmake/config-ix.cmake
compiler-rt/trunk/lib/builtins/CMakeLists.txt
Modified: compiler-rt/trunk/cmake/Modules/CompilerRTDarwinUtils.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/Modules/CompilerRTDarwinUtils.cmake?rev=248383&r1=248382&r2=248383&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/Modules/CompilerRTDarwinUtils.cmake (original)
+++ compiler-rt/trunk/cmake/Modules/CompilerRTDarwinUtils.cmake Wed Sep 23 10:18:17 2015
@@ -99,3 +99,114 @@ function(darwin_filter_host_archs input
endif()
set(${output} ${tmp_var} PARENT_SCOPE)
endfunction()
+
+set(DARWIN_EXCLUDE_DIR ${CMAKE_SOURCE_DIR}/lib/builtins/Darwin-excludes)
+
+# Read and process the exclude file into a list of symbols
+function(darwin_read_exclude_file output_var file)
+ if(EXISTS ${DARWIN_EXCLUDE_DIR}/${file}.txt)
+ file(READ ${DARWIN_EXCLUDE_DIR}/${file}.txt ${file}_EXCLUDES)
+ string(REPLACE "\n" ";" ${file}_EXCLUDES ${${file}_EXCLUDES})
+ set(${output_var} ${${file}_EXCLUDES} PARENT_SCOPE)
+ endif()
+endfunction()
+
+# this function takes an OS, architecture and minimum version and provides a
+# list of builtin functions to exclude
+function(darwin_find_excluded_builtins_list os arch min_version)
+ darwin_read_exclude_file(${os}_BUILTINS ${os})
+ darwin_read_exclude_file(${os}_${arch}_BASE_BUILTINS ${os}-${arch})
+
+ file(GLOB builtin_lists ${DARWIN_EXCLUDE_DIR}/${os}*-${arch}.txt)
+ foreach(builtin_list ${builtin_lists})
+ string(REGEX MATCH "${os}([0-9\\.]*)-${arch}.txt" VERSION_MATCHED "${builtin_list}")
+ if (VERSION_MATCHED AND NOT CMAKE_MATCH_1 VERSION_LESS min_version)
+ if(NOT smallest_version)
+ set(smallest_version ${CMAKE_MATCH_1})
+ elseif(CMAKE_MATCH_1 VERSION_LESS smallest_version)
+ set(smallest_version ${CMAKE_MATCH_1})
+ endif()
+ endif()
+ endforeach()
+
+ if(smallest_version)
+ darwin_read_exclude_file(${arch}_${os}_BUILTINS ${os}${smallest_version}-${arch})
+ endif()
+
+ set(${arch}_${os}_EXCLUDED_BUILTINS
+ ${${arch}_${os}_BUILTINS}
+ ${${os}_${arch}_BASE_BUILTINS}
+ ${${os}_BUILTINS} PARENT_SCOPE)
+endfunction()
+
+# adds a single builtin library for a single OS & ARCH
+function(darwin_add_builtin_library name)
+ cmake_parse_arguments(LIB
+ ""
+ "PARENT_TARGET;OS;ARCH"
+ "SOURCES;CFLAGS"
+ ${ARGN})
+ set(libname "${name}_${LIB_ARCH}_${LIB_OS}")
+ add_library(${libname} STATIC ${LIB_SOURCES})
+ set_target_compile_flags(${libname}
+ -isysroot ${DARWIN_${LIB_OS}_SYSROOT}
+ ${DARWIN_${LIB_OS}_BUILTIN_MIN_VER_FLAG}
+ ${LIB_CFLAGS})
+ set_target_properties(${libname} PROPERTIES
+ OUTPUT_NAME ${libname}${COMPILER_RT_OS_SUFFIX})
+ set_target_properties(${libname} PROPERTIES
+ OSX_ARCHITECTURES ${LIB_ARCH})
+
+ if(LIB_PARENT_TARGET)
+ add_dependencies(${LIB_PARENT_TARGET} ${libname})
+ endif()
+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)
+ foreach (os ${ARGN})
+ 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})
+ 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_add_builtin_library(clang_rt.builtins
+ OS ${os}
+ ARCH ${arch}
+ SOURCES ${${arch}_SOURCES}
+ CFLAGS "-std=c99" -arch ${arch}
+ PARENT_TARGET builtins)
+ list(APPEND ${os}_builtin_libs clang_rt.builtins_${arch}_${os})
+ list(APPEND ${os}_builtin_lipo_flags -arch ${arch} $<TARGET_FILE:clang_rt.builtins_${arch}_${os}>)
+ endforeach()
+
+ if(${os}_builtin_libs)
+ add_custom_command(OUTPUT ${COMPILER_RT_LIBRARY_OUTPUT_DIR}/libclang_rt.${os}.a
+ COMMAND lipo -output
+ ${COMPILER_RT_LIBRARY_OUTPUT_DIR}/libclang_rt.${os}.a
+ -create ${${os}_builtin_lipo_flags}
+ DEPENDS ${${os}_builtin_libs}
+ )
+ add_custom_target(clang_rt.${os}
+ DEPENDS ${COMPILER_RT_LIBRARY_OUTPUT_DIR}/libclang_rt.${os}.a)
+ add_dependencies(builtins clang_rt.${os})
+ endif()
+ endforeach()
+endmacro()
+
Modified: compiler-rt/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=248383&r1=248382&r2=248383&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake (original)
+++ compiler-rt/trunk/cmake/config-ix.cmake Wed Sep 23 10:18:17 2015
@@ -274,9 +274,9 @@ if(APPLE)
option(COMPILER_RT_ENABLE_IOS "Enable building for iOS - Experimental" Off)
- find_darwin_sdk_dir(OSX_SDK_DIR macosx)
- find_darwin_sdk_dir(IOSSIM_SDK_DIR iphonesimulator)
- find_darwin_sdk_dir(IOS_SDK_DIR iphoneos)
+ find_darwin_sdk_dir(DARWIN_osx_SYSROOT macosx)
+ find_darwin_sdk_dir(DARWIN_iossim_SYSROOT iphonesimulator)
+ find_darwin_sdk_dir(DARWIN_ios_SYSROOT iphoneos)
# Note: In order to target x86_64h on OS X the minimum deployment target must
# be 10.8 or higher.
@@ -312,10 +312,13 @@ if(APPLE)
set(DARWIN_osx_LINKFLAGS
${DARWIN_COMMON_LINKFLAGS}
-mmacosx-version-min=${SANITIZER_MIN_OSX_VERSION})
-
- if(OSX_SDK_DIR)
- list(APPEND DARWIN_osx_CFLAGS -isysroot ${OSX_SDK_DIR})
- list(APPEND DARWIN_osx_LINKFLAGS -isysroot ${OSX_SDK_DIR})
+ set(DARWIN_osx_BUILTIN_MIN_VER 10.5)
+ set(DARWIN_osx_BUILTIN_MIN_VER_FLAG
+ -mmacosx-version-min=${DARWIN_osx_BUILTIN_MIN_VER})
+
+ if(DARWIN_osx_SYSROOT)
+ list(APPEND DARWIN_osx_CFLAGS -isysroot ${DARWIN_osx_SYSROOT})
+ list(APPEND DARWIN_osx_LINKFLAGS -isysroot ${DARWIN_osx_SYSROOT})
endif()
# Figure out which arches to use for each OS
@@ -332,15 +335,18 @@ if(APPLE)
set(CAN_TARGET_${arch} 1)
endforeach()
- if(IOSSIM_SDK_DIR)
+ if(DARWIN_iossim_SYSROOT)
set(DARWIN_iossim_CFLAGS
${DARWIN_COMMON_CFLAGS}
-mios-simulator-version-min=7.0
- -isysroot ${IOSSIM_SDK_DIR})
+ -isysroot ${DARWIN_iossim_SYSROOT})
set(DARWIN_iossim_LINKFLAGS
${DARWIN_COMMON_LINKFLAGS}
-mios-simulator-version-min=7.0
- -isysroot ${IOSSIM_SDK_DIR})
+ -isysroot ${DARWIN_iossim_SYSROOT})
+ set(DARWIN_iossim_BUILTIN_MIN_VER 6.0)
+ set(DARWIN_iossim_BUILTIN_MIN_VER_FLAG
+ -mios-simulator-version-min=${DARWIN_iossim_BUILTIN_MIN_VER})
list(APPEND SANITIZER_COMMON_SUPPORTED_OS iossim)
list(APPEND BUILTIN_SUPPORTED_OS iossim)
@@ -354,15 +360,18 @@ if(APPLE)
endforeach()
endif()
- if(IOS_SDK_DIR AND COMPILER_RT_ENABLE_IOS)
+ if(DARWIN_ios_SYSROOT AND COMPILER_RT_ENABLE_IOS)
set(DARWIN_ios_CFLAGS
${DARWIN_COMMON_CFLAGS}
-miphoneos-version-min=7.0
- -isysroot ${IOS_SDK_DIR})
+ -isysroot ${DARWIN_ios_SYSROOT})
set(DARWIN_ios_LINKFLAGS
${DARWIN_COMMON_LINKFLAGS}
-miphoneos-version-min=7.0
- -isysroot ${IOS_SDK_DIR})
+ -isysroot ${DARWIN_ios_SYSROOT})
+ set(DARWIN_ios_BUILTIN_MIN_VER 6.0)
+ set(DARWIN_ios_BUILTIN_MIN_VER_FLAG
+ -miphoneos-version-min=${DARWIN_ios_BUILTIN_MIN_VER})
list(APPEND SANITIZER_COMMON_SUPPORTED_OS ios)
list(APPEND BUILTIN_SUPPORTED_OS ios)
Modified: compiler-rt/trunk/lib/builtins/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/CMakeLists.txt?rev=248383&r1=248382&r2=248383&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/builtins/CMakeLists.txt Wed Sep 23 10:18:17 2015
@@ -315,45 +315,7 @@ set(arm64_SOURCES ${aarch64_SOURCES})
add_custom_target(builtins)
if (APPLE)
- foreach (os ${BUILTIN_SUPPORTED_OS})
- 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 ()
-
- 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}/libclang_rt.builtins_${os}.a
- COMMAND lipo -output
- ${COMPILER_RT_LIBRARY_OUTPUT_DIR}/libclang_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}/libclang_rt.builtins_${os}.a)
- add_dependencies(builtins clang_rt.builtins_${os})
- endif()
- endforeach()
+ darwin_add_builtin_libraries(${BUILTIN_SUPPORTED_OS})
elseif (NOT WIN32 OR MINGW)
foreach (arch ${BUILTIN_SUPPORTED_ARCH})
if (CAN_TARGET_${arch})
Added: compiler-rt/trunk/lib/builtins/Darwin-excludes/README.TXT
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/Darwin-excludes/README.TXT?rev=248383&view=auto
==============================================================================
--- compiler-rt/trunk/lib/builtins/Darwin-excludes/README.TXT (added)
+++ compiler-rt/trunk/lib/builtins/Darwin-excludes/README.TXT Wed Sep 23 10:18:17 2015
@@ -0,0 +1,11 @@
+This folder contains list of symbols that should be excluded from the builtin
+libraries for Darwin. There are two reasons symbols are excluded:
+
+(1) They aren't supported on Darwin
+(2) They are contained within the OS on the minimum supported target
+
+The builtin libraries must contain all symbols not provided by the lowest
+supported target OS. Meaning if minimum deployment target is iOS 6, all builtins
+not included in the ios6-<arch>.txt files need to be included. The one catch is
+that this is per-architecture. Since iOS 6 doesn't support arm64, when supporting
+iOS 6, the minimum deployment target for arm64 binaries is iOS 7.
Added: compiler-rt/trunk/lib/builtins/Darwin-excludes/ios.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/Darwin-excludes/ios.txt?rev=248383&view=auto
==============================================================================
--- compiler-rt/trunk/lib/builtins/Darwin-excludes/ios.txt (added)
+++ compiler-rt/trunk/lib/builtins/Darwin-excludes/ios.txt Wed Sep 23 10:18:17 2015
@@ -0,0 +1 @@
+apple_versioning
Added: compiler-rt/trunk/lib/builtins/Darwin-excludes/ios6-armv7.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/Darwin-excludes/ios6-armv7.txt?rev=248383&view=auto
==============================================================================
--- compiler-rt/trunk/lib/builtins/Darwin-excludes/ios6-armv7.txt (added)
+++ compiler-rt/trunk/lib/builtins/Darwin-excludes/ios6-armv7.txt Wed Sep 23 10:18:17 2015
@@ -0,0 +1,120 @@
+absvdi2
+absvsi2
+adddf3
+adddf3vfp
+addsf3
+addsf3vfp
+addvdi3
+addvsi3
+ashldi3
+ashrdi3
+bswapdi2
+bswapsi2
+clzdi2
+clzsi2
+cmpdi2
+ctzdi2
+ctzsi2
+divdc3
+divdf3
+divdf3vfp
+divdi3
+divmodsi4
+divsc3
+divsf3
+divsf3vfp
+divsi3
+eqdf2
+eqdf2vfp
+eqsf2
+eqsf2vfp
+extendsfdf2
+extendsfdf2vfp
+ffsdi2
+fixdfdi
+fixdfsi
+fixdfsivfp
+fixsfdi
+fixsfsi
+fixsfsivfp
+fixunsdfdi
+fixunsdfsi
+fixunsdfsivfp
+fixunssfdi
+fixunssfsi
+fixunssfsivfp
+floatdidf
+floatdisf
+floatsidf
+floatsidfvfp
+floatsisf
+floatsisfvfp
+floatundidf
+floatundisf
+floatunsidf
+floatunsisf
+floatunssidfvfp
+floatunssisfvfp
+gcc_personality_sj0
+gedf2
+gedf2vfp
+gesf2
+gesf2vfp
+gtdf2
+gtdf2vfp
+gtsf2
+gtsf2vfp
+ledf2
+ledf2vfp
+lesf2
+lesf2vfp
+lshrdi3
+ltdf2
+ltdf2vfp
+ltsf2
+ltsf2vfp
+moddi3
+modsi3
+muldc3
+muldf3
+muldf3vfp
+muldi3
+mulodi4
+mulosi4
+mulsc3
+mulsf3
+mulsf3vfp
+mulvdi3
+mulvsi3
+nedf2
+nedf2vfp
+negdi2
+negvdi2
+negvsi2
+nesf2
+nesf2vfp
+paritydi2
+paritysi2
+popcountdi2
+popcountsi2
+powidf2
+powisf2
+subdf3
+subdf3vfp
+subsf3
+subsf3vfp
+subvdi3
+subvsi3
+truncdfsf2
+truncdfsf2vfp
+ucmpdi2
+udivdi3
+udivmoddi4
+udivmodsi4
+udivsi3
+umoddi3
+umodsi3
+unorddf2
+unorddf2vfp
+unordsf2
+unordsf2vfp
Added: compiler-rt/trunk/lib/builtins/Darwin-excludes/ios6-armv7s.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/Darwin-excludes/ios6-armv7s.txt?rev=248383&view=auto
==============================================================================
--- compiler-rt/trunk/lib/builtins/Darwin-excludes/ios6-armv7s.txt (added)
+++ compiler-rt/trunk/lib/builtins/Darwin-excludes/ios6-armv7s.txt Wed Sep 23 10:18:17 2015
@@ -0,0 +1,120 @@
+absvdi2
+absvsi2
+adddf3
+adddf3vfp
+addsf3
+addsf3vfp
+addvdi3
+addvsi3
+ashldi3
+ashrdi3
+bswapdi2
+bswapsi2
+clzdi2
+clzsi2
+cmpdi2
+ctzdi2
+ctzsi2
+divdc3
+divdf3
+divdf3vfp
+divdi3
+divmodsi4
+divsc3
+divsf3
+divsf3vfp
+divsi3
+eqdf2
+eqdf2vfp
+eqsf2
+eqsf2vfp
+extendsfdf2
+extendsfdf2vfp
+ffsdi2
+fixdfdi
+fixdfsi
+fixdfsivfp
+fixsfdi
+fixsfsi
+fixsfsivfp
+fixunsdfdi
+fixunsdfsi
+fixunsdfsivfp
+fixunssfdi
+fixunssfsi
+fixunssfsivfp
+floatdidf
+floatdisf
+floatsidf
+floatsidfvfp
+floatsisf
+floatsisfvfp
+floatundidf
+floatundisf
+floatunsidf
+floatunsisf
+floatunssidfvfp
+floatunssisfvfp
+gcc_personality_sj0
+gedf2
+gedf2vfp
+gesf2
+gesf2vfp
+gtdf2
+gtdf2vfp
+gtsf2
+gtsf2vfp
+ledf2
+ledf2vfp
+lesf2
+lesf2vfp
+lshrdi3
+ltdf2
+ltdf2vfp
+ltsf2
+ltsf2vfp
+moddi3
+modsi3
+muldc3
+muldf3
+muldf3vfp
+muldi3
+mulodi4
+mulosi4
+mulsc3
+mulsf3
+mulsf3vfp
+mulvdi3
+mulvsi3
+nedf2
+nedf2vfp
+negdi2
+negvdi2
+negvsi2
+nesf2
+nesf2vfp
+paritydi2
+paritysi2
+popcountdi2
+popcountsi2
+powidf2
+powisf2
+subdf3
+subdf3vfp
+subsf3
+subsf3vfp
+subvdi3
+subvsi3
+truncdfsf2
+truncdfsf2vfp
+ucmpdi2
+udivdi3
+udivmoddi4
+udivmodsi4
+udivsi3
+umoddi3
+umodsi3
+unorddf2
+unorddf2vfp
+unordsf2
+unordsf2vfp
Added: compiler-rt/trunk/lib/builtins/Darwin-excludes/ios7-arm64.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/Darwin-excludes/ios7-arm64.txt?rev=248383&view=auto
==============================================================================
--- compiler-rt/trunk/lib/builtins/Darwin-excludes/ios7-arm64.txt (added)
+++ compiler-rt/trunk/lib/builtins/Darwin-excludes/ios7-arm64.txt Wed Sep 23 10:18:17 2015
@@ -0,0 +1,16 @@
+clzti2
+divti3
+fixdfti
+fixsfti
+fixunsdfti
+floattidf
+floattisf
+floatuntidf
+floatuntisf
+gcc_personality_v0
+modti3
+powidf2
+powisf2
+udivmodti4
+udivti3
+umodti3
More information about the llvm-commits
mailing list