Compiler-rt: Fix MIPS CMake variables set

Move the code which sets CMake variables for MIPS to
compiler-rt/cmake/base-config-ix.cmake from compiler-rt/CMakeLists.txt.

compiler-rt/CMakeLists.txt includes compiler-rt/cmake/base-config-ix.cmake
very early. If the variables are set in compiler/CMakeLists.txt,
compiler-rt/cmake/base-config-ix.cmake cannot use them.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D157900
This commit is contained in:
YunQiang Su 2023-08-23 17:02:49 -04:00 committed by Brad Smith
parent dc02070d69
commit dbf03ad68e
2 changed files with 13 additions and 14 deletions

View File

@ -124,20 +124,6 @@ if ("${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" MATCHES ".*hf$")
CHECK_SYMBOL_EXISTS (__thumb__ "" COMPILER_RT_ARM_THUMB)
endif()
endif()
if (${COMPILER_RT_DEFAULT_TARGET_ARCH} MATCHES "^mips")
CHECK_SYMBOL_EXISTS (_MIPS_ARCH_MIPS32R6 "" COMPILER_RT_MIPS32R6)
CHECK_SYMBOL_EXISTS (_MIPS_ARCH_MIPS64R6 "" COMPILER_RT_MIPS64R6)
CHECK_SYMBOL_EXISTS (__mips64 "" COMPILER_RT_MIPS_64)
CHECK_SYMBOL_EXISTS (__MIPSEL__ "" COMPILER_RT_MIPS_EL)
if ("${COMPILER_RT_MIPS_64}")
set(COMPILER_RT_DEFAULT_TARGET_ARCH "mips64")
else()
set(COMPILER_RT_DEFAULT_TARGET_ARCH "mips")
endif()
if ("${COMPILER_RT_MIPS_EL}")
set(COMPILER_RT_DEFAULT_TARGET_ARCH "${COMPILER_RT_DEFAULT_TARGET_ARCH}el")
endif()
endif()
if ("${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" MATCHES ".*android.*")
set(ANDROID 1)
string(REGEX MATCH "-target(=| +)[^ ]+android[a-z]*([0-9]+)" ANDROID_API_LEVEL "${CMAKE_C_FLAGS}")

View File

@ -226,6 +226,19 @@ macro(test_targets)
test_target_arch(sparc "" "-m32")
test_target_arch(sparcv9 "" "-m64")
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "mips")
CHECK_SYMBOL_EXISTS (_MIPS_ARCH_MIPS32R6 "" COMPILER_RT_MIPS32R6)
CHECK_SYMBOL_EXISTS (_MIPS_ARCH_MIPS64R6 "" COMPILER_RT_MIPS64R6)
CHECK_SYMBOL_EXISTS (__mips64 "" COMPILER_RT_MIPS_64)
CHECK_SYMBOL_EXISTS (__MIPSEL__ "" COMPILER_RT_MIPS_EL)
if ("${COMPILER_RT_MIPS_64}")
set(COMPILER_RT_DEFAULT_TARGET_ARCH "mips64")
else()
set(COMPILER_RT_DEFAULT_TARGET_ARCH "mips")
endif()
if ("${COMPILER_RT_MIPS_EL}")
set(COMPILER_RT_DEFAULT_TARGET_ARCH "${COMPILER_RT_DEFAULT_TARGET_ARCH}el")
endif()
# FIXME: Ideally, we would build the N32 library too.
if("${COMPILER_RT_MIPS_EL}" AND ("${COMPILER_RT_MIPS32R6}" OR "${COMPILER_RT_MIPS64R6}"))
test_target_arch(mipsel "" "-mips32r6" "-mabi=32" "-D_LARGEFILE_SOURCE=1" "-D_FILE_OFFSET_BITS=64")