diff options
author | Chris Bieneman <beanz@apple.com> | 2015-09-29 23:13:45 +0000 |
---|---|---|
committer | Chris Bieneman <beanz@apple.com> | 2015-09-29 23:13:45 +0000 |
commit | bcc4ac930dfaaf8c4d5f2de02849006898177f23 (patch) | |
tree | 227fd6bcd7de13392ef7b5d5f94fb5ab385774aa | |
parent | 8c4562320207ab7656e1e2670b7cd4afde3620f1 (diff) |
[CMake] [Darwin] Support building the macho_embedded builtin libraries.
Summary: This ports functionality from the clang_macho_embedded.mk platform makefile over to CMake.
Reviewers: bogner, samsonov, bob.wilson
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D13226
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@248850 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | cmake/Modules/CompilerRTDarwinUtils.cmake | 84 | ||||
-rw-r--r-- | lib/builtins/CMakeLists.txt | 5 | ||||
-rw-r--r-- | lib/builtins/macho_embedded/arm.txt | 18 | ||||
-rw-r--r-- | lib/builtins/macho_embedded/common.txt | 93 | ||||
-rw-r--r-- | lib/builtins/macho_embedded/i386.txt | 7 | ||||
-rw-r--r-- | lib/builtins/macho_embedded/thumb2.txt | 24 |
6 files changed, 229 insertions, 2 deletions
diff --git a/cmake/Modules/CompilerRTDarwinUtils.cmake b/cmake/Modules/CompilerRTDarwinUtils.cmake index 1e017b8b3..474c9fdae 100644 --- a/cmake/Modules/CompilerRTDarwinUtils.cmake +++ b/cmake/Modules/CompilerRTDarwinUtils.cmake @@ -100,8 +100,6 @@ function(darwin_filter_host_archs input output) 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_list_from_file output_var file) if(EXISTS ${file}) @@ -233,6 +231,8 @@ 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) + set(DARWIN_EXCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Darwin-excludes) + if(CMAKE_CONFIGURATION_TYPES) foreach(type ${CMAKE_CONFIGURATION_TYPES}) set(CMAKE_C_FLAGS_${type} -O3) @@ -310,5 +310,85 @@ macro(darwin_add_builtin_libraries) OUTPUT_DIR ${COMPILER_RT_LIBRARY_OUTPUT_DIR}) endif() endforeach() + darwin_add_embedded_builtin_libraries() endmacro() +function(darwin_add_embedded_builtin_libraries) + set(MACHO_SYM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/macho_embedded) + if(CMAKE_CONFIGURATION_TYPES) + foreach(type ${CMAKE_CONFIGURATION_TYPES}) + set(CMAKE_C_FLAGS_${type} -Oz) + set(CMAKE_CXX_FLAGS_${type} -Oz) + endforeach() + else() + set(CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE} -Oz) + endif() + + set(CMAKE_C_FLAGS "-Wall -fomit-frame-pointer -ffreestanding") + set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS}) + set(CMAKE_ASM_FLAGS ${CMAKE_C_FLAGS}) + + set(SOFT_FLOAT_FLAG -mfloat-abi=soft) + set(HARD_FLOAT_FLAG -mfloat-abi=hard) + + set(PIC_FLAG_ -fPIC) + set(STATIC_FLAG -static) + + set(DARWIN_macho_embedded_ARCHS armv6m armv7m armv7em armv7 i386 x86_64) + + set(DARWIN_macho_embedded_LIBRARY_OUTPUT_DIR + ${COMPILER_RT_OUTPUT_DIR}/lib/macho_embedded) + + set(DARWIN_SOFT_FLOAT_ARCHS armv6m armv7m armv7em armv7) + set(DARWIN_HARD_FLOAT_ARCHS armv7em armv7 i386 x86_64) + + darwin_read_list_from_file(common_FUNCTIONS ${MACHO_SYM_DIR}/common.txt) + darwin_read_list_from_file(thumb2_FUNCTIONS ${MACHO_SYM_DIR}/thumb2.txt) + darwin_read_list_from_file(arm_FUNCTIONS ${MACHO_SYM_DIR}/arm.txt) + darwin_read_list_from_file(i386_FUNCTIONS ${MACHO_SYM_DIR}/i386.txt) + + + set(armv6m_FUNCTIONS ${common_FUNCTIONS} ${arm_FUNCTIONS}) + set(armv7m_FUNCTIONS ${common_FUNCTIONS} ${arm_FUNCTIONS} ${thumb2_FUNCTIONS}) + set(armv7em_FUNCTIONS ${common_FUNCTIONS} ${arm_FUNCTIONS} ${thumb2_FUNCTIONS}) + set(armv7_FUNCTIONS ${common_FUNCTIONS} ${arm_FUNCTIONS} ${thumb2_FUNCTIONS}) + set(i386_FUNCTIONS ${common_FUNCTIONS} ${i386_FUNCTIONS}) + set(x86_64_FUNCTIONS ${common_FUNCTIONS}) + + foreach(arch ${DARWIN_macho_embedded_ARCHS}) + darwin_filter_builtin_sources(${arch}_filtered_sources + INCLUDE ${arch}_FUNCTIONS + ${${arch}_SOURCES}) + if(NOT ${arch}_filtered_sources) + message("${arch}_SOURCES: ${${arch}_SOURCES}") + message("${arch}_FUNCTIONS: ${${arch}_FUNCTIONS}") + message(FATAL_ERROR "Empty filtered sources!") + endif() + endforeach() + + foreach(float_type SOFT HARD) + foreach(type PIC STATIC) + string(TOLOWER "${float_type}_${type}" lib_suffix) + foreach(arch ${DARWIN_${float_type}_FLOAT_ARCHS}) + set(DARWIN_macho_embedded_SYSROOT ${DARWIN_osx_SYSROOT}) + if(${arch} MATCHES "^arm") + set(DARWIN_macho_embedded_SYSROOT ${DARWIN_ios_SYSROOT}) + endif() + darwin_add_builtin_library(clang_rt ${lib_suffix} + OS macho_embedded + ARCH ${arch} + SOURCES ${${arch}_filtered_sources} + CFLAGS -arch ${arch} ${${type}_FLAG} ${${float_type}_FLOAT_FLAG} + PARENT_TARGET builtins) + endforeach() + foreach(lib ${macho_embedded_${lib_suffix}_libs}) + set_target_properties(${lib} PROPERTIES LINKER_LANGUAGE C) + endforeach() + darwin_lipo_libs(clang_rt.${lib_suffix} + PARENT_TARGET builtins + LIPO_FLAGS ${macho_embedded_${lib_suffix}_lipo_flags} + DEPENDS ${macho_embedded_${lib_suffix}_libs} + OUTPUT_DIR ${DARWIN_macho_embedded_LIBRARY_OUTPUT_DIR}) + endforeach() + endforeach() +endfunction() diff --git a/lib/builtins/CMakeLists.txt b/lib/builtins/CMakeLists.txt index dcfe6bddd..d39427afa 100644 --- a/lib/builtins/CMakeLists.txt +++ b/lib/builtins/CMakeLists.txt @@ -318,6 +318,11 @@ set(armv7_SOURCES ${arm_SOURCES}) set(armv7s_SOURCES ${arm_SOURCES}) set(arm64_SOURCES ${aarch64_SOURCES}) +# macho_embedded archs +set(armv6m_SOURCES ${GENERIC_SOURCES}) +set(armv7m_SOURCES ${arm_SOURCES}) +set(armv7em_SOURCES ${arm_SOURCES}) + add_custom_target(builtins) if (APPLE) diff --git a/lib/builtins/macho_embedded/arm.txt b/lib/builtins/macho_embedded/arm.txt new file mode 100644 index 000000000..f66fef5ea --- /dev/null +++ b/lib/builtins/macho_embedded/arm.txt @@ -0,0 +1,18 @@ +aeabi_cdcmpeq +aeabi_cdrcmple +aeabi_cfcmpeq +aeabi_cfrcmple +aeabi_dcmpeq +aeabi_dcmpge +aeabi_dcmpgt +aeabi_dcmple +aeabi_dcmplt +aeabi_drsub +aeabi_fcmpeq +aeabi_fcmpge +aeabi_fcmpgt +aeabi_fcmple +aeabi_fcmplt +aeabi_frsub +aeabi_idivmod +aeabi_uidivmod diff --git a/lib/builtins/macho_embedded/common.txt b/lib/builtins/macho_embedded/common.txt new file mode 100644 index 000000000..687accf4b --- /dev/null +++ b/lib/builtins/macho_embedded/common.txt @@ -0,0 +1,93 @@ +absvdi2 +absvsi2 +addvdi3 +addvsi3 +ashldi3 +ashrdi3 +bswapdi2 +bswapsi2 +clzdi2 +clzsi2 +cmpdi2 +ctzdi2 +ctzsi2 +divdc3 +divdi3 +divsc3 +divmodsi4 +udivmodsi4 +do_global_dtors +ffsdi2 +fixdfdi +fixsfdi +fixunsdfdi +fixunsdfsi +fixunssfdi +fixunssfsi +floatdidf +floatdisf +floatundidf +floatundisf +gcc_bcmp +lshrdi3 +moddi3 +muldc3 +muldi3 +mulsc3 +mulvdi3 +mulvsi3 +negdi2 +negvdi2 +negvsi2 +paritydi2 +paritysi2 +popcountdi2 +popcountsi2 +powidf2 +powisf2 +subvdi3 +subvsi3 +ucmpdi2 +udiv_w_sdiv +udivdi3 +udivmoddi4 +umoddi3 +adddf3 +addsf3 +cmpdf2 +cmpsf2 +div0 +divdf3 +divsf3 +divsi3 +extendsfdf2 +extendhfsf2 +ffssi2 +fixdfsi +fixsfsi +floatsidf +floatsisf +floatunsidf +floatunsisf +comparedf2 +comparesf2 +modsi3 +muldf3 +mulsf3 +negdf2 +negsf2 +subdf3 +subsf3 +truncdfhf2 +truncdfsf2 +truncsfhf2 +udivsi3 +umodsi3 +unorddf2 +unordsf2 +atomic_flag_clear +atomic_flag_clear_explicit +atomic_flag_test_and_set +atomic_flag_test_and_set_explicit +atomic_signal_fence +atomic_thread_fence diff --git a/lib/builtins/macho_embedded/i386.txt b/lib/builtins/macho_embedded/i386.txt new file mode 100644 index 000000000..b92e44bb3 --- /dev/null +++ b/lib/builtins/macho_embedded/i386.txt @@ -0,0 +1,7 @@ +i686.get_pc_thunk.eax +i686.get_pc_thunk.ebp +i686.get_pc_thunk.ebx +i686.get_pc_thunk.ecx +i686.get_pc_thunk.edi +i686.get_pc_thunk.edx +i686.get_pc_thunk.esi diff --git a/lib/builtins/macho_embedded/thumb2.txt b/lib/builtins/macho_embedded/thumb2.txt new file mode 100644 index 000000000..9c19d7ceb --- /dev/null +++ b/lib/builtins/macho_embedded/thumb2.txt @@ -0,0 +1,24 @@ +switch16 +switch32 +switch8 +switchu8 +sync_fetch_and_add_4 +sync_fetch_and_sub_4 +sync_fetch_and_and_4 +sync_fetch_and_or_4 +sync_fetch_and_xor_4 +sync_fetch_and_nand_4 +sync_fetch_and_max_4 +sync_fetch_and_umax_4 +sync_fetch_and_min_4 +sync_fetch_and_umin_4 +sync_fetch_and_add_8 +sync_fetch_and_sub_8 +sync_fetch_and_and_8 +sync_fetch_and_or_8 +sync_fetch_and_xor_8 +sync_fetch_and_nand_8 +sync_fetch_and_max_8 +sync_fetch_and_umax_8 +sync_fetch_and_min_8 +sync_fetch_and_umin_8 |