rearrange flags for mingw to fix release mode link errors (due to mingw bug)