[x265] [PATCH] Fix compilation errors on MAC Apple silicon
Kalaiyarasi Saravanan
kalaiyarasi at multicorewareinc.com
Wed Aug 11 08:38:38 UTC 2021
>From 47f2a32447172d033b7ebf9d7641ddbff47b758c Mon Sep 17 00:00:00 2001
From: lwWang <liwei at multicorewareinc.com>
Date: Wed, 11 Aug 2021 10:50:43 +0800
Subject: [PATCH] fix the compiling errors on MAC
---
source/CMakeLists.txt | 7 +++-
source/cmake/FindNeon.cmake | 17 ++++++--
source/common/aarch64/asm.S | 28 ++++++++++++-
source/common/aarch64/ipfilter8.S | 66 ++++++++++++++++--------------
source/common/aarch64/mc-a.S | 4 ++
source/common/aarch64/pixel-util.S | 4 ++
source/common/aarch64/sad-a.S | 20 +++++----
source/test/testharness.h | 2 +-
8 files changed, 100 insertions(+), 48 deletions(-)
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index b4e57b592..f2fd51137 100755
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -40,7 +40,7 @@ SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake"
"${CMAKE_MODULE_PATH}")
# System architecture detection
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" SYSPROC)
set(X86_ALIASES x86 i386 i686 x86_64 amd64)
-set(ARM_ALIASES armv6l armv7l aarch64)
+set(ARM_ALIASES armv6l armv7l aarch64 arm64)
list(FIND X86_ALIASES "${SYSPROC}" X86MATCH)
list(FIND ARM_ALIASES "${SYSPROC}" ARMMATCH)
set(POWER_ALIASES ppc64 ppc64le)
@@ -248,7 +248,10 @@ if(GCC)
elseif(ARM)
if(ARM64)
set(ARM_ARGS -fPIC)
- add_definitions(-DHAVE_NEON)
+ find_package(Neon)
+ if(CPU_HAS_NEON)
+ add_definitions(-DHAVE_NEON)
+ endif()
else()
find_package(Neon)
if(CPU_HAS_NEON)
diff --git a/source/cmake/FindNeon.cmake b/source/cmake/FindNeon.cmake
index 0062449c3..2b8751248 100644
--- a/source/cmake/FindNeon.cmake
+++ b/source/cmake/FindNeon.cmake
@@ -1,10 +1,19 @@
include(FindPackageHandleStandardArgs)
# Check the version of neon supported by the ARM CPU
-execute_process(COMMAND cat /proc/cpuinfo | grep Features | grep neon
- OUTPUT_VARIABLE neon_version
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
+if(APPLE)
+ execute_process(COMMAND sysctl -a
+ COMMAND grep "hw.optional.neon: 1"
+ OUTPUT_VARIABLE neon_version
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+else()
+ execute_process(COMMAND cat /proc/cpuinfo | grep Features | grep neon
+ OUTPUT_VARIABLE neon_version
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+endif()
+
if(neon_version)
set(CPU_HAS_NEON 1)
endif()
diff --git a/source/common/aarch64/asm.S b/source/common/aarch64/asm.S
index 5f020a11a..527f819ed 100644
--- a/source/common/aarch64/asm.S
+++ b/source/common/aarch64/asm.S
@@ -23,32 +23,56 @@
.arch armv8-a
+#ifdef __APPLE__
+#define PREFIX 1
+#endif
+
#ifdef PREFIX
#define EXTERN_ASM _
+#define HAVE_AS_FUNC 0
#else
#define EXTERN_ASM
+#define HAVE_AS_FUNC 1
#endif
#ifdef __ELF__
#define ELF
#else
+#ifdef PREFIX
+#define ELF #
+#else
#define ELF @
#endif
-
-#define HAVE_AS_FUNC 1
+#endif
#if HAVE_AS_FUNC
#define FUNC
#else
+#ifdef PREFIX
+#define FUNC #
+#else
#define FUNC @
#endif
+#endif
+
+#ifdef __APPLE__
+.macro endfunc
+ELF .size \name, . - \name
+FUNC .endfunc
+.endm
+#endif
.macro function name, export=1
+#ifdef __APPLE__
+ .global \name
+ endfunc
+#else
.macro endfunc
ELF .size \name, . - \name
FUNC .endfunc
.purgem endfunc
.endm
+#endif
.align 2
.if \export == 1
.global EXTERN_ASM\name
diff --git a/source/common/aarch64/ipfilter8.S
b/source/common/aarch64/ipfilter8.S
index 908c7db46..685f839b8 100644
--- a/source/common/aarch64/ipfilter8.S
+++ b/source/common/aarch64/ipfilter8.S
@@ -23,7 +23,11 @@
#include "asm.S"
+#ifdef __APPLE__
+.section __RODATA, __rodata
+#else
.section .rodata
+#endif
.align 4
@@ -197,10 +201,10 @@
b.eq 15f
b 7f
14:
- HPS_FILTER_4 \a \b \filterhps
+ HPS_FILTER_4 \a, \b, \filterhps
b 10f
15:
- HPS_FILTER_12 \a \b \filterhps
+ HPS_FILTER_12 \a, \b, \filterhps
b 10f
7:
cmp w5, #0
@@ -371,44 +375,44 @@ function x265_interp_8tap_horiz_ps_\w\()x\h\()_neon
cmp w4, #3
b.eq 3f
0:
- HPS_FILTER \w \h qpel_filter_0_32b
+ HPS_FILTER \w, \h, qpel_filter_0_32b
b 5f
1:
- HPS_FILTER \w \h qpel_filter_1_32b
+ HPS_FILTER \w, \h, qpel_filter_1_32b
b 5f
2:
- HPS_FILTER \w \h qpel_filter_2_32b
+ HPS_FILTER \w, \h, qpel_filter_2_32b
b 5f
3:
- HPS_FILTER \w \h qpel_filter_3_32b
+ HPS_FILTER \w, \h, qpel_filter_3_32b
b 5f
5:
ret
endfunc
.endm
-LUMA_HPS 4 4
-LUMA_HPS 4 8
-LUMA_HPS 4 16
-LUMA_HPS 8 4
-LUMA_HPS 8 8
-LUMA_HPS 8 16
-LUMA_HPS 8 32
-LUMA_HPS 12 16
-LUMA_HPS 16 4
-LUMA_HPS 16 8
-LUMA_HPS 16 12
-LUMA_HPS 16 16
-LUMA_HPS 16 32
-LUMA_HPS 16 64
-LUMA_HPS 24 32
-LUMA_HPS 32 8
-LUMA_HPS 32 16
-LUMA_HPS 32 24
-LUMA_HPS 32 32
-LUMA_HPS 32 64
-LUMA_HPS 48 64
-LUMA_HPS 64 16
-LUMA_HPS 64 32
-LUMA_HPS 64 48
-LUMA_HPS 64 64
+LUMA_HPS 4,4
+LUMA_HPS 4,8
+LUMA_HPS 4,16
+LUMA_HPS 8,4
+LUMA_HPS 8,8
+LUMA_HPS 8,16
+LUMA_HPS 8,32
+LUMA_HPS 12,16
+LUMA_HPS 16,4
+LUMA_HPS 16,8
+LUMA_HPS 16,12
+LUMA_HPS 16,16
+LUMA_HPS 16,32
+LUMA_HPS 16,64
+LUMA_HPS 24,32
+LUMA_HPS 32,8
+LUMA_HPS 32,16
+LUMA_HPS 32,24
+LUMA_HPS 32,32
+LUMA_HPS 32,64
+LUMA_HPS 48,64
+LUMA_HPS 64,16
+LUMA_HPS 64,32
+LUMA_HPS 64,48
+LUMA_HPS 64,64
diff --git a/source/common/aarch64/mc-a.S b/source/common/aarch64/mc-a.S
index cbaf9b501..339b53ae4 100644
--- a/source/common/aarch64/mc-a.S
+++ b/source/common/aarch64/mc-a.S
@@ -23,7 +23,11 @@
#include "asm.S"
+#ifdef __APPLE__
+.section __RODATA,__rodata
+#else
.section .rodata
+#endif
.align 4
diff --git a/source/common/aarch64/pixel-util.S
b/source/common/aarch64/pixel-util.S
index a085ebdfa..13c85ad8f 100644
--- a/source/common/aarch64/pixel-util.S
+++ b/source/common/aarch64/pixel-util.S
@@ -24,7 +24,11 @@
#include "asm.S"
+#ifdef __APPLE__
+.section __RODATA,__rodata
+#else
.section .rodata
+#endif
.align 4
diff --git a/source/common/aarch64/sad-a.S b/source/common/aarch64/sad-a.S
index c27cce5ce..04269d381 100644
--- a/source/common/aarch64/sad-a.S
+++ b/source/common/aarch64/sad-a.S
@@ -23,7 +23,11 @@
#include "asm.S"
+#ifdef __APPLE__
+.section __RODATA,__rodata
+#else
.section .rodata
+#endif
.align 4
@@ -94,12 +98,12 @@ function x265_sad_x\x\()_8x\h\()_neon
endfunc
.endm
-SAD_X_8xN 3 4
-SAD_X_8xN 3 8
-SAD_X_8xN 3 16
-SAD_X_8xN 3 32
+SAD_X_8xN 3,4
+SAD_X_8xN 3,8
+SAD_X_8xN 3,16
+SAD_X_8xN 3,32
-SAD_X_8xN 4 4
-SAD_X_8xN 4 8
-SAD_X_8xN 4 16
-SAD_X_8xN 4 32
+SAD_X_8xN 4,4
+SAD_X_8xN 4,8
+SAD_X_8xN 4,16
+SAD_X_8xN 4,32
diff --git a/source/test/testharness.h b/source/test/testharness.h
index 6e680953f..088343b51 100644
--- a/source/test/testharness.h
+++ b/source/test/testharness.h
@@ -73,7 +73,7 @@ protected:
#include <x86intrin.h>
#elif ( !defined(__APPLE__) && defined (__GNUC__) && defined(__ARM_NEON__))
#include <arm_neon.h>
-#elif defined(__GNUC__) && (!defined(__clang__) || __clang_major__ < 4)
+#else
/* fallback for older GCC/MinGW */
static inline uint32_t __rdtsc(void)
{
--
2.22.0.windows.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20210811/af7ce88a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fix-the-compiling-errors-on-MAC.patch
Type: application/octet-stream
Size: 7564 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20210811/af7ce88a/attachment-0001.obj>
More information about the x265-devel
mailing list