无法构建交叉编译器
Can't build cross compiler
我似乎无法将 Rust 构建为交叉编译器,无论是在 Windows 上使用 MSYS2 还是在全新安装的 Debian Wheezy 上。两者的错误是相同的。我运行这个配置:
./configure --target=arm-unknown-linux-gnueabihf,x86_64-pc-windows-gnu
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
如果我不指定跨架构,一切都可以正常构建。我是否缺少一些特殊的配置标志来完成这项工作?
错误消息说 make 没有找到 arm-linux-gnueabihf-gcc
二进制文件,它应该是一个生成 ARM 代码的 C 编译器。这意味着您可能没有安装任何 ARM C 交叉编译工具链。
我知道 Ubuntu 有交叉编译器的包(14.04 中的 gcc-arm-linux-gnueabihf)所以 Debian 可能有相同的包。您还可以在 Linaro website. If you are building for the Rapsberry Pi, you can also find toolchains to build for Raspbian and Archlinux on https://github.com/raspberrypi/tools.
上找到针对 Windows 和 Linux 的完全打包的 ARM C 交叉编译器
下面是 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
然后您可以通过以下行使用交叉编译器。如果你不想把它放在你的路径中,你可以提供 arm-linux-gnueabihf-gcc 二进制文件的完整路径。
rustc --target=arm-unknown-linux-gnueabihf -C linker=arm-linux-gnueabihf-gcc hello.rs
如果您使用的是 Cargo,则可以使用此选项指定要用于 .cargo/config
中每个目标的链接器:
[target.arm-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
我似乎无法将 Rust 构建为交叉编译器,无论是在 Windows 上使用 MSYS2 还是在全新安装的 Debian Wheezy 上。两者的错误是相同的。我运行这个配置:
./configure --target=arm-unknown-linux-gnueabihf,x86_64-pc-windows-gnu
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
如果我不指定跨架构,一切都可以正常构建。我是否缺少一些特殊的配置标志来完成这项工作?
错误消息说 make 没有找到 arm-linux-gnueabihf-gcc
二进制文件,它应该是一个生成 ARM 代码的 C 编译器。这意味着您可能没有安装任何 ARM C 交叉编译工具链。
我知道 Ubuntu 有交叉编译器的包(14.04 中的 gcc-arm-linux-gnueabihf)所以 Debian 可能有相同的包。您还可以在 Linaro website. If you are building for the Rapsberry Pi, you can also find toolchains to build for Raspbian and Archlinux on https://github.com/raspberrypi/tools.
上找到针对 Windows 和 Linux 的完全打包的 ARM C 交叉编译器下面是 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
然后您可以通过以下行使用交叉编译器。如果你不想把它放在你的路径中,你可以提供 arm-linux-gnueabihf-gcc 二进制文件的完整路径。
rustc --target=arm-unknown-linux-gnueabihf -C linker=arm-linux-gnueabihf-gcc hello.rs
如果您使用的是 Cargo,则可以使用此选项指定要用于 .cargo/config
中每个目标的链接器:
[target.arm-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"