The Crystal Programming Language Forum

Problem compiling crystal from source on RaspberryPI 4

Hi,

Out of curiosity I am trying to compile crystal on a RaspberryPI 4.
I followed the usual method of cross-compiling the compiler, linking on the PI.

When I then try to use that compiler to compile the same version of crystal on the PI that it was cross-compiled from i get this:

pi@ceres:~/crystal $ make
Using /usr/bin/llvm-config-8 [version=8.0.0]
CRYSTAL_CONFIG_PATH="/home/pi/crystal/src" CRYSTAL_CONFIG_LIBRARY_PATH="" CRYSTAL_CONFIG_BUILD_COMMIT="0e2e1d067" ./bin/crystal build  -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib
GC Warning: Repeated allocation of very large block (appr. size 1052672):
	May lead to memory leak and poor performance
GC Warning: Repeated allocation of very large block (appr. size 1052672):
	May lead to memory leak and poor performance
Invalid memory access (signal 11) at address 0x0
[0xb6f33c] ???
[0xa843c0] __crystal_sigfault_handler +136
Invalid memory access (signal 11) at address 0x0
[0xb6f33c] ???
[0xa843c0] __crystal_sigfault_handler +136
Invalid memory access (signal 11) at address 0x0
[0xb6f33c] ???
[0xa843c0] __crystal_sigfault_handler +136
Invalid memory access (signal 11) at address 0x0
[0xb6f33c] ???
[0xa843c0] __crystal_sigfault_handler +136
Invalid memory access (signal 11) at address 0x0
[0xb6f33c] ???
[0xa843c0] __crystal_sigfault_handler +136
Invalid memory access (signal 11) at address 0x0
[0xb6f33c] ???
[0xa843c0] __crystal_sigfault_handler +136
Invalid memory access (signal 11) at address 0x0
[0xb6f33c] ???
[0xa843c0] __crystal_sigfault_handler +136
Invalid memory access (signal 11) at address 0x0
[0xb6f33c] ???
[0xa843c0] __crystal_sigfault_handler +136
Invalid memory access (signal 11) at address 0x0
[0xb6f33c] ???
[0xa843c0] __crystal_sigfault_handler +136
cc: error: _main.o: No such file or directory
cc: error: S-lice40U-I-nt841.o: No such file or directory
cc: error: P-ointer40U-I-nt841.o: No such file or directory
cc: error: A-rgumentE-rror.o: No such file or directory
cc: error: C-allS-tack.o: No such file or directory
cc: error: A-rray40P-ointer40V-oid4141.o: No such file or directory
cc: error: P-ointer40P-ointer40V-oid4141.o: No such file or directory

many more lines of the cc: errors, then:

cc: error: L-ibU-nwind5858A-ction.o: No such file or directory
cc: error: L-E-B-R-eader.o: No such file or directory
cc: error: C-allS-tack5858R-epeatedF-rame.o: No such file or directory
Error: execution of command failed with code: 1: `cc "${@}" -o '/home/pi/crystal/.build/crystal'  -rdynamic  /home/pi/crystal/src/llvm/ext/llvm_ext.o `/usr/bin/llvm-config-8 --libs --system-libs --ldflags 2> /dev/null` -lstdc++ -lpcre -lm /usr/local/lib/libgc.a -lpthread /home/pi/crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/lib -L/usr/local/lib`
make: *** [Makefile:132: .build/crystal] Error 1

Any ideas whats going wrong there?
It should work, right?
Or is there a reason why compiling crystal would fail on arm?

Compiling the compiler requires something between 4GB and 8GB of memory. Does your raspberry pi have that memory?

it has 4GB ram.

interesting. I’ll try to see if it hits that when compilig.

I’ll almost sure 4GB is not enough to compile the compiler.

For cross compiling into a raspberry pi you’ll want to compile your programs, not the compiler.

I did Cross compile the compiler. I was just curious if the new RaspberryPI 4 was ‘good enough’ to build crystal on it.

That would make it easy to build a debian package for Raspbian.

# mkswap?

I’ll try that soon, just have to dig up some USB harddrive somewhere, I don’t want to swap to the sdcard.

I had some more time (i.e. needed something to procrastinate) and added a usb3 ssd to my PI4.
It turns out I didn’t have to do that, because compiling crystal does not even touch the swapspace.

I also rebuild the GC with the latest code tagged with a version (v.8.0.4)
Build using llvm-8.

I even re-cross-compiled the compiler with --target armv6k-unknown-linux-gnueabihf because I noticed that the old PIs self-identified as armv6-unknown-linux-gnueabihf (armv6 vs. armv6k)

same result.

After that I also tried to run make compiler_spec and make spec but both also fail with the same error.
(or something so similar that I cant see a difference)

The reason I want to follow this up is 2 tings:

  • that I don’t see why this would not work unless the whole compiler is unreliable on RaspberryPI4 and that would be something someone would maybe want to fix.
  • I get very similar compile errors when I try to compile invidious on the PI (although that was quite hard to even get that far due to other problems, so I might have broken it.)

I don’t think I have the expertise to take this any further, but if anyone has any suggestions or things to try to provide more information, please tell me.