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 AARM (aarch64, ARMv8) support #81

Open
4 of 5 tasks
KonradHoeffner opened this issue Jan 6, 2025 · 5 comments
Open
4 of 5 tasks

add AARM (aarch64, ARMv8) support #81

KonradHoeffner opened this issue Jan 6, 2025 · 5 comments
Assignees
Milestone

Comments

@KonradHoeffner
Copy link
Owner

KonradHoeffner commented Jan 6, 2025

  • compile it on the ARM server
  • add aarch64-unknown-linux-gnu target to release build list (cross compile for now)
  • download and execute release binary on aarch64 to verify that it works
  • remove hardcoded targets from MUSL Dockerfile
  • build aarch64 Docker image and upload it to ghcr.io
@KonradHoeffner KonradHoeffner added this to the 0.3 milestone Jan 6, 2025
@KonradHoeffner KonradHoeffner self-assigned this Jan 6, 2025
@KonradHoeffner
Copy link
Owner Author

rickview$ cargo build --target aarch64-unknown-linux-gnu
[...]
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: /usr/bin/ld: /home/konrad/projekte/rust/rickview/target/aarch64-unknown-linux-gnu/debug/deps/rickview-de10ff75536621c7.00r2lj4688y5echhmsibucwe6.rcgu.o: Relocations in generic ELF (EM: 183)
          /usr/bin/ld: /home/konrad/projekte/rust/rickview/target/aarch64-unknown-linux-gnu/debug/deps/rickview-de10ff75536621c7.00r2lj4688y5echhmsibucwe6.rcgu.o: Relocations in generic ELF (EM: 183)
          /usr/bin/ld: /home/konrad/projekte/rust/rickview/target/aarch64-unknown-linux-gnu/debug/deps/rickview-de10ff75536621c7.00r2lj4688y5echhmsibucwe6.rcgu.o: Relocations in generic ELF (EM: 183)
          /usr/bin/ld: /home/konrad/projekte/rust/rickview/target/aarch64-unknown-linux-gnu/debug/deps/rickview-de10ff75536621c7.00r2lj4688y5echhmsibucwe6.rcgu.o: Relocations in generic ELF (EM: 183)
          /usr/bin/ld: /home/konrad/projekte/rust/rickview/target/aarch64-unknown-linux-gnu/debug/deps/rickview-de10ff75536621c7.00r2lj4688y5echhmsibucwe6.rcgu.o: Relocations in generic ELF (EM: 183)
          /usr/bin/ld: /home/konrad/projekte/rust/rickview/target/aarch64-unknown-linux-gnu/debug/deps/rickview-de10ff75536621c7.00r2lj4688y5echhmsibucwe6.rcgu.o: Relocations in generic ELF (EM: 183)
          /usr/bin/ld: /home/konrad/projekte/rust/rickview/target/aarch64-unknown-linux-gnu/debug/deps/rickview-de10ff75536621c7.00r2lj4688y5echhmsibucwe6.rcgu.o: Relocations in generic ELF (EM: 183)
          /usr/bin/ld: /home/konrad/projekte/rust/rickview/target/aarch64-unknown-linux-gnu/debug/deps/rickview-de10ff75536621c7.00r2lj4688y5echhmsibucwe6.rcgu.o: Relocations in generic ELF (EM: 183)
          /usr/bin/ld: /home/konrad/projekte/rust/rickview/target/aarch64-unknown-linux-gnu/debug/deps/rickview-de10ff75536621c7.00r2lj4688y5echhmsibucwe6.rcgu.o: Relocations in generic ELF (EM: 183)
          /usr/bin/ld: /home/konrad/projekte/rust/rickview/target/aarch64-unknown-linux-gnu/debug/deps/rickview-de10ff75536621c7.00r2lj4688y5echhmsibucwe6.rcgu.o: Relocations in generic ELF (EM: 183)
          /usr/bin/ld: /home/konrad/projekte/rust/rickview/target/aarch64-unknown-linux-gnu/debug/deps/rickview-de10ff75536621c7.00r2lj4688y5echhmsibucwe6.rcgu.o: Relocations in generic ELF (EM: 183)
          /usr/bin/ld: /home/konrad/projekte/rust/rickview/target/aarch64-unknown-linux-gnu/debug/deps/rickview-de10ff75536621c7.00r2lj4688y5echhmsibucwe6.rcgu.o: error adding symbols: file in wrong format
          collect2: error: ld returned 1 exit status

@KonradHoeffner
Copy link
Owner Author

KonradHoeffner commented Jan 6, 2025

The linker needed to be put into .cargo/config.toml:

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"

Update: this is only needed when cross compiling. It could actually cause an error on an actual ARM machine in case gcc is installed but not gcc-aarch64-linux-gnu, which seems to be a redirect to gcc in that case.

@KonradHoeffner
Copy link
Owner Author

QEMU allows running aarch64 images on Arch Linux on AMD64 but it is very slow.

@KonradHoeffner
Copy link
Owner Author

While cross compiling the executable in the release workflow worked, creating the appropriate multi platform Dockerfile with musl is getting more time consuming then I thought.
I think the best way forward is to unify the docker-glibc and master branch, and just having two separate Dockerfiles from now on.
The current Dockerfile could be renamed to Dockerfile.musl and the one from Docker-glibc could become the default Dockerfile.
The reasoning is that the glibc Dockerfile builds perfectly fine on aarch64 because the base images it uses (lukemathwalker/cargo-chef and debian:stable-slim) are available for aarch64 and work as-is.
The musl Dockerfile on the other hand is hardcoded to use --target=x86_64-unknown-linux-musl.
While we could probably map the target platform, like linux/arm64 to the appropriate Rust target value, this seems cumbersome and brittle and also would need to be updated in case more targets are needed in the future.
I'm testing if the target actually needs to be specified in the first place.

While this method does not allow cross compilation or multi platform Dockerfiles, at least one can build the Dockerfile on the server (git clone and then docker build) for now and then use a Linux aarch64 runner as soon as those are available for public GitHub repositories.

@KonradHoeffner
Copy link
Owner Author

KonradHoeffner commented Jan 16, 2025

Linux arm64 is finally available! 🎉

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

No branches or pull requests

1 participant