Crate llvm_build_utils [−] [src]
build.rs utils for building LLVM-IR and bytecode
Building assembly in a cross platform manner is a very painful endeavour requiring to be aware
of various assemblers available and syntaxes they use. Using LLVM-IR as the assembly is a
better alternative and this crate provides tools converting your .ll
or .bc
files into .a
archives containing machine code. These archives can then be statically linked to your project.
This library does not need an installation of LLVM or ar
to work. The LLVM which comes with
rustc is used instead. While this library works perfectly on stable versions of the compiler,
the library may be incompatible with a future version of rustc.
Usage
First, you’ll want to both add a build script for your crate (build.rs
) and also add this
crate to your Cargo.toml
via:
[package]
# ...
build = "build.rs"
[build-dependencies]
llvm_build_utils = "0.3"
Then write your build.rs
like this:
extern crate llvm_build_utils; use llvm_build_utils::*; fn main() { build_archive("libyourthing.a", &[ ("input.ll", BuildOptions { ..BuildOptions::default() // customise how the file is built }) ]).expect("error happened").print(); }
Running a cargo build
should produce libyourthing.a
which then may be linked to your Rust
executable/library.
Structs
BuildOptions | |
Printout |
Output for cargo |
Enums
ArchiveKind |
The format of generated archive file |
CodegenModel |
Codegen model |
Optimisation |
Codegen optimisation level |
Relocations |
Relocation mode |
Functions
build_archive |
Produce a static library (archive) containing machine code |
build_archive_kind |
Produce a static library (archive) in specific format |