Build for fat library(x86_64 and arm64) on macOS Apple M1
I can easy build fat library(x86_64 and arm64) from source https://github.com/libffi/libffi 3.4.2 on macOS Apple M1.
./configure CFLAGS="-arch x86_64 -arch arm64" \
LDFLAGS="-framework CoreFoundation" \
--prefix=/some_place/libffi-3.4.2 \
--enable-shared=no
--- Verify using file command ---
file /some_place/libffi-3.4.2/lib/libffi.a
/some_place/libffi-3.4.2/lib/libffi.a: Mach-O universal binary with 2 architectures: [x86_64:current ar archive random librarycurrent ar archive random library] [arm64:current ar archive random librarycurrent ar archive random library]
/some_place/libffi-3.4.2/lib/libffi.a (for architecture x86_64): current ar archive random library
/some_place/libffi-3.4.2/lib/libffi.a (for architecture arm64): current ar archive random library
Is it possible to build fat library on macOS Apple M1 with meson build system
?
Could you give me some advice?
I also try to build but always failed. please take a look Meson build result
meson build --native-file /some_place/universal-libffi.txt
/some_place/universal-libffi.txt
--------------------------------
[binaries]
c = 'clang'
objc = 'clang'
cpp = 'clang++'
ar = 'ar'
ld = 'ld'
strip = 'strip'
lipo = 'lipo'
ranlib = 'ranlib'
pkg-config = '/some_place/bin/universal/pkg-config-0.29.2/bin/pkg-config'
[built-in options]
prefix = '/some_place/libffi'
c_args = ['-arch', 'x86_64']
c_link_args = ['-framework', 'CoreFoundation']
cpp_args = ['-arch', 'x86_64']
cpp_link_args = ['-framework', 'CoreFoundation']
default_library = 'static'
buildtype = 'release'
Meson build result
The Meson build system
Version: 0.63.2
Source dir: /some_place/Downloads/libffi-meson
Build dir: /some_place/Downloads/libffi-meson/build
Build type: native build
Project name: libffi
Project version: 3.2.9999
C compiler for the host machine: clang (clang 13.1.6 "Apple clang version 13.1.6 (clang-1316.0.21.2.5)")
C linker for the host machine: clang ld64 764
Host machine cpu family: aarch64
Host machine cpu: arm64
Message: host cpu: arm64
Message: host cpu_family: aarch64
Message: host system: darwin
Checking if "ASM .cfi" compiles: NO
Checking for size of "size_t" : 8
Checking for size of "long double" : 16
Checking for size of "double" : 8
Message: sizeof "long double" is greater than "double"
Message: .eh_frame is hard-coded to ro
Message: Cannot use PROT_EXEC on this target, using fallback
Checking for function "memcpy" : YES
Checking for function "mkostemp" : YES
Has header "alloca.h" : YES
Has header "inttypes.h" : YES
Has header "stdint.h" : YES
Compiler for C supports function attribute visibility: YES
Program test-cc-supports-hidden-visibility.py found: YES (/Applications/Xcode.app/Contents/Developer/usr/bin/python3 /some_place/Downloads/libffi-meson/test-cc-supports-hidden-visibility.py)
Message: .hidden pseudo-op is NOT available: .hidden not found in the outputted assembly
Configuring fficonfig.h using configuration
Program msvcc.sh found: YES (/Users/tuming/Downloads/libffi-meson/msvcc.sh)
Configuring ffi-aarch64.h using configuration
Configuring ffitarget.h using configuration
Configuring ffi.h using configuration
Compiler for C supports arguments -x assembler-with-cpp: NO
Build targets in project: 1
libffi 3.2.9999
User defined options
Native files: /some_place/universal-libffi.txt
Found ninja-1.11.1 at /some_place/bin/universal/ninja-1.11.1/bin/ninja
tuming@Tumings-Mac-mini libffi-meson % ninja -C build
ninja: Entering directory `build'
[1/8] Compiling C object src/libffi.a.p/aarch64_sysv.S.o
FAILED: src/libffi.a.p/aarch64_sysv.S.o
clang -Isrc/libffi.a.p -Isrc -I../src -I. -I.. -Iinclude -I../include -fcolor-diagnostics -Wall -Winvalid-pch -O3 -DFFI_BUILDING -DFFI_STATIC_BUILD -arch x86_64 -DTARGET=AARCH64 -MD -MQ src/libffi.a.p/aarch64_sysv.S.o -MF src/libffi.a.p/aarch64_sysv.S.o.d -o src/libffi.a.p/aarch64_sysv.S.o -c ../src/aarch64/sysv.S
In file included from ../src/aarch64/sysv.S:24:
include/ffi.h:10:10: fatal error: 'ffi-x86_64.h' file not found
#include "ffi-x86_64.h"
^~~~~~~~~~~~~~
1 error generated.
[2/8] Compiling C object src/libffi.a.p/types.c.o
FAILED: src/libffi.a.p/types.c.o
clang -Isrc/libffi.a.p -Isrc -I../src -I. -I.. -Iinclude -I../include -fcolor-diagnostics -Wall -Winvalid-pch -O3 -DFFI_BUILDING -DFFI_STATIC_BUILD -arch x86_64 -DTARGET=AARCH64 -MD -MQ src/libffi.a.p/types.c.o -MF src/libffi.a.p/types.c.o.d -o src/libffi.a.p/types.c.o -c ../src/types.c
In file included from ../src/types.c:31:
include/ffi.h:10:10: fatal error: 'ffi-x86_64.h' file not found
#include "ffi-x86_64.h"
^~~~~~~~~~~~~~
1 error generated.
[3/8] Compiling C object src/libffi.a.p/closures.c.o
FAILED: src/libffi.a.p/closures.c.o
clang -Isrc/libffi.a.p -Isrc -I../src -I. -I.. -Iinclude -I../include -fcolor-diagnostics -Wall -Winvalid-pch -O3 -DFFI_BUILDING -DFFI_STATIC_BUILD -arch x86_64 -DTARGET=AARCH64 -MD -MQ src/libffi.a.p/closures.c.o -MF src/libffi.a.p/closures.c.o.d -o src/libffi.a.p/closures.c.o -c ../src/closures.c
In file included from ../src/closures.c:34:
include/ffi.h:10:10: fatal error: 'ffi-x86_64.h' file not found
#include "ffi-x86_64.h"
^~~~~~~~~~~~~~
1 error generated.
[4/8] Compiling C object src/libffi.a.p/raw_api.c.o
FAILED: src/libffi.a.p/raw_api.c.o
clang -Isrc/libffi.a.p -Isrc -I../src -I. -I.. -Iinclude -I../include -fcolor-diagnostics -Wall -Winvalid-pch -O3 -DFFI_BUILDING -DFFI_STATIC_BUILD -arch x86_64 -DTARGET=AARCH64 -MD -MQ src/libffi.a.p/raw_api.c.o -MF src/libffi.a.p/raw_api.c.o.d -o src/libffi.a.p/raw_api.c.o -c ../src/raw_api.c
In file included from ../src/raw_api.c:29:
include/ffi.h:10:10: fatal error: 'ffi-x86_64.h' file not found
#include "ffi-x86_64.h"
^~~~~~~~~~~~~~
1 error generated.
[5/8] Compiling C object src/libffi.a.p/java_raw_api.c.o
FAILED: src/libffi.a.p/java_raw_api.c.o
clang -Isrc/libffi.a.p -Isrc -I../src -I. -I.. -Iinclude -I../include -fcolor-diagnostics -Wall -Winvalid-pch -O3 -DFFI_BUILDING -DFFI_STATIC_BUILD -arch x86_64 -DTARGET=AARCH64 -MD -MQ src/libffi.a.p/java_raw_api.c.o -MF src/libffi.a.p/java_raw_api.c.o.d -o src/libffi.a.p/java_raw_api.c.o -c ../src/java_raw_api.c
In file included from ../src/java_raw_api.c:38:
include/ffi.h:10:10: fatal error: 'ffi-x86_64.h' file not found
#include "ffi-x86_64.h"
^~~~~~~~~~~~~~
1 error generated.
[6/8] Compiling C object src/libffi.a.p/prep_cif.c.o
FAILED: src/libffi.a.p/prep_cif.c.o
clang -Isrc/libffi.a.p -Isrc -I../src -I. -I.. -Iinclude -I../include -fcolor-diagnostics -Wall -Winvalid-pch -O3 -DFFI_BUILDING -DFFI_STATIC_BUILD -arch x86_64 -DTARGET=AARCH64 -MD -MQ src/libffi.a.p/prep_cif.c.o -MF src/libffi.a.p/prep_cif.c.o.d -o src/libffi.a.p/prep_cif.c.o -c ../src/prep_cif.c
In file included from ../src/prep_cif.c:26:
include/ffi.h:10:10: fatal error: 'ffi-x86_64.h' file not found
#include "ffi-x86_64.h"
^~~~~~~~~~~~~~
1 error generated.
[7/8] Compiling C object src/libffi.a.p/aarch64_ffi.c.o
FAILED: src/libffi.a.p/aarch64_ffi.c.o
clang -Isrc/libffi.a.p -Isrc -I../src -I. -I.. -Iinclude -I../include -fcolor-diagnostics -Wall -Winvalid-pch -O3 -DFFI_BUILDING -DFFI_STATIC_BUILD -arch x86_64 -DTARGET=AARCH64 -MD -MQ src/libffi.a.p/aarch64_ffi.c.o -MF src/libffi.a.p/aarch64_ffi.c.o.d -o src/libffi.a.p/aarch64_ffi.c.o -c ../src/aarch64/ffi.c
In file included from ../src/aarch64/ffi.c:26:
include/ffi.h:10:10: fatal error: 'ffi-x86_64.h' file not found
#include "ffi-x86_64.h"
^~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.