README 15.8 KB
Newer Older
1 2
Status
======
Anthony Green committed
3

4 5
libffi-4?? was released on TBD.  Check the libffi web
page for updates: <URL:http://sourceware.org/libffi/>.
Anthony Green committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29


What is libffi?
===============

Compilers for high level languages generate code that follow certain
conventions. These conventions are necessary, in part, for separate
compilation to work. One such convention is the "calling
convention". The "calling convention" is essentially a set of
assumptions made by the compiler about where function arguments will
be found on entry to a function. A "calling convention" also specifies
where the return value for a function is found.

Some programs may not know at the time of compilation what arguments
are to be passed to a function. For instance, an interpreter may be
told at run-time about the number and types of arguments used to call
a given function. Libffi can be used in such programs to provide a
bridge from the interpreter program to compiled code.

The libffi library provides a portable, high level programming
interface to various calling conventions. This allows a programmer to
call any function specified by a call interface description at run
time.  

30
FFI stands for Foreign Function Interface.  A foreign function
Anthony Green committed
31 32 33 34 35 36 37 38
interface is the popular name for the interface that allows code
written in one language to call code written in another language. The
libffi library really only provides the lowest, machine dependent
layer of a fully featured foreign function interface. A layer must
exist above libffi that handles type conversions for values passed
between the two languages.


39 40 41
Supported Platforms
===================

42 43 44 45
Libffi has been ported to many different platforms.
For specific configuration details and testing status, please
refer to the wiki page here:

46
 http://www.moxielogic.org/wiki/index.php?title=Libffi_3.2
47 48 49 50

At the time of release, the following basic configurations have been
tested:

51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|-----------------+------------------+-------------------------|
| Architecture    | Operating System | Compiler                |
|-----------------+------------------+-------------------------|
| AArch64 (ARM64) | iOS              | Clang                   |
| AArch64         | Linux            | GCC                     |
| Alpha           | Linux            | GCC                     |
| Alpha           | Tru64            | GCC                     |
| ARC             | Linux            | GCC                     |
| ARM             | Linux            | GCC                     |
| ARM             | iOS              | GCC                     |
| AVR32           | Linux            | GCC                     |
| Blackfin        | uClinux          | GCC                     |
| HPPA            | HPUX             | GCC                     |
| IA-64           | Linux            | GCC                     |
| M68K            | FreeMiNT         | GCC                     |
| M68K            | Linux            | GCC                     |
| M68K            | RTEMS            | GCC                     |
| M88K            | OpenBSD/mvme88k  | GCC                     |
| Meta            | Linux            | GCC                     |
| MicroBlaze      | Linux            | GCC                     |
| MIPS            | IRIX             | GCC                     |
| MIPS            | Linux            | GCC                     |
| MIPS            | RTEMS            | GCC                     |
| MIPS64          | Linux            | GCC                     |
| Moxie           | Bare metal       | GCC                     |
| Nios II         | Linux            | GCC                     |
| OpenRISC        | Linux            | GCC                     |
| PowerPC 32-bit  | AIX              | IBM XL C                |
| PowerPC 64-bit  | AIX              | IBM XL C                |
| PowerPC         | AMIGA            | GCC                     |
| PowerPC         | Linux            | GCC                     |
| PowerPC         | Mac OSX          | GCC                     |
| PowerPC         | FreeBSD          | GCC                     |
| PowerPC 64-bit  | FreeBSD          | GCC                     |
| PowerPC 64-bit  | Linux ELFv1      | GCC                     |
| PowerPC 64-bit  | Linux ELFv2      | GCC                     |
| S390            | Linux            | GCC                     |
| S390X           | Linux            | GCC                     |
| SPARC           | Linux            | GCC                     |
| SPARC           | Solaris          | GCC                     |
| SPARC           | Solaris          | Oracle Solaris Studio C |
| SPARC64         | Linux            | GCC                     |
| SPARC64         | FreeBSD          | GCC                     |
| SPARC64         | Solaris          | Oracle Solaris Studio C |
| TILE-Gx/TILEPro | Linux            | GCC                     |
| VAX             | OpenBSD/vax      | GCC                     |
| X86             | FreeBSD          | GCC                     |
| X86             | GNU HURD         | GCC                     |
| X86             | Interix          | GCC                     |
| X86             | kFreeBSD         | GCC                     |
| X86             | Linux            | GCC                     |
| X86             | Mac OSX          | GCC                     |
| X86             | OpenBSD          | GCC                     |
| X86             | OS/2             | GCC                     |
| X86             | Solaris          | GCC                     |
| X86             | Solaris          | Oracle Solaris Studio C |
| X86             | Windows/Cygwin   | GCC                     |
| X86             | Windows/MingW    | GCC                     |
| X86-64          | FreeBSD          | GCC                     |
| X86-64          | Linux            | GCC                     |
| X86-64          | Linux/x32        | GCC                     |
| X86-64          | OpenBSD          | GCC                     |
| X86-64          | Solaris          | Oracle Solaris Studio C |
| X86-64          | Windows/Cygwin   | GCC                     |
| X86-64          | Windows/MingW    | GCC                     |
| Xtensa          | Linux            | GCC                     |
|-----------------+------------------+-------------------------|
118

119
Please send additional platform test results to
120 121
libffi-discuss@sourceware.org and feel free to update the wiki page
above.
Anthony Green committed
122 123 124 125 126 127 128 129 130

Installing libffi
=================

First you must configure the distribution for your particular
system. Go to the directory you wish to build libffi in and run the
"configure" program found in the root directory of the libffi source
distribution.

131 132 133
If you're building libffi directly from version control, configure won't
exist yet; run ./autogen.sh first.

Anthony Green committed
134 135 136 137 138 139 140 141 142 143 144 145 146
You may want to tell configure where to install the libffi library and
header files. To do that, use the --prefix configure switch.  Libffi
will install under /usr/local by default. 

If you want to enable extra run-time debugging checks use the the
--enable-debug configure switch. This is useful when your program dies
mysteriously while using libffi. 

Another useful configure switch is --enable-purify-safety. Using this
will add some extra code which will suppress certain warnings when you
are using Purify with libffi. Only use this switch when using 
Purify, as it will slow down the library.

147 148 149 150
It's also possible to build libffi on Windows platforms with
Microsoft's Visual C++ compiler.  In this case, use the msvcc.sh
wrapper script during configuration like so:

151 152 153 154 155 156 157 158 159 160
path/to/configure CC=path/to/msvcc.sh CXX=path/to/msvcc.sh LD=link CPP="cl -nologo -EP"

For 64-bit Windows builds, use CC="path/to/msvcc.sh -m64" and
CXX="path/to/msvcc.sh -m64".  You may also need to specify --build
appropriately.

It is also possible to build libffi on Windows platforms with the LLVM
project's clang-cl compiler, like below:

path/to/configure CC="path/to/msvcc.sh -clang-cl" CXX="path/to/msvcc.sh -clang-cl" LD=link CPP="clang-cl -EP"
Anthony Green committed
161

162 163 164 165
When building with MSVC under a MingW environment, you may need to
remove the line in configure that sets 'fix_srcfile_path' to a 'cygpath'
command.  ('cygpath' is not present in MingW, and is not required when
using MingW-style paths.)
Anthony Green committed
166

Anthony Green committed
167
For iOS builds, the 'libffi.xcodeproj' Xcode project is available.
168

Anthony Green committed
169 170 171
Configure has many other options. Use "configure --help" to see them all.

Once configure has finished, type "make". Note that you must be using
172
GNU make.  You can ftp GNU make from ftp.gnu.org:/pub/gnu/make .
Anthony Green committed
173

174 175
To ensure that libffi is working as advertised, type "make check".
This will require that you have DejaGNU installed.
Anthony Green committed
176 177 178 179

To install the library and header files, type "make install".


180 181
History
=======
Anthony Green committed
182

183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
See the git log for details at http://github.com/atgreen/libffi.

4.0 TBD
        New API in support of GO closures.

3.2.1 Nov-12-14
        Build fix for non-iOS AArch64 targets.

3.2 Nov-11-14
        Add C99 Complex Type support (currently only supported on
          s390).
	Add support for PASCAL and REGISTER calling conventions on x86
	  Windows/Linux.
	Add OpenRISC and Cygwin-64 support.
        Bug fixes.

3.1 May-19-14
        Add AArch64 (ARM64) iOS support.
        Add Nios II support.
        Add m88k and DEC VAX support.
	Add support for stdcall, thiscall, and fastcall on non-Windows
	  32-bit x86 targets such as Linux.
	Various Android, MIPS N32, x86, FreeBSD and UltraSPARC IIi
	  fixes.
	Make the testsuite more robust: eliminate several spurious
	  failures, and respect the $CC and $CXX environment variables.
	Archive off the manually maintained ChangeLog in favor of git
	  log.

3.0.13 Mar-17-13
	Add Meta support.
	Add missing Moxie bits.
	Fix stack alignment bug on 32-bit x86.
	Build fix for m68000 targets.
	Build fix for soft-float Power targets.
	Fix the install dir location for some platforms when building
	  with GCC (OS X, Solaris).
	Fix Cygwin regression.

3.0.12 Feb-11-13
        Add Moxie support.
	Add AArch64 support.
Anthony Green committed
225 226
	Add Blackfin support.
	Add TILE-Gx/TILEPro support.
227 228
	Add MicroBlaze support.
	Add Xtensa support.
Anthony Green committed
229
	Add support for PaX enabled kernels with MPROTECT.
230 231 232
	Add support for native vendor compilers on
	  Solaris and AIX.
	Work around LLVM/GCC interoperability issue on x86_64.
Anthony Green committed
233 234

3.0.11 Apr-11-12
Anthony Green committed
235
        Lots of build fixes.
Anthony Green committed
236
	Add support for variadic functions (ffi_prep_cif_var).
Anthony Green committed
237
	Add Linux/x32 support.
Anthony Green committed
238 239 240 241
	Add thiscall, fastcall and MSVC cdecl support on Windows.
	Add Amiga and newer MacOS support.
	Add m68k FreeMiNT support.
	Integration with iOS' xcode build tools.
Anthony Green committed
242 243 244 245 246 247 248 249 250
	Fix Octeon and MC68881 support.
	Fix code pessimizations.

3.0.10 Aug-23-11
        Add support for Apple's iOS.
	Add support for ARM VFP ABI.
        Add RTEMS support for MIPS and M68K.
	Fix instruction cache clearing problems on
	  ARM and SPARC.
251 252
	Fix the N64 build on mips-sgi-irix6.5.
	Enable builds with Microsoft's compiler.
Anthony Green committed
253 254 255 256 257
	Enable x86 builds with Oracle's Solaris compiler.
	Fix support for calling code compiled with Oracle's Sparc
	  Solaris compiler.
	Testsuite fixes for Tru64 Unix.
	Additional platform support.
258

259 260 261 262 263
3.0.9 Dec-31-09
        Add AVR32 and win64 ports.  Add ARM softfp support.
	Many fixes for AIX, Solaris, HP-UX, *BSD.
	Several PowerPC and x86-64 bug fixes.
	Build DLL for windows.
Anthony Green committed
264

265 266
3.0.8 Dec-19-08
        Add *BSD, BeOS, and PA-Linux support.
Anthony Green committed
267

268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
3.0.7 Nov-11-08
        Fix for ppc FreeBSD.
	(thanks to Andreas Tobler)

3.0.6 Jul-17-08
        Fix for closures on sh.
	Mark the sh/sh64 stack as non-executable.
	(both thanks to Kaz Kojima)

3.0.5 Apr-3-08
        Fix libffi.pc file.
	Fix #define ARM for IcedTea users.
	Fix x86 closure bug.

3.0.4 Feb-24-08
        Fix x86 OpenBSD configury.

3.0.3 Feb-22-08
        Enable x86 OpenBSD thanks to Thomas Heller, and
	x86-64 FreeBSD thanks to Björn König and Andreas Tobler.
	Clean up test instruction in README.

3.0.2 Feb-21-08
        Improved x86 FreeBSD support.
	Thanks to Björn König.

3.0.1 Feb-15-08
        Fix instruction cache flushing bug on MIPS.
	Thanks to David Daney.

3.0.0 Feb-15-08
        Many changes, mostly thanks to the GCC project.
	Cygnus Solutions is now Red Hat.

  [10 years go by...]

Anthony Green committed
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
1.20 Oct-5-98
	Raffaele Sena produces ARM port.

1.19 Oct-5-98
	Fixed x86 long double and long long return support.
	m68k bug fixes from Andreas Schwab.
	Patch for DU assembler compatibility for the Alpha from Richard
	Henderson.

1.18 Apr-17-98
	Bug fixes and MIPS configuration changes.

1.17 Feb-24-98
	Bug fixes and m68k port from Andreas Schwab. PowerPC port from
	Geoffrey Keating. Various bug x86, Sparc and MIPS bug fixes.

1.16 Feb-11-98
	Richard Henderson produces Alpha port.

1.15 Dec-4-97
	Fixed an n32 ABI bug. New libtool, auto* support.

1.14 May-13-97
	libtool is now used to generate shared and static libraries.
	Fixed a minor portability problem reported by Russ McManus
	<mcmanr@eq.gs.com>.

1.13 Dec-2-96
	Added --enable-purify-safety to keep Purify from complaining
	about certain low level code.
	Sparc fix for calling functions with < 6 args.
	Linux x86 a.out fix.

1.12 Nov-22-96
	Added missing ffi_type_void, needed for supporting void return 
	types. Fixed test case for non MIPS machines. Cygnus Support 
	is now Cygnus Solutions. 

1.11 Oct-30-96
	Added notes about GNU make.

1.10 Oct-29-96
	Added configuration fix for non GNU compilers.

1.09 Oct-29-96
	Added --enable-debug configure switch. Clean-ups based on LCLint 
	feedback. ffi_mips.h is always installed. Many configuration 
	fixes. Fixed ffitest.c for sparc builds.

1.08 Oct-15-96
	Fixed n32 problem. Many clean-ups.

1.07 Oct-14-96
	Gordon Irlam rewrites v8.S again. Bug fixes.

1.06 Oct-14-96
	Gordon Irlam improved the sparc port. 

1.05 Oct-14-96
	Interface changes based on feedback.

1.04 Oct-11-96
	Sparc port complete (modulo struct passing bug).

1.03 Oct-10-96
	Passing struct args, and returning struct values works for
	all architectures/calling conventions. Expanded tests.

1.02 Oct-9-96
	Added SGI n32 support. Fixed bugs in both o32 and Linux support.
	Added "make test".

1.01 Oct-8-96
	Fixed float passing bug in mips version. Restructured some
	of the code. Builds cleanly with SGI tools.

1.00 Oct-7-96
	First release. No public announcement.


Authors & Credits
=================

387
libffi was originally written by Anthony Green <green@moxielogic.com>.
388 389 390 391

The developers of the GNU Compiler Collection project have made
innumerable valuable contributions.  See the ChangeLog file for
details.
Anthony Green committed
392

393 394
Some of the ideas behind libffi were inspired by Gianni Mariani's free
gencall library for Silicon Graphics machines.
Anthony Green committed
395 396 397 398

The closure mechanism was designed and implemented by Kresten Krab
Thorup.

399 400 401
Major processor architecture ports were contributed by the following
developers:

Anthony Green committed
402
aarch64		Marcus Shawcroft, James Greenhalgh
403 404
alpha		Richard Henderson
arm		Raffaele Sena
Anthony Green committed
405
blackfin        Alexandre Keunecke I. de Mendonca
406 407 408 409 410
cris		Simon Posnjak, Hans-Peter Nilsson
frv		Anthony Green
ia64		Hans Boehm
m32r		Kazuhiro Inaoka
m68k		Andreas Schwab
411 412
m88k		Miod Vallat
microblaze	Nathan Rossi
413 414
mips		Anthony Green, Casey Marshall
mips64		David Daney
415 416 417
moxie		Anthony Green
nios ii		Sandra Loosemore
openrisc        Sebastian Macke
418 419 420 421 422 423 424 425
pa		Randolph Chung, Dave Anglin, Andreas Tobler
powerpc		Geoffrey Keating, Andreas Tobler, 
			 David Edelsohn, John Hornkvist
powerpc64	Jakub Jelinek
s390		Gerhard Tonn, Ulrich Weigand
sh		Kaz Kojima
sh64		Kaz Kojima
sparc		Anthony Green, Gordon Irlam
Anthony Green committed
426
tile-gx/tilepro Walter Lee
427
vax		Miod Vallat
428 429
x86		Anthony Green, Jon Beniston
x86-64		Bo Thorsen
430
xtensa		Chris Zankel
Anthony Green committed
431 432 433 434

Jesper Skov and Andrew Haley both did more than their fair share of
stepping through the code and tracking down bugs.

435 436
Thanks also to Tom Tromey for bug fixes, documentation and
configuration help.
Anthony Green committed
437 438 439 440

Thanks to Jim Blandy, who provided some useful feedback on the libffi
interface.

441 442 443 444 445 446 447
Andreas Tobler has done a tremendous amount of work on the testsuite.

Alex Oliva solved the executable page problem for SElinux.

The list above is almost certainly incomplete and inaccurate.  I'm
happy to make corrections or additions upon request.

Anthony Green committed
448 449 450
If you have a problem, or have found a bug, please send a note to the
author at green@moxielogic.com, or the project mailing list at
libffi-discuss@sourceware.org.