Skip to content

Commit

Permalink
Correct cpu features detection during cross-compiation
Browse files Browse the repository at this point in the history
Closes #4150
  • Loading branch information
aol-nnov committed Nov 12, 2024
1 parent 0946631 commit 33e8a26
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 12 deletions.
68 changes: 68 additions & 0 deletions aclocal.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# generated automatically by aclocal 1.16.5 -*- Autoconf -*-

# Copyright (C) 1996-2021 Free Software Foundation, Inc.

# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.

m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the current language's compiler
# or gives an error. (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <[email protected]>
# Copyright (c) 2011 Maarten Bosmans <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 6

AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS

102 changes: 94 additions & 8 deletions aconfigure
Original file line number Diff line number Diff line change
Expand Up @@ -4505,11 +4505,11 @@ if test x$ac_prog_cxx_stdcxx = xno
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5
printf %s "checking for $CXX option to enable C++11 features... " >&6; }
if test ${ac_cv_prog_cxx_11+y}
if test ${ac_cv_prog_cxx_cxx11+y}
then :
printf %s "(cached) " >&6
else $as_nop
ac_cv_prog_cxx_11=no
ac_cv_prog_cxx_cxx11=no
ac_save_CXX=$CXX
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
Expand Down Expand Up @@ -4551,11 +4551,11 @@ if test x$ac_prog_cxx_stdcxx = xno
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5
printf %s "checking for $CXX option to enable C++98 features... " >&6; }
if test ${ac_cv_prog_cxx_98+y}
if test ${ac_cv_prog_cxx_cxx98+y}
then :
printf %s "(cached) " >&6
else $as_nop
ac_cv_prog_cxx_98=no
ac_cv_prog_cxx_cxx98=no
ac_save_CXX=$CXX
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
Expand Down Expand Up @@ -10270,6 +10270,88 @@ printf "%s\n" "Checking if libyuv is disabled...no" >&6; }
fi


case $target_cpu in
arm*)
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mfpu=neon" >&5
printf %s "checking whether C compiler accepts -mfpu=neon... " >&6; }
if test ${ax_cv_check_cflags___mfpu_neon+y}
then :
printf %s "(cached) " >&6
else $as_nop

ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS -mfpu=neon"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main (void)
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
ax_cv_check_cflags___mfpu_neon=yes
else $as_nop
ax_cv_check_cflags___mfpu_neon=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___mfpu_neon" >&5
printf "%s\n" "$ax_cv_check_cflags___mfpu_neon" >&6; }
if test "x$ax_cv_check_cflags___mfpu_neon" = xyes
then :
ax_cv_support_neon_ext=yes
else $as_nop
:
fi

;;
aarch64*)
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -march=armv8-a+simd" >&5
printf %s "checking whether C compiler accepts -march=armv8-a+simd... " >&6; }
if test ${ax_cv_check_cflags___march_armv8_apsimd+y}
then :
printf %s "(cached) " >&6
else $as_nop

ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS -march=armv8-a+simd"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main (void)
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
ax_cv_check_cflags___march_armv8_apsimd=yes
else $as_nop
ax_cv_check_cflags___march_armv8_apsimd=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___march_armv8_apsimd" >&5
printf "%s\n" "$ax_cv_check_cflags___march_armv8_apsimd" >&6; }
if test "x$ax_cv_check_cflags___march_armv8_apsimd" = xyes
then :
ax_cv_support_neon_ext=yes
else $as_nop
:
fi

;;
esac



Expand Down Expand Up @@ -10338,10 +10420,14 @@ printf "%s\n" "Checking if libwebrtc is disabled...no" >&6; }
;;
*win32* | *w32* | *darwin* | *linux*)
case $target in
armv7l*gnueabihf)
ac_webrtc_instset=neon
ac_webrtc_cflags="-DWEBRTC_ARCH_ARM_V7 -mfloat-abi=hard -mfpu=neon"
;;
armv*gnueabihf)
if test "x$ax_cv_support_neon_ext" = "xyes"; then
ac_webrtc_instset=neon
ac_webrtc_cflags="-DWEBRTC_ARCH_ARM_V7 -mfloat-abi=hard -mfpu=neon"
else
ac_webrtc_instset=generic
fi
;;
arm-apple-darwin* | aarch64*)
ac_webrtc_instset=neon
ac_webrtc_cflags="-DWEBRTC_ARCH_ARM64"
Expand Down
21 changes: 17 additions & 4 deletions aconfigure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2415,6 +2415,15 @@ AC_ARG_ENABLE(libyuv,
fi],
AC_MSG_RESULT([Checking if libyuv is disabled...no]))

dnl proper neon detector
case $target_cpu in
arm*)
AX_CHECK_COMPILE_FLAG(-mfpu=neon, ax_cv_support_neon_ext=yes, [])
;;
aarch64*)
AX_CHECK_COMPILE_FLAG(-march=armv8-a+simd, ax_cv_support_neon_ext=yes, [])
;;
esac

dnl # Include webrtc
AC_SUBST(ac_no_webrtc)
Expand Down Expand Up @@ -2480,10 +2489,14 @@ AC_ARG_ENABLE(libwebrtc,
;;
*win32* | *w32* | *darwin* | *linux*)
case $target in
armv7l*gnueabihf)
ac_webrtc_instset=neon
ac_webrtc_cflags="-DWEBRTC_ARCH_ARM_V7 -mfloat-abi=hard -mfpu=neon"
;;
armv*gnueabihf)
if test "x$ax_cv_support_neon_ext" = "xyes"; then
ac_webrtc_instset=neon
ac_webrtc_cflags="-DWEBRTC_ARCH_ARM_V7 -mfloat-abi=hard -mfpu=neon"
else
ac_webrtc_instset=generic
fi
;;
arm-apple-darwin* | aarch64*)
ac_webrtc_instset=neon
ac_webrtc_cflags="-DWEBRTC_ARCH_ARM64"
Expand Down

0 comments on commit 33e8a26

Please sign in to comment.