libffi issueshttps://gitlab.freedesktop.org/gstreamer/meson-ports/libffi/-/issues2022-09-13T07:42:24Zhttps://gitlab.freedesktop.org/gstreamer/meson-ports/libffi/-/issues/11Build for fat library(x86_64 and arm64) on macOS Apple M12022-09-13T07:42:24ZTuming WenBuild for fat library(x86_64 and arm64) on macOS Apple M1I 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....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`?<br>
Could you give me some advice?<br>
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.
```https://gitlab.freedesktop.org/gstreamer/meson-ports/libffi/-/issues/9Build failure with `-Dc_std=c11`2022-02-07T04:10:11ZLászló VáradyBuild failure with `-Dc_std=c11`When configuring the project with `-Dc_std=cXX` (89, 99, 11), the compilation fails due to an incorrectly detected PCREL check:
```sh
$ meson setup -Dc_std=c11 build
...
$ meson compile -C build
[1/10] Compiling C object src/libffi.so.7...When configuring the project with `-Dc_std=cXX` (89, 99, 11), the compilation fails due to an incorrectly detected PCREL check:
```sh
$ meson setup -Dc_std=c11 build
...
$ meson compile -C build
[1/10] Compiling C object src/libffi.so.7.1.0.p/x86_unix64.S.o
FAILED: src/libffi.so.7.1.0.p/x86_unix64.S.o
cc -Isrc/libffi.so.7.1.0.p -Isrc -I../src -I. -I.. -Iinclude -I../include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c11 -O2 -g -DFFI_BUILDING -fPIC -DTARGET=X86_64 -MD -MQ src/libffi.so.7.1.0.p/x86_unix64.S.o -MF src/libffi.so.7.1.0.p/x86_unix64.S.o.d -o src/libffi.so.7.1.0.p/x86_unix64.S.o -c ../src/x86/unix64.S
../src/x86/unix64.S: Assembler messages:
../src/x86/unix64.S:451: Error: junk at end of line, first unrecognized character is `@'
```
The problematic check:
```
Command line: cc /tmpg5c31nq9/testfile.c -o /tmpg5c31nq9/output.obj -c -D_FILE_OFFSET_BITS=64 -O0 -std=c11
Code:
asm (".text; foo: nop; .data; .long foo-.; .text");
Compiler stdout:
Compiler stderr:
/tmpg5c31nq9/testfile.c:1:6: error: expected declaration specifiers or '...' before string constant
1 | asm (".text; foo: nop; .data; .long foo-.; .text");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Checking if "ASM x86 PCREL" : compiles: NO
```
Workaround:
Using `-Dc_std=gnuXX`.https://gitlab.freedesktop.org/gstreamer/meson-ports/libffi/-/issues/7Can't build with clang-cl after recent (16.9.0) MSVC 2019 update2022-05-17T12:45:42ZAleksandr MezinCan't build with clang-cl after recent (16.9.0) MSVC 2019 updateFails to build with clang-cl again:
```
[9/9] Linking target src/ffi-7.dll
FAILED: src/ffi-7.dll src/ffi-7.pdb
"lld-link" /MACHINE:x64 /OUT:src/ffi-7.dll src/x86_win64_intel_S.obj src/ffi-7.dll.p/prep_cif.c.obj src/ffi-7.dll.p/types.c....Fails to build with clang-cl again:
```
[9/9] Linking target src/ffi-7.dll
FAILED: src/ffi-7.dll src/ffi-7.pdb
"lld-link" /MACHINE:x64 /OUT:src/ffi-7.dll src/x86_win64_intel_S.obj src/ffi-7.dll.p/prep_cif.c.obj src/ffi-7.dll.p/types.c.obj src/ffi-7.dll.p/raw_api.c.obj src/ffi-7.dll.p/java_raw_api.c.obj src/ffi-7.dll.p/closures.c.obj src/ffi-7.dll.p/x86_ffiw64.c.obj "/nologo" "/DEBUG" "/PDB:src\ffi-7.pdb" "/DLL" "/IMPLIB:src\ffi.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib" "advapi32.lib"
lld-link: error: duplicate symbol: ffi_type_void
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/types.c.obj
lld-link: error: duplicate symbol: ffi_type_uint8
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/types.c.obj
lld-link: error: duplicate symbol: ffi_type_sint8
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/types.c.obj
lld-link: error: duplicate symbol: ffi_type_uint16
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/types.c.obj
lld-link: error: duplicate symbol: ffi_type_sint16
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/types.c.obj
lld-link: error: duplicate symbol: ffi_type_uint32
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/types.c.obj
lld-link: error: duplicate symbol: ffi_type_sint32
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/types.c.obj
lld-link: error: duplicate symbol: ffi_type_uint64
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/types.c.obj
lld-link: error: duplicate symbol: ffi_type_sint64
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/types.c.obj
lld-link: error: duplicate symbol: ffi_type_pointer
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/types.c.obj
lld-link: error: duplicate symbol: ffi_type_float
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/types.c.obj
lld-link: error: duplicate symbol: ffi_type_double
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/types.c.obj
lld-link: error: duplicate symbol: ffi_type_void
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/raw_api.c.obj
lld-link: error: duplicate symbol: ffi_type_uint8
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/raw_api.c.obj
lld-link: error: duplicate symbol: ffi_type_sint8
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/raw_api.c.obj
lld-link: error: duplicate symbol: ffi_type_uint16
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/raw_api.c.obj
lld-link: error: duplicate symbol: ffi_type_sint16
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/raw_api.c.obj
lld-link: error: duplicate symbol: ffi_type_uint32
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/raw_api.c.obj
lld-link: error: duplicate symbol: ffi_type_sint32
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/raw_api.c.obj
lld-link: error: duplicate symbol: ffi_type_uint64
>>> defined at src/ffi-7.dll.p/prep_cif.c.obj
>>> defined at src/ffi-7.dll.p/raw_api.c.obj
lld-link: error: too many errors emitted, stopping now (use /errorlimit:0 to see all errors)
ninja: build stopped: subcommand failed.
```https://gitlab.freedesktop.org/gstreamer/meson-ports/libffi/-/issues/3Building using meson on POWER2020-12-03T18:01:06ZWileam Y. PhanBuilding using meson on POWERHi,
I want to build Midnight Commander on an IBM POWER9 machine, which has GLib as a dependency, so I tried building GLib using `meson` first. Using version 2.67.0 tarball, I get the following error message:
```
subprojects/libffi/src/m...Hi,
I want to build Midnight Commander on an IBM POWER9 machine, which has GLib as a dependency, so I tried building GLib using `meson` first. Using version 2.67.0 tarball, I get the following error message:
```
subprojects/libffi/src/meson.build:71:2: ERROR: Problem encountered: Unsupported pair: system "linux", cpu family "ppc64"
```
Here are some system details:
```
$ uname -a
Linux tellico-master0 4.14.0-115.10.1.el7a.ppc64le #1 SMP Wed Jun 26 09:32:17 UTC 2019 ppc64le ppc64le ppc64le GNU/Linux
```
```
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.6 (Maipo)
```
```
$ gcc --version
gcc (Spack GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```
Any help would be appreciated. Thanks!https://gitlab.freedesktop.org/gstreamer/meson-ports/libffi/-/issues/1Build files assume host_system is 'darwin' when cross-compiling to iOS2020-05-28T20:02:58ZNirbheek Chauhannirbheek.chauhan@gmail.comBuild files assume host_system is 'darwin' when cross-compiling to iOSSo, the [current situation in Meson](https://github.com/mesonbuild/meson/issues/6257) is that [the only `host_machine.system()` values specified are for native compilation](https://mesonbuild.com/Reference-tables.html#operating-system-na...So, the [current situation in Meson](https://github.com/mesonbuild/meson/issues/6257) is that [the only `host_machine.system()` values specified are for native compilation](https://mesonbuild.com/Reference-tables.html#operating-system-names). When cross-compiling, the cross files can specify anything. This means that some people use `system = 'darwin'` and others (like cerbero) use `system = 'ios'` in the cross file.
This is, obviously, a very shitty situation.
Why am I filing it here? Well, we check for `host_system == 'ios'` in all gstreamer code, and in glib, but not in libffi. The only thing this changes is:
```patch
--- _builddir-host_system=darwin/fficonfig.h
+++ _builddir-host_system=ios/fficonfig.h
@@ -10,7 +10,7 @@
/* #undef FFI_DEBUG */
/* Cannot use PROT_EXEC on this target, so, we revert to alternative means */
-#define FFI_EXEC_TRAMPOLINE_TABLE 1
+#define FFI_EXEC_TRAMPOLINE_TABLE 0
/* Define this if you want to enable pax emulated trampolines */
/* #undef FFI_MMAP_EXEC_EMUTRAMP_PAX */
```
It's `0` when `host_system` is `ios` and `1` when it's `darwin`. Now I'm not sure if we should change this or not, so I'm filing an issue so we can deal with it later. Perhaps after we sync with upstream.