Increasingly, I've been running into situations where it would be beneficial, from a cross-platform and cross-compiler point of view, to selectively enable flags and features depending on the capabilities and defaults of the C compiler is being used. There is some support for doing stuff like when gcc, but it's crude.
Let's say for example that a project would benefit from LTO compiles - what's the best way to enable this for compilers that support it and gracefully degrade to non-LTO? Only recent GCC versions support it.
A similar situation arises with dialects - which one is the default for a given compiler (C99, C11, etc) changes over time, while something like a wrapper might need to force a particular version for a particular compiler - likewise for -arch flags and the like.
Autoconf solves this pragmatically, simply by running tests for each interesting feature and spitting out a decision variable that can be used later in the build process - what would nim's approach be?
A non-solution is to dump this one the user of the code (ie "go edit your nim.cfg") - this doesn't scale.
Seems indeed useful to have a standard library module for that.
Could be based on stuff like this :
const output = staticExec("cc --version")`
when output.hasSomeProperty: ... # eg: check version > something
const hasLTO = not staticExec("clang -flto --version").contains("error")
when hasLTO: ...