Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a release for armv7l #187

Open
RancidCrab55 opened this issue Oct 21, 2022 · 6 comments
Open

Add a release for armv7l #187

RancidCrab55 opened this issue Oct 21, 2022 · 6 comments

Comments

@RancidCrab55
Copy link

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?

@mucinoab
Copy link
Contributor

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

@bonfus
Copy link

bonfus commented Oct 30, 2022

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.

@RancidCrab55
Copy link
Author

RancidCrab55 commented Nov 6, 2022

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.

@boxdot
Copy link
Owner

boxdot commented Nov 7, 2022

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.

@bonfus
Copy link

bonfus commented Nov 8, 2022

@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.

@bonfus
Copy link

bonfus commented Aug 7, 2024

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 sfackler/rust-openssl#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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants