v.builder: add -DNDEBUG for non debug -prod builds (affects sokol performance)

pull/6219/head
Delyan Angelov 2020-08-24 23:10:22 +03:00
parent 3efa670d6a
commit 995a5fed1f
1 changed files with 6 additions and 0 deletions

View File

@ -274,6 +274,12 @@ fn (mut v Builder) cc() {
if v.pref.is_prod { if v.pref.is_prod {
args << optimization_options args << optimization_options
} }
if v.pref.is_prod && !debug_mode {
// sokol and other C libraries that use asserts
// have much better performance when NDEBUG is defined
// See also http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
args << '-DNDEBUG'
}
if debug_mode && os.user_os() != 'windows' { if debug_mode && os.user_os() != 'windows' {
linker_flags << ' -rdynamic ' // needed for nicer symbolic backtraces linker_flags << ' -rdynamic ' // needed for nicer symbolic backtraces
} }