C optimization levels?

When I’m compiling C source files via build.zig, do I have to supply the -O2 optimization flag or does zig handle optimization based on whether its release-fast , release-small , etc. ?

1 Like

I’m not aware of an official source for an answer, but I just compiled one of my projects with zig build --verbose-cc and zig build -Drelease-fast=true --versbose-cc and compared the difference. The first included the -Og flag, and the second used -O2, so it seems that the various build modes do pass optimization flags to C code by default.

1 Like

Thanks! Zig is really smart! :slightly_smiling_face:

1 Like