Skip to content

Commit 6a668f9

Browse files
xclaesseWill Wray
authored and
Will Wray
committed
libffi: Update to latest upstream PR version
This uses meson port from libffi/libffi#746 as of 2023-08-17.
1 parent 75486ac commit 6a668f9

File tree

7 files changed

+133
-70
lines changed

7 files changed

+133
-70
lines changed

ci_config.json

+6
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,12 @@
313313
"libpciaccess-dev"
314314
]
315315
},
316+
"libffi": {
317+
"_comment": "libffi has too many unit tests and it exceed command line limit to rebuild test targets",
318+
"test_options": [
319+
"--no-rebuild"
320+
]
321+
},
316322
"libffmpegthumbnailer": {
317323
"brew_packages": [
318324
"ffmpeg@4"

releases.json

+1
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,7 @@
12691269
"libffi"
12701270
],
12711271
"versions": [
1272+
"3.4.4-3",
12721273
"3.4.4-2",
12731274
"3.4.4-1"
12741275
]

subprojects/packagefiles/libffi/include/meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ configure_file(input : 'ffi.h.in',
99
configuration : ffi_h_conf,
1010
install_dir : get_option('includedir'))
1111

12-
install_headers(f'../src/@targetdir@/ffitarget.h')
12+
install_headers('../src' / targetdir / 'ffitarget.h')

subprojects/packagefiles/libffi/meson-scripts/test-cc-supports-hidden-visibility.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
res = subprocess.run(args, stdout=subprocess.PIPE, universal_newlines=True, check=True)
2020

2121
with open(outfile, 'r') as f:
22-
if re.search('\.hidden.*foo', f.read()):
22+
if re.search('(\.hidden|\.private_extern).*foo', f.read()):
2323
sys.exit(0)
2424
print('.hidden not found in the outputted assembly')
2525
sys.exit(1)

subprojects/packagefiles/libffi/meson.build

+61-41
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
project('libffi', 'c', version : '3.4.4',
2-
meson_version : '>= 0.64.0',
3-
default_options : ['buildtype=debugoptimized',
2+
meson_version : '>= 0.56.0',
3+
default_options : ['debug=true',
4+
'optimization=3',
45
'warning_level=1'])
56

67
fs = import('fs')
78

89
libtool_version = run_command('meson-scripts/extract-libtool-version.py',
910
meson.current_source_dir() / 'libtool-version',
10-
check: true).stdout().split(':')
11+
check: true).stdout().strip().split(':')
1112
current = libtool_version[0].to_int()
1213
revision = libtool_version[1].to_int()
1314
age = libtool_version[2].to_int()
@@ -20,6 +21,7 @@ host_cpu_family = host_machine.cpu_family()
2021
host_system = host_machine.system()
2122

2223
cc = meson.get_compiler('c')
24+
is_msvc = cc.get_id() == 'msvc'
2325
is_msvc_like = cc.get_argument_syntax() == 'msvc'
2426
is_gnu_like = cc.get_argument_syntax() == 'gcc'
2527

@@ -82,67 +84,72 @@ have_long_double_variant = false
8284
if host_cpu_family == 'aarch64' and host_system in ['cygwin', 'windows']
8385
target = 'ARM_WIN64'
8486
targetdir = 'aarch64'
85-
if is_msvc_like
87+
if is_msvc
8688
asm_sources = ['win64_armasm.S']
8789
endif
8890
elif host_cpu_family == 'aarch64'
8991
target = 'AARCH64'
90-
elif host_cpu_family.startswith('alpha')
92+
elif host_cpu_family == 'alpha'
9193
target = 'ALPHA'
9294
asm_sources = ['osf.S']
9395
# Support 128-bit long double, changeable via command-line switch.
9496
have_long_double = 'defined(__LONG_DOUBLE_128__)'
95-
elif host_cpu_family.startswith('arc')
97+
elif host_cpu_family == 'arc'
9698
target = 'ARC'
9799
asm_sources = ['arcompact.S']
98100
elif host_cpu_family == 'arm' and host_system in ['cygwin', 'windows']
99101
target = 'ARM_WIN32'
100102
targetdir = 'arm'
101-
if is_msvc_like
103+
if is_msvc
102104
asm_sources = ['sysv_msvc_arm32.S']
103105
endif
104106
elif host_cpu_family == 'arm'
105107
target = 'ARM'
106-
elif host_cpu_family.startswith('avr32')
108+
elif host_cpu_family == 'avr'
107109
target = 'AVR32'
108-
elif host_cpu_family.startswith('bfin')
110+
elif host_cpu_family == 'bfin'
111+
# FIXME: bfin family is missing in Meson
109112
target = 'BFIN'
110113
elif host_cpu_family == 'cris'
114+
# FIXME: cris family is missing in Meson
111115
target = 'LIBFFI_CRIS'
112116
targetdir = 'cris'
113117
elif host_cpu_family == 'csky'
114118
target = 'CSKY'
115119
elif host_cpu_family == 'frv'
120+
# FIXME: frv family is missing in Meson
116121
target = 'FRV'
117122
asm_sources = ['eabi.S']
118-
elif (host_cpu_family.startswith('hppa') and host_system in ['linux', 'openbsd']) or \
119-
(host_cpu_family.startswith('parisc') and host_system == 'linux')
123+
elif (host_cpu_family in ['hppa', 'hppa64'] and host_system in ['linux', 'openbsd']) or \
124+
(host_cpu_family == 'parisc' and host_system == 'linux')
125+
# FIXME: hppa family is missing in Meson
120126
target = 'PA_LINUX'
121127
targetdir = 'pa'
122128
asm_sources = ['linux.S']
123-
elif host_cpu_family.startswith('hppa') and not '64' in host_cpu_family and host_system in ['hpux']
129+
elif host_cpu_family == 'hppa' and host_system in ['hpux']
130+
# FIXME: hppa family is missing in Meson
124131
target = 'PA_HPUX'
125132
targetdir = 'pa'
126133
asm_sources = ['hpux32.S']
127134
elif host_cpu_family == 'x86' and host_system in ['freebsd', 'openbsd']
128135
target = 'X86_FREEBSD'
129136
targetdir = 'x86'
130-
if is_msvc_like
137+
if is_msvc
131138
asm_sources = ['sysv_intel.S']
132139
endif
133140
elif (host_cpu_family == 'x86' and host_system in ['cygwin', 'windows', 'os2', 'interix']) or \
134141
(host_cpu_family == 'x86_64' and host_system in ['cygwin', 'windows'])
135142
targetdir = 'x86'
136143
if size_t == 4
137144
target = 'X86_WIN32'
138-
if is_msvc_like
145+
if is_msvc
139146
asm_sources = ['sysv_intel.S']
140147
masm_args += '/safeseh'
141148
endif
142149
else
143150
target = 'X86_WIN64'
144151
c_sources = ['ffiw64.c']
145-
if is_msvc_like
152+
if is_msvc
146153
asm_sources = ['win64_intel.S']
147154
else
148155
asm_sources = ['win64.S']
@@ -152,7 +159,7 @@ elif host_cpu_family in ['x86', 'x86_64'] and host_system in ['darwin', 'ios']
152159
targetdir = 'x86'
153160
if size_t == 4
154161
target = 'X86_DARWIN'
155-
if is_msvc_like
162+
if is_msvc
156163
asm_sources = ['sysv_intel.S']
157164
endif
158165
else
@@ -169,7 +176,7 @@ elif host_cpu_family in ['x86', 'x86_64']
169176
asm_sources = ['unix64.S', 'win64.S']
170177
else
171178
target = 'X86'
172-
if is_msvc_like
179+
if is_msvc
173180
asm_sources = ['sysv_intel.S']
174181
endif
175182
endif
@@ -178,10 +185,11 @@ elif host_cpu_family in ['x86', 'x86_64']
178185
c_sources = ['ffi64.c', 'ffiw64.c']
179186
asm_sources = ['unix64.S', 'win64.S']
180187
endif
181-
elif host_cpu_family.startswith('ia64')
188+
elif host_cpu_family == 'ia64'
182189
target = 'IA64'
183190
asm_sources = ['unix.S']
184191
elif host_cpu_family == 'kvx'
192+
# FIXME: kvx family is missing in Meson
185193
target = 'KVX'
186194
elif host_cpu_family == 'loongarch64'
187195
target = 'LOONGARCH64'
@@ -190,76 +198,84 @@ elif host_cpu_family.startswith('m32r')
190198
elif host_cpu_family == 'm68k'
191199
target = 'M68K'
192200
elif host_cpu_family == 'm88k'
201+
# FIXME: m88k family is missing in Meson
193202
target = 'M88K'
194203
asm_sources = ['obsd.S']
195-
elif host_cpu_family.startswith('microblaze')
204+
elif host_cpu_family == 'microblaze'
196205
target = 'MICROBLAZE'
197206
elif host_cpu_family == 'moxie'
207+
# This CPU family is used in CI cross compilation
198208
target = 'MOXIE'
199209
asm_sources = ['eabi.S']
200210
elif host_cpu_family == 'metag'
211+
# FIXME: metag family is missing in Meson
201212
target = 'METAG'
202-
elif host_cpu_family.startswith('mips') and \
213+
elif host_cpu_family in ['mips', 'mips64'] and \
203214
(host_system.startswith('irix5.') or host_system.startswith('irix6.') or host_system.startswith('rtems'))
204215
target = 'MIPS'
205216
asm_sources = ['o32.S', 'n32.S']
206-
elif host_cpu_family.startswith('mips') and host_system in ['linux', 'openbsd', 'freebsd']
217+
elif host_cpu_family in ['mips', 'mips64'] and host_system in ['linux', 'openbsd', 'freebsd']
207218
target = 'MIPS'
208219
asm_sources = ['o32.S', 'n32.S']
209220
# Support 128-bit long double for NewABI.
210221
have_long_double = 'defined(__mips64)'
211-
elif host_cpu_family.startswith('nios2') and host_system == 'linux'
222+
elif host_cpu_family == 'nios2' and host_system == 'linux'
223+
# FIXME: nios2 family is missing in Meson
212224
target = 'NIOS2'
213-
elif host_cpu_family.startswith('or1k')
225+
elif host_cpu_family == 'or1k'
226+
# FIXME: or1k family is missing in Meson
214227
target = 'OR1K'
215-
elif (host_cpu_family.startswith('powerpc') and \
228+
elif (host_cpu_family in ['ppc', 'ppc64'] and \
216229
host_system in ['linux', 'sysv', 'amigaos', 'eabi', 'beos', 'rtems']) or \
217-
(host_cpu_family in ['powerpc64', 'powerpc64le'] and host_system == 'freebsd')
230+
(host_cpu_family == 'ppc64' and host_system == 'freebsd')
218231
target = 'POWERPC'
219232
c_sources = ['ffi.c', 'ffi_sysv.c', 'ffi_linux64.c']
220233
asm_sources = ['sysv.S', 'ppc_closure.S', 'linux64.S', 'linux64_closure.S']
221234
have_long_double_variant = true
222-
elif host_cpu_family.startswith('powerpc') and host_system == 'darwin'
235+
elif host_cpu_family in ['ppc', 'ppc64'] and host_system == 'darwin'
223236
target = 'POWERPC_DARWIN'
224237
targetdir = 'powerpc'
225238
c_sources = ['ffi_darwin.c']
226239
asm_sources = ['darwin.S', 'darwin_closure.S']
227-
elif host_cpu_family in ['powerpc', 'rs6000'] and host_system in ['darwin', 'aix']
240+
elif host_cpu_family in ['ppc', 'rs6000'] and host_system in ['darwin', 'aix']
228241
target = 'POWERPC_AIX'
229242
targetdir = 'powerpc'
230243
c_sources = ['ffi_darwin.c']
231244
asm_sources = ['aix.S aix_closure.S']
232-
elif host_cpu_family == 'powerpc' and host_system in ['freebsd', 'openbsd', 'netbsd']
245+
elif host_cpu_family == 'ppc' and host_system in ['freebsd', 'openbsd', 'netbsd']
233246
target = 'POWERPC_FREEBSD'
234247
targetdir = 'powerpc'
235248
c_sources = ['ffi.c', 'ffi_sysv.c']
236249
asm_sources = ['sysv.S', ' pc_closure.S']
237-
have_long_double_variant = true
238-
elif host_cpu_family == 'powerpcspe' and host_system == 'freebsd'
239-
target = 'POWERPC_FREEBSD'
240-
targetdir = 'powerpc'
241-
c_sources = ['ffi.c', 'ffi_sysv.c']
242-
asm_sources = ['sysv.S', ' pc_closure.S']
243-
add_project_arguments('-D__NO_FPRS__', language: 'c')
244-
elif host_cpu_family.startswith('riscv')
250+
if cc.get_define('__SPE__') != ''
251+
add_project_arguments('-D__NO_FPRS__', language: 'c')
252+
else
253+
have_long_double_variant = true
254+
endif
255+
elif host_cpu_family in ['riscv32', 'riscv64']
245256
target = 'RISCV'
246-
elif host_cpu_family.startswith('s390')
257+
elif host_cpu_family in ['s390', 's390x']
247258
target = 'S390'
248259
elif host_cpu_family == 'sh64' or host_cpu_family.startswith('sh5')
260+
# FIXME: Meson only has sh4 family
249261
target = 'SH64'
250262
elif host_cpu_family.startswith('sh')
263+
# FIXME: Meson only has sh4 family
251264
target = 'SH'
252-
elif host_cpu_family.startswith('sparc')
265+
elif host_cpu_family in ['sparc', 'sparc64']
253266
target = 'SPARC'
254267
c_sources = ['ffi.c', 'ffi64.c']
255268
asm_sources = ['v8.S', 'v9.S']
256-
elif host_cpu_family.startswith('tile')
269+
elif host_cpu_family == 'tile'
270+
# FIXME: tile family is missing in Meson
257271
target = 'TILE'
258272
asm_sources = ['tile.S']
259273
elif host_cpu_family == 'vax'
274+
# FIXME: vax family is missing in Meson
260275
target = 'VAX'
261276
asm_sources = ['elfbsd.S']
262-
elif host_cpu_family.startswith('xtensa')
277+
elif host_cpu_family == 'xtensa'
278+
# FIXME: xtensa family is missing in Meson
263279
target = 'XTENSA'
264280
else
265281
error('Unsupported pair: system "@0@", cpu family "@1@"'.format(host_system, host_cpu_family))
@@ -421,7 +437,11 @@ if get_option('doc')
421437
endif
422438

423439
if get_option('tests')
424-
subdir('testsuite')
440+
if meson.version().version_compare('>=0.58.0')
441+
subdir('testsuite')
442+
else
443+
error('Meson >= 0.58 is required for unit tests')
444+
endif
425445
endif
426446

427447
install_man([

subprojects/packagefiles/libffi/src/meson.build

+49-16
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,18 @@ endforeach
2323

2424
ffiinc = include_directories('..', '../include', targetdir)
2525

26-
if is_msvc_like
26+
if is_msvc
2727
# MSVC, cannot compile assembly files directly. They need to be preprocessed
2828
# with the C compiler first, then compiled with MASM.
29-
ffi_asm_sources = cc.preprocess(ffi_asm_sources,
30-
output: '@[email protected]',
31-
include_directories: ffiinc,
32-
)
33-
add_languages('masm', native: false)
29+
if meson.version().version_compare('>=0.64.0')
30+
ffi_asm_sources = cc.preprocess(ffi_asm_sources,
31+
output: '@[email protected]',
32+
include_directories: ffiinc,
33+
)
34+
add_languages('masm', native: false)
35+
else
36+
error('Meson >= 0.64 is required with MSVC')
37+
endif
3438
endif
3539

3640
ffi_link_args = []
@@ -39,13 +43,33 @@ ffi_map_file = []
3943
if get_option('ffi-build-versioned')
4044
libffi_map_in = meson.project_source_root() / 'libffi.map.in'
4145
arg_prefix = '-Wl,--version-script='
42-
if cc.has_link_argument(arg_prefix + libffi_map_in)
43-
ffi_map_file = cc.preprocess(libffi_map_in,
44-
output: '@BASENAME@',
45-
include_directories: ffiinc,
46-
compile_args: '-DGENERATE_LIBFFI_MAP',
47-
)
48-
ffi_link_args += arg_prefix + ffi_map_file[0].full_path()
46+
if cc.has_multi_link_arguments(['-shared', arg_prefix + libffi_map_in])
47+
if meson.version().version_compare('>=0.64.0')
48+
ffi_map_file = cc.preprocess(libffi_map_in,
49+
output: '@BASENAME@',
50+
include_directories: ffiinc,
51+
compile_args: '-DGENERATE_LIBFFI_MAP',
52+
)
53+
ffi_map_abs = ffi_map_file[0].full_path()
54+
else
55+
ffi_map_file = configure_file(
56+
output: 'libffi.map',
57+
command: [
58+
meson.get_compiler('c'),
59+
get_option('c_args'),
60+
'-I' + join_paths(meson.current_build_dir(), '..'),
61+
'-I' + join_paths(meson.current_build_dir(), '..', 'include'),
62+
'-I' + join_paths(meson.current_source_dir(), targetdir),
63+
'-DGENERATE_LIBFFI_MAP',
64+
'-E', '-x', 'assembler-with-cpp',
65+
join_paths(meson.current_source_dir(),'../libffi.map.in'),
66+
'-o',
67+
'@OUTPUT@'
68+
],
69+
)
70+
ffi_map_abs = meson.current_build_dir() / 'libffi.map'
71+
endif
72+
ffi_link_args += arg_prefix + ffi_map_abs
4973
endif
5074
endif
5175

@@ -54,16 +78,25 @@ if get_option('default_library') == 'static'
5478
public_c_args += ['-DFFI_STATIC_BUILD']
5579
endif
5680

81+
# masm_args is new in Meson 0.64, older versions fails when passing unknown
82+
# keyword arguments. We only need it when using MSVC which already requires
83+
# Meson >= 0.64 above, this tricks avoids passing it to older versions.
84+
extra_kwargs = {}
85+
if meson.version().version_compare('>=0.64.0')
86+
extra_kwargs += {'masm_args': masm_args}
87+
endif
88+
5789
ffi_lib = library('ffi', ffi_c_sources, ffi_asm_sources,
58-
c_args : ['-DTARGET=' + target, '-DFFI_BUILDING_DLL', public_c_args],
59-
masm_args : masm_args,
90+
c_args : ['-DFFI_BUILDING_DLL', public_c_args],
6091
include_directories : ffiinc,
6192
link_args: ffi_link_args,
6293
link_depends: ffi_map_file,
6394
version : ffi_version,
6495
soversion : ffi_soversion,
6596
darwin_versions : ffi_darwin_versions,
66-
install : true)
97+
install : true,
98+
kwargs: extra_kwargs,
99+
)
67100

68101
pkgconf = import('pkgconfig')
69102
pkgconf.generate(ffi_lib,

0 commit comments

Comments
 (0)