1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/build/autoconf/arch.m4 Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,261 @@ 1.4 +dnl This Source Code Form is subject to the terms of the Mozilla Public 1.5 +dnl License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 +dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +AC_DEFUN([MOZ_ARCH_OPTS], 1.9 +[ 1.10 + 1.11 +dnl ======================================================== 1.12 +dnl = ARM toolchain tweaks 1.13 +dnl ======================================================== 1.14 + 1.15 +MOZ_THUMB=toolchain-default 1.16 +MOZ_THUMB_INTERWORK=toolchain-default 1.17 +MOZ_FPU=toolchain-default 1.18 +MOZ_FLOAT_ABI=toolchain-default 1.19 +MOZ_SOFT_FLOAT=toolchain-default 1.20 +MOZ_ALIGN=toolchain-default 1.21 + 1.22 +MOZ_ARG_WITH_STRING(arch, 1.23 +[ --with-arch=[[type|toolchain-default]] 1.24 + Use specific CPU features (-march=type). Resets 1.25 + thumb, fpu, float-abi, etc. defaults when set], 1.26 + if test -z "$GNU_CC"; then 1.27 + AC_MSG_ERROR([--with-arch is not supported on non-GNU toolchains]) 1.28 + fi 1.29 + MOZ_ARCH=$withval) 1.30 + 1.31 +if test -z "$MOZ_ARCH"; then 1.32 + dnl Defaults 1.33 + case "${CPU_ARCH}-${OS_TARGET}" in 1.34 + arm-Android) 1.35 + MOZ_THUMB=yes 1.36 + MOZ_ARCH=armv7-a 1.37 + MOZ_FPU=vfp 1.38 + MOZ_FLOAT_ABI=softfp 1.39 + MOZ_ALIGN=no 1.40 + ;; 1.41 + arm-Darwin) 1.42 + MOZ_ARCH=toolchain-default 1.43 + MOZ_THUMB=yes 1.44 + ;; 1.45 + esac 1.46 +fi 1.47 + 1.48 +if test "$MOZ_ARCH" = "armv6" -a "$OS_TARGET" = "Android"; then 1.49 + MOZ_FPU=vfp 1.50 +fi 1.51 + 1.52 +MOZ_ARG_WITH_STRING(thumb, 1.53 +[ --with-thumb[[=yes|no|toolchain-default]]] 1.54 +[ Use Thumb instruction set (-mthumb)], 1.55 + if test -z "$GNU_CC"; then 1.56 + AC_MSG_ERROR([--with-thumb is not supported on non-GNU toolchains]) 1.57 + fi 1.58 + MOZ_THUMB=$withval) 1.59 + 1.60 +MOZ_ARG_WITH_STRING(thumb-interwork, 1.61 +[ --with-thumb-interwork[[=yes|no|toolchain-default]] 1.62 + Use Thumb/ARM instuctions interwork (-mthumb-interwork)], 1.63 + if test -z "$GNU_CC"; then 1.64 + AC_MSG_ERROR([--with-thumb-interwork is not supported on non-GNU toolchains]) 1.65 + fi 1.66 + MOZ_THUMB_INTERWORK=$withval) 1.67 + 1.68 +MOZ_ARG_WITH_STRING(fpu, 1.69 +[ --with-fpu=[[type|toolchain-default]] 1.70 + Use specific FPU type (-mfpu=type)], 1.71 + if test -z "$GNU_CC"; then 1.72 + AC_MSG_ERROR([--with-fpu is not supported on non-GNU toolchains]) 1.73 + fi 1.74 + MOZ_FPU=$withval) 1.75 + 1.76 +MOZ_ARG_WITH_STRING(float-abi, 1.77 +[ --with-float-abi=[[type|toolchain-default]] 1.78 + Use specific arm float ABI (-mfloat-abi=type)], 1.79 + if test -z "$GNU_CC"; then 1.80 + AC_MSG_ERROR([--with-float-abi is not supported on non-GNU toolchains]) 1.81 + fi 1.82 + MOZ_FLOAT_ABI=$withval) 1.83 + 1.84 +MOZ_ARG_WITH_STRING(soft-float, 1.85 +[ --with-soft-float[[=yes|no|toolchain-default]] 1.86 + Use soft float library (-msoft-float)], 1.87 + if test -z "$GNU_CC"; then 1.88 + AC_MSG_ERROR([--with-soft-float is not supported on non-GNU toolchains]) 1.89 + fi 1.90 + MOZ_SOFT_FLOAT=$withval) 1.91 + 1.92 +case "$MOZ_ARCH" in 1.93 +toolchain-default|"") 1.94 + arch_flag="" 1.95 + ;; 1.96 +*) 1.97 + arch_flag="-march=$MOZ_ARCH" 1.98 + ;; 1.99 +esac 1.100 + 1.101 +case "$MOZ_THUMB" in 1.102 +yes) 1.103 + MOZ_THUMB2=1 1.104 + thumb_flag="-mthumb" 1.105 + ;; 1.106 +no) 1.107 + MOZ_THUMB2= 1.108 + thumb_flag="-marm" 1.109 + ;; 1.110 +*) 1.111 + _SAVE_CFLAGS="$CFLAGS" 1.112 + CFLAGS="$arch_flag" 1.113 + AC_TRY_COMPILE([],[return sizeof(__thumb2__);], 1.114 + MOZ_THUMB2=1, 1.115 + MOZ_THUMB2=) 1.116 + CFLAGS="$_SAVE_CFLAGS" 1.117 + thumb_flag="" 1.118 + ;; 1.119 +esac 1.120 + 1.121 +if test "$MOZ_THUMB2" = 1; then 1.122 + AC_DEFINE(MOZ_THUMB2) 1.123 +fi 1.124 + 1.125 +case "$MOZ_THUMB_INTERWORK" in 1.126 +yes) 1.127 + thumb_interwork_flag="-mthumb-interwork" 1.128 + ;; 1.129 +no) 1.130 + thumb_interwork_flag="-mno-thumb-interwork" 1.131 + ;; 1.132 +*) # toolchain-default 1.133 + thumb_interwork_flag="" 1.134 + ;; 1.135 +esac 1.136 + 1.137 +case "$MOZ_FPU" in 1.138 +toolchain-default|"") 1.139 + fpu_flag="" 1.140 + ;; 1.141 +*) 1.142 + fpu_flag="-mfpu=$MOZ_FPU" 1.143 + ;; 1.144 +esac 1.145 + 1.146 +case "$MOZ_FLOAT_ABI" in 1.147 +toolchain-default|"") 1.148 + float_abi_flag="" 1.149 + ;; 1.150 +*) 1.151 + float_abi_flag="-mfloat-abi=$MOZ_FLOAT_ABI" 1.152 + ;; 1.153 +esac 1.154 + 1.155 +case "$MOZ_SOFT_FLOAT" in 1.156 +yes) 1.157 + soft_float_flag="-msoft-float" 1.158 + ;; 1.159 +no) 1.160 + soft_float_flag="-mno-soft-float" 1.161 + ;; 1.162 +*) # toolchain-default 1.163 + soft_float_flag="" 1.164 + ;; 1.165 +esac 1.166 + 1.167 +case "$MOZ_ALIGN" in 1.168 +no) 1.169 + align_flag="-mno-unaligned-access" 1.170 + ;; 1.171 +yes) 1.172 + align_flag="-munaligned-access" 1.173 + ;; 1.174 +*) 1.175 + align_flag="" 1.176 + ;; 1.177 +esac 1.178 + 1.179 +if test -n "$align_flag"; then 1.180 + _SAVE_CFLAGS="$CFLAGS" 1.181 + CFLAGS="$CFLAGS $align_flag" 1.182 + AC_MSG_CHECKING(whether alignment flag ($align_flag) is supported) 1.183 + AC_TRY_COMPILE([],[],,align_flag="") 1.184 + CFLAGS="$_SAVE_CFLAGS" 1.185 +fi 1.186 + 1.187 +dnl Use echo to avoid accumulating space characters 1.188 +all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag` 1.189 +if test -n "$all_flags"; then 1.190 + _SAVE_CFLAGS="$CFLAGS" 1.191 + CFLAGS="$all_flags" 1.192 + AC_MSG_CHECKING(whether the chosen combination of compiler flags ($all_flags) works) 1.193 + AC_TRY_COMPILE([],[return 0;], 1.194 + AC_MSG_RESULT([yes]), 1.195 + AC_MSG_ERROR([no])) 1.196 + 1.197 + CFLAGS="$_SAVE_CFLAGS $all_flags" 1.198 + CXXFLAGS="$CXXFLAGS $all_flags" 1.199 + ASFLAGS="$ASFLAGS $all_flags" 1.200 + if test -n "$thumb_flag"; then 1.201 + LDFLAGS="$LDFLAGS $thumb_flag" 1.202 + fi 1.203 +fi 1.204 + 1.205 +AC_SUBST(MOZ_THUMB2) 1.206 + 1.207 +if test "$CPU_ARCH" = "arm"; then 1.208 + AC_MSG_CHECKING(for ARM SIMD support in compiler) 1.209 + # We try to link so that this also fails when 1.210 + # building with LTO. 1.211 + AC_TRY_LINK([], 1.212 + [asm("uqadd8 r1, r1, r2");], 1.213 + result="yes", result="no") 1.214 + AC_MSG_RESULT("$result") 1.215 + if test "$result" = "yes"; then 1.216 + AC_DEFINE(HAVE_ARM_SIMD) 1.217 + HAVE_ARM_SIMD=1 1.218 + fi 1.219 + 1.220 + AC_MSG_CHECKING(ARM version support in compiler) 1.221 + dnl Determine the target ARM architecture (5 for ARMv5, v5T, v5E, etc.; 6 for ARMv6, v6K, etc.) 1.222 + ARM_ARCH=`${CC-cc} ${CFLAGS} -dM -E - < /dev/null | sed -n 's/.*__ARM_ARCH_\([[0-9]][[0-9]]*\).*/\1/p'` 1.223 + AC_MSG_RESULT("$ARM_ARCH") 1.224 + 1.225 + AC_MSG_CHECKING(for ARM NEON support in compiler) 1.226 + # We try to link so that this also fails when 1.227 + # building with LTO. 1.228 + AC_TRY_LINK([], 1.229 + [asm(".fpu neon\n vadd.i8 d0, d0, d0");], 1.230 + result="yes", result="no") 1.231 + AC_MSG_RESULT("$result") 1.232 + if test "$result" = "yes"; then 1.233 + AC_DEFINE(HAVE_ARM_NEON) 1.234 + HAVE_ARM_NEON=1 1.235 + 1.236 + dnl We don't need to build NEON support if we're targetting a non-NEON device. 1.237 + dnl This matches media/webrtc/trunk/webrtc/build/common.gypi. 1.238 + if test -n "$ARM_ARCH"; then 1.239 + if test "$ARM_ARCH" -lt 7; then 1.240 + BUILD_ARM_NEON= 1.241 + else 1.242 + AC_DEFINE(BUILD_ARM_NEON) 1.243 + BUILD_ARM_NEON=1 1.244 + fi 1.245 + fi 1.246 + fi 1.247 + 1.248 +fi # CPU_ARCH = arm 1.249 + 1.250 +AC_SUBST(HAVE_ARM_SIMD) 1.251 +AC_SUBST(HAVE_ARM_NEON) 1.252 +AC_SUBST(BUILD_ARM_NEON) 1.253 +AC_SUBST(ARM_ARCH) 1.254 + 1.255 +if test -n "$MOZ_ARCH"; then 1.256 + NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-arch=$MOZ_ARCH" 1.257 + NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-thumb=$MOZ_THUMB" 1.258 + NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-thumb-interwork=$MOZ_THUMB_INTERWORK" 1.259 + NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-fpu=$MOZ_FPU" 1.260 + NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-float-abi=$MOZ_FLOAT_ABI" 1.261 + NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-soft-float=$MOZ_SOFT_FLOAT" 1.262 +fi 1.263 + 1.264 +])