From 995a5fed1f877a608fd47bc3d678d4ae8e167321 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 24 Aug 2020 23:10:22 +0300 Subject: [PATCH] v.builder: add -DNDEBUG for non debug -prod builds (affects sokol performance) --- vlib/v/builder/cc.v | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index 4b35988b9f..37605bc39e 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -274,6 +274,12 @@ fn (mut v Builder) cc() { if v.pref.is_prod { 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' { linker_flags << ' -rdynamic ' // needed for nicer symbolic backtraces }