[CMake] Fix MIPSr6 build for compiler-rt
The current version pass -mips64r2 or -mips32r2 options,
which make it failed to build on r6 platform.
In this patch: we detect whether we are MIPSr6 by
_MIPS_ARCH_MIPS32R6/_MIPS_ARCH_MIPS64R6
The out and install path is set to the default triple instead of
hardcoded one, since the clang ask for it.
Differential Revision: https://reviews.llvm.org/D135735
This commit is contained in:
parent
a8c92b69e7
commit
9221aa6d64
@ -122,6 +122,20 @@ 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}")
|
||||
|
||||
@ -479,6 +479,7 @@ endfunction()
|
||||
function(get_compiler_rt_target arch variable)
|
||||
string(FIND ${COMPILER_RT_DEFAULT_TARGET_TRIPLE} "-" dash_index)
|
||||
string(SUBSTRING ${COMPILER_RT_DEFAULT_TARGET_TRIPLE} ${dash_index} -1 triple_suffix)
|
||||
string(SUBSTRING ${COMPILER_RT_DEFAULT_TARGET_TRIPLE} 0 ${dash_index} triple_cpu)
|
||||
if(COMPILER_RT_DEFAULT_TARGET_ONLY)
|
||||
# Use exact spelling when building only for the target specified to CMake.
|
||||
set(target "${COMPILER_RT_DEFAULT_TARGET_TRIPLE}")
|
||||
@ -488,6 +489,17 @@ function(get_compiler_rt_target arch variable)
|
||||
set(target "x86_64${triple_suffix}")
|
||||
elseif(${arch} STREQUAL "sparc64")
|
||||
set(target "sparcv9${triple_suffix}")
|
||||
elseif("${arch}" MATCHES "mips64|mips64el")
|
||||
string(REGEX REPLACE "-gnu.*" "-gnuabi64" triple_suffix_gnu "${triple_suffix}")
|
||||
string(REGEX REPLACE "mipsisa32" "mipsisa64" triple_cpu_mips "${triple_cpu}")
|
||||
string(REGEX REPLACE "^mips$" "mips64" triple_cpu_mips "${triple_cpu_mips}")
|
||||
string(REGEX REPLACE "^mipsel$" "mips64el" triple_cpu_mips "${triple_cpu_mips}")
|
||||
set(target "${triple_cpu_mips}${triple_suffix_gnu}")
|
||||
elseif("${arch}" MATCHES "mips|mipsel")
|
||||
string(REGEX REPLACE "-gnuabi.*" "-gnu" triple_suffix_gnu "${triple_suffix}")
|
||||
string(REGEX REPLACE "mipsisa64" "mipsisa32" triple_cpu_mips "${triple_cpu}")
|
||||
string(REGEX REPLACE "mips64" "mips" triple_cpu_mips "${triple_cpu_mips}")
|
||||
set(target "${triple_cpu_mips}${triple_suffix_gnu}")
|
||||
else()
|
||||
set(target "${arch}${triple_suffix}")
|
||||
endif()
|
||||
|
||||
@ -215,17 +215,21 @@ macro(test_targets)
|
||||
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "sparc")
|
||||
test_target_arch(sparc "" "-m32")
|
||||
test_target_arch(sparcv9 "" "-m64")
|
||||
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "mipsel|mips64el")
|
||||
# Gcc doesn't accept -m32/-m64 so we do the next best thing and use
|
||||
# -mips32r2/-mips64r2. We don't use -mips1/-mips3 because we want to match
|
||||
# clang's default CPU's. In the 64-bit case, we must also specify the ABI
|
||||
# since the default ABI differs between gcc and clang.
|
||||
# FIXME: Ideally, we would build the N32 library too.
|
||||
test_target_arch(mipsel "" "-mips32r2" "-mabi=32" "-D_LARGEFILE_SOURCE" "-D_FILE_OFFSET_BITS=64")
|
||||
test_target_arch(mips64el "" "-mips64r2" "-mabi=64")
|
||||
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "mips")
|
||||
test_target_arch(mips "" "-mips32r2" "-mabi=32" "-D_LARGEFILE_SOURCE" "-D_FILE_OFFSET_BITS=64")
|
||||
test_target_arch(mips64 "" "-mips64r2" "-mabi=64")
|
||||
# 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" "-D_FILE_OFFSET_BITS=64")
|
||||
test_target_arch(mips64el "" "-mips64r6" "-mabi=64")
|
||||
elseif("${COMPILER_RT_MIPS_EL}")
|
||||
test_target_arch(mipsel "" "-mips32r2" "-mabi=32" "-D_LARGEFILE_SOURCE" "-D_FILE_OFFSET_BITS=64")
|
||||
test_target_arch(mips64el "" "-mips64r2" "-mabi=64")
|
||||
elseif("${COMPILER_RT_MIPS32R6}" OR "${COMPILER_RT_MIPS64R6}")
|
||||
test_target_arch(mips "" "-mips32r6" "-mabi=32" "-D_LARGEFILE_SOURCE" "-D_FILE_OFFSET_BITS=64")
|
||||
test_target_arch(mips64 "" "-mips64r6" "-mabi=64")
|
||||
else()
|
||||
test_target_arch(mips "" "-mips32r2" "-mabi=32" "-D_LARGEFILE_SOURCE" "-D_FILE_OFFSET_BITS=64")
|
||||
test_target_arch(mips64 "" "-mips64r2" "-mabi=64")
|
||||
endif()
|
||||
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "arm")
|
||||
if(WIN32)
|
||||
test_target_arch(arm "" "" "")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user