From 31175ccf192b5bd4b8ae2cdab0a6dbddec4d4c84 Mon Sep 17 00:00:00 2001 From: Jonas Holzman Date: Thu, 3 Apr 2025 18:37:30 +0200 Subject: [PATCH] Deps: macOS: Fix libffi build error on Xcode 16.3 / Apple Clang 17 This PR adds a simple patch to fix libffi compilation errors on Xcode 16.3 / Apple Clang 17. This patch has been ported from libffi Github PR #857[1] and has now since been included in libffi 3.4.7 [1]: https://github.com/libffi/libffi/pull/857 The reason why we patch libffi v3.4.4 instead of just upgrading to 3.4.7 is that Python require specific versions of its dependencies. (See comment in build_environment/cmake/versions.cmake about updating Python version) Once we upgrade Python and libffi is updated to 3.4.7 or beyond, this patch can be safely removed. Pull Request: https://projects.blender.org/blender/blender/pulls/136934 --- build_files/build_environment/cmake/ffi.cmake | 6 +++- .../patches/ffi_apple_clang_17.diff | 34 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 build_files/build_environment/patches/ffi_apple_clang_17.diff diff --git a/build_files/build_environment/cmake/ffi.cmake b/build_files/build_environment/cmake/ffi.cmake index aac186af961..24c62be7c5a 100644 --- a/build_files/build_environment/cmake/ffi.cmake +++ b/build_files/build_environment/cmake/ffi.cmake @@ -26,7 +26,11 @@ ExternalProject_Add(external_ffi PATCH_COMMAND ${PATCH_CMD} -p 0 -d ${BUILD_DIR}/ffi/src/external_ffi < - ${PATCH_DIR}/ffi.diff + ${PATCH_DIR}/ffi.diff && + # Fix compilation errors on Apple Clang >= 17, remove when FFI is updated beyond 3.4.7, see PR #136934 for details. + ${PATCH_CMD} -p 1 -d + ${BUILD_DIR}/ffi/src/external_ffi < + ${PATCH_DIR}/ffi_apple_clang_17.diff INSTALL_DIR ${LIBDIR}/ffi ) diff --git a/build_files/build_environment/patches/ffi_apple_clang_17.diff b/build_files/build_environment/patches/ffi_apple_clang_17.diff new file mode 100644 index 00000000000..a264d7b76d1 --- /dev/null +++ b/build_files/build_environment/patches/ffi_apple_clang_17.diff @@ -0,0 +1,34 @@ +diff --git a/src/aarch64/sysv.S b/src/aarch64/sysv.S +index eeaf3f8..329889c 100644 +--- a/src/aarch64/sysv.S ++++ b/src/aarch64/sysv.S +@@ -76,8 +76,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + x5 closure + */ + +- cfi_startproc + CNAME(ffi_call_SYSV): ++ cfi_startproc + /* Sign the lr with x1 since that is where it will be stored */ + SIGN_LR_WITH_REG(x1) + +@@ -268,8 +268,8 @@ CNAME(ffi_closure_SYSV_V): + #endif + + .align 4 +- cfi_startproc + CNAME(ffi_closure_SYSV): ++ cfi_startproc + SIGN_LR + stp x29, x30, [sp, #-ffi_closure_SYSV_FS]! + cfi_adjust_cfa_offset (ffi_closure_SYSV_FS) +@@ -500,8 +500,8 @@ CNAME(ffi_go_closure_SYSV_V): + #endif + + .align 4 +- cfi_startproc + CNAME(ffi_go_closure_SYSV): ++ cfi_startproc + stp x29, x30, [sp, #-ffi_closure_SYSV_FS]! + cfi_adjust_cfa_offset (ffi_closure_SYSV_FS) + cfi_rel_offset (x29, 0)