Skip to content

Commit

Permalink
[Libffi] Temporary revert to 3.2.2 to build for aarch64-freebsd (#10016)
Browse files Browse the repository at this point in the history
* [Libffi] Temporary revert to 3.2.2 to build for aarch64-freebsd

* fixup! [Libffi] Temporary revert to 3.2.2 to build for aarch64-freebsd
  • Loading branch information
JamesWrigley authored Dec 17, 2024
1 parent 2569873 commit c82c599
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 14 deletions.
35 changes: 21 additions & 14 deletions L/Libffi/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
using BinaryBuilder

name = "Libffi"
upstream_version = "3.4.6"
version = VersionNumber(upstream_version)
version = v"3.2.1"


# Collection of sources required to build libffi
sources = [
ArchiveSource("https://github.com/libffi/libffi/releases/download/v$(upstream_version)/libffi-$(upstream_version).tar.gz",
"b0dea9df23c863a7a50e825440f3ebffabd65df1497108e5d437747843895a4e"),
ArchiveSource("https://sourceware.org/pub/libffi/libffi-$(version).tar.gz",
"d06ebb8e1d9a22d19e38d63fdb83954253f39bedc5d46232a05645685722ca37"),
DirectorySource("./bundled"),
]

version = v"3.2.2" # <-- this is a lie, we need to bump the version to require julia v1.6

# Bash recipe for building across all platforms
script = raw"""
cd $WORKSPACE/srcdir/libffi-*/
atomic_patch -p1 ../patches/0001-libdir-no-touchy.patch
# Required on aarch64-apple-darwin to build with newer versions of LLVM. See:
# - https://github.com/llvm/llvm-project/issues/72802
# - Similar issue: https://github.com/libffi/libffi/issues/807
# - In Julia: https://github.com/JuliaLang/julia/pull/54634
if [[ ${target} == aarch64-apple-* ]]; then
atomic_patch -p1 ../patches/0002-aarch64-llvm18.patch
fi
update_configure_scripts
./configure --prefix=${prefix} \
--build=${MACHTYPE} \
--host=${target} \
--disable-static \
--enable-shared \
--disable-multi-os-directory
autoreconf -f -i
./configure --prefix=${prefix} --build=${MACHTYPE} --host=${target} --disable-static --enable-shared
make -j${nproc}
make install
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = supported_platforms()
platforms = supported_platforms(; experimental=true)

# The products that we will ensure are always built
products = [
Expand All @@ -38,6 +47,4 @@ dependencies = Dependency[
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6", preferred_gcc_version=v"6")

# Build trigger: 2
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6")
31 changes: 31 additions & 0 deletions L/Libffi/bundled/patches/0001-libdir-no-touchy.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--- libffi-3.2.1-orig/configure.ac 2021-11-18 00:13:42.753131022 -0500
+++ libffi-3.2.1/configure.ac 2021-11-18 00:14:43.014058771 -0500
@@ -590,26 +590,7 @@
AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
fi)

-# These variables are only ever used when we cross-build to X86_WIN32.
-# And we only support this with GCC, so...
-if test "x$GCC" = "xyes"; then
- if test -n "$with_cross_host" &&
- test x"$with_cross_host" != x"no"; then
- toolexecdir="${exec_prefix}"/'$(target_alias)'
- toolexeclibdir="${toolexecdir}"/lib
- else
- toolexecdir="${libdir}"/gcc-lib/'$(target_alias)'
- toolexeclibdir="${libdir}"
- fi
- multi_os_directory=`$CC $CFLAGS -print-multi-os-directory`
- case $multi_os_directory in
- .) ;; # Avoid trailing /.
- ../*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
- esac
- AC_SUBST(toolexecdir)
-else
- toolexeclibdir="${libdir}"
-fi
+toolexeclibdir="${libdir}"
AC_SUBST(toolexeclibdir)

AC_CONFIG_COMMANDS(include, [test -d include || mkdir include])

22 changes: 22 additions & 0 deletions L/Libffi/bundled/patches/0002-aarch64-llvm18.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- libffi-clean/src/aarch64/sysv.S 2014-11-08 13:47:24.000000000 +0100
+++ libffi-3.2.1/src/aarch64/sysv.S 2024-12-14 13:17:42.329889690 +0100
@@ -100,8 +100,8 @@

#define ffi_call_SYSV_FS (8 * 4)

- .cfi_startproc
CNAME(ffi_call_SYSV):
+ .cfi_startproc
stp x29, x30, [sp, #-16]!
cfi_adjust_cfa_offset (16)
cfi_rel_offset (x29, 0)
@@ -247,8 +247,8 @@
#ifdef __APPLE__
.align 2
#endif
- .cfi_startproc
CNAME(ffi_closure_SYSV):
+ .cfi_startproc
stp x29, x30, [sp, #-16]!
cfi_adjust_cfa_offset (16)
cfi_rel_offset (x29, 0)

0 comments on commit c82c599

Please sign in to comment.