0001-configure.ac-fix-architecture-detection.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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
  5. The current architecture detection, based on the "host_cpu" part of the
  6. tuple does not work properly for a number of reason:
  7. - The code assumes that if host_cpu starts with "arm" then ARM
  8. instructions are available, which is incorrect. Indeed, Cortex-M
  9. platforms can run Linux, they are ARM platforms (so host_cpu = arm),
  10. but they don't support ARM instructions: they support only the
  11. Thumb-2 instruction set.
  12. - The armv7 case is also not very useful, as it is not standard at all
  13. to pass armv7 as host_cpu even if the host system is actually ARMv7
  14. based.
  15. - For the same reason, the armv8 case is not very useful: armv8 is
  16. never used as the host_cpu part of a tuple.
  17. So, this commit moves away from a host_cpu based logic, and instead
  18. tests using AC_CHECK_DECLS() the built-in definitions of the compiler:
  19. - If we have __ARM_ARCH_ISA_ARM defined, then it's an ARM processor
  20. that supports the ARM instruction set (this allows to exclude Thumb-2
  21. only processors).
  22. - If we have __ARM_ARCH_7A__, then we have an ARMv7-A processor, and
  23. we can enable the corresponding optimizations
  24. - Same for __i386__ and __x86_64__.
  25. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  26. ---
  27. Submitted upstream, under a slightly different form so that it applies
  28. on master:
  29. https://lists.freedesktop.org/archives/pulseaudio-discuss/2016-August/026600.html
  30. ---
  31. configure.ac | 27 +++++++++------------------
  32. 1 file changed, 9 insertions(+), 18 deletions(-)
  33. diff --git a/configure.ac b/configure.ac
  34. index 6f9553b..836c6ad 100644
  35. --- a/configure.ac
  36. +++ b/configure.ac
  37. @@ -55,24 +55,15 @@ AS_CASE(["${host}"],
  38. )
  39. AC_SUBST(PLATFORM_CFLAGS)
  40. -AS_CASE(["${host_cpu}"],
  41. - [i?86|x86_64],
  42. - [
  43. - HAVE_X86=1
  44. - ],
  45. - [armv7*|armv8*],
  46. - [
  47. - HAVE_ARM=1
  48. - HAVE_ARMV7=1
  49. - ARCH_CFLAGS="-DWEBRTC_ARCH_ARM -DWEBRTC_ARCH_ARM_V7"
  50. - ],
  51. - [arm*],
  52. - [
  53. - HAVE_ARM=1
  54. - ARCH_CFLAGS="-DWEBRTC_ARCH_ARM"
  55. - ]
  56. - # FIXME: Add MIPS support, see webrtc/BUILD.gn for defines
  57. -)
  58. +# Testing __ARM_ARCH_ISA_ARM since the code contains ARM instructions,
  59. +# which don't work on Thumb-2 only platforms (ARMv7-M).
  60. +AC_CHECK_DECLS([__ARM_ARCH_ISA_ARM],
  61. + [HAVE_ARM=1; ARCH_CFLAGS="${ARCH_CFLAGS} -DWEBRTC_ARCH_ARM"])
  62. +AC_CHECK_DECLS([__ARM_ARCH_7A__],
  63. + [HAVE_ARMV7=1; ARCH_CFLAGS="${ARCH_CFLAGS} -DWEBRTC_ARCH_ARM_V7"])
  64. +AC_CHECK_DECLS([__i386__], [HAVE_X86=1])
  65. +AC_CHECK_DECLS([__x86_64__], [HAVE_X86=1])
  66. +
  67. AM_CONDITIONAL(HAVE_X86, [test "x${HAVE_X86}" = "x1"])
  68. AM_CONDITIONAL(HAVE_ARM, [test "x${HAVE_ARM}" = "x1"])
  69. AM_CONDITIONAL(HAVE_ARMV7, [test "x${HAVE_ARMV7}" = "x1"])
  70. --
  71. 2.7.4