我如何让 Rust 编译器转储它生成的 LLVM?
How do I get the Rust compiler to dump out the LLVM it generates?
我想看看 Rust 编译器生成的 LLVM。更好的办法是让它转出 LLVM 并停止。这可以是位码格式或汇编文本。
你可以传递你想要的格式--emit
例如
rustc --emit=asm,llvm-bc,llvm-ir xxx.rs
或
cargo rustc -- --emit=asm,llvm-bc,llvm-ir
更多信息请看rustc --help
为了快速访问 LLVM IR 或 x86_64 程序集,Playground (and the alternate Playground) 具有 "LLVM" 和 "ASM" 按钮,它们使用适当的选项调用编译器。
您可以操作 RUSTFLAGS
环境变量,然后执行构建,例如
RUSTFLAGS="--emit=llvm-ir" cargo build
如果您无法直接访问构建命令(例如,当您构建类似 Servo 的东西时,它会很有用,它使用名为 mach
的抽象构建工具)。
我知道这更像是一种边缘情况,但我发现它在尝试获取 Servo 代码的 IR 转储时很有用。
我想看看 Rust 编译器生成的 LLVM。更好的办法是让它转出 LLVM 并停止。这可以是位码格式或汇编文本。
你可以传递你想要的格式--emit
例如
rustc --emit=asm,llvm-bc,llvm-ir xxx.rs
或
cargo rustc -- --emit=asm,llvm-bc,llvm-ir
更多信息请看rustc --help
为了快速访问 LLVM IR 或 x86_64 程序集,Playground (and the alternate Playground) 具有 "LLVM" 和 "ASM" 按钮,它们使用适当的选项调用编译器。
您可以操作 RUSTFLAGS
环境变量,然后执行构建,例如
RUSTFLAGS="--emit=llvm-ir" cargo build
如果您无法直接访问构建命令(例如,当您构建类似 Servo 的东西时,它会很有用,它使用名为 mach
的抽象构建工具)。
我知道这更像是一种边缘情况,但我发现它在尝试获取 Servo 代码的 IR 转储时很有用。