Hello,
considering that Nim compiler partly hides away used C/C++ backend compiler flags, I'd like to ask what you consider a template for debug/release configuration when targeting C/C++. Or how you handle the switch between debug/release during development.
I know this is more a question about how specific C/C++ compiler/environment works, but I'd look at it as a way to talk about how to extend the "good defaults" proposed by the Nim compiler
I'm using GCC here to wrap C code and test out for any leak. I use a proc to define which route to go. I tried to use -d:[debug|release] with when but I failed.
config.nims
switch("maxLoopIterationsVM", "100000000")
proc release =
switch("d", "release")
switch("opt", "speed")
switch("passC", "-flto")
switch("passL", "-flto")
proc debug =
switch("d", "debug")
switch("opt", "none")
switch("debugger", "native")
switch("d", "useMalloc")
switch("passC", "-fsanitize=address,undefined -fno-omit-frame-pointer")
switch("passL", "-fsanitize=address,undefined")
debug()
You can use this syntax, it is used in the default nim.cfg:
@if release or danger:
<put flags here>
@elif debug:
<put flags here>
@else:
<put flags here>
@end