1 From 233413841882608c6d5b98b6ce89fcb8a292db82 Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Sat, 6 Aug 2016 10:22:34 +0200
4 Subject: [PATCH] configure.ac: fix architecture detection
6 The current architecture detection, based on the "host_cpu" part of the
7 tuple does not work properly for a number of reason:
9 - The code assumes that if host_cpu starts with "arm" then ARM
10 instructions are available, which is incorrect. Indeed, Cortex-M
11 platforms can run Linux, they are ARM platforms (so host_cpu = arm),
12 but they don't support ARM instructions: they support only the
13 Thumb-2 instruction set.
15 - The armv7 case is also not very useful, as it is not standard at all
16 to pass armv7 as host_cpu even if the host system is actually ARMv7
19 - For the same reason, the armv8 case is not very useful: armv8 is
20 never used as the host_cpu part of a tuple.
22 So, this commit moves away from a host_cpu based logic, and instead
23 tests using AC_CHECK_DECLS() the built-in definitions of the compiler:
25 - If we have __ARM_ARCH_ISA_ARM defined, then it's an ARM processor
26 that supports the ARM instruction set (this allows to exclude Thumb-2
29 - If we have __ARM_ARCH_7A__, then we have an ARMv7-A processor, and
30 we can enable the corresponding optimizations
32 - Same for __i386__ and __x86_64__.
34 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
36 Submitted upstream, under a slightly different form so that it applies
39 https://lists.freedesktop.org/archives/pulseaudio-discuss/2016-August/026600.html
41 configure.ac | 27 +++++++++------------------
42 1 file changed, 9 insertions(+), 18 deletions(-)
44 diff --git a/configure.ac b/configure.ac
45 index 6f9553b..836c6ad 100644
48 @@ -55,24 +55,15 @@ AS_CASE(["${host}"],
50 AC_SUBST(PLATFORM_CFLAGS)
52 -AS_CASE(["${host_cpu}"],
61 - ARCH_CFLAGS="-DWEBRTC_ARCH_ARM -DWEBRTC_ARCH_ARM_V7"
66 - ARCH_CFLAGS="-DWEBRTC_ARCH_ARM"
68 - # FIXME: Add MIPS support, see webrtc/BUILD.gn for defines
70 +# Testing __ARM_ARCH_ISA_ARM since the code contains ARM instructions,
71 +# which don't work on Thumb-2 only platforms (ARMv7-M).
72 +AC_CHECK_DECLS([__ARM_ARCH_ISA_ARM],
73 + [HAVE_ARM=1; ARCH_CFLAGS="${ARCH_CFLAGS} -DWEBRTC_ARCH_ARM"])
74 +AC_CHECK_DECLS([__ARM_ARCH_7A__],
75 + [HAVE_ARMV7=1; ARCH_CFLAGS="${ARCH_CFLAGS} -DWEBRTC_ARCH_ARM_V7"])
76 +AC_CHECK_DECLS([__i386__], [HAVE_X86=1])
77 +AC_CHECK_DECLS([__x86_64__], [HAVE_X86=1])
79 AM_CONDITIONAL(HAVE_X86, [test "x${HAVE_X86}" = "x1"])
80 AM_CONDITIONAL(HAVE_ARM, [test "x${HAVE_ARM}" = "x1"])
81 AM_CONDITIONAL(HAVE_ARMV7, [test "x${HAVE_ARMV7}" = "x1"])