[compiler-rt][cmake] Fix not lipo libclang_rt.cc_kext.a when building on OS X

Summary:

Fix r252525 - cmake configure failed to connect target builtins to target compiler-rt  because of early return call.

Patch by: Jacky Tsao (cao.zhong1)

Reviewers: beanz

Subscribers: llvm-commits

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

llvm-svn: 253692
This commit is contained in:
Chris Bieneman 2015-11-20 18:45:42 +00:00
parent e310f11223
commit 8085475db2
1 changed files with 87 additions and 89 deletions

View File

@ -343,96 +343,94 @@ macro(darwin_add_embedded_builtin_libraries)
# architectures we bail here.
set(DARWIN_SOFT_FLOAT_ARCHS armv6m armv7m armv7em armv7)
set(DARWIN_HARD_FLOAT_ARCHS armv7em armv7)
if(NOT COMPILER_RT_SUPPORTED_ARCH MATCHES ".*armv.*")
return()
endif()
list(FIND COMPILER_RT_SUPPORTED_ARCH i386 i386_idx)
if(i386_idx GREATER -1)
list(APPEND DARWIN_HARD_FLOAT_ARCHS i386)
endif()
list(FIND COMPILER_RT_SUPPORTED_ARCH x86_64 x86_64_idx)
if(x86_64_idx GREATER -1)
list(APPEND DARWIN_HARD_FLOAT_ARCHS x86_64)
endif()
set(MACHO_SYM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/macho_embedded)
set(CFLAGS "-Oz -Wall -fomit-frame-pointer -ffreestanding")
set(CMAKE_C_FLAGS "")
set(CMAKE_CXX_FLAGS "")
set(CMAKE_ASM_FLAGS "")
set(SOFT_FLOAT_FLAG -mfloat-abi=soft)
set(HARD_FLOAT_FLAG -mfloat-abi=hard)
set(ENABLE_PIC Off)
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_macho_embedded_LIBRARY_INSTALL_DIR
${COMPILER_RT_INSTALL_PATH}/lib/macho_embedded)
set(CFLAGS_armv7 "-target thumbv7-apple-darwin-eabi")
set(CFLAGS_i386 "-march=pentium")
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(thumb2_64_FUNCTIONS ${MACHO_SYM_DIR}/thumb2-64.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} ${thumb2_64_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!")
if(COMPILER_RT_SUPPORTED_ARCH MATCHES ".*armv.*")
list(FIND COMPILER_RT_SUPPORTED_ARCH i386 i386_idx)
if(i386_idx GREATER -1)
list(APPEND DARWIN_HARD_FLOAT_ARCHS i386)
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})
set(float_flag)
if(${arch} MATCHES "^arm")
# x86 targets are hard float by default, but the complain about the
# float ABI flag, so don't pass it unless we're targeting arm.
set(float_flag ${${float_type}_FLOAT_FLAG})
endif()
darwin_add_builtin_library(clang_rt ${lib_suffix}
OS macho_embedded
ARCH ${arch}
SOURCES ${${arch}_filtered_sources}
CFLAGS ${CFLAGS} -arch ${arch} ${${type}_FLAG} ${float_flag} ${CFLAGS_${arch}}
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}
INSTALL_DIR ${DARWIN_macho_embedded_LIBRARY_INSTALL_DIR})
list(FIND COMPILER_RT_SUPPORTED_ARCH x86_64 x86_64_idx)
if(x86_64_idx GREATER -1)
list(APPEND DARWIN_HARD_FLOAT_ARCHS x86_64)
endif()
set(MACHO_SYM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/macho_embedded)
set(CFLAGS "-Oz -Wall -fomit-frame-pointer -ffreestanding")
set(CMAKE_C_FLAGS "")
set(CMAKE_CXX_FLAGS "")
set(CMAKE_ASM_FLAGS "")
set(SOFT_FLOAT_FLAG -mfloat-abi=soft)
set(HARD_FLOAT_FLAG -mfloat-abi=hard)
set(ENABLE_PIC Off)
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_macho_embedded_LIBRARY_INSTALL_DIR
${COMPILER_RT_INSTALL_PATH}/lib/macho_embedded)
set(CFLAGS_armv7 "-target thumbv7-apple-darwin-eabi")
set(CFLAGS_i386 "-march=pentium")
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(thumb2_64_FUNCTIONS ${MACHO_SYM_DIR}/thumb2-64.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} ${thumb2_64_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()
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})
set(float_flag)
if(${arch} MATCHES "^arm")
# x86 targets are hard float by default, but the complain about the
# float ABI flag, so don't pass it unless we're targeting arm.
set(float_flag ${${float_type}_FLOAT_FLAG})
endif()
darwin_add_builtin_library(clang_rt ${lib_suffix}
OS macho_embedded
ARCH ${arch}
SOURCES ${${arch}_filtered_sources}
CFLAGS ${CFLAGS} -arch ${arch} ${${type}_FLAG} ${float_flag} ${CFLAGS_${arch}}
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}
INSTALL_DIR ${DARWIN_macho_embedded_LIBRARY_INSTALL_DIR})
endforeach()
endforeach()
endif()
endmacro()