#bitcode #llvm #clang #ir #gllvm

构建 rllvm

构建整个程序的 LLVM 位码文件的工具

2 个版本

0.1.1 2023年6月22日
0.1.0 2023年6月22日

#382 in 构建实用工具

自定义许可

86KB
2K SLoC

整个程序 LLVM in Rust (rllvm)

rllvm CI

rllvmgllvm 的 Rust 版本,为具有源代码的项目提供了编译器包装,用于构建整个程序的 LLVM 位码文件。

有关更多详细信息,请参阅 gllvmwllvm

安装

cargo install rllvm

入门

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

配置

默认配置文件 ~/.rllvm/config.toml 将在不存在时自动创建,内容如下

配置键 必需? 说明
llvm_config_filepath llvm-config 的绝对文件路径
clang_filepath clang 的绝对文件路径
clangxx_filepath clang++ 的绝对文件路径
llvm_ar_filepath llvm-ar 的绝对文件路径
llvm_link_filepath llvm-link 的绝对文件路径
llvm_objcopy_filepath llvm-objcopy 的绝对文件路径
bitcode_store_path 存储中间位码文件的目录的绝对路径
llvm_link_flags llvm-link 提供的额外用户链接标志
lto_ldflags 为链接时间优化提供的额外用户链接标志
bitcode_generation_flags 为位码生成提供的额外用户标志,例如,"-flto -fwhole-program-vtables"
is_configure_only 仅配置模式,跳过位码生成(默认:false)
log_level 日志级别(0:无,1:错误,2:警告,3:信息,4:调试,5:跟踪)

以下是一个配置文件的示例

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

依赖项

~7–21MB
~264K SLoC