[waf] Add --variant=asan (#186)

This commit is contained in:
Fangrui Song 2017-12-24 16:24:26 -08:00 committed by GitHub
parent 2ffc068760
commit 338db49637

11
wscript
View File

@ -117,17 +117,26 @@ def configure(ctx):
ctx.load('compiler_cxx')
cxxflags = ['-g', '-std=c++11', '-Wall', '-Wno-sign-compare', '-Werror']
ldflags = []
# /Zi: -g, /WX: -Werror, /W3: roughly -Wall, there is no -std=c++11 equivalent in MSVC.
# /wd4722: ignores warning C4722 (destructor never returns) in loguru
# /wd4267: ignores warning C4267 (conversion from 'size_t' to 'type'), roughly -Wno-sign-compare
msvcflags = ['/nologo', '/FS', '/EHsc', '/Zi', '/W3', '/WX', '/wd4996', '/wd4722', '/wd4267', '/wd4800']
if ctx.options.variant != 'debug':
if ctx.options.variant == 'asan':
cxxflags.append('-fsanitize=address,undefined')
cxxflags.append('-O')
ldflags.append('-fsanitize=address,undefined')
elif ctx.options.variant == 'debug':
pass
else:
cxxflags.append('-O3')
msvcflags.append('/O2') # There is no O3
if ctx.env.CXX_NAME != 'msvc':
# If environment variable CXXFLAGS is unset, provide a sane default.
if not ctx.env.CXXFLAGS:
ctx.env.CXXFLAGS = cxxflags
if not ctx.env.LDFLAGS:
ctx.env.LDFLAGS = ldflags
else:
ctx.env.CXXFLAGS = msvcflags