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

Closed
5 tasks done
KonradHoeffner opened this issue Jan 6, 2025 · 8 comments
Closed
5 tasks done

add AARM (aarch64, ARMv8) support #81

KonradHoeffner opened this issue Jan 6, 2025 · 8 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! 🎉

@KonradHoeffner
Copy link
Owner Author

c1d7276 builds multi-platform Docker image with linux64 as before and now also arm64 using QEMU.

@KonradHoeffner
Copy link
Owner Author

KonradHoeffner commented Jan 22, 2025

Unfortunately, the cross compiling GitHub action build failed because of the transitive dependency of ureq to ring, as documented in briansmith/ring#2127.
Now trying it with the glibc branch which has the non-musl (GNU?) base image which is a bit larger.

Potential fixes to investigate

  • replace ureq with something else, it is only used at a single point in the code to load the knowledge base over an HTTP(s) URI
  • non-MUSL image
  • could it be caused by cargo chef or easier to work around when not using that?
  • use a separate github action without cross compilation

@KonradHoeffner
Copy link
Owner Author

Finally got it to work in 977f557 however I'm not sure if caching works and it's probably not configured optimally.
See https://github.com/KonradHoeffner/rickview/blob/master/.github/workflows/docker.yml.
Repository name is hard coded right now because the dynamic one contains capital letters, which are not accepted by the docker actions.

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