Build not running on Alpine arm64

I start a container to build my program...

docker run -it -v $PWD/my-project:/my-project rust:alpine

The host machine is a Raspberry Pi 4...

# uname -a
Linux pi-4 5.10.61-0-rpi4 #1-Alpine SMP PREEMPT Thu Aug 26 22:38:20 UTC 2021 aarch64 Linux

I build my project...

cargo build --release --target aarch64-unknown-linux-musl

Then I try to run the binary and it doesn't work...

# ./target/aarch64-unknown-linux-musl/release/ecr-creds-updater
/bin/sh: ./target/aarch64-unknown-linux-musl/release/ecr-creds-updater: not found

Inspecting the binary...

# file target/aarch64-unknown-linux-musl/release/ecr-creds-updater
target/aarch64-unknown-linux-musl/release/ecr-creds-updater: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/, with debug_info, not stripped

Ok, so the interpreter doesn't exist...

# ls /lib/
ls: /lib/ No such file or directory

But I can fix that...

# apk add gcompat

# ls /lib/

But now it complains about the async runtime...

# ./target/aarch64-unknown-linux-musl/release/ecr-creds-updater
thread 'main' panicked at 'Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.', /usr/local/cargo/registry/src/
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
Aborted (core dumped)

Some things to note...

  • I'm not trying to cross compile
  • I'm not trying to statically link
  • This exact same project works totally fine on OS X.

What's going on? Thanks for the help.

Does it work with aarch64-unknown-linux-gnu on rust:bullseye?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.