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