[compiler-rt] r227496 - [CMake] Get rid of TARGET_64_BIT_CFLAGS: explicitly list required flags for each architecture.

Alexey Samsonov vonosmas at gmail.com
Thu Jan 29 13:32:35 PST 2015


Author: samsonov
Date: Thu Jan 29 15:32:34 2015
New Revision: 227496

URL: http://llvm.org/viewvc/llvm-project?rev=227496&view=rev
Log:
[CMake] Get rid of TARGET_64_BIT_CFLAGS: explicitly list required flags for each architecture.

Modified:
    compiler-rt/trunk/CMakeLists.txt
    compiler-rt/trunk/cmake/config-ix.cmake

Modified: compiler-rt/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=227496&r1=227495&r2=227496&view=diff
==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Thu Jan 29 15:32:34 2015
@@ -163,29 +163,6 @@ set(COMPILER_RT_BINARY_DIR ${CMAKE_CURRE
 # Setup custom SDK sysroots.
 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
 # and target a UNIX-like system or Windows.
 # We can run tests on Android even when we are cross-compiling.

Modified: compiler-rt/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=227496&r1=227495&r2=227496&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake (original)
+++ compiler-rt/trunk/cmake/config-ix.cmake Thu Jan 29 15:32:34 2015
@@ -121,6 +121,13 @@ macro(detect_target_arch)
   endif()
 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.
 if(ANDROID)
   # Can't rely on LLVM_NATIVE_ARCH in cross-compilation.
@@ -129,21 +136,23 @@ if(ANDROID)
   set(COMPILER_RT_OS_SUFFIX "-android")
 else()
   if("${LLVM_NATIVE_ARCH}" STREQUAL "X86")
-    if (NOT MSVC)
-      test_target_arch(x86_64 ${TARGET_64_BIT_CFLAGS})
+    if(NOT MSVC)
+      test_target_arch(x86_64 "-m64")
+      test_target_arch(i386 "-m32")
+    else()
+      test_target_arch(i386 "")
     endif()
-    test_target_arch(i386 ${TARGET_32_BIT_CFLAGS})
   elseif("${LLVM_NATIVE_ARCH}" STREQUAL "PowerPC")
-    test_target_arch(powerpc64 ${TARGET_64_BIT_CFLAGS})
-    test_target_arch(powerpc64le ${TARGET_64_BIT_CFLAGS})
+    test_target_arch(powerpc64 "-m64")
+    test_target_arch(powerpc64le "-m64")
   elseif("${LLVM_NATIVE_ARCH}" STREQUAL "Mips")
     if("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "mipsel|mips64el")
       # regex for mipsel, mips64el
-      test_target_arch(mipsel ${TARGET_32_BIT_CFLAGS})
-      test_target_arch(mips64el ${TARGET_64_BIT_CFLAGS})
+      test_target_arch(mipsel "-m32")
+      test_target_arch(mips64el "-m64")
     else()
-      test_target_arch(mips ${TARGET_32_BIT_CFLAGS})
-      test_target_arch(mips64 ${TARGET_64_BIT_CFLAGS})
+      test_target_arch(mips "-m32")
+      test_target_arch(mips64 "-m64")
     endif()
   elseif("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "arm")
     test_target_arch(arm "-march=armv7-a")
@@ -169,6 +178,15 @@ function(filter_available_targets out_va
   set(${out_var} ${archs} PARENT_SCOPE)
 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.
 filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH
   x86_64 i386 i686 powerpc64 powerpc64le arm aarch64 mips mips64 mipsel mips64el)





More information about the llvm-commits mailing list