Crystal is now available on Termux AArch64

You can now install Crystal from Termux’s official package repository on AArch64 Android devices:

u0_a211@localhost:~$ apt search crystal$
Sorting... Done
Full Text Search... Done
crystal/stable 1.9.0 aarch64
  Fast and statically typed, compiled language with Ruby-like syntax

u0_a211@localhost:~$ apt info crystal
Package: crystal
Version: 1.9.0
Maintainer: @HertzDevil
Installed-Size: 23.9 MB
Depends: libc++, libevent, libgc, libgmp, libiconv, libllvm (<< 17), libxml2, libyaml, openssl, pcre2, zlib
Recommends: clang, libffi, make, pkg-config
Homepage: https://crystal-lang.org
Download-Size: 3590 kB
APT-Sources: https://packages.termux.dev/apt/termux-main stable/main aarch64 Packages
Description: Fast and statically typed, compiled language with Ruby-like syntax

The playground and all third-party dependencies in the standard library are available. The interpreter is currently not built. Note that -Duse_libiconv is not enabled by default at the moment, and without that flag you will end up linking against the far less useful system iconv in Bionic.

Crystal can be installed with just pkg install crystal. If you have Docker, you could also clone the build environment and try building Crystal locally with scripts/run-docker.sh scripts/build-package.sh -I -a aarch64 crystal.

9 Likes

Yeah discovered this package yesterday, and it seems that ‘shards’ was also installed with it. Thank you

Help please.

I get different results, such as

$ apt info crystal
E: Invalid operation info

install (broken):

$ pkg install crystal
Checking availability of current mirror: ok
Reading package lists... Done
Building dependency tree... Done
E: Unable to locate package crystal

get version (fails):

$ crystal -v
No command crystal found, did you mean:
 Command crontab in package cronie
 Command prtstat in package psmisc

I’m on a Armor 12 5G.

Oh, bummer; It’s not avail yet (at least for me).

$ pkg search crystal
Checking availability of current mirror: ok
Sorting... Done
Full Text Search... Done

Is it normal that compiling small programs take 15s? My system is Android 13, Snapdragon 695, 6/128. Everytime I compile one of my toy programs “codegen (bc+obj)” takes around 13-14s. Rust package takes less than 3s compiling those same programs(rust versions of course). I hope this can be improved.

1 Like

It is hard for current Crystal, you can search incremental compiling in the form.

I dont’t think it’s incremental compilation since I delete the cache before I build/run those rust programs. And it is true even for first build/run. And incremental compilation is disabled for --release profile in rust.

Yes, that’s totally within expectations.
The Crystal compiler needs to do a lot for semantic analysis, so it takes some time, unfortunately.

Is it possible to build statically within Termux?
What are the general develop packages needed?

AFAIU it’s technically possible, but static linking on Android is not recommended or really useful. Statically linked executables are not exactly portable, they can break between Android versions.

This page says:

On non-rooted Android 8 or newer, statically linked programs will not run due to issues with seccomp filter.

PRoot allows this, but then your program won’t be directly compiled and run under Termux anyway.

1 Like

I like this. When I am at the bus stop waiting for the bus to come, I can open my smart phone, look at a simple question and snippet posted on the Crystal forum, launch Termux, launch vi, save it to a file, compile and run it, see what happens, and write a reply. Just the fact that Crystal runs on a smart phone is amazing, but also practical.

2 Likes