#bitcode #llvm #clang #ir #gllvm

build rllvm

A tool to build whole-program LLVM bitcode files

2 releases

0.1.1 Jun 22, 2023
0.1.0 Jun 22, 2023

#344 in Build Utils

Custom license

86KB
2K SLoC

Whole Program LLVM in Rust (rllvm)

rllvm CI

rllvm is a Rust port of gllvm and provides compiler wrappers to build whole-program LLVM bitcode files for projects with source codes.

For more details, please refer to gllvm or wllvm.

Installation

cargo install rllvm

Get Started

rllvm-cxx -o hello tests/data/hello.cc
rllvm-get-bc hello  # Extract the bitcode file `hello.bc`
llvm-dis hello.bc  # Obtain readable `hello.ll` file

Configuration

The default configuration file ~/.rllvm/config.toml will be automatically created, if it does not exist, with the following entries:

Configuration Key Required? Notes
llvm_config_filepath Yes The absolute filepath of llvm-config
clang_filepath Yes The absolute filepath of clang
clangxx_filepath Yes The absolute filepath of clang++
llvm_ar_filepath Yes The absolute filepath of llvm-ar
llvm_link_filepath Yes The absolute filepath of llvm-link
llvm_objcopy_filepath Yes The absolute filepath of llvm-objcopy
bitcode_store_path No The absolute path of the directory that stores intermediate bitcode files
llvm_link_flags No Extra user-provided linking flags for llvm-link
lto_ldflags No Extra user-provided linking flags for link time optimization
bitcode_generation_flags No Extra user-provided flags for bitcode generation, e.g., "-flto -fwhole-program-vtables"
is_configure_only No The configure only mode, which skips the bitcode generation (Default: false)
log_level No Log level (0: nothing, 1: error, 2: warn, 3: info, 4: debug, 5: trace)

Here is an example of the configuration file:

llvm_config_filepath = '/usr/local/Cellar/llvm/16.0.4/bin/llvm-config'
clang_filepath = '/usr/local/Cellar/llvm/16.0.4/bin/clang'
clangxx_filepath = '/usr/local/Cellar/llvm/16.0.4/bin/clang++'
llvm_ar_filepath = '/usr/local/Cellar/llvm/16.0.4/bin/llvm-ar'
llvm_link_filepath = '/usr/local/Cellar/llvm/16.0.4/bin/llvm-link'
llvm_objcopy_filepath = '/usr/local/Cellar/llvm/16.0.4/bin/llvm-objcopy'
bitcode_store_path = '/tmp/bitcode_store'
log_level = 3

Dependencies

~7–19MB
~253K SLoC