[package]
name = "my-awesome-project"
version = "0.0.1"
edition = "2021"
[dependencies]
lief = { git = "https://github.com/lief-project/LIEF", branch = "main" }
The API is documented here: https://docs.rs/crate/lief/latest and the nightly documentation is available here: https://lief-rs.s3.fr-par.scw.cloud/doc/latest/lief/index.html LIEF’s Rust bindings are split in two parts: It turns out that the Similarly the .rs file generated by autocxx does not need to be regenerated every time. For a given tag or commit those files can be pre-compiled or pre-generated. To avoid waiting on tasks that can be pre-computed, LIEF pre-compiles these elements and download them either from Github (for release) or a S3 bucket for nightly builds. If one needs to avoid downloading these pre-compiled files, you can set This variable can also be used while building with in offline mode (e.g. As of now, the following targets are supported with pre-compilation: Target Description Regular Linux x86-64 (Ubuntu 20.04, Debian 11.5, …) Linux aarch64 (Debian 12+) macOS 11+ x86-64 macOS 11+ arm64 (Apple Silicon) iOS 12+ Regular Windows x86-64 (static UCRT runtime) Regular Windows x86-64 (dynamic UCRT runtime The assets of the pre-compiled output are: LIEF static library: LIEF static library must be compiled as described in the Compilation section using the CMake option: Precompiled FFI Bindings¶
lief
: the high-level-rust-idiomatic APIlief-ffi
: the low-level FFI API generated by autocxxlief-ffi
package can take some time to be compiled (around 1 or 2 minutes) but most of this time is spent for compiling auto-generated C++ code (generated by cxx.rs).LIEF_RUST_PRECOMPILED
¶LIEF_RUST_PRECOMPILED
to point to the directory that contains these files:/home/romain/out
├── lib
│ ├── libLIEF.a
│ └── liblief-sys.a
└── rs
└── autocxx-autocxx_ffi-gen.rs
3 directories, 3 files
LIEF_RUST_PRECOMPILED=/home/romain/out cargo build [...]
cargo --offline
).x86_64-unknown-linux-gnu
aarch64-unknown-linux-gnu
x86_64-apple-darwin
aarch64-apple-darwin
aarch64-apple-ios
x86_64-pc-windows-msvc[MT]
x86_64-pc-windows-msvc[MD]
.dll
)Precompilation¶
LIEF.a, LIEF.lib
liefsys.{a, lib}
: C++ part of cxx.rsautocxx-autocxx_ffi-gen.rs
bridge generated by autocxx.-DLIEF_RUST_API=ON
.liefsys.{a, lib}
and autocxx-autocxx_ffi-gen.rs
can be generated using the lief-ffigen
modules:$ cd api/rust/cargo
$ cargo build --release -p lief-ffigen
$ ./target/release/lief-ffigen \
--output-dir ./out-gen \
--lief-dir <path-to-lief-sdk> \
--target x86_64-unknown-linux-gnu \
--host x86_64-unknown-linux-gnu
--lief-dir
must point to the install location of the SDK while out-gen/
contains the generated artifacts.