无法构建交叉编译器

naa*_*ing 3 rust

我似乎无法将Rust作为交叉编译器构建,无论是在带有MSYS2的Windows上还是在全新安装的Debian Wheezy上.两者的错误都是一样的.我运行这个配置:

./configure --target=arm-unknown-linux-gnueabihf,x86_64-pc-windows-gnu
Run Code Online (Sandbox Code Playgroud)

make make,但是make install失败了:

[...]
prepare: tmp/dist/rustc-1.0.0-dev-x86_64-pc-windows-gnu-image/bin/rustlib/x86_64-pc-windows-gnu/lib/rustdoc-*.dll
prepare: tmp/dist/rustc-1.0.0-dev-x86_64-pc-windows-gnu-image/bin/rustlib/x86_64-pc-windows-gnu/lib/fmt_macros-*.dll
prepare: tmp/dist/rustc-1.0.0-dev-x86_64-pc-windows-gnu-image/bin/rustlib/x86_64-pc-windows-gnu/lib/libmorestack.a
prepare: tmp/dist/rustc-1.0.0-dev-x86_64-pc-windows-gnu-image/bin/rustlib/x86_64-pc-windows-gnu/lib/libcompiler-rt.a
compile: arm-unknown-linux-gnueabihf/rt/arch/arm/morestack.o
make[1]: arm-linux-gnueabihf-gcc: Command not found
/home/Sandro/rust/mk/rt.mk:94: recipe for target 'arm-unknown-linux-gnueabihf/rt/arch/arm/morestack.o' failed
make[1]: *** [arm-unknown-linux-gnueabihf/rt/arch/arm/morestack.o] Error 127
make[1]: Leaving directory '/home/Sandro/rust'
/home/Sandro/rust/mk/install.mk:22: recipe for target 'install' failed
make: *** [install] Error 2
Run Code Online (Sandbox Code Playgroud)

如果我没有指定交叉架构,那么一切都会很好.我错过了一些特殊的配置标志来使其工作吗?

Vae*_*den 7

错误消息说make没有找到arm-linux-gnueabihf-gcc二进制文件,它应该是生成ARM代码的C编译器.这意味着您可能没有安装任何ARM C交叉编译工具链.

我知道Ubuntu有交叉编译器包(gcc-arm-linux-gnueabihf于14.04),所以Debian可能有相同的包.您还可以在Linaro网站上找到适用于Windows和Linux的完全打包的ARM C交叉编译器.如果您正在为Rapsberry Pi构建,您还可以在https://github.com/raspberrypi/tools上找到为Raspbian和Archlinux构建的工具链.

这是Linux下带有Linaro工具链的示例(应该与主机的分发无关)

$ wget http://releases.linaro.org/14.11/components/toolchain/binaries/arm-linux-gnueabihf/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.tar.xz
$ tar -xf gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.tar.xz
$ export PATH=$PATH:$PWD/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf/bin
$ cd <your_configured_rustc_build_directory>
$ make
Run Code Online (Sandbox Code Playgroud)

然后,您可以使用以下行的交叉编译器.如果您不想将它放在PATH中,可以提供arm-linux-gnueabihf-gcc二进制文件的完整路径.

rustc --target=arm-unknown-linux-gnueabihf -C linker=arm-linux-gnueabihf-gcc hello.rs
Run Code Online (Sandbox Code Playgroud)

如果您正在使用Cargo,则可以使用.cargo/config此选项指定要用于每个目标的链接器:

[target.arm-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
Run Code Online (Sandbox Code Playgroud)