gpt4 book ai didi

rust - 无法构建交叉编译器

转载 作者:行者123 更新时间:2023-11-29 07:57:03 24 4
gpt4 key购买 nike

我似乎无法将 Rust 构建为交叉编译器,无论是在带有 MSYS2 的 Windows 上还是在全新安装的 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 上找到适用于 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

然后您可以通过以下行使用交叉编译器。如果您不想将其放入您的 PATH,您可以提供 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 - 无法构建交叉编译器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29652280/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com