Crates.io | flint3-sys |
lib.rs | flint3-sys |
version | 3.2.4 |
source | src |
created_at | 2025-05-21 17:17:42.720743+00 |
updated_at | 2025-05-21 21:15:06.705568+00 |
description | Rust bindings to the FLINT C library |
homepage | |
repository | https://github.com/lairez/flint3-sys |
max_upload_size | |
id | 1683678 |
size | 46,707,438 |
FLINT bindings for the Rust programming language, using bindgen.
Since the FLINT API evolves quickly, this crate always compiles FLINT from source and never attempts to use a system library.
This crate follows FLINT's versioning, except for the patch version, which may increase faster.
gmp-mpfr-sys
: Enables a dependency on the gmp-mpfr-sys crate and builds FLINT against GMP and MPFR libraries compiled by it. If this feature is not enabled, there is a system dependency on GMP and MPFR.
force-bindgen
: Adds bindgen as a build dependency and regenerates the bindings. Useful for maintenance (see below).
This crate passes the following metadata to its dependents:
DEP_FLINT_LIB_DIR
: Path to the directory containing libflint.a
.DEP_FLINT_INCLUDE_DIR
: Path to the directory containing FLINT headers, such as DEP_FLINT_INCLUDE_DIR/flint/flint.h
.This is useful for crates that need to compile a C library depending on FLINT. See the Cargo book for more details.
This crate is distributed under the MIT license.
Note that FLINT itself is licensed under the LGPLv3.
Creating a *-sys
crate involves several design decisions, as outlined by Kornel.
While FLINT is available via many package managers, using the system library can introduce issues due to FLINT's unstable API.
Using pkg-config to link against a system-installed FLINT is straightforward, but building against it requires running bindgen on the system headers. This:
For these reasons, this crate builds FLINT from source.
For FLINT's dependencies (GMP and MPFR), you may choose to compile them from source (using the gmp-mpfr-sys feature) or rely on the system libraries. Compiling from source typically yields better performance.
Note: flint3-sys does not expose any part of the GMP or MPFR APIs.
build.rs
?There are two approaches:
By default, the first option is used as it's much faster. However, it may lead to desynchronization: the headers used to generate the bindings are not necessarily the ones you'll have after building FLINT. Parts of FLINT's headers are generated by its ./configure
script, so constants like FLINT_HAVE_FFT_SMALL
might not match.
To regenerate bindings manually, enable the force-bindgen feature.
To update the bundled version of FLINT:
./flint
submodule.KEEP_BINDGEN_OUTPUT=1 cargo build -F force-bindgen
to regenerate ./bindgen/flint.rs
and ./bindgen/extern.c
.