-
Notifications
You must be signed in to change notification settings - Fork 52
Description
recently I did some research into how to to use rust and cargo to cross-compile, especially for armhf.
I found out, it's rather easy to set up rust for that: if rust-bin is your rust-provider, download rust-std-${PN}-${ARCH-TRIPLE}.tar.xz and install it with: ./install.sh --disable-verify --prefix=/opt/${P}/ --mandir="/usr/share/${P}/man" --disable-ldconfig
which gives you a rust-bin with the ability to cross-compile. (since rustc is more or less a frontend to llvm, you should have it emerged with llvm_target_arm?)
also emerge a full cross toolchain with crossdev, since rustc needs the cross-gcc as a linker.
now, it is common practice to cross-compile with emerge-wrappers, so an emerge-armv7a-unknown-linux-gnueabihf -auvND world should bootstrap a base cross system to work with, inheriting @System, and from there on it should be possible to compile individual packages and copy the tbz2 files from the cross environement over to the memory restrained arm device and emerge with the -k option to grab a binary if possible. Done that with sys-devel/gcc, sys-devel/llvm, dev-libs/boost, etc. pp.
Now, with a host where rustc has the foreign rust-std installed it should just work to emerge, for instance, dev-util/cbindgen this way. It does, however, with a bit of a show stopper:
>>> Completed installing cbindgen-0.6.7 into /usr/armv7a-unknown-linux-gnueabihf/tmp/portage/dev-util/cbindgen-0.6.7/image
* Final size of build directory: 188124 KiB (183.7 MiB)
* Final size of installed tree: 8072 KiB ( 7.8 MiB)
strip: armv7a-unknown-linux-gnueabihf-strip --strip-unneeded -R .comment -R .GCC.command.line -R .note.gnu.gold-version
/usr/bin/cbindgen
armv7a-unknown-linux-gnueabihf-strip:/usr/armv7a-unknown-linux-gnueabihf/tmp/portage/dev-util/cbindgen-0.6.7/image/usr/bin/cbindgen: file format not recognized
./
./usr/
./usr/bin/
./usr/bin/cbindgen
>>> Done.
the binary is in fact not a cross-compiled one, but for the hosts arch, thus cross-strip can't do anything about it.