How to compile Crystal with specific CPU support?

I have question regarding native CPU support.
I use Gentoo Linux on my server with Xeon (Intel Xeon W 2000 / D-2100 (Skylake H0/M0/U0) {Skylake}, 14nm) and I usually use GCC flag -march=native that uses all features of CPU that it builds on. If I don’t use that flag GCC by default uses only x86_64 without all the features that CPU provides and it loses a lot of performance.

My question is when Crystal compiles how I can tweak it to use all potential of those cores?
Should I dive deep into LLVM library to check the parameters?

    --mcpu CPU                       Target specific cpu type
    --mattr CPU                      Target specific features
    --mcmodel MODEL                  Target specific code model

Are options when using crystal build. I never used them, but seems like that’s what you want?

1 Like

Funny enough I completely forgot about those settings and yes, LLVM also supports march=native so it should bring performance improvements. I will definitely will play with it.

3 Likes