Jon*_*nio 5 llvm llvm-clang rust
我正在尝试使用 clang 运行.ll文件并收到链接器错误。我有一个文件test.rs,只包含一个带有println!语句的主函数。我使用命令生成 LLVM IR rustc --emit=llvm-ir --crate-type=bin test.rs。当我尝试运行输出test.ll文件时clang test.ll,出现链接器错误:
Undefined symbols for architecture x86_64:
"std::io::stdio::_print::h178318b95760562a", referenced from:
rust_test::main::h84a9713c734a1b45 in rust_test-9ea667.o
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
所以我认为 clang 找不到 Rust 库,并尝试使用命令提供它们的路径clang -L$HOME/.rustup/toolchains/<arch>/lib test.ll,但我收到相同的错误。
这里的目标是在 Rust 中创建几个函数,我将从 LLVM 调用它们,因此我将有一个自定义函数file.ll,它将使用 Rust LLVM IR 将提供的函数。我注意到rustc有一个crate-type名为的命令行参数staticlib,并尝试使用它,但无济于事。
| 归档时间: |
|
| 查看次数: |
633 次 |
| 最近记录: |