source-level debugging not quite working
The fixes for #3844 made it easier to build with -g but source-level debugging is still not quite working correctly. The reason is that #3844 added -g without removing optimization options.
With most tool chains, if you turn on both debug support and optimization, examination of local variables etc. usually doesn't work.
The most common approach for adjusting a Makefile to build for debugging is to modify whatever make variable holds the "optimization" options (i.e. typically "-O" or similar), so that when building for debug the optimization flags are replaced with a "-g" flag. That both turns on full source-level debugging support, and turns off optimization. That's what we should be doing as well.
In most ilumos makefiles, the variable we're interested in for this is COPTFLAG, but sometimes COPTFLAG64, CCOPTFLAG, CCOPTFLAG64