1 dnl This Source Code Form is subject to the terms of the Mozilla Public
2 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
3 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 AC_DEFUN([MOZ_ARCH_OPTS],
8 dnl ========================================================
9 dnl = ARM toolchain tweaks
10 dnl ========================================================
12 MOZ_THUMB=toolchain-default
13 MOZ_THUMB_INTERWORK=toolchain-default
14 MOZ_FPU=toolchain-default
15 MOZ_FLOAT_ABI=toolchain-default
16 MOZ_SOFT_FLOAT=toolchain-default
17 MOZ_ALIGN=toolchain-default
19 MOZ_ARG_WITH_STRING(arch,
20 [ --with-arch=[[type|toolchain-default]]
21 Use specific CPU features (-march=type). Resets
22 thumb, fpu, float-abi, etc. defaults when set],
23 if test -z "$GNU_CC"; then
24 AC_MSG_ERROR([--with-arch is not supported on non-GNU toolchains])
28 if test -z "$MOZ_ARCH"; then
30 case "${CPU_ARCH}-${OS_TARGET}" in
39 MOZ_ARCH=toolchain-default
44 if test "$MOZ_ARCH" = "armv6" -a "$OS_TARGET" = "Android"; then
49 MOZ_ARG_WITH_STRING(thumb,
50 [ --with-thumb[[=yes|no|toolchain-default]]]
51 [ Use Thumb instruction set (-mthumb)],
52 if test -z "$GNU_CC"; then
53 AC_MSG_ERROR([--with-thumb is not supported on non-GNU toolchains])
57 MOZ_ARG_WITH_STRING(thumb-interwork,
58 [ --with-thumb-interwork[[=yes|no|toolchain-default]]
59 Use Thumb/ARM instuctions interwork (-mthumb-interwork)],
60 if test -z "$GNU_CC"; then
61 AC_MSG_ERROR([--with-thumb-interwork is not supported on non-GNU toolchains])
63 MOZ_THUMB_INTERWORK=$withval)
65 MOZ_ARG_WITH_STRING(fpu,
66 [ --with-fpu=[[type|toolchain-default]]
67 Use specific FPU type (-mfpu=type)],
68 if test -z "$GNU_CC"; then
69 AC_MSG_ERROR([--with-fpu is not supported on non-GNU toolchains])
73 MOZ_ARG_WITH_STRING(float-abi,
74 [ --with-float-abi=[[type|toolchain-default]]
75 Use specific arm float ABI (-mfloat-abi=type)],
76 if test -z "$GNU_CC"; then
77 AC_MSG_ERROR([--with-float-abi is not supported on non-GNU toolchains])
79 MOZ_FLOAT_ABI=$withval)
81 MOZ_ARG_WITH_STRING(soft-float,
82 [ --with-soft-float[[=yes|no|toolchain-default]]
83 Use soft float library (-msoft-float)],
84 if test -z "$GNU_CC"; then
85 AC_MSG_ERROR([--with-soft-float is not supported on non-GNU toolchains])
87 MOZ_SOFT_FLOAT=$withval)
94 arch_flag="-march=$MOZ_ARCH"
108 _SAVE_CFLAGS="$CFLAGS"
110 AC_TRY_COMPILE([],[return sizeof(__thumb2__);],
113 CFLAGS="$_SAVE_CFLAGS"
118 if test "$MOZ_THUMB2" = 1; then
119 AC_DEFINE(MOZ_THUMB2)
122 case "$MOZ_THUMB_INTERWORK" in
124 thumb_interwork_flag="-mthumb-interwork"
127 thumb_interwork_flag="-mno-thumb-interwork"
129 *) # toolchain-default
130 thumb_interwork_flag=""
135 toolchain-default|"")
139 fpu_flag="-mfpu=$MOZ_FPU"
143 case "$MOZ_FLOAT_ABI" in
144 toolchain-default|"")
148 float_abi_flag="-mfloat-abi=$MOZ_FLOAT_ABI"
152 case "$MOZ_SOFT_FLOAT" in
154 soft_float_flag="-msoft-float"
157 soft_float_flag="-mno-soft-float"
159 *) # toolchain-default
166 align_flag="-mno-unaligned-access"
169 align_flag="-munaligned-access"
176 if test -n "$align_flag"; then
177 _SAVE_CFLAGS="$CFLAGS"
178 CFLAGS="$CFLAGS $align_flag"
179 AC_MSG_CHECKING(whether alignment flag ($align_flag) is supported)
180 AC_TRY_COMPILE([],[],,align_flag="")
181 CFLAGS="$_SAVE_CFLAGS"
184 dnl Use echo to avoid accumulating space characters
185 all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag`
186 if test -n "$all_flags"; then
187 _SAVE_CFLAGS="$CFLAGS"
189 AC_MSG_CHECKING(whether the chosen combination of compiler flags ($all_flags) works)
190 AC_TRY_COMPILE([],[return 0;],
191 AC_MSG_RESULT([yes]),
194 CFLAGS="$_SAVE_CFLAGS $all_flags"
195 CXXFLAGS="$CXXFLAGS $all_flags"
196 ASFLAGS="$ASFLAGS $all_flags"
197 if test -n "$thumb_flag"; then
198 LDFLAGS="$LDFLAGS $thumb_flag"
204 if test "$CPU_ARCH" = "arm"; then
205 NEON_FLAGS="-mfpu=neon"
206 AC_MSG_CHECKING(for ARM SIMD support in compiler)
207 # We try to link so that this also fails when
210 [asm("uqadd8 r1, r1, r2");],
211 result="yes", result="no")
212 AC_MSG_RESULT("$result")
213 if test "$result" = "yes"; then
214 AC_DEFINE(HAVE_ARM_SIMD)
218 AC_MSG_CHECKING(ARM version support in compiler)
219 dnl Determine the target ARM architecture (5 for ARMv5, v5T, v5E, etc.; 6 for ARMv6, v6K, etc.)
220 ARM_ARCH=`${CC-cc} ${CFLAGS} -dM -E - < /dev/null | sed -n 's/.*__ARM_ARCH_\([[0-9]][[0-9]]*\).*/\1/p'`
221 AC_MSG_RESULT("$ARM_ARCH")
223 AC_MSG_CHECKING(for ARM NEON support in compiler)
224 # We try to link so that this also fails when
227 [asm(".fpu neon\n vadd.i8 d0, d0, d0");],
228 result="yes", result="no")
229 AC_MSG_RESULT("$result")
230 if test "$result" = "yes"; then
231 AC_DEFINE(HAVE_ARM_NEON)
234 dnl We don't need to build NEON support if we're targetting a non-NEON device.
235 dnl This matches media/webrtc/trunk/webrtc/build/common.gypi.
236 if test -n "$ARM_ARCH"; then
237 if test "$ARM_ARCH" -lt 7; then
240 AC_DEFINE(BUILD_ARM_NEON)
248 AC_SUBST(HAVE_ARM_SIMD)
249 AC_SUBST(HAVE_ARM_NEON)
250 AC_SUBST(BUILD_ARM_NEON)
252 AC_SUBST_LIST(NEON_FLAGS)