How to cross-compile Crystal?

345 views
Skip to first unread message

Anatol Pomozov

unread,
Mar 9, 2015, 5:23:01 PM3/9/15
to crysta...@googlegroups.com
Hi

I wan to run a small web-app written in Crystall at my web router. The router is my only home computer that is always on and I want to utilize it for serving my application. The router is MIPS based and runs OpenWRT. I want to add crystal package to OpenWRT and then compile my app for this platform.

I see that Crystal uses precompiled binaries to compile itself. But how did you get those binaries? In my case I need precompiled MIPS binaries. Are there any instructions that allow me to build Crystal for MIPS?

Jonne Haß

unread,
Mar 9, 2015, 5:53:20 PM3/9/15
to crysta...@googlegroups.com
Expect some hurdles along the way ;) To cross compile run llvm-config --host-target on the target platform to get the host triple, then crystal build --cross-compile <said_triple> src/compiler/crystal.cr, you might also need --mcpu option. Check crystal build --help for more options in general. That will emit you an object file and print you a command to link it to an executable on the target platform or inside your cross-compile toolchain.

Good luck,
Jonne
> --
> You received this message because you are subscribed to the Google
> Groups "Crystal" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to crystal-lang...@googlegroups.com
> <mailto:crystal-lang...@googlegroups.com>.
> To post to this group, send email to crysta...@googlegroups.com
> <mailto:crysta...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/crystal-lang.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/crystal-lang/a33f07e2-fd61-496f-b5a3-2290e6f4674c%40googlegroups.com
> <https://groups.google.com/d/msgid/crystal-lang/a33f07e2-fd61-496f-b5a3-2290e6f4674c%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Jonne Haß

unread,
Mar 9, 2015, 5:55:42 PM3/9/15
to crysta...@googlegroups.com
Oh, I have to correct myself already, the target triple goes to the --target option these days, --cross-compile overrides the detection of flags used for ifdef statements.

Ary Borenszweig

unread,
Mar 9, 2015, 5:59:11 PM3/9/15
to crysta...@googlegroups.com

To unsubscribe from this group and stop receiving emails from it, send an email to crystal-lang...@googlegroups.com.
To post to this group, send email to crysta...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Ary Borenszweing         Manas Technology Solutions
[ar.phone]                      5258.5240       #ARY(279)
[us.phone]                      312.612.1050    #ARY(279)
[email]                         aboren...@manas.com.ar
[web]                           www.manas.com.ar
[blog]                           weblogs.manas.com.ar/ary
Reply all
Reply to author
Forward
0 new messages