The Crystal Programming Language Forum

Crystal and LLVM

I am using Crystal 0.30.1
$ crystal version
Crystal 0.30.1 [5e6a1b672] (2019-08-12)
LLVM: 4.0.0
Default target: x86_64-unknown-linux-gnu

Confusing is the version of LLVM 4.0.0 as I saw mentioning of Crystal using a higher version of LLVM (6/7) ?

The linux distribution packages use llvm-4.0.
We expect to bump in the future, but we’ve been using the llvm-4.0 prebuilt package so far.

If you install any newer llvm and build the compiler from sources you can have a crystal backed with a newer llvm.

I tested different LLVMs on the FreeBSD, and crystal 0.30 compiled with LLVM 8 is cca 30% slower in compile times compared to LLVM 6 - is it normal?

What’s “cca”?

  • compilation of test project with crystal/llvm6 [freebsd]: 60-70 seconds
  • compilation of test project with crystal/llvm8 [freebsd]: 92 seconds (and more)

I don’t think each newer LLVM version means a faster LLVM. It just means more features and (possibly) more optimizations in the final binary. But I know from experience that each LLVM version is slower than the previous one.