From 22d91148ca9f9728787e2597391e40526580eeb7 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 26 Sep 2019 21:58:08 +0300 Subject: [PATCH] compiler: passing -g3 adds mode debug info --- compiler/cc.v | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/compiler/cc.v b/compiler/cc.v index 7874e6cbe6..76347bc346 100644 --- a/compiler/cc.v +++ b/compiler/cc.v @@ -70,11 +70,27 @@ fn (v mut V) cc() { v.out_name = ModPath + v.dir + '.o' //v.out_name println('Building ${v.out_name}...') } + + mut debug_options := '-g' + mut optimization_options := '-O2' + if v.pref.ccompiler.contains('clang') { + if v.pref.is_debug { + debug_options = '-g -O0' + } + optimization_options = '-O3 -flto' + } + if v.pref.ccompiler.contains('gcc') { + if v.pref.is_debug { + debug_options = '-g3' + } + optimization_options = '-O3 -fno-strict-aliasing -flto' + } + if v.pref.is_prod { - a << '-O2' + a << optimization_options } else { - a << '-g' + a << debug_options } if v.pref.is_debug && os.user_os() != 'windows'{