Skip to content

Commit

Permalink
build: decrease level of debug information produced by default
Browse files Browse the repository at this point in the history
Refs: #5279
Change-Id: I5c96d3e58d507c5ab01e0ae79348be15e078ac9a
  • Loading branch information
Pesa committed Aug 6, 2023
1 parent 502c4c3 commit 12b8aaa
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions .waf-tools/default-compiler-flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import platform
from waflib import Configure, Logs, Utils


def options(opt):
opt.add_option('--debug', '--with-debug', action='store_true', default=False,
help='Compile in debugging mode with minimal optimizations (-Og)')


def configure(conf):
conf.start_msg('Checking C++ compiler version')

Expand Down Expand Up @@ -48,14 +50,15 @@ def configure(conf):
else:
conf.end_msg(ccverstr)

conf.areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
conf.areCustomCxxflagsPresent = len(conf.env.CXXFLAGS) > 0

# General flags are always applied (e.g., selecting C++ language standard)
generalFlags = conf.flags.getGeneralFlags(conf)
conf.add_supported_cxxflags(generalFlags['CXXFLAGS'])
conf.add_supported_linkflags(generalFlags['LINKFLAGS'])
conf.env.DEFINES += generalFlags['DEFINES']


@Configure.conf
def check_compiler_flags(conf):
# Debug or optimized CXXFLAGS and LINKFLAGS are applied only if the
Expand All @@ -78,10 +81,11 @@ def check_compiler_flags(conf):

conf.env.DEFINES += extraFlags['DEFINES']


@Configure.conf
def add_supported_cxxflags(self, cxxflags):
"""
Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
Check which cxxflags are supported by the active compiler and add them to env.CXXFLAGS variable.
"""
if len(cxxflags) == 0:
return
Expand All @@ -97,10 +101,11 @@ def add_supported_cxxflags(self, cxxflags):
self.end_msg(' '.join(supportedFlags))
self.env.prepend_value('CXXFLAGS', supportedFlags)


@Configure.conf
def add_supported_linkflags(self, linkflags):
"""
Check which linkflags are supported by compiler and add them to env.LINKFLAGS variable
Check which linkflags are supported by the active compiler and add them to env.LINKFLAGS variable.
"""
if len(linkflags) == 0:
return
Expand Down Expand Up @@ -133,10 +138,12 @@ def getOptimizedFlags(self, conf):
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in optimized mode"""
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['NDEBUG']}


class GccBasicFlags(CompilerFlags):
"""
This class defines basic flags that work for both gcc and clang compilers
This class defines common flags that work for both gcc and clang compilers.
"""

def getGeneralFlags(self, conf):
flags = super(GccBasicFlags, self).getGeneralFlags(conf)
flags['CXXFLAGS'] += ['-std=c++17']
Expand All @@ -147,7 +154,7 @@ def getGeneralFlags(self, conf):
def getDebugFlags(self, conf):
flags = super(GccBasicFlags, self).getDebugFlags(conf)
flags['CXXFLAGS'] += ['-Og',
'-g3',
'-g',
'-Wall',
'-Wextra',
'-Wpedantic',
Expand All @@ -165,7 +172,7 @@ def getDebugFlags(self, conf):
def getOptimizedFlags(self, conf):
flags = super(GccBasicFlags, self).getOptimizedFlags(conf)
flags['CXXFLAGS'] += ['-O2',
'-g',
'-g1',
'-Wall',
'-Wextra',
'-Wpedantic',
Expand All @@ -177,6 +184,7 @@ def getOptimizedFlags(self, conf):
flags['LINKFLAGS'] += ['-Wl,-O1']
return flags


class GccFlags(GccBasicFlags):
def getDebugFlags(self, conf):
flags = super(GccFlags, self).getDebugFlags(conf)
Expand All @@ -196,6 +204,7 @@ def getOptimizedFlags(self, conf):
flags['CXXFLAGS'] += ['-Wno-psabi'] # Bug #5106
return flags


class ClangFlags(GccBasicFlags):
def getGeneralFlags(self, conf):
flags = super(ClangFlags, self).getGeneralFlags(conf)
Expand Down

0 comments on commit 12b8aaa

Please sign in to comment.