xref: /aosp_15_r20/external/libffi/README.md (revision 1fd5a2e1d639cd1ddf29dd0c484c123bbd850c21)
1Status
2======
3
4[![Build Status](https://travis-ci.org/libffi/libffi.svg?branch=master)](https://travis-ci.org/libffi/libffi)
5[![Build status](https://ci.appveyor.com/api/projects/status/8lko9vagbx4w2kxq?svg=true)](https://ci.appveyor.com/project/atgreen/libffi)
6
7libffi-3.3 was released on November 23, 2019.  Check the libffi web
8page for updates: <URL:http://sourceware.org/libffi/>.
9
10
11What is libffi?
12===============
13
14Compilers for high level languages generate code that follow certain
15conventions. These conventions are necessary, in part, for separate
16compilation to work. One such convention is the "calling
17convention". The "calling convention" is essentially a set of
18assumptions made by the compiler about where function arguments will
19be found on entry to a function. A "calling convention" also specifies
20where the return value for a function is found.
21
22Some programs may not know at the time of compilation what arguments
23are to be passed to a function. For instance, an interpreter may be
24told at run-time about the number and types of arguments used to call
25a given function. Libffi can be used in such programs to provide a
26bridge from the interpreter program to compiled code.
27
28The libffi library provides a portable, high level programming
29interface to various calling conventions. This allows a programmer to
30call any function specified by a call interface description at run
31time.
32
33FFI stands for Foreign Function Interface.  A foreign function
34interface is the popular name for the interface that allows code
35written in one language to call code written in another language. The
36libffi library really only provides the lowest, machine dependent
37layer of a fully featured foreign function interface. A layer must
38exist above libffi that handles type conversions for values passed
39between the two languages.
40
41
42Supported Platforms
43===================
44
45Libffi has been ported to many different platforms.
46
47At the time of release, the following basic configurations have been
48tested:
49
50| Architecture    | Operating System | Compiler                |
51| --------------- | ---------------- | ----------------------- |
52| AArch64 (ARM64) | iOS              | Clang                   |
53| AArch64         | Linux            | GCC                     |
54| AArch64         | Windows          | MSVC                    |
55| Alpha           | Linux            | GCC                     |
56| Alpha           | Tru64            | GCC                     |
57| ARC             | Linux            | GCC                     |
58| ARM             | Linux            | GCC                     |
59| ARM             | iOS              | GCC                     |
60| ARM             | Windows          | MSVC                    |
61| AVR32           | Linux            | GCC                     |
62| Blackfin        | uClinux          | GCC                     |
63| HPPA            | HPUX             | GCC                     |
64| IA-64           | Linux            | GCC                     |
65| M68K            | FreeMiNT         | GCC                     |
66| M68K            | Linux            | GCC                     |
67| M68K            | RTEMS            | GCC                     |
68| M88K            | OpenBSD/mvme88k  | GCC                     |
69| Meta            | Linux            | GCC                     |
70| MicroBlaze      | Linux            | GCC                     |
71| MIPS            | IRIX             | GCC                     |
72| MIPS            | Linux            | GCC                     |
73| MIPS            | RTEMS            | GCC                     |
74| MIPS64          | Linux            | GCC                     |
75| Moxie           | Bare metal       | GCC                     |
76| Nios II         | Linux            | GCC                     |
77| OpenRISC        | Linux            | GCC                     |
78| PowerPC 32-bit  | AIX              | IBM XL C                |
79| PowerPC 64-bit  | AIX              | IBM XL C                |
80| PowerPC         | AMIGA            | GCC                     |
81| PowerPC         | Linux            | GCC                     |
82| PowerPC         | Mac OSX          | GCC                     |
83| PowerPC         | FreeBSD          | GCC                     |
84| PowerPC 64-bit  | FreeBSD          | GCC                     |
85| PowerPC 64-bit  | Linux ELFv1      | GCC                     |
86| PowerPC 64-bit  | Linux ELFv2      | GCC                     |
87| RISC-V 32-bit   | Linux            | GCC                     |
88| RISC-V 64-bit   | Linux            | GCC                     |
89| S390            | Linux            | GCC                     |
90| S390X           | Linux            | GCC                     |
91| SPARC           | Linux            | GCC                     |
92| SPARC           | Solaris          | GCC                     |
93| SPARC           | Solaris          | Oracle Solaris Studio C |
94| SPARC64         | Linux            | GCC                     |
95| SPARC64         | FreeBSD          | GCC                     |
96| SPARC64         | Solaris          | Oracle Solaris Studio C |
97| TILE-Gx/TILEPro | Linux            | GCC                     |
98| VAX             | OpenBSD/vax      | GCC                     |
99| X86             | FreeBSD          | GCC                     |
100| X86             | GNU HURD         | GCC                     |
101| X86             | Interix          | GCC                     |
102| X86             | kFreeBSD         | GCC                     |
103| X86             | Linux            | GCC                     |
104| X86             | Mac OSX          | GCC                     |
105| X86             | OpenBSD          | GCC                     |
106| X86             | OS/2             | GCC                     |
107| X86             | Solaris          | GCC                     |
108| X86             | Solaris          | Oracle Solaris Studio C |
109| X86             | Windows/Cygwin   | GCC                     |
110| X86             | Windows/MingW    | GCC                     |
111| X86-64          | FreeBSD          | GCC                     |
112| X86-64          | Linux            | GCC                     |
113| X86-64          | Linux/x32        | GCC                     |
114| X86-64          | OpenBSD          | GCC                     |
115| X86-64          | Solaris          | Oracle Solaris Studio C |
116| X86-64          | Windows/Cygwin   | GCC                     |
117| X86-64          | Windows/MingW    | GCC                     |
118| X86-64          | Mac OSX          | GCC                     |
119| Xtensa          | Linux            | GCC                     |
120
121Please send additional platform test results to
122[email protected].
123
124Installing libffi
125=================
126
127First you must configure the distribution for your particular
128system. Go to the directory you wish to build libffi in and run the
129"configure" program found in the root directory of the libffi source
130distribution.  Note that building libffi requires a C99 compatible
131compiler.
132
133If you're building libffi directly from git hosted sources, configure
134won't exist yet; run ./autogen.sh first.  This will require that you
135install autoconf, automake and libtool.
136
137You may want to tell configure where to install the libffi library and
138header files. To do that, use the ``--prefix`` configure switch.  Libffi
139will install under /usr/local by default.
140
141If you want to enable extra run-time debugging checks use the the
142``--enable-debug`` configure switch. This is useful when your program dies
143mysteriously while using libffi.
144
145Another useful configure switch is ``--enable-purify-safety``. Using this
146will add some extra code which will suppress certain warnings when you
147are using Purify with libffi. Only use this switch when using
148Purify, as it will slow down the library.
149
150If you don't want to build documentation, use the ``--disable-docs``
151configure switch.
152
153It's also possible to build libffi on Windows platforms with
154Microsoft's Visual C++ compiler.  In this case, use the msvcc.sh
155wrapper script during configuration like so:
156
157    path/to/configure CC=path/to/msvcc.sh CXX=path/to/msvcc.sh LD=link CPP="cl -nologo -EP" CPPFLAGS="-DFFI_BUILDING_DLL"
158
159For 64-bit Windows builds, use ``CC="path/to/msvcc.sh -m64"`` and
160``CXX="path/to/msvcc.sh -m64"``.  You may also need to specify
161``--build`` appropriately.
162
163It is also possible to build libffi on Windows platforms with the LLVM
164project's clang-cl compiler, like below:
165
166    path/to/configure CC="path/to/msvcc.sh -clang-cl" CXX="path/to/msvcc.sh -clang-cl" LD=link CPP="clang-cl -EP"
167
168When building with MSVC under a MingW environment, you may need to
169remove the line in configure that sets 'fix_srcfile_path' to a 'cygpath'
170command.  ('cygpath' is not present in MingW, and is not required when
171using MingW-style paths.)
172
173To build static library for ARM64 with MSVC using visual studio solution, msvc_build folder have
174   aarch64/Ffi_staticLib.sln
175   required header files in aarch64/aarch64_include/
176
177
178SPARC Solaris builds require the use of the GNU assembler and linker.
179Point ``AS`` and ``LD`` environment variables at those tool prior to
180configuration.
181
182For iOS builds, the ``libffi.xcodeproj`` Xcode project is available.
183
184Configure has many other options. Use ``configure --help`` to see them all.
185
186Once configure has finished, type "make". Note that you must be using
187GNU make.  You can ftp GNU make from ftp.gnu.org:/pub/gnu/make .
188
189To ensure that libffi is working as advertised, type "make check".
190This will require that you have DejaGNU installed.
191
192To install the library and header files, type ``make install``.
193
194
195History
196=======
197
198See the git log for details at http://github.com/libffi/libffi.
199
200    3.3 Nov-23-19
201        Add RISC-V support.
202        New API in support of GO closures.
203        Add IEEE754 binary128 long double support for 64-bit Power
204        Default to Microsoft's 64 bit long double ABI with Visual C++.
205        GNU compiler uses 80 bits (128 in memory) FFI_GNUW64 ABI.
206        Add Windows on ARM64 (WOA) support.
207        Add Windows 32-bit ARM support.
208        Raw java (gcj) API deprecated.
209	Add pre-built PDF documentation to source distribution.
210        Many new tests cases and bug fixes.
211
212    3.2.1 Nov-12-14
213        Build fix for non-iOS AArch64 targets.
214
215    3.2 Nov-11-14
216        Add C99 Complex Type support (currently only supported on
217          s390).
218        Add support for PASCAL and REGISTER calling conventions on x86
219          Windows/Linux.
220        Add OpenRISC and Cygwin-64 support.
221        Bug fixes.
222
223    3.1 May-19-14
224        Add AArch64 (ARM64) iOS support.
225        Add Nios II support.
226        Add m88k and DEC VAX support.
227        Add support for stdcall, thiscall, and fastcall on non-Windows
228          32-bit x86 targets such as Linux.
229        Various Android, MIPS N32, x86, FreeBSD and UltraSPARC IIi
230          fixes.
231        Make the testsuite more robust: eliminate several spurious
232          failures, and respect the $CC and $CXX environment variables.
233        Archive off the manually maintained ChangeLog in favor of git
234          log.
235
236    3.0.13 Mar-17-13
237        Add Meta support.
238        Add missing Moxie bits.
239        Fix stack alignment bug on 32-bit x86.
240        Build fix for m68000 targets.
241        Build fix for soft-float Power targets.
242        Fix the install dir location for some platforms when building
243          with GCC (OS X, Solaris).
244        Fix Cygwin regression.
245
246    3.0.12 Feb-11-13
247        Add Moxie support.
248        Add AArch64 support.
249        Add Blackfin support.
250        Add TILE-Gx/TILEPro support.
251        Add MicroBlaze support.
252        Add Xtensa support.
253        Add support for PaX enabled kernels with MPROTECT.
254        Add support for native vendor compilers on
255          Solaris and AIX.
256        Work around LLVM/GCC interoperability issue on x86_64.
257
258    3.0.11 Apr-11-12
259        Lots of build fixes.
260        Add support for variadic functions (ffi_prep_cif_var).
261        Add Linux/x32 support.
262        Add thiscall, fastcall and MSVC cdecl support on Windows.
263        Add Amiga and newer MacOS support.
264        Add m68k FreeMiNT support.
265        Integration with iOS' xcode build tools.
266        Fix Octeon and MC68881 support.
267        Fix code pessimizations.
268
269    3.0.10 Aug-23-11
270        Add support for Apple's iOS.
271        Add support for ARM VFP ABI.
272        Add RTEMS support for MIPS and M68K.
273        Fix instruction cache clearing problems on
274          ARM and SPARC.
275        Fix the N64 build on mips-sgi-irix6.5.
276        Enable builds with Microsoft's compiler.
277        Enable x86 builds with Oracle's Solaris compiler.
278        Fix support for calling code compiled with Oracle's Sparc
279          Solaris compiler.
280        Testsuite fixes for Tru64 Unix.
281        Additional platform support.
282
283    3.0.9 Dec-31-09
284        Add AVR32 and win64 ports.  Add ARM softfp support.
285        Many fixes for AIX, Solaris, HP-UX, *BSD.
286        Several PowerPC and x86-64 bug fixes.
287        Build DLL for windows.
288
289    3.0.8 Dec-19-08
290        Add *BSD, BeOS, and PA-Linux support.
291
292    3.0.7 Nov-11-08
293        Fix for ppc FreeBSD.
294        (thanks to Andreas Tobler)
295
296    3.0.6 Jul-17-08
297        Fix for closures on sh.
298        Mark the sh/sh64 stack as non-executable.
299        (both thanks to Kaz Kojima)
300
301    3.0.5 Apr-3-08
302        Fix libffi.pc file.
303        Fix #define ARM for IcedTea users.
304        Fix x86 closure bug.
305
306    3.0.4 Feb-24-08
307        Fix x86 OpenBSD configury.
308
309    3.0.3 Feb-22-08
310        Enable x86 OpenBSD thanks to Thomas Heller, and
311          x86-64 FreeBSD thanks to Björn König and Andreas Tobler.
312        Clean up test instruction in README.
313
314    3.0.2 Feb-21-08
315        Improved x86 FreeBSD support.
316        Thanks to Björn König.
317
318    3.0.1 Feb-15-08
319        Fix instruction cache flushing bug on MIPS.
320        Thanks to David Daney.
321
322    3.0.0 Feb-15-08
323        Many changes, mostly thanks to the GCC project.
324        Cygnus Solutions is now Red Hat.
325
326      [10 years go by...]
327
328    1.20 Oct-5-98
329        Raffaele Sena produces ARM port.
330
331    1.19 Oct-5-98
332        Fixed x86 long double and long long return support.
333        m68k bug fixes from Andreas Schwab.
334        Patch for DU assembler compatibility for the Alpha from Richard
335          Henderson.
336
337    1.18 Apr-17-98
338        Bug fixes and MIPS configuration changes.
339
340    1.17 Feb-24-98
341        Bug fixes and m68k port from Andreas Schwab. PowerPC port from
342        Geoffrey Keating. Various bug x86, Sparc and MIPS bug fixes.
343
344    1.16 Feb-11-98
345        Richard Henderson produces Alpha port.
346
347    1.15 Dec-4-97
348        Fixed an n32 ABI bug. New libtool, auto* support.
349
350    1.14 May-13-97
351        libtool is now used to generate shared and static libraries.
352        Fixed a minor portability problem reported by Russ McManus
353        <[email protected]>.
354
355    1.13 Dec-2-96
356        Added --enable-purify-safety to keep Purify from complaining
357          about certain low level code.
358        Sparc fix for calling functions with < 6 args.
359        Linux x86 a.out fix.
360
361    1.12 Nov-22-96
362        Added missing ffi_type_void, needed for supporting void return
363          types. Fixed test case for non MIPS machines. Cygnus Support
364          is now Cygnus Solutions.
365
366    1.11 Oct-30-96
367        Added notes about GNU make.
368
369    1.10 Oct-29-96
370        Added configuration fix for non GNU compilers.
371
372    1.09 Oct-29-96
373        Added --enable-debug configure switch. Clean-ups based on LCLint
374        feedback. ffi_mips.h is always installed. Many configuration
375        fixes. Fixed ffitest.c for sparc builds.
376
377    1.08 Oct-15-96
378        Fixed n32 problem. Many clean-ups.
379
380    1.07 Oct-14-96
381        Gordon Irlam rewrites v8.S again. Bug fixes.
382
383    1.06 Oct-14-96
384        Gordon Irlam improved the sparc port.
385
386    1.05 Oct-14-96
387        Interface changes based on feedback.
388
389    1.04 Oct-11-96
390        Sparc port complete (modulo struct passing bug).
391
392    1.03 Oct-10-96
393        Passing struct args, and returning struct values works for
394        all architectures/calling conventions. Expanded tests.
395
396    1.02 Oct-9-96
397        Added SGI n32 support. Fixed bugs in both o32 and Linux support.
398        Added "make test".
399
400    1.01 Oct-8-96
401        Fixed float passing bug in mips version. Restructured some
402        of the code. Builds cleanly with SGI tools.
403
404    1.00 Oct-7-96
405        First release. No public announcement.
406
407Authors & Credits
408=================
409
410libffi was originally written by Anthony Green <[email protected]>.
411
412The developers of the GNU Compiler Collection project have made
413innumerable valuable contributions.  See the ChangeLog file for
414details.
415
416Some of the ideas behind libffi were inspired by Gianni Mariani's free
417gencall library for Silicon Graphics machines.
418
419The closure mechanism was designed and implemented by Kresten Krab
420Thorup.
421
422Major processor architecture ports were contributed by the following
423developers:
424
425    aarch64             Marcus Shawcroft, James Greenhalgh
426    alpha               Richard Henderson
427    arc                 Hackers at Synopsis
428    arm                 Raffaele Sena
429    avr32               Bradley Smith
430    blackfin            Alexandre Keunecke I. de Mendonca
431    cris                Simon Posnjak, Hans-Peter Nilsson
432    frv                 Anthony Green
433    ia64                Hans Boehm
434    m32r                Kazuhiro Inaoka
435    m68k                Andreas Schwab
436    m88k                Miod Vallat
437    metag               Hackers at Imagination Technologies
438    microblaze          Nathan Rossi
439    mips                Anthony Green, Casey Marshall
440    mips64              David Daney
441    moxie               Anthony Green
442    nios ii             Sandra Loosemore
443    openrisc            Sebastian Macke
444    pa                  Randolph Chung, Dave Anglin, Andreas Tobler
445    powerpc             Geoffrey Keating, Andreas Tobler,
446                        David Edelsohn, John Hornkvist
447    powerpc64           Jakub Jelinek
448    riscv               Michael Knyszek, Andrew Waterman, Stef O'Rear
449    s390                Gerhard Tonn, Ulrich Weigand
450    sh                  Kaz Kojima
451    sh64                Kaz Kojima
452    sparc               Anthony Green, Gordon Irlam
453    tile-gx/tilepro     Walter Lee
454    vax                 Miod Vallat
455    x86                 Anthony Green, Jon Beniston
456    x86-64              Bo Thorsen
457    xtensa              Chris Zankel
458
459Jesper Skov and Andrew Haley both did more than their fair share of
460stepping through the code and tracking down bugs.
461
462Thanks also to Tom Tromey for bug fixes, documentation and
463configuration help.
464
465Thanks to Jim Blandy, who provided some useful feedback on the libffi
466interface.
467
468Andreas Tobler has done a tremendous amount of work on the testsuite.
469
470Alex Oliva solved the executable page problem for SElinux.
471
472The list above is almost certainly incomplete and inaccurate.  I'm
473happy to make corrections or additions upon request.
474
475If you have a problem, or have found a bug, please send a note to the
476author at [email protected], or the project mailing list at
477[email protected].
478