我正在为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'?

最佳答案

参见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传递它。

关于rust - 如何将 LLVM 后端参数传递给 Xargo?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52654660/

10-09 19:40