Open RancidCrab55 opened 1 year ago
Yes you can, I am not entirely sure about that particular architecture but you can cross-compile in rust quite easily. Here are some basic instructions: The rustup book - Cross-compilation
Just cross compiled on archlinux.
My steps (paru is the AUR helper):
paru arm-linux-gnueabihf
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=/usr/bin/arm-linux-gnueabihf-gcc
cargo build --release --tar get=armv7-unknown-linux-gnueabihf
but this results in glibc dependence. I used musl avoid this. Here's the commands
paru arm-musl
rustup target add --toolchain stable armv7-unknown-linux-musleabi
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABI_LINKER=/opt/muslcc/arm-linux-musleabi-cross/bin/arm-linux-musleabi-gcc
CC=/opt/muslcc/arm-linux-musleabi-cross/bin/arm-linux-musleabi-gcc cargo build --release --target=armv7-unknown-linux-musleabi
Edit: fixed newline.
Thanks for your input!
unfortunately I can't seem to get it to run.
the first part works and I can now build for glibc but that doesn't run on the N900 even with gcompat (Segmentation fault).
paru arm-musl
gives me
arm-linux-musleabi-gcc: command not found
and I can't find out how to install that.
I would recommend to try cross
. You can install it with cargo install cross
. Compilation is then:
cross build --release --target=armv7-unknown-linux-musleabi
To list all possible rust target archs you can do: rustc --print target-list
.
@RancidCrab55 on my laptop:
$ pacman -Qo arm-linux-musleabi-gcc
/opt/muslcc/arm-linux-musleabi-cross/bin/arm-linux-musleabi-gcc is owned by muslcc-arm-linux-musleabi-cross-bin 11.2.1-1
Maybe you just have to add it to the PATH?
Once you manage to get the compiler everything should be straightforward. I noticed that with the cross compiled version I can no longer use my previous config and I have to relink the device, though.
Just in case anyone else need to cross compile for arm, a new error just came up:
arm-linux-ld: cannot find -latomic: No such file or directory
It's possibly due to https://github.com/sfackler/rust-openssl/issues/1779
Until this is fixed, libatomic.a
must be linked manually, with something like
TARGET_CC=/opt/path/to/bin/arm-linux-cc RUSTFLAGS='-Clink-arg=-L/path/to/dir/containing/libatomic/lib/ -Clink-arg=-s' cargo build --release --target=armv7-unknown-linux-musleabihf
I'd love to try gurk on my Nokia N900 with Postmarket OS. However I can't build it on there as it is way to slow. It would be awsome to get a release for 32bit arm. Specifically: armv7l musl libc (armhf)
Or is there a way I can build a binary on my PC for that architecture?