I use following command cross compile a aarch64 linux musl binary in AMD64 platform.
mkdir -p bin && shards build --production --release --no-debug --error-trace --static --stats --time -Dstrict_multi_assign -Dno_number_autocast -Duse_pcre2 -Dno_restrictions_augmenter --cross-compile --target=aarch64-linux-musl |tail -1 > bin/app.sh
It works, the content of generated file bin/app.sh is:
cc /app/bin/hello_world.o -o /app/bin/hello_world -rdynamic -static -L/usr/bin/../lib/crystal -lpcre2-8 -lgc -levent
When it run on a linux/arm64
container, get following error.
0.151 /usr/lib/gcc/aarch64-alpine-linux-musl/13.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: cannot find -lgc: No such file or directory
0.208 collect2: error: ld returned 1 exit status
I don’t know why it went wrong, musl-dev
was installed before cross linking.
RUN --mount=type=cache,target=/var/cache/apk \
set -ux; \
apk add \
--update \
git \
pcre2-dev \
libevent-static \
musl-dev g++ make automake libtool autoconf curl \
;
Any idea?