Fix waf configure --variant=debug on Linux

This commit is contained in:
Fangrui Song 2018-01-07 15:17:14 -08:00
parent 78dc0c4341
commit cef1559f6d
3 changed files with 41 additions and 34 deletions

View File

@ -123,7 +123,7 @@ void IncludeComplete::Rescan() {
config_->includeCompletionBlacklist); config_->includeCompletionBlacklist);
is_scanning = true; is_scanning = true;
WorkThread::StartThread("include_scanner", [this]() { WorkThread::StartThread("scan_includes", [this]() {
Timer timer; Timer timer;
InsertStlIncludes(); InsertStlIncludes();

43
wscript
View File

@ -137,39 +137,45 @@ def configure(ctx):
ctx.resetenv(ctx.options.variant) ctx.resetenv(ctx.options.variant)
ctx.load('compiler_cxx') ctx.load('compiler_cxx')
cxxflags = ['-g', '-std=c++11', '-Wall', '-Wno-sign-compare', '-Werror']
if ctx.options.use_clang_cxx:
# include/clang/Format/Format.h error: multi-line comment
cxxflags.append('-Wno-comment')
# otherwise use of some Clang C++ functions may report `undefined references to typeinfo`
cxxflags.append('-fno-rtti')
ldflags = [] ldflags = []
if ctx.env.CXX_NAME == 'msvc':
# /Zi: -g, /WX: -Werror, /W3: roughly -Wall, there is no -std=c++11 equivalent in MSVC. # /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 # /wd4722: ignores warning C4722 (destructor never returns) in loguru
# /wd4267: ignores warning C4267 (conversion from 'size_t' to 'type'), roughly -Wno-sign-compare # /wd4267: ignores warning C4267 (conversion from 'size_t' to 'type'), roughly -Wno-sign-compare
# /MD: use multithread c library from DLL # /MD: use multithread c library from DLL
msvcflags = ['/nologo', '/FS', '/EHsc', '/Zi', '/W3', '/WX', '/wd4996', '/wd4722', '/wd4267', '/wd4800', '/MD'] cxxflags = ['/nologo', '/FS', '/EHsc', '/Zi', '/W3', '/WX', '/wd4996', '/wd4722', '/wd4267', '/wd4800', '/MD']
if ctx.options.variant == 'debug':
cxxflags += ['/Zi', '/FS']
ldflags += ['/DEBUG']
else:
cxxflags.append('/O2') # There is no O3
else:
if ctx.env.CXXFLAGS:
cxxflags = ctx.env.CXXFLAGS
else:
cxxflags = ['-g', '-Wall', '-Wno-sign-compare', '-Werror']
if all(not x.startswith('-std=') for x in ctx.env.CXXFLAGS):
cxxflags.append('-std=c++11')
if ctx.options.use_clang_cxx:
# include/clang/Format/Format.h error: multi-line comment
cxxflags.append('-Wno-comment')
# Without -fno-rtti, some Clang C++ functions may report `undefined references to typeinfo`
cxxflags.append('-fno-rtti')
if ctx.options.variant == 'asan': if ctx.options.variant == 'asan':
cxxflags.append('-fsanitize=address,undefined') cxxflags.append('-fsanitize=address,undefined')
cxxflags.append('-O') cxxflags.append('-O')
ldflags.append('-fsanitize=address,undefined') ldflags.append('-fsanitize=address,undefined')
elif ctx.options.variant == 'debug': elif ctx.options.variant == 'debug':
msvcflags += ['/Zi', '/FS'] pass
ldflags += ['/DEBUG']
else: else:
cxxflags.append('-O3') 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 ctx.env.CXXFLAGS = cxxflags
elif all(not x.startswith('-std=') for x in ctx.env.CXXFLAGS):
ctx.env.CXXFLAGS.append('-std=c++11')
if not ctx.env.LDFLAGS: if not ctx.env.LDFLAGS:
ctx.env.LDFLAGS = ldflags ctx.env.LDFLAGS = ldflags
else:
ctx.env.CXXFLAGS = msvcflags
ctx.check(header_name='stdio.h', features='cxx cxxprogram', mandatory=True) ctx.check(header_name='stdio.h', features='cxx cxxprogram', mandatory=True)
@ -370,8 +376,9 @@ def build(bld):
'third_party/sparsepp/'] + 'third_party/sparsepp/'] +
(['libclang'] if bld.env['use_clang_cxx'] else []), (['libclang'] if bld.env['use_clang_cxx'] else []),
defines=[ defines=[
#'_GLIBCXX_USE_CXX11_ABI=0', 'clang+llvm-$version-x86_64-linux-gnu-ubuntu-14.04' is pre CXX11_ABI
'LOGURU_WITH_STREAMS=1', 'LOGURU_WITH_STREAMS=1',
'LOGURU_FILENAME_WIDTH=18',
'LOGURU_THREADNAME_WIDTH=13',
'DEFAULT_RESOURCE_DIRECTORY="' + default_resource_directory + '"'] + 'DEFAULT_RESOURCE_DIRECTORY="' + default_resource_directory + '"'] +
(['USE_CLANG_CXX=1', 'LOGURU_RTTI=0'] (['USE_CLANG_CXX=1', 'LOGURU_RTTI=0']
if bld.env['use_clang_cxx'] if bld.env['use_clang_cxx']