Cross-compiling Crystal to aarch64


ubuntu 18.04 is out for aarch64 on the raspberry pi, and that’s awesome, but I need my crystal on it. Crystal is perfect for these tiny machines, and so it’d be awesome if I could build my apps.

I’ve been following instructions from here: (The original blog post is in russian). I’ve gotten it mostly built, except for one problem:

dkowis@pitwo:~/gitwork/crystal$ cc 'crystal.o' -o 'crystal'  -rdynamic  /home/dkowis/gitwork/crystal/src/llvm/ext/llvm_ext.o `/usr/bin/llvm-config-6.0 --libs --system-libs --ldflags 2> /dev/null` -lstdc++ -lpcre -lm -lpthread /home/dkowis/gitwork/crystal/src/ext/libcrystal.a -levent -lrt -ldl -lgc -L/home/dkowis/.anyenv/envs/crenv/versions/0.28.0/bin/../lib/crystal/lib -L/usr/lib -L/usr/local/lib
crystal.o: In function `initialize_inst_combine':
/home/dkowis/gitwork/crystal/src/llvm/ undefined reference to `LLVMInitializeInstCombine'
collect2: error: ld returned 1 exit status

I think that means there’s a bug in LLVM that I don’t have the fix for in ubuntu 18.04 llvm (1:6.0-41~exp5~ubuntu1). Has anyone else encountered this problem, or have a solution for it? I’ve also asked in ubuntu-specific land, but I’m not allowed to put more than 2 links in a post.



I’m also in IRC as @beepdog (I think)


I don’t know the state of crystal on aarch64 but I know people have opened a few issues on it. This is the most current issue which might be worth updating with your process and errors.

Also someone linked this gist which you might want to try. It looks like a script to statically compile crystal for aarch64.

1 Like