0001-CMakeLists.txt-do-not-force-compiler-flags.patch 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. From b56e9125db34614b2157516df3ee724180f2084f Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  3. Date: Sat, 13 Jul 2024 09:59:26 +0200
  4. Subject: [PATCH] CMakeLists.txt: do not force compiler flags
  5. The compiler flags enforced by CMakeLists.txt can be problematic:
  6. - When CROSS_COMPILE_ARM is set, one is not necessarily building for
  7. armv6 with soft float-abi: one may be using ARMv7 with hard float
  8. - When CROSS_COMPILE_ARM is not set, forcing -mfloat-abi=hard is
  9. similarly wrong
  10. Those compiler flags should be passed by the user depending on the
  11. exact target platform.
  12. Inspired from
  13. https://gitweb.gentoo.org/repo/gentoo.git/tree/media-libs/x265/files/arm-r1.patch,
  14. and earlier work from Bertrand Jacquin <bertrand@jacquin.bzh> and
  15. Bernd Kuhls <bernd.kuhls@t-online.de>.
  16. Upstream: https://bitbucket.org/multicoreware/x265_git/pull-requests/26
  17. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  18. ---
  19. source/CMakeLists.txt | 10 +++-------
  20. source/dynamicHDR10/CMakeLists.txt | 6 +++---
  21. 2 files changed, 6 insertions(+), 10 deletions(-)
  22. diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
  23. index a407271b4..a34bf4d4f 100755
  24. --- a/source/CMakeLists.txt
  25. +++ b/source/CMakeLists.txt
  26. @@ -239,11 +239,7 @@ if(GCC)
  27. endif()
  28. endif()
  29. if(ARM AND CROSS_COMPILE_ARM)
  30. - if(ARM64)
  31. - set(ARM_ARGS -fPIC)
  32. - else()
  33. - set(ARM_ARGS -march=armv6 -mfloat-abi=soft -mfpu=vfp -marm -fPIC)
  34. - endif()
  35. + set(ARM_ARGS -fPIC)
  36. message(STATUS "cross compile arm")
  37. elseif(ARM)
  38. if(ARM64)
  39. @@ -252,10 +248,10 @@ if(GCC)
  40. else()
  41. find_package(Neon)
  42. if(CPU_HAS_NEON)
  43. - set(ARM_ARGS -mcpu=native -mfloat-abi=hard -mfpu=neon -marm -fPIC)
  44. + set(ARM_ARGS -mfpu=neon -fPIC)
  45. add_definitions(-DHAVE_NEON)
  46. else()
  47. - set(ARM_ARGS -mcpu=native -mfloat-abi=hard -mfpu=vfp -marm)
  48. + set(ARM_ARGS -fPIC)
  49. endif()
  50. endif()
  51. endif()
  52. diff --git a/source/dynamicHDR10/CMakeLists.txt b/source/dynamicHDR10/CMakeLists.txt
  53. index 22fb79d44..2cea7c48a 100644
  54. --- a/source/dynamicHDR10/CMakeLists.txt
  55. +++ b/source/dynamicHDR10/CMakeLists.txt
  56. @@ -43,14 +43,14 @@ if(GCC)
  57. endif()
  58. endif()
  59. if(ARM AND CROSS_COMPILE_ARM)
  60. - set(ARM_ARGS -march=armv6 -mfloat-abi=soft -mfpu=vfp -marm -fPIC)
  61. + set(ARM_ARGS -fPIC)
  62. elseif(ARM)
  63. find_package(Neon)
  64. if(CPU_HAS_NEON)
  65. - set(ARM_ARGS -mcpu=native -mfloat-abi=hard -mfpu=neon -marm -fPIC)
  66. + set(ARM_ARGS -fPIC)
  67. add_definitions(-DHAVE_NEON)
  68. else()
  69. - set(ARM_ARGS -mcpu=native -mfloat-abi=hard -mfpu=vfp -marm)
  70. + set(ARM_ARGS -fPIC)
  71. endif()
  72. endif()
  73. add_definitions(${ARM_ARGS})
  74. --
  75. 2.45.2