2 个版本
0.1.1 | 2023年6月22日 |
---|---|
0.1.0 | 2023年6月22日 |
#382 in 构建实用工具
86KB
2K SLoC
整个程序 LLVM in Rust (rllvm)
rllvm
是 gllvm
的 Rust 版本,为具有源代码的项目提供了编译器包装,用于构建整个程序的 LLVM 位码文件。
安装
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