The Crystal Programming Language Forum

Cross compiling to ARM (Debian, Crouton, Asus Chromebit)

I found the tutorial online and successfully cross compiled the latest Crystal compiler. Debug compiling is not working but, the release works.

Here is the tutorial link:
https://translate.google.com/translate?hl=en&sl=auto&tl=en&u=http%3A%2F%2Fconstxife.ru%2Fblog%2F2018%2F10%2F16%2Frpi-crystal.html

1 Like

this is awesome. It would be awesome to get this into the CI pipeline

It works without problems when I try a build with “–release --no-debug”. It is not working when I try a plain “crystal run”.

I used the latest libraries versions on Debian and, it was probably wrong. However, I just wanted to have a working crystal version in order to learn Crystal programming language on machine I use on TV in my living room. :)

Here is the result of a “crystal run” build:

Invalid memory access (signal 11) at address 0x0
[0x22c0d70] ???
[0x21fff28] __crystal_sigfault_handler +136
Invalid memory access (signal 11) at address 0x0
[0x22c0d70] ???
[0x21fff28] __crystal_sigfault_handler +136
Invalid memory access (signal 11) at address 0x0
[0x22c0d70] ???
[0x21fff28] __crystal_sigfault_handler +136
Invalid memory access (signal 11) at address 0x0
[0x22c0d70] ???
[0x21fff28] __crystal_sigfault_handler +136
Invalid memory access (signal 11) at address 0x0
Invalid memory access (signal 11) at address 0x0
[0x22c0d70] ???
[0x22c0d70] ???
[0x21fff28] __crystal_sigfault_handler +136
[0x21fff28] __crystal_sigfault_handler +136
Invalid memory access (signal 11) at address 0x0
[0x22c0d70] ???
[0x21fff28] __crystal_sigfault_handler +136
Invalid memory access (signal 11) at address 0x0
[0x22c0d70] ???
[0x21fff28] __crystal_sigfault_handler +136
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
cc: error: P-ointer40V-oid41.o: No such file or directory
cc: error: E-xception.o: No such file or directory
cc: error: P-ointer40L-ibU-nwind5858C-ontrolB-lock41.o: No such file or directory
cc: error: U-I-nt32.o: No such file or directory
cc: error: U-I-nt8.o: No such file or directory
cc: error: D-ir.o: No such file or directory
cc: error: C-rystal5858S-ystem5858D-ir.o: No such file or directory
cc: error: E-rrno.o: No such file or directory
cc: error: S-tring.o: No such file or directory
cc: error: G-C-.o: No such file or directory
cc: error: R-eflect40I-nt3241.o: No such file or directory
cc: error: I-nt32.o: No such file or directory
cc: error: C-har.o: No such file or directory
cc: error: S-taticA-rray40U-I-nt84432441.o: No such file or directory
cc: error: I-ndexE-rror.o: No such file or directory
cc: error: S-tring5858B-uilder.o: No such file or directory
cc: error: S-lice40T-41.o: No such file or directory
cc: error: I-O-5858E-ncoder.o: No such file or directory
cc: error: I-conv.o: No such file or directory
cc: error: S-taticA-rray40U-I-nt84432102441.o: No such file or directory
cc: error: M-ath.o: No such file or directory
cc: error: I-nvalidB-yteS-equenceE-rror.o: No such file or directory
cc: error: S-taticA-rray40U-I-nt8443212941.o: No such file or directory
cc: error: I-nt64.o: No such file or directory
cc: error: D-ivisionB-yZ-eroE-rror.o: No such file or directory
cc: error: A-rray40S-tring41.o: No such file or directory
cc: error: P-ointer40S-tring41.o: No such file or directory
cc: error: P-roc40I-nt324432N-il41.o: No such file or directory
cc: error: S-taticA-rray40I-nt8443225641.o: No such file or directory
cc: error: P-ointer40I-nt841.o: No such file or directory
cc: error: F-iber5858S-tackP-ool.o: No such file or directory
cc: error: D-eque40P-ointer40V-oid4141.o: No such file or directory
cc: error: T-hread5858M-utex.o: No such file or directory
cc: error: F-ile5858P-ermissions.o: No such file or directory
cc: error: F-iber.o: No such file or directory
cc: error: T-hread5858L-inkedL-ist40F-iber41.o: No such file or directory
cc: error: C-rystal5858S-ystem5858R-andom.o: No such file or directory
cc: error: C-rystal5858S-cheduler.o: No such file or directory
cc: error: T-hread.o: No such file or directory
cc: error: A-tomic40U-I-nt841.o: No such file or directory
cc: error: A-tomic40T-hread3212432N-il41.o: No such file or directory
cc: error: F-iber5858C-ontext.o: No such file or directory
cc: error: T-hread5858L-inkedL-ist40T-hread41.o: No such file or directory
cc: error: N-il.o: No such file or directory
cc: error: N-ilA-ssertionE-rror.o: No such file or directory
cc: error: C-rystal5858S-pinL-ock.o: No such file or directory
cc: error: D-eque40F-iber41.o: No such file or directory
cc: error: P-ointer40F-iber41.o: No such file or directory
cc: error: T-ime5858S-pan.o: No such file or directory
cc: error: C-rystal5858E-ventL-oop.o: No such file or directory
cc: error: C-rystal5858E-vent5858B-ase.o: No such file or directory
cc: error: C-rystal5858E-vent.o: No such file or directory
cc: error: L-ibC-5858T-imeval.o: No such file or directory
cc: error: F-loat64.o: No such file or directory
cc: error: U-I-nt64.o: No such file or directory
cc: error: C-rystal5858S-ystem.o: No such file or directory
cc: error: E-N-V-.o: No such file or directory
cc: error: C-rystal5858S-ystem5858E-nv.o: No such file or directory
cc: error: F-ile.o: No such file or directory
cc: error: C-rystal5858S-ystem5858F-ile.o: No such file or directory
cc: error: C-har5858R-eader.o: No such file or directory
cc: error: C-rystal5858T-hre-1a3c0c3e3b0f8107f598df47513fbad7.o: No such file or directory
cc: error: H-ash40T-hread4432D-eque40F-iber4141.o: No such file or directory
cc: error: P-ointer40H-ash58-ba622b1c6ea9db0b943e2b37ba0c5af2.o: No such file or directory
cc: error: C-rystal5858T-hre-328ba26086c06ca27f79c0f6529d7399.o: No such file or directory
cc: error: H-ash40T-hread4432C-rystal5858E-vent41.o: No such file or directory
cc: error: P-ointer40H-ash58-e27196573eea5e5746b383aacfde8695.o: No such file or directory
cc: error: C-rystal5858S-ystem5858F-ileD-escriptor.o: No such file or directory
cc: error: I-O-5858E-rror.o: No such file or directory
cc: error: H-ash5858E-ntry40T-hread4432D-eque40F-iber4141.o: No such file or directory
cc: error: C-rystal5858H-asher.o: No such file or directory
cc: error: S-taticA-rray40U-I-nt644432241.o: No such file or directory
cc: error: P-ointer40U-I-nt6441.o: No such file or directory
cc: error: P-ointer40U-I-nt1641.o: No such file or directory
cc: error: P-ointer40U-I-nt3241.o: No such file or directory
cc: error: H-ash5858E-ntry40T-hread4432C-rystal5858E-vent41.o: No such file or directory
cc: error: L-ibE-vent25858E-ventF-lags.o: No such file or directory
cc: error: I-O-5858T-imeout.o: No such file or directory
cc: error: R-ange40B-4432E-41.o: No such file or directory
cc: error: R-ange40I-nt324432I-nt3241.o: No such file or directory
cc: error: D-ebug5858E-L-F-.o: No such file or directory
cc: error: I-O-5858F-ileD-escriptor43.o: No such file or directory
cc: error: D-ebug5858E-L-F-5858E-rror.o: No such file or directory
cc: error: D-ebug5858E-L-F-5858E-ndianness.o: No such file or directory
cc: error: D-ebug5858E-L-F-5858O-S-A-B-I-.o: No such file or directory
cc: error: S-taticA-rray40U-I-nt84432409641.o: No such file or directory
cc: error: I-O-5858E-O-F-E-rror.o: No such file or directory
cc: error: D-ebug5858E-L-F-5858I-dent.o: No such file or directory
cc: error: U-I-nt16.o: No such file or directory
cc: error: I-O-5858B-yteF-ormat5858B-igE-ndian.o: No such file or directory
cc: error: S-taticA-rray40U-I-nt84432241.o: No such file or directory
cc: error: I-O-5858B-yteF-ormat5858L-ittleE-ndian.o: No such file or directory
cc: error: D-ebug5858E-L-F-5858K-lass.o: No such file or directory
cc: error: S-taticA-rray40U-I-nt84432841.o: No such file or directory
cc: error: A-rray40D-ebug5858E-L-F-5858S-ectionH-eader41.o: No such file or directory
cc: error: P-ointer40D-ebug5858E-L-F-5858S-ectionH-eader41.o: No such file or directory
cc: error: I-O-5858S-eek.o: No such file or directory
cc: error: D-ebug5858E-L-F-5858S-ectionH-eader.o: No such file or directory
cc: error: I-O-5858D-ecoder.o: No such file or directory
cc: error: D-ebug5858D-W-A-R-F-5858L-ineN-umbers.o: No such file or directory
cc: error: A-rray40A-rray40D-d5580c0e9cb0bd8af7e90c96221706e1.o: No such file or directory
cc: error: P-ointer40A-rray4-6533bdad81433bcf155b99ac74756686.o: No such file or directory
cc: error: D-ebug5858D-W-A-R-F-5858L-ineN-umbers5858S-equence.o: No such file or directory
cc: error: A-rray40T-uple40S-5992430a1a7ef1627717adfb71332538.o: No such file or directory
cc: error: P-ointer40T-uple4-13415771527eed75ea796bf4f3711255.o: No such file or directory
cc: error: A-rray40U-I-nt841.o: No such file or directory
cc: error: I-nt8.o: No such file or directory
cc: error: S-taticA-rray40U-I-nt84432141.o: No such file or directory
cc: error: D-ebug5858D-W-A-R-F-.o: No such file or directory
cc: error: D-ebug5858D-W-A-R-F-5858L-ineN-umbers5858R-egister.o: No such file or directory
cc: error: D-ebug5858D-W-A-R-F-5858L-ineN-umbers5858R-ow.o: No such file or directory
cc: error: A-rray40D-ebug585-1d195a7f864d2d3790ebeadd84b7a4df.o: No such file or directory
cc: error: P-ointer40D-ebug5-a50eac5c43900f6bca76f68ff8c8549d.o: No such file or directory
cc: error: D-ebug5858D-W-A-R-F-5858L-N-E-.o: No such file or directory
cc: error: D-ebug5858D-W-A-R-F-5858L-N-S-.o: No such file or directory
cc: error: D-ebug5858D-W-A-R-F-5858S-trings.o: No such file or directory
cc: error: A-rray40T-uple40U-17f47b8c2b2bf857c34636b13252c378.o: No such file or directory
cc: error: P-ointer40T-uple4-31bcd381043369e5d6217fbdd493d188.o: No such file or directory
cc: error: D-ebug5858D-W-A-R-F-5858I-nfo.o: No such file or directory
cc: error: D-ebug5858D-W-A-R-F-5858A-bbrev.o: No such file or directory
cc: error: A-rray40D-ebug5858D-W-A-R-F-5858A-bbrev41.o: No such file or directory
cc: error: P-ointer40D-ebug5858D-W-A-R-F-5858A-bbrev41.o: No such file or directory
cc: error: A-rray40D-ebug585-b448de41619185732a02b2b0c778beb9.o: No such file or directory
cc: error: P-ointer40D-ebug5-038cd8f166075bfacc819464bf65667a.o: No such file or directory
cc: error: D-ebug5858D-W-A-R-F-5858A-bbrev5858A-ttribute.o: No such file or directory
cc: error: A-rray40T-uple40D-2934b2835f929d23ac3adb7e5b7b0afe.o: No such file or directory
cc: error: P-ointer40T-uple4-6ff119ef58145d1144587389190a4e25.o: No such file or directory
cc: error: D-ebug5858D-W-A-R-F-5858F-O-R-M-.o: No such file or directory
cc: error: U-nicode5858C-aseO-ptions.o: No such file or directory
cc: error: U-nicode.o: No such file or directory
cc: error: A-rray40T-uple40I-nt324432I-nt324432I-nt324141.o: No such file or directory
cc: error: P-ointer40T-uple40I-nt324432I-nt324432I-nt324141.o: No such file or directory
cc: error: H-ash40I-nt324432-c36c7b59ada9577e04b34b7156d26117.o: No such file or directory
cc: error: P-ointer40H-ash58-df002967aa38240c2ffc8370480b96df.o: No such file or directory
cc: error: H-ash5858E-ntry40-ea883736b6a497e8c0f2d29083b2162a.o: No such file or directory
cc: error: A-rray40T-uple40I-nt324432I-nt324141.o: No such file or directory
cc: error: P-ointer40T-uple40I-nt324432I-nt324141.o: No such file or directory
cc: error: D-ebug5858D-W-A-R-F-5858T-A-G-.o: No such file or directory
cc: error: D-ebug5858D-W-A-R-F-5858A-T-.o: No such file or directory
cc: error: B-ool.o: No such file or directory
cc: error: T-ypeC-astE-rror.o: No such file or directory
cc: error: S-tring5858T-oU-64I-nfo.o: No such file or directory
cc: error: A-tE-xitH-andlers.o: No such file or directory
cc: error: A-rray40P-roc40I–412183da1a81233e2c20c488cb2e890d.o: No such file or directory
cc: error: P-ointer40P-roc40-6252237c86bac28658266374d639ebc8.o: No such file or directory
cc: error: I-O-5858F-ileD-escriptor.o: No such file or directory
cc: error: S-taticA-rray40U-I-nt8443225641.o: No such file or directory
cc: error: E-xception43.o: No such file or directory
cc: error: T-ime5858L-ocatio-c92d7ae948ed8f4d38520c6d460d1469.o: No such file or directory
cc: error: T-ime5858L-ocation5858I-nvalidL-ocationN-ameE-rror.o: No such file or directory
cc: error: T-ime5858L-ocation5858I-nvalidT-Z-D-ataE-rror.o: No such file or directory
cc: error: T-ime5858F-ormat5858E-rror.o: No such file or directory
cc: error: T-ime5858F-loatingT-imeC-onversionE-rror.o: No such file or directory
cc: error: B-ase645858E-rror.o: No such file or directory
cc: error: P-ath5858E-rror.o: No such file or directory
cc: error: F-ile5858B-adP-atternE-rror.o: No such file or directory
cc: error: C-oncurrentE-xecutionE-xception.o: No such file or directory
cc: error: C-oncurrent5858C-anceledE-rror.o: No such file or directory
cc: error: C-hannel5858C-losedE-rror.o: No such file or directory
cc: error: E-numerable5858E-mptyE-rror.o: No such file or directory
cc: error: N-otI-mplementedE-rror.o: No such file or directory
cc: error: O-verflowE-rror.o: No such file or directory
cc: error: K-eyE-rror.o: No such file or directory
cc: error: P-rocess.o: No such file or directory
cc: error: C-rystal5858S-ystem5858F-ileI-nfo.o: No such file or directory
cc: error: F-ile5858T-ype.o: No such file or directory
cc: error: C-rystal5858S-ystem5858F-iber.o: No such file or directory
cc: error: P-roc40F-iber4432-6eb246a0a45118d3c5507cc830b14a70.o: No such file or directory
cc: error: S-ignal.o: No such file or directory
cc: error: A-tomic5858F-lag.o: No such file or directory
cc: error: L-ibC-5858S-igsetT-.o: No such file or directory
cc: error: C-rystal5858S-ignal.o: No such file or directory
cc: error: I-O-.o: No such file or directory
cc: error: S-taticA-rray40I-nt324432241.o: No such file or directory
cc: error: P-ointer40I-nt3241.o: No such file or directory
cc: error: H-ash40S-ignal4432P-roc40S-ignal4432N-il4141.o: No such file or directory
cc: error: P-ointer40H-ash58-0716a66562827a635360751c7a0bfb0b.o: No such file or directory
cc: error: H-ash5858E-ntry40-37a9b13947932e73bc9389d755897071.o: No such file or directory
cc: error: C-rystal5858S-ignalC-hildH-andler.o: No such file or directory
cc: error: M-utex.o: No such file or directory
cc: error: A-tomic40I-nt3241.o: No such file or directory
cc: error: M-utex5858P-rotection.o: No such file or directory
cc: error: H-ash40I-nt324432C-hannel40I-nt324141.o: No such file or directory
cc: error: P-ointer40H-ash58-438550d1ae4863022fe79cbb17acca82.o: No such file or directory
cc: error: H-ash5858E-ntry40I-nt324432C-hannel40I-nt324141.o: No such file or directory
cc: error: C-hannel40I-nt3241.o: No such file or directory
cc: error: C-hannel5858S-ender40I-nt3241.o: No such file or directory
cc: error: P-ointer40C-hannel5858S-ender40I-nt324141.o: No such file or directory
cc: error: C-rystal5858P-oin-c4f99d9688c0365d7ded28861381dd6c.o: No such file or directory
cc: error: P-ointer40C-hannel5858R-eceiver40I-nt324141.o: No such file or directory
cc: error: C-hannel5858R-eceiver40I-nt3241.o: No such file or directory
cc: error: C-hannel5858S-electC-ontext40I-nt3241.o: No such file or directory
cc: error: C-hannel5858S-electC-ontextS-haredS-tate.o: No such file or directory
cc: error: A-tomic40C-hannel5858S-electS-tate41.o: No such file or directory
cc: error: D-eque40I-nt3241.o: No such file or directory
cc: error: C-hannel5858D-eliveryS-tate.o: No such file or directory
cc: error: C-rystal5858P-oin-50c6dff1ac01adb5932ab2c073b74d07.o: No such file or directory
cc: error: C-hannel5858S-electC-ontext40N-il41.o: No such file or directory
cc: error: H-ash40I-nt324432I-nt3241.o: No such file or directory
cc: error: P-ointer40H-ash5858E-ntry40I-nt324432I-nt324141.o: No such file or directory
cc: error: H-ash5858E-ntry40I-nt324432I-nt3241.o: No such file or directory
cc: error: H-ash40T-uple40U-I-nt644432S-ymbol414432B-ool41.o: No such file or directory
cc: error: P-ointer40H-ash58-60a3eb55c544b99184778abc7dcee256.o: No such file or directory
cc: error: H-ash40S-tring443-d0ef6a484ca24b5e9e1cd150630d96a3.o: No such file or directory
cc: error: P-ointer40H-ash58-78e716075e5ec360a5549c235b8e9c11.o: No such file or directory
cc: error: E-xample.o: No such file or directory
cc: error: C-rystal5858O-nceS-tate.o: No such file or directory
cc: error: A-rray40P-ointer40B-ool4141.o: No such file or directory
cc: error: P-ointer40P-ointer40B-ool4141.o: No such file or directory
cc: error: P-ointer40B-ool41.o: No such file or directory
cc: error: P-roc40N-il41.o: No such file or directory
cc: error: L-ibU-nwind5858S-tate.o: No such file or directory
cc: error: L-ibU-nwind5858R-easonC-ode.o: No such file or directory
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
cc: error: C-rystal.o: No such file or directory
Error: execution of command failed with code: 1: cc "${@}" -o '/home/fhornung/.cache/crystal/crystal-run-withmacro.tmp' -rdynamic -lpcre -lm -lgc -lpthread /usr/share/crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/bin/../lib/crystal/lib -L/usr/lib -L/usr/local/lib

I the same or very similar error when I crosscompile the compiler to raspberrypi 4 and try to build crystal localy, try to make spec or build invidious.

when I compile my own software that is supposed to run on a PI, it compiles without problems.

It’s weird, and I am considering making a Platform-bug report about it.

Message with broken words usually means “not enough memory”. It’s kind of expected when building crystal spec locally, a bit strange for a smaller project, but still possible.

This is the memory usage of “make” trying to compile crystal just before it crashes.
the line starting with “total” is the output of “pmap -x | grep total”
the rest is the output from “free”
(while true; do pmap -x |grep total;free; sleep 1;done)

total kB 1559692 1114712 1082268
              total        used        free      shared  buff/cache   available
Mem:        3999784     1211040     1802476       52296      986268     2584252
Swap:       8388604        2824     8385780
total kB 1559760 1114788 1082344
              total        used        free      shared  buff/cache   available
Mem:        3999784     1211612     1801904       52296      986268     2583680
Swap:       8388604        2824     8385780
total kB 1666320 1115540 1083096
              total        used        free      shared  buff/cache   available
Mem:        3999784     1215836     1797676       52296      986272     2579456
Swap:       8388604        2824     8385780

This does not look to me like a OOM problem. The PI im trying this on is a raspberryPI 4 with 4GB ram and 8GB swap.

If there is any reason why this should not work on ARM that is known, this is no problem,but no-one came up with a known issue yet.

Swap size doesn’t help because 32-bit arch has a limit of 4GB per process. There are similar failures on 32-bit linux CI (https://github.com/crystal-lang/crystal/issues/6961, https://github.com/crystal-lang/crystal/pull/7263 etc).

Hmm. interesting. I didn’t think of that.
So, the build would not fail because it runs out of memory, but because it tries to request more than 32bit system can handle for one process.

Ok, luckily there is a 64-bit kernel available for the PI, so it should be possible to try again with a 64 bit build of the compiler.
First try compiling with target aarch64-linux-gnu results in this:

 mavu   0.31.1 … 2  ~  repo  crystal  ./bin/crystal build src/compiler/crystal.cr --cross-compile --target aarch64-linux-gnu --debug -s -D without_openssl -D without_zlib
Parse:                             00:00:00.000128138 (   0.25MB)
Semantic (top level):              00:00:00.384310020 ( 107.45MB)
Semantic (new):                    00:00:00.002453518 ( 107.45MB)
Semantic (type declarations):      00:00:00.064506305 ( 107.45MB)
Semantic (abstract def check):     00:00:00.010037809 ( 107.45MB)
Semantic (ivars initializers):     00:00:04.352083861 ( 829.38MB)
Semantic (cvars initializers):     00:00:00.005466468 ( 829.38MB)
Semantic (main):                   00:00:03.604796005 ( 943.38MB)
Semantic (cleanup):                00:00:00.147846056 ( 959.38MB)
Semantic (recursive struct check): 00:00:00.002551871 ( 959.38MB)
Codegen (crystal):                 00:00:05.403226779 (1247.38MB)
Invalid memory access (signal 11) at address 0x20
[0x7f4a6a9c9fc6] ???
[0x7f4a6a91ff4e] ???
[0x7f4a6b797461] ???

Some more research needed on how to actually do this :slight_smile:
the aarch64-linux-gnu was just a guess.