如何将LLVM后端参数传递给Xargo?

时间:2018-10-04 20:26:30

标签: rust llvm

我正在为AArch64架构编译Rust应用程序,我需要传递LLVM后端参数-mgeneral-regs-only,以便代码仅使用通用寄存器。

当我需要交叉编译应用程序时,如何将参数传递给Xargo?

As suggested,我尝试用RUSTFLAGS运行命令,但遇到有关未知命令行参数的错误:

RUSTFLAGS='-C llvm-args=-mgeneral-regs-only' xargo build --target aarch64-unknown-none
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `rustc - --crate-name ___ --print=file-names -C llvm-args=-mgeneral-regs-only --sysroot /home/.xargo -Z force-unstable-if-unmarked --target aarch64-unknown-none --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro` (exit code: 1)
--- stderr
rustc: Unknown command line argument '-mgeneral-regs-only'.  Try: 'rustc -help'
rustc: Did you mean '-mark-data-regions'?

1 个答案:

答案 0 :(得分:0)

请参见the Xargo documentation about compiling the sysroot with custom rustc flagsrustc允许通过-C开关设置LLVM标志:

$ rustc -C help
...
-C            llvm-args=val -- a list of arguments to pass to llvm (space separated)
...

您应该可以使用RUSTFLAGS='-C llvm-args=-mgeneral-regs-only' xargo build来传递它。