summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2016-08-06 11:02:43 +0200
committerArun Raghavan <arun@arunraghavan.net>2016-08-10 20:37:27 +0530
commitff77a85c28564d939d554ba264480d1876cbc316 (patch)
tree7754f54bc7f31eabe857218c0cb32c53b59f055f
parent7d15b10fb0829d456486da6a49a84492dd3eca4f (diff)
build: fix architecture detection
The current architecture detection, based on the "host_cpu" part of the tuple does not work properly for a number of reason: - The code assumes that if host_cpu starts with "arm" then ARM instructions are available, which is incorrect. Indeed, Cortex-M platforms can run Linux, they are ARM platforms (so host_cpu = arm), but they don't support ARM instructions: they support only the Thumb-2 instruction set. - The armv7 case is also not very useful, as it is not standard at all to pass armv7 as host_cpu even if the host system is actually ARMv7 based. - For the same reason, the armv8 case is not very useful: ARMv8 is AArch64, and there is already a separate case to handle this architecture. So, this commit moves away from a host_cpu based logic, and instead tests using AC_CHECK_DECLS() the built-in definitions of the compiler: - If we have __ARM_ARCH_ISA_ARM defined, then it's an ARM processor that supports the ARM instruction set (this allows to exclude Thumb-2 only processors). - If we have __ARM_ARCH_7A__, then we have an ARMv7-A processor, and we can enable the corresponding optimizations - Same for __aarch64__, __i386__ and __x86_64__. In addition, we remove the AC_MSG_ERROR() that makes the build fail for all architectures but the ones that are explicitly supported. Indeed, webrtc-audio-processing builds just fine for other architectures (tested on MIPS), it's just that none of the architecture-specific optimizations will be used. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-rw-r--r--configure.ac35
1 files changed, 11 insertions, 24 deletions
diff --git a/configure.ac b/configure.ac
index b4b9ddf..acbb3e2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,30 +83,17 @@ AC_SUBST(PLATFORM_CFLAGS)
AM_CONDITIONAL(HAVE_POSIX, [test "x${HAVE_POSIX}" = "x1"])
AM_CONDITIONAL(HAVE_WIN, [test "x${HAVE_WIN}" = "x1"])
-AS_CASE(["${host_cpu}"],
- [i?86|x86_64],
- [
- HAVE_X86=1
- ],
- [armv7*|armv8*],
- [
- HAVE_ARM=1
- HAVE_ARMV7=1
- ARCH_CFLAGS="-DWEBRTC_ARCH_ARM -DWEBRTC_ARCH_ARM_V7"
- ],
- [arm*],
- [
- HAVE_ARM=1
- ARCH_CFLAGS="-DWEBRTC_ARCH_ARM"
- ],
- [aarch64*],
- [
- HAVE_NEON=1
- ARCH_CFLAGS="-DWEBRTC_HAS_NEON -DWEBRTC_ARCH_ARM64"
- ],
- # FIXME: Add MIPS support, see webrtc/BUILD.gn for defines
- [AC_MSG_ERROR([Unsupported CPU type $host_cpu])]
-)
+# Testing __ARM_ARCH_ISA_ARM since the code contains ARM instructions,
+# which don't work on Thumb-2 only platforms (ARMv7-M).
+AC_CHECK_DECLS([__ARM_ARCH_ISA_ARM],
+ [HAVE_ARM=1; ARCH_CFLAGS="${ARCH_CFLAGS} -DWEBRTC_ARCH_ARM"])
+AC_CHECK_DECLS([__ARM_ARCH_7A__],
+ [HAVE_ARMV7=1; ARCH_CFLAGS="${ARCH_CFLAGS} -DWEBRTC_ARCH_ARM_V7"])
+AC_CHECK_DECLS([__aarch64__],
+ [HAVE_NEON=1; ARCH_CFLAGS="${ARCH_CFLAGS} -DWEBRTC_HAS_NEON -DWEBRTC_ARCH_ARM64"])
+AC_CHECK_DECLS([__i386__], [HAVE_X86=1])
+AC_CHECK_DECLS([__x86_64__], [HAVE_X86=1])
+
AM_CONDITIONAL(HAVE_X86, [test "x${HAVE_X86}" = "x1"])
AM_CONDITIONAL(HAVE_ARM, [test "x${HAVE_ARM}" = "x1"])
AM_CONDITIONAL(HAVE_ARMV7, [test "x${HAVE_ARMV7}" = "x1"])