Opened 21 months ago

Last modified 18 months ago

#62449 new defect

libffi @3.3_1: not building universal on arm64

Reported by: kencu (Ken) Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: universal arm64 Cc: NateCrawford (Nathan Crawford), nortcele
Port: libffi

Description

seems to be building the x86_64 parts as arm64 in some places, no doubt due to lack of arch flags where they need to be:

make[3]: *** [libffi_convenience.la] Error 1
make[3]: *** Waiting for unfinished jobs....
libtool: link: /usr/bin/clang -dynamiclib  -o .libs/libffi.7.dylib  src/.libs/prep_cif.o src/.libs/types.o src/.libs/raw_api.o src/.libs/java_raw_api.o src/.libs/closures.o src/x86/.libs/ffi64.o src/x86/.libs/unix64.o src/x86/.libs/ffiw64.o src/x86/.libs/win64.o   -L/opt/kencuuniversal/lib  -O3 -Wl,-headerpad_max_install_names -arch x86_64 -Wl,-syslibroot -Wl,/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk -Wl,-headerpad_max_install_names -arch x86_64 -Wl,-syslibroot -Wl,/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk   -install_name  /opt/kencuuniversal/lib/libffi.7.dylib -compatibility_version 9 -current_version 9.0 -Wl,-single_module
ld: warning: ignoring file src/.libs/prep_cif.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file src/.libs/types.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file src/.libs/raw_api.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file src/.libs/java_raw_api.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file src/.libs/closures.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file src/x86/.libs/ffiw64.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file src/x86/.libs/ffi64.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
Undefined symbols for architecture x86_64:
  "_ffi_closure_unix64_inner", referenced from:
      _ffi_closure_unix64 in unix64.o
  "_ffi_closure_win64_inner", referenced from:
      _ffi_closure_win64 in win64.o
% file ./x86_64-apple-darwin20.3.0/src/raw_api.o
./x86_64-apple-darwin20.3.0/src/raw_api.o: Mach-O 64-bit object arm64

Attachments (1)

libffi-fail-universal-arm64.log (92.8 KB) - added by kencu (Ken) 21 months ago.

Download all attachments as: .zip

Change History (8)

Changed 21 months ago by kencu (Ken)

comment:1 Changed 20 months ago by NateCrawford (Nathan Crawford)

Cc: NateCrawford added

comment:2 Changed 20 months ago by jrjsmrtn

I was following https://github.com/libffi/libffi/issues/571 so I quickly patched the libffi portfile to build and test the git master with +universal:

in ~/Repositories/macports-ports
$ git diff
diff --git a/devel/libffi/Portfile b/devel/libffi/Portfile
index aea69e87cd3..b6a4368b3fd 100644
--- a/devel/libffi/Portfile
+++ b/devel/libffi/Portfile
@@ -4,9 +4,9 @@ PortSystem          1.0
 PortGroup           muniversal 1.0
 PortGroup           github 1.0

-github.setup        libffi libffi 3.3 v
-revision            1
-github.tarball_from releases
+github.setup        libffi libffi eafab2356e8dcf5f01d2bcfa311cafba3b395a7e
+version             20210324
+
 categories          devel
 platforms           darwin
 license             MIT
@@ -21,12 +21,9 @@ long_description    The libffi library provides a portable, high level \

 homepage            https://www.sourceware.org/libffi/

-checksums           rmd160  2cd43b66d792f1bad76df2e19a8411beacfcb8e0 \
-                    sha256  72fba7922703ddfa7a028d513ac15a85c8d54c8d67f55fa5a4802885dc652056 \
-                    size    1305466
-
-# committed upstream, see https://github.com/libffi/libffi/pull/583
-patchfiles          patch-libffi-darwin-powerpc-no-go-closures.diff
+checksums           rmd160  e31a0e50acf68f4b202e4fa9cfddaccd46ffa74b \
+                    sha256  6b84af773859a8823aa609bd31fa2e777bdcaa2dbffeac7339689d8d9d3df0e8 \
+                    size    539046

 if {${os.platform} eq "darwin" && ${os.major} < 10 && ![string match *clang* ${configure.compiler}]} {
     # https://trac.macports.org/ticket/61170

AFAICT, all tests are successful except for testsuite/libffi.go/go.exp:

$ sudo port -ds build libffi +universal && sudo port -ds test libffi +universal
[...]

in /opt/local/var/macports/build/_Users_gm_Repositories_macports-ports_devel_libffi/libffi/work/libffi-eafab2356e8dcf5f01d2bcfa311cafba3b395a7e-arm64
$ less aarch64-apple-darwin20.3.0/testsuite/libffi.log
[...]
Running ../../testsuite/libffi.go/go.exp ...
set_ld_library_path_env_vars: ld_library_path=:/opt/local/var/macports/build/_Users_gm_Repositories_macports-ports_devel_libffi/libffi/work/libffi-eafab2356e8dcf5f01d2bcfa311cafb
a3b395a7e-arm64/aarch64-apple-darwin20.3.0/testsuite/../.libs:/opt/local/var/macports/build/_Users_gm_Repositories_macports-ports_devel_libffi/libffi/work/libffi-eafab2356e8dcf5f
01d2bcfa311cafba3b395a7e-arm64/aarch64-apple-darwin20.3.0/testsuite/../.libs:/opt/local/var/macports/build/_Users_gm_Repositories_macports-ports_devel_libffi/libffi/work/libffi-e
afab2356e8dcf5f01d2bcfa311cafba3b395a7e-arm64/aarch64-apple-darwin20.3.0/testsuite/../.libs:/opt/local/var/macports/build/_Users_gm_Repositories_macports-ports_devel_libffi/libff
i/work/libffi-eafab2356e8dcf5f01d2bcfa311cafba3b395a7e-arm64/aarch64-apple-darwin20.3.0/testsuite/../.libs:/opt/local/var/macports/build/_Users_gm_Repositories_macports-ports_dev
el_libffi/libffi/work/libffi-eafab2356e8dcf5f01d2bcfa311cafba3b395a7e-arm64/aarch64-apple-darwin20.3.0/testsuite/../.libs
Executing on host: /usr/bin/clang ffitest9457.c   -I/opt/local/var/macports/build/_Users_gm_Repositories_macports-ports_devel_libffi/libffi/work/libffi-eafab2356e8dcf5f01d2bcfa31
1cafba3b395a7e-arm64/aarch64-apple-darwin20.3.0/testsuite/../include -I../../testsuite/../include  -I/opt/local/var/macports/build/_Users_gm_Repositories_macports-ports_devel_lib
ffi/libffi/work/libffi-eafab2356e8dcf5f01d2bcfa311cafba3b395a7e-arm64/aarch64-apple-darwin20.3.0/testsuite/../include/.. -L/opt/local/var/macports/build/_Users_gm_Repositories_ma
cports-ports_devel_libffi/libffi/work/libffi-eafab2356e8dcf5f01d2bcfa311cafba3b395a7e-arm64/aarch64-apple-darwin20.3.0/testsuite/../.libs -Wl,-allow_stack_execute -S -o /dev/null
    (timeout = 300)
spawn -ignore SIGHUP /usr/bin/clang ffitest9457.c -I/opt/local/var/macports/build/_Users_gm_Repositories_macports-ports_devel_libffi/libffi/work/libffi-eafab2356e8dcf5f01d2bcfa31
1cafba3b395a7e-arm64/aarch64-apple-darwin20.3.0/testsuite/../include -I../../testsuite/../include -I/opt/local/var/macports/build/_Users_gm_Repositories_macports-ports_devel_libf
fi/libffi/work/libffi-eafab2356e8dcf5f01d2bcfa311cafba3b395a7e-arm64/aarch64-apple-darwin20.3.0/testsuite/../include/.. -L/opt/local/var/macports/build/_Users_gm_Repositories_mac
ports-ports_devel_libffi/libffi/work/libffi-eafab2356e8dcf5f01d2bcfa311cafba3b395a7e-arm64/aarch64-apple-darwin20.3.0/testsuite/../.libs -Wl,-allow_stack_execute -S -o /dev/null
clang: warning: -Wl,-allow_stack_execute: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L/opt/local/var/macports/build/_Users_gm_Repositories_macports-ports_devel_libffi/libffi/work/libffi-eafab2356e8dcf5f01d2bcf
a311cafba3b395a7e-arm64/aarch64-apple-darwin20.3.0/testsuite/../.libs' [-Wunused-command-line-argument]
ffitest9457.c:5:3: error: Failed #ifdef FFI_GO_CLOSURES
# error Failed #ifdef FFI_GO_CLOSURES
  ^
1 error generated.
compiler exited with status 1
UNSUPPORTED: ../../testsuite/libffi.go/aa-direct.c
UNSUPPORTED: ../../testsuite/libffi.go/closure1.c
testcase ../../testsuite/libffi.go/go.exp completed in 0 seconds

                === libffi Summary ===

# of expected passes            547
# of unexpected failures        1
# of unsupported tests          204
runtest completed at Tue Apr 13 12:15:21 2021

As, according to https://github.com/libffi/libffi/issues/571, there is still work to do with libffi on M1, I was thinking of adding a libffi-devel subport to ease testing, at least until libffi 3.4 is released. What do you think ?

comment:3 Changed 20 months ago by jrjsmrtn

I was thinking of adding a libffi-devel subport to ease testing

Ok, not a good idea as ports depending on libffi will not have a dependency on libffi-devel...

comment:4 Changed 19 months ago by ryandesign (Ryan Schmidt)

Keywords: arm64 added

To clarify, it's that building x86_64/arm64 universal on an Apple Silicon machine fails. Building x86_64/arm64 universal on an Intel machine presumably succeeds because we have the binary on our packages server.

comment:5 Changed 18 months ago by DDeanBrown (Dean)

Also fails on Intel machine when building from source. I got it to fail by doing

port install libffi +universal

using non-standard install prefix, and also got it to fail by doing

port install -s libffi +universal

with default install prefix of /opt/local

comment:6 Changed 18 months ago by DDeanBrown (Dean)

Forgot to add this to my comment - the failures are on a Intel Mac running 11.3, could be that it's OK on Intel Mac running 10.x

comment:7 Changed 18 months ago by nortcele

Cc: nortcele added
Note: See TracTickets for help on using tickets.