百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
L

libffi

> 编程语言
开源

一个便携式外部函数接口库。

4.3K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个便携式外部函数接口库。

Status

libffi-3.8.0 was released on August 8, 2026.

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.

FFI stands for Foreign Function Interface. A foreign function 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.

Supported Platforms

Libffi has been ported to many different platforms.

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

Architecture Operating System Compiler
AArch64 (ARM64) iOS Clang
AArch64 Linux GCC
AArch64 Windows MSVC
Alpha Linux GCC
Alpha Tru64 GCC
ARC Linux GCC
ARC32 Linux GCC
ARC64 Linux GCC
ARM Linux GCC
ARM iOS GCC
ARM Windows MSVC
AVR32 Linux GCC
Blackfin uClinux GCC
CSKY Linux GCC
HPPA HPUX GCC
HPPA64 HPUX GCC
KVX Linux GCC
IA-64 Linux GCC
LoongArch32 Linux GCC
LoongArch64 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
OpenRISC Linux GCC
PowerPC 32-bit AIX 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
RISC-V 32-bit Linux GCC
RISC-V 64-bit Linux GCC
S390 Linux GCC
S390X Linux GCC
SH3 Linux GCC
SH4 Linux GCC
SH5/SH64 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
WASM32 Emscripten EMCC
WASM64 Emscripten EMCC
X86 FreeBSD GCC
X86 GNU HURD GCC
X86 Interix GCC
X86 kFreeBSD GCC
X86 Linux 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 DragonFly BSD 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
X86-64 Mac OSX GCC
Xtensa Linux GCC

Please send additional platform test results to [email protected].

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. Note that building libffi requires a C99 compatible compiler. If you're building libffi directly from git hosted sources, configure won't exist yet; run ./autogen.sh first. This will require that you install autoconf, automake, libtool and texinfo.

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.

If you don't want to build documentation, use the --disable-docs configure switch.

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:

path/to/configure CC=path/to/msvcc.sh CXX=path/to/msvcc.sh LD=link CPP="cl -nologo -EP" CXXCPP="cl -nologo -EP" CPPFLAGS="-DFFI_BUILDING_DLL"

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"

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.)

To build static library for ARM64 with MSVC using visual studio solution, msvc_build folder have aarch64/Ffi_staticLib.sln required header files in aarch64/aarch64_include/

SPARC Solaris builds require the use of the GNU assembler and linker. Point AS and LD environment variables at those tool prior to configuration.

For iOS builds, the libffi.xcodeproj Xcode project is available.

Configure has many other options. Use configure --help to see them all.

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

To ensure that libffi is working as advertised, type "make check". This will require that you have DejaGNU installed.

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

History

See the git log for details at http://github.com/libffi/libffi.

TBD
    Fix aarch64 and arm big-endian closures receiving garbage
      sub-word integer and scalar-float arguments, and aarch64
      big-endian sub-word/float return values, by offsetting to the
      least-significant bytes of the register or stack slot
      (#1012, closes #1011 and #675).

3.8.0 August-8-2026
    Add FFI_TYPE_VECTOR (SIMD) type support with libffi-computed
      layout, for aarch64 and x86-64 (#1000, closes #773).
    Add ffi_call_plan_size to report the total memory a reusable call
      plan owns, for embedders that account for the memory held by
      long-lived plans.
    Add powerpc64 ELFv2 _Complex long double support for both
      IBM-128 (double-double) and IEEE-128 formats (#1003, closes #1001).
    Fix powerpc64 big-endian ELFv2 closures returning 5-, 6-, or
      7-byte structs: missing return jump-table entries produced a
      wrong result and leaked a libffi code pointer.
    Fix ia64 return-value jump-table desync after the FFI_TYPE_LAST
      bump, which corrupted small-struct and HFA returns.
    Fix powerpc Darwin closure returns broken by #951 (#1002).
    Return small (1, 2, 4 or 8 byte) structs in registers on the i386
      FreeBSD and OpenBSD targets, matching the platform ABI and
      fixing a segfault on struct returns through ffi_call and closures.
    Cache the static trampoline "unsupported" result on hosts whose
      page size exceeds the trampoline table mapping, avoiding
      redundant re-initialization on every closure allocation
      (e.g. 64K-page aarch64).

3.7.1 July-10-2026
    Fix aarch64 ffi_call memory corruption when passing many large
      structs by value.
    Fix i386 thiscall/fastcall closure stack cleanup for 64-bit
      integer and struct arguments.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言