forked from OSchip/llvm-project
[CMake] Get rid of TARGET_64_BIT_CFLAGS: explicitly list required flags for each architecture.
llvm-svn: 227496
This commit is contained in:
parent
bc63f42e0d
commit
807f1b539c
|
@ -163,29 +163,6 @@ set(COMPILER_RT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
# Setup custom SDK sysroots.
|
# Setup custom SDK sysroots.
|
||||||
set(COMPILER_RT_LINUX_SDK_SYSROOT ${COMPILER_RT_SOURCE_DIR}/SDKs/linux)
|
set(COMPILER_RT_LINUX_SDK_SYSROOT ${COMPILER_RT_SOURCE_DIR}/SDKs/linux)
|
||||||
|
|
||||||
# Detect whether the current target platform is 32-bit or 64-bit, and setup
|
|
||||||
# the correct commandline flags needed to attempt to target 32-bit and 64-bit.
|
|
||||||
if (NOT CMAKE_SIZEOF_VOID_P EQUAL 4 AND
|
|
||||||
NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
||||||
message(FATAL_ERROR "Please use architecture with 4 or 8 byte pointers.")
|
|
||||||
endif()
|
|
||||||
if (NOT MSVC)
|
|
||||||
set(TARGET_64_BIT_CFLAGS "-m64")
|
|
||||||
set(TARGET_32_BIT_CFLAGS "-m32")
|
|
||||||
else()
|
|
||||||
set(TARGET_64_BIT_CFLAGS "")
|
|
||||||
set(TARGET_32_BIT_CFLAGS "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
function(get_target_flags_for_arch arch out_var)
|
|
||||||
list(FIND COMPILER_RT_SUPPORTED_ARCH ${arch} ARCH_INDEX)
|
|
||||||
if(ARCH_INDEX EQUAL -1)
|
|
||||||
message(FATAL_ERROR "Unsupported architecture: ${arch}")
|
|
||||||
else()
|
|
||||||
set(${out_var} ${TARGET_${arch}_CFLAGS} PARENT_SCOPE)
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
# We support running instrumented tests when we're not cross compiling
|
# We support running instrumented tests when we're not cross compiling
|
||||||
# and target a UNIX-like system or Windows.
|
# and target a UNIX-like system or Windows.
|
||||||
# We can run tests on Android even when we are cross-compiling.
|
# We can run tests on Android even when we are cross-compiling.
|
||||||
|
|
|
@ -121,6 +121,13 @@ macro(detect_target_arch)
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
# Detect whether the current target platform is 32-bit or 64-bit, and setup
|
||||||
|
# the correct commandline flags needed to attempt to target 32-bit and 64-bit.
|
||||||
|
if (NOT CMAKE_SIZEOF_VOID_P EQUAL 4 AND
|
||||||
|
NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
message(FATAL_ERROR "Please use architecture with 4 or 8 byte pointers.")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Generate the COMPILER_RT_SUPPORTED_ARCH list.
|
# Generate the COMPILER_RT_SUPPORTED_ARCH list.
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
# Can't rely on LLVM_NATIVE_ARCH in cross-compilation.
|
# Can't rely on LLVM_NATIVE_ARCH in cross-compilation.
|
||||||
|
@ -129,21 +136,23 @@ if(ANDROID)
|
||||||
set(COMPILER_RT_OS_SUFFIX "-android")
|
set(COMPILER_RT_OS_SUFFIX "-android")
|
||||||
else()
|
else()
|
||||||
if("${LLVM_NATIVE_ARCH}" STREQUAL "X86")
|
if("${LLVM_NATIVE_ARCH}" STREQUAL "X86")
|
||||||
if (NOT MSVC)
|
if(NOT MSVC)
|
||||||
test_target_arch(x86_64 ${TARGET_64_BIT_CFLAGS})
|
test_target_arch(x86_64 "-m64")
|
||||||
|
test_target_arch(i386 "-m32")
|
||||||
|
else()
|
||||||
|
test_target_arch(i386 "")
|
||||||
endif()
|
endif()
|
||||||
test_target_arch(i386 ${TARGET_32_BIT_CFLAGS})
|
|
||||||
elseif("${LLVM_NATIVE_ARCH}" STREQUAL "PowerPC")
|
elseif("${LLVM_NATIVE_ARCH}" STREQUAL "PowerPC")
|
||||||
test_target_arch(powerpc64 ${TARGET_64_BIT_CFLAGS})
|
test_target_arch(powerpc64 "-m64")
|
||||||
test_target_arch(powerpc64le ${TARGET_64_BIT_CFLAGS})
|
test_target_arch(powerpc64le "-m64")
|
||||||
elseif("${LLVM_NATIVE_ARCH}" STREQUAL "Mips")
|
elseif("${LLVM_NATIVE_ARCH}" STREQUAL "Mips")
|
||||||
if("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "mipsel|mips64el")
|
if("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "mipsel|mips64el")
|
||||||
# regex for mipsel, mips64el
|
# regex for mipsel, mips64el
|
||||||
test_target_arch(mipsel ${TARGET_32_BIT_CFLAGS})
|
test_target_arch(mipsel "-m32")
|
||||||
test_target_arch(mips64el ${TARGET_64_BIT_CFLAGS})
|
test_target_arch(mips64el "-m64")
|
||||||
else()
|
else()
|
||||||
test_target_arch(mips ${TARGET_32_BIT_CFLAGS})
|
test_target_arch(mips "-m32")
|
||||||
test_target_arch(mips64 ${TARGET_64_BIT_CFLAGS})
|
test_target_arch(mips64 "-m64")
|
||||||
endif()
|
endif()
|
||||||
elseif("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "arm")
|
elseif("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "arm")
|
||||||
test_target_arch(arm "-march=armv7-a")
|
test_target_arch(arm "-march=armv7-a")
|
||||||
|
@ -169,6 +178,15 @@ function(filter_available_targets out_var)
|
||||||
set(${out_var} ${archs} PARENT_SCOPE)
|
set(${out_var} ${archs} PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
function(get_target_flags_for_arch arch out_var)
|
||||||
|
list(FIND COMPILER_RT_SUPPORTED_ARCH ${arch} ARCH_INDEX)
|
||||||
|
if(ARCH_INDEX EQUAL -1)
|
||||||
|
message(FATAL_ERROR "Unsupported architecture: ${arch}")
|
||||||
|
else()
|
||||||
|
set(${out_var} ${TARGET_${arch}_CFLAGS} PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
# Architectures supported by compiler-rt libraries.
|
# Architectures supported by compiler-rt libraries.
|
||||||
filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH
|
filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH
|
||||||
x86_64 i386 i686 powerpc64 powerpc64le arm aarch64 mips mips64 mipsel mips64el)
|
x86_64 i386 i686 powerpc64 powerpc64le arm aarch64 mips mips64 mipsel mips64el)
|
||||||
|
|
Loading…
Reference in New Issue