From: Andrey Kamaev Date: Mon, 27 Aug 2012 15:45:24 +0000 (+0400) Subject: Support for the gold linker (NDK r8b is required) X-Git-Tag: accepted/2.0/20130307.220821~364^2~215^2~36^2~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c0786e9d338664d2d932aa76ade99030181cf9ea;p=profile%2Fivi%2Fopencv.git Support for the gold linker (NDK r8b is required) --- diff --git a/android/android.toolchain.cmake b/android/android.toolchain.cmake index 97b9f39..1b42f01 100644 --- a/android/android.toolchain.cmake +++ b/android/android.toolchain.cmake @@ -187,7 +187,8 @@ # [+] updated for NDK r8b # [~] all intermediate files generated by toolchain are moved into CMakeFiles # [~] libstdc++ and libsupc are removed from explicit link libraries -# [+] added ccache support (via NDK_CCACHE environment or cmake variable) +# [+] added CCache support (via NDK_CCACHE environment or cmake variable) +# [+] added gold linker support for NDK r8b # ------------------------------------------------------------------------------ cmake_minimum_required( VERSION 2.6.3 ) @@ -941,7 +942,7 @@ if( ANDROID_SO_UNDEFINED ) endif() __INIT_VARIABLE( ANDROID_FUNCTION_LEVEL_LINKING VALUES ON ) -set( ANDROID_FUNCTION_LEVEL_LINKING ON CACHE BOOL "Allows or disallows undefined symbols in shared libraries" FORCE ) +set( ANDROID_FUNCTION_LEVEL_LINKING ${ANDROID_FUNCTION_LEVEL_LINKING} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" FORCE ) mark_as_advanced( ANDROID_FUNCTION_LEVEL_LINKING ) if( ANDROID_FUNCTION_LEVEL_LINKING ) set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fdata-sections -ffunction-sections" ) @@ -954,6 +955,15 @@ if( ARMEABI_V7A ) set( ANDROID_LINKER_FLAGS "-Wl,--fix-cortex-a8 ${ANDROID_LINKER_FLAGS}" ) endif() +if( CMAKE_HOST_UNIX AND ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" AND (ARMEABI_V7A OR X86) ) + __INIT_VARIABLE( ANDROID_USE_GOLD_LINKER VALUES ON ) + set( ANDROID_USE_GOLD_LINKER ${ANDROID_USE_GOLD_LINKER} CACHE BOOL "Enables gold linker" FORCE ) + mark_as_advanced( ANDROID_USE_GOLD_LINKER ) + if( ANDROID_USE_GOLD_LINKER ) + set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=gold" ) + endif() +endif() + # cache flags set( CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags" ) set( CMAKE_C_FLAGS "${_CMAKE_C_FLAGS}" CACHE STRING "c flags" ) @@ -1058,7 +1068,8 @@ if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" ) set( __toolchain_config "") foreach( __var NDK_CCACHE ANDROID_ABI ANDROID_FORCE_ARM_BUILD ANDROID_NATIVE_API_LEVEL ANDROID_NO_UNDEFINED ANDROID_SO_UNDEFINED ANDROID_SET_OBSOLETE_VARIABLES LIBRARY_OUTPUT_PATH_ROOT ANDROID_USE_STLPORT - ANDROID_FORBID_SYGWIN ANDROID_NDK ANDROID_STANDALONE_TOOLCHAIN ANDROID_FUNCTION_LEVEL_LINKING __ndklibspath ) + ANDROID_FORBID_SYGWIN ANDROID_NDK ANDROID_STANDALONE_TOOLCHAIN ANDROID_FUNCTION_LEVEL_LINKING + ANDROID_USE_GOLD_LINKER __ndklibspath ) if( DEFINED ${__var} ) if( "${__var}" MATCHES " ") set( __toolchain_config "${__toolchain_config}set( ${__var} \"${${__var}}\" CACHE INTERNAL \"\" )\n" ) @@ -1092,9 +1103,11 @@ endif() # ANDROID_NO_UNDEFINED : ON/OFF # ANDROID_SO_UNDEFINED : OFF/ON (default depends on NDK version) # ANDROID_FUNCTION_LEVEL_LINKING : ON/OFF +# ANDROID_USE_GOLD_LINKER : ON/OFF (default depends on NDK version and host & target platforms) # Variables that takes effect only at first run: # ANDROID_FORCE_ARM_BUILD : ON/OFF # LIBRARY_OUTPUT_PATH_ROOT : +# NDK_CCACHE : # Can be set only at the first run: # ANDROID_NDK # ANDROID_STANDALONE_TOOLCHAIN