A friendly libffi fork with a Zig build script and bindings. https://sourceware.org/libffi
Find a file
Alex Rønne Petersen 51ffe54d28
All checks were successful
/ build (x86_64-linux) (push) Successful in 1m38s
add Zig build script and bindings; remove all files unneeded in our fork
Co-authored-by: Techatrix <techatrix@mailbox.org>
2025-12-05 10:32:15 +01:00
.forgejo/workflows add Zig build script and bindings; remove all files unneeded in our fork 2025-12-05 10:32:15 +01:00
include add Zig build script and bindings; remove all files unneeded in our fork 2025-12-05 10:32:15 +01:00
lib add Zig build script and bindings; remove all files unneeded in our fork 2025-12-05 10:32:15 +01:00
src add Zig build script and bindings; remove all files unneeded in our fork 2025-12-05 10:32:15 +01:00
.editorconfig add Zig build script and bindings; remove all files unneeded in our fork 2025-12-05 10:32:15 +01:00
.gitattributes add Zig build script and bindings; remove all files unneeded in our fork 2025-12-05 10:32:15 +01:00
.gitignore add Zig build script and bindings; remove all files unneeded in our fork 2025-12-05 10:32:15 +01:00
.markdownlint.json add Zig build script and bindings; remove all files unneeded in our fork 2025-12-05 10:32:15 +01:00
build.zig add Zig build script and bindings; remove all files unneeded in our fork 2025-12-05 10:32:15 +01:00
build.zig.zon add Zig build script and bindings; remove all files unneeded in our fork 2025-12-05 10:32:15 +01:00
example.zig add Zig build script and bindings; remove all files unneeded in our fork 2025-12-05 10:32:15 +01:00
fficonfig.zig.h add Zig build script and bindings; remove all files unneeded in our fork 2025-12-05 10:32:15 +01:00
LICENSE Update License date and improve rcedit DLL metadata (#919) 2025-06-08 06:16:38 -04:00
README.md add Zig build script and bindings; remove all files unneeded in our fork 2025-12-05 10:32:15 +01:00
RELEASE.md add Zig build script and bindings; remove all files unneeded in our fork 2025-12-05 10:32:15 +01:00

Vezel libffi Fork

This is a friendly fork of libffi. The notable changes made in this fork are the additions of a Zig build script, making it easy to integrate libffi into Zig projects using the Zig package manager, and a set of idiomatic Zig bindings for libffi's main API. Additionally, to reduce the package download size, we have removed a large number of files that are unnecessary when using libffi in a Zig project. Importantly, all library source code is identical to upstream, so in terms of API/ABI compatibility, using this fork is no different from linking to a system libffi package.

Usage

The minimum Zig version supported by this project can be found in the minimum_zig_version field of the build.zig.zon file. We generally try to track the latest release of Zig. But do note that the master branch may sometimes contain code that only works with a master build of Zig.

Please note that the master branch is rebased on top of upstream periodically. You should use a release tag rather than master. For example:

zig fetch --save=libffi https://codeberg.org/vezel/libffi/archive/vX.Y.Z-B.tar.gz
# Or, to use Git:
zig fetch --save=libffi git+https://codeberg.org/vezel/libffi.git#vX.Y.Z-B

(You can find the latest version on the releases page.)

Consume the library in your build.zig:

const libffi = b.dependency("libffi", .{
    .target = target,
    .optimize = optimize,
});

exe.root_module.addImport("ffi", libffi.module("ffi"));

if (b.systemIntegrationOption("ffi", .{})) {
    exe.root_module.linkSystemLibrary("ffi", .{});
} else {
    exe.root_module.linkLibrary(libffi.artifact("ffi"));
}

You can now use the Zig bindings in your code. See example.zig for basic usage.

License

This project is licensed under the terms found in LICENSE; this file is unchanged from upstream.