michael@0: dnl This Source Code Form is subject to the terms of the Mozilla Public michael@0: dnl License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: AC_DEFUN([MOZ_ARCH_OPTS], michael@0: [ michael@0: michael@0: dnl ======================================================== michael@0: dnl = ARM toolchain tweaks michael@0: dnl ======================================================== michael@0: michael@0: MOZ_THUMB=toolchain-default michael@0: MOZ_THUMB_INTERWORK=toolchain-default michael@0: MOZ_FPU=toolchain-default michael@0: MOZ_FLOAT_ABI=toolchain-default michael@0: MOZ_SOFT_FLOAT=toolchain-default michael@0: MOZ_ALIGN=toolchain-default michael@0: michael@0: MOZ_ARG_WITH_STRING(arch, michael@0: [ --with-arch=[[type|toolchain-default]] michael@0: Use specific CPU features (-march=type). Resets michael@0: thumb, fpu, float-abi, etc. defaults when set], michael@0: if test -z "$GNU_CC"; then michael@0: AC_MSG_ERROR([--with-arch is not supported on non-GNU toolchains]) michael@0: fi michael@0: MOZ_ARCH=$withval) michael@0: michael@0: if test -z "$MOZ_ARCH"; then michael@0: dnl Defaults michael@0: case "${CPU_ARCH}-${OS_TARGET}" in michael@0: arm-Android) michael@0: MOZ_THUMB=yes michael@0: MOZ_ARCH=armv7-a michael@0: MOZ_FPU=vfp michael@0: MOZ_FLOAT_ABI=softfp michael@0: MOZ_ALIGN=no michael@0: ;; michael@0: arm-Darwin) michael@0: MOZ_ARCH=toolchain-default michael@0: MOZ_THUMB=yes michael@0: ;; michael@0: esac michael@0: fi michael@0: michael@0: if test "$MOZ_ARCH" = "armv6" -a "$OS_TARGET" = "Android"; then michael@0: MOZ_FPU=vfp michael@0: fi michael@0: michael@0: MOZ_ARG_WITH_STRING(thumb, michael@0: [ --with-thumb[[=yes|no|toolchain-default]]] michael@0: [ Use Thumb instruction set (-mthumb)], michael@0: if test -z "$GNU_CC"; then michael@0: AC_MSG_ERROR([--with-thumb is not supported on non-GNU toolchains]) michael@0: fi michael@0: MOZ_THUMB=$withval) michael@0: michael@0: MOZ_ARG_WITH_STRING(thumb-interwork, michael@0: [ --with-thumb-interwork[[=yes|no|toolchain-default]] michael@0: Use Thumb/ARM instuctions interwork (-mthumb-interwork)], michael@0: if test -z "$GNU_CC"; then michael@0: AC_MSG_ERROR([--with-thumb-interwork is not supported on non-GNU toolchains]) michael@0: fi michael@0: MOZ_THUMB_INTERWORK=$withval) michael@0: michael@0: MOZ_ARG_WITH_STRING(fpu, michael@0: [ --with-fpu=[[type|toolchain-default]] michael@0: Use specific FPU type (-mfpu=type)], michael@0: if test -z "$GNU_CC"; then michael@0: AC_MSG_ERROR([--with-fpu is not supported on non-GNU toolchains]) michael@0: fi michael@0: MOZ_FPU=$withval) michael@0: michael@0: MOZ_ARG_WITH_STRING(float-abi, michael@0: [ --with-float-abi=[[type|toolchain-default]] michael@0: Use specific arm float ABI (-mfloat-abi=type)], michael@0: if test -z "$GNU_CC"; then michael@0: AC_MSG_ERROR([--with-float-abi is not supported on non-GNU toolchains]) michael@0: fi michael@0: MOZ_FLOAT_ABI=$withval) michael@0: michael@0: MOZ_ARG_WITH_STRING(soft-float, michael@0: [ --with-soft-float[[=yes|no|toolchain-default]] michael@0: Use soft float library (-msoft-float)], michael@0: if test -z "$GNU_CC"; then michael@0: AC_MSG_ERROR([--with-soft-float is not supported on non-GNU toolchains]) michael@0: fi michael@0: MOZ_SOFT_FLOAT=$withval) michael@0: michael@0: case "$MOZ_ARCH" in michael@0: toolchain-default|"") michael@0: arch_flag="" michael@0: ;; michael@0: *) michael@0: arch_flag="-march=$MOZ_ARCH" michael@0: ;; michael@0: esac michael@0: michael@0: case "$MOZ_THUMB" in michael@0: yes) michael@0: MOZ_THUMB2=1 michael@0: thumb_flag="-mthumb" michael@0: ;; michael@0: no) michael@0: MOZ_THUMB2= michael@0: thumb_flag="-marm" michael@0: ;; michael@0: *) michael@0: _SAVE_CFLAGS="$CFLAGS" michael@0: CFLAGS="$arch_flag" michael@0: AC_TRY_COMPILE([],[return sizeof(__thumb2__);], michael@0: MOZ_THUMB2=1, michael@0: MOZ_THUMB2=) michael@0: CFLAGS="$_SAVE_CFLAGS" michael@0: thumb_flag="" michael@0: ;; michael@0: esac michael@0: michael@0: if test "$MOZ_THUMB2" = 1; then michael@0: AC_DEFINE(MOZ_THUMB2) michael@0: fi michael@0: michael@0: case "$MOZ_THUMB_INTERWORK" in michael@0: yes) michael@0: thumb_interwork_flag="-mthumb-interwork" michael@0: ;; michael@0: no) michael@0: thumb_interwork_flag="-mno-thumb-interwork" michael@0: ;; michael@0: *) # toolchain-default michael@0: thumb_interwork_flag="" michael@0: ;; michael@0: esac michael@0: michael@0: case "$MOZ_FPU" in michael@0: toolchain-default|"") michael@0: fpu_flag="" michael@0: ;; michael@0: *) michael@0: fpu_flag="-mfpu=$MOZ_FPU" michael@0: ;; michael@0: esac michael@0: michael@0: case "$MOZ_FLOAT_ABI" in michael@0: toolchain-default|"") michael@0: float_abi_flag="" michael@0: ;; michael@0: *) michael@0: float_abi_flag="-mfloat-abi=$MOZ_FLOAT_ABI" michael@0: ;; michael@0: esac michael@0: michael@0: case "$MOZ_SOFT_FLOAT" in michael@0: yes) michael@0: soft_float_flag="-msoft-float" michael@0: ;; michael@0: no) michael@0: soft_float_flag="-mno-soft-float" michael@0: ;; michael@0: *) # toolchain-default michael@0: soft_float_flag="" michael@0: ;; michael@0: esac michael@0: michael@0: case "$MOZ_ALIGN" in michael@0: no) michael@0: align_flag="-mno-unaligned-access" michael@0: ;; michael@0: yes) michael@0: align_flag="-munaligned-access" michael@0: ;; michael@0: *) michael@0: align_flag="" michael@0: ;; michael@0: esac michael@0: michael@0: if test -n "$align_flag"; then michael@0: _SAVE_CFLAGS="$CFLAGS" michael@0: CFLAGS="$CFLAGS $align_flag" michael@0: AC_MSG_CHECKING(whether alignment flag ($align_flag) is supported) michael@0: AC_TRY_COMPILE([],[],,align_flag="") michael@0: CFLAGS="$_SAVE_CFLAGS" michael@0: fi michael@0: michael@0: dnl Use echo to avoid accumulating space characters michael@0: all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag` michael@0: if test -n "$all_flags"; then michael@0: _SAVE_CFLAGS="$CFLAGS" michael@0: CFLAGS="$all_flags" michael@0: AC_MSG_CHECKING(whether the chosen combination of compiler flags ($all_flags) works) michael@0: AC_TRY_COMPILE([],[return 0;], michael@0: AC_MSG_RESULT([yes]), michael@0: AC_MSG_ERROR([no])) michael@0: michael@0: CFLAGS="$_SAVE_CFLAGS $all_flags" michael@0: CXXFLAGS="$CXXFLAGS $all_flags" michael@0: ASFLAGS="$ASFLAGS $all_flags" michael@0: if test -n "$thumb_flag"; then michael@0: LDFLAGS="$LDFLAGS $thumb_flag" michael@0: fi michael@0: fi michael@0: michael@0: AC_SUBST(MOZ_THUMB2) michael@0: michael@0: if test "$CPU_ARCH" = "arm"; then michael@0: AC_MSG_CHECKING(for ARM SIMD support in compiler) michael@0: # We try to link so that this also fails when michael@0: # building with LTO. michael@0: AC_TRY_LINK([], michael@0: [asm("uqadd8 r1, r1, r2");], michael@0: result="yes", result="no") michael@0: AC_MSG_RESULT("$result") michael@0: if test "$result" = "yes"; then michael@0: AC_DEFINE(HAVE_ARM_SIMD) michael@0: HAVE_ARM_SIMD=1 michael@0: fi michael@0: michael@0: AC_MSG_CHECKING(ARM version support in compiler) michael@0: dnl Determine the target ARM architecture (5 for ARMv5, v5T, v5E, etc.; 6 for ARMv6, v6K, etc.) michael@0: ARM_ARCH=`${CC-cc} ${CFLAGS} -dM -E - < /dev/null | sed -n 's/.*__ARM_ARCH_\([[0-9]][[0-9]]*\).*/\1/p'` michael@0: AC_MSG_RESULT("$ARM_ARCH") michael@0: michael@0: AC_MSG_CHECKING(for ARM NEON support in compiler) michael@0: # We try to link so that this also fails when michael@0: # building with LTO. michael@0: AC_TRY_LINK([], michael@0: [asm(".fpu neon\n vadd.i8 d0, d0, d0");], michael@0: result="yes", result="no") michael@0: AC_MSG_RESULT("$result") michael@0: if test "$result" = "yes"; then michael@0: AC_DEFINE(HAVE_ARM_NEON) michael@0: HAVE_ARM_NEON=1 michael@0: michael@0: dnl We don't need to build NEON support if we're targetting a non-NEON device. michael@0: dnl This matches media/webrtc/trunk/webrtc/build/common.gypi. michael@0: if test -n "$ARM_ARCH"; then michael@0: if test "$ARM_ARCH" -lt 7; then michael@0: BUILD_ARM_NEON= michael@0: else michael@0: AC_DEFINE(BUILD_ARM_NEON) michael@0: BUILD_ARM_NEON=1 michael@0: fi michael@0: fi michael@0: fi michael@0: michael@0: fi # CPU_ARCH = arm michael@0: michael@0: AC_SUBST(HAVE_ARM_SIMD) michael@0: AC_SUBST(HAVE_ARM_NEON) michael@0: AC_SUBST(BUILD_ARM_NEON) michael@0: AC_SUBST(ARM_ARCH) michael@0: michael@0: if test -n "$MOZ_ARCH"; then michael@0: NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-arch=$MOZ_ARCH" michael@0: NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-thumb=$MOZ_THUMB" michael@0: NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-thumb-interwork=$MOZ_THUMB_INTERWORK" michael@0: NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-fpu=$MOZ_FPU" michael@0: NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-float-abi=$MOZ_FLOAT_ABI" michael@0: NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-soft-float=$MOZ_SOFT_FLOAT" michael@0: fi michael@0: michael@0: ])