Search code examples
debuggingcompilationcrystal-lang

Purpose of no-codegen option on crystal build?


What is purpose of no-codegen option when building crystal project ?

I have quite large codebase and when building without this option, it can take up to 20 seconds to build. When I use no-codegen option, it reduces build time to 6 seconds. But I don't understand can executable be debugged when that option is included (currently I debug using LLDB when building with --debug flag)?


Solution

  • --no-codegen means no code is generated. It does not produce any binary.

    The purpose of this flag is to check the validity of a program, without actually building it. This is useful when you can't execute the result anyway, then the binary generation can be skipped. For example, this is used for the code examples in the Crystal repo: They are built in CI with --no-codegen just to check that the code is valid, but verifying their execution is out of scope for automated tests.