[PATCH] Cleanup compiler-rt Android build and provide better diagnostics

Greg Fitzgerald gregf at codeaurora.org
Fri May 30 15:43:12 PDT 2014


Hi eugenis,

Cleanup Android build and provide better diagnostics
    
No longer need to set ANDROID if COMPILER_RT_TEST_TARGET_TRIPLE is arm-linux-androideabi.
    
No need to set COMMON_ANDROID_FLAGS.  These flags are already in CMAKE_CXX_FLAGS which are used in try_compile().

If try_compile() fails when we expect it to pass, output an error message.

http://reviews.llvm.org/D3970

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -136,6 +136,12 @@
     "Default triple for cross-compiled executables")
 string(REPLACE "-" ";" TARGET_TRIPLE_LIST ${COMPILER_RT_TEST_TARGET_TRIPLE})
 list(GET TARGET_TRIPLE_LIST 0 COMPILER_RT_TEST_TARGET_ARCH)
+list(GET TARGET_TRIPLE_LIST 1 COMPILER_RT_TEST_TARGET_OS)
+list(GET TARGET_TRIPLE_LIST 2 COMPILER_RT_TEST_TARGET_ABI)
+
+if ("${COMPILER_RT_TEST_TARGET_ABI}" STREQUAL "androideabi")
+  set(ANDROID 1)
+endif()
 
 string(TOLOWER ${CMAKE_SYSTEM_NAME} COMPILER_RT_OS_DIR)
 set(COMPILER_RT_LIBRARY_OUTPUT_DIR
@@ -199,29 +205,32 @@
   set(TARGET_${arch}_CFLAGS ${ARGN})
   try_compile(CAN_TARGET_${arch} ${CMAKE_BINARY_DIR} ${SIMPLE_SOURCE}
               COMPILE_DEFINITIONS "${TARGET_${arch}_CFLAGS}"
+              OUTPUT_VARIABLE TARGET_${arch}_OUTPUT
               CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${TARGET_${arch}_CFLAGS}")
   if(${CAN_TARGET_${arch}})
     list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch})
+  elseif("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "${arch}" OR
+         "${arch}" STREQUAL "arm_android")
+    # Bail out if we cannot target the architecture we plan to test.
+    message(FATAL_ERROR "Cannot compile for ${arch}:\n${TARGET_${arch}_OUTPUT}")
   endif()
 endmacro()
 
-if(ANDROID_COMMON_FLAGS)
-  test_target_arch(arm_android "${ANDROID_COMMON_FLAGS}")
-else()
-  if("${LLVM_NATIVE_ARCH}" STREQUAL "X86")
-    if (NOT MSVC)
-      test_target_arch(x86_64 ${TARGET_64_BIT_CFLAGS})
-    endif()
-    test_target_arch(i386 ${TARGET_32_BIT_CFLAGS})
-  elseif("${LLVM_NATIVE_ARCH}" STREQUAL "PowerPC")
-    test_target_arch(powerpc64 ${TARGET_64_BIT_CFLAGS})
+if("${LLVM_NATIVE_ARCH}" STREQUAL "X86")
+  if (NOT MSVC)
+    test_target_arch(x86_64 ${TARGET_64_BIT_CFLAGS})
   endif()
+  test_target_arch(i386 ${TARGET_32_BIT_CFLAGS})
+elseif("${LLVM_NATIVE_ARCH}" STREQUAL "PowerPC")
+  test_target_arch(powerpc64 ${TARGET_64_BIT_CFLAGS})
+endif()
 
-  # Build ARM libraries if we are configured to test on ARM
-  if("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "arm|aarch64")
-    test_target_arch(arm "-march=armv7-a")
-    test_target_arch(aarch64 "-march=armv8-a")
-  endif()
+# Build ARM libraries if we are configured to test on ARM
+if(ANDROID)
+  test_target_arch(arm_android "")
+elseif("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "arm|aarch64")
+  test_target_arch(arm "-march=armv7-a")
+  test_target_arch(aarch64 "-march=armv8-a")
 endif()
 
 # We support running instrumented tests when we're not cross compiling
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3970.9966.patch
Type: text/x-patch
Size: 2595 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140530/d70c1d8e/attachment.bin>


More information about the llvm-commits mailing list