2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-22 09:56:22 +01:00

wscript: refactor cflags appending, add optional polyhedral optimizations

This commit is contained in:
Alibek Omarov 2019-10-11 04:12:07 +03:00
parent ae624801ac
commit 7782fa09ac

55
wscript
View File

@ -61,6 +61,9 @@ def options(opt):
grp.add_option('--enable-lto', action = 'store_true', dest = 'LTO', default = False,
help = 'enable Link Time Optimization [default: %default]')
grp.add_option('--enable-poly-opt', action = 'store_true', dest = 'POLLY', default = False,
help = 'enable polyhedral optimization if possible [default: %default]')
opt.load('subproject')
opt.add_subproject(subdirs())
@ -210,28 +213,46 @@ def configure(conf):
'-Werror=declaration-after-statement'
]
conf.env.append_unique('LINKFLAGS', conf.get_flags_by_type(
linker_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC))
linkflags = conf.get_flags_by_type(linker_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC)
cflags = conf.get_flags_by_type(compiler_c_cxx_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC)
if conf.env.COMPILER_CC == 'msvc':
conf.env.append_unique('CFLAGS', cflags)
conf.env.append_unique('CXXFLAGS', cflags)
else:
# Here we don't differentiate C or C++ flags
if conf.options.LTO:
lto_cflags = {
'msvc': ['/GL'],
'gcc': ['-flto'],
'clang': ['-flto']
}
lto_linkflags = {
'msvc': ['/LTCG'],
'gcc': ['-flto'],
'clang': ['-flto']
}
cflags += conf.get_flags_by_compiler(lto_cflags, conf.env.COMPILER_CC)
linkflags += conf.get_flags_by_compiler(lto_linkflags, conf.env.COMPILER_CC)
if conf.options.POLLY:
polly_cflags = {
'gcc': ['-fgraphite-identity'],
'clang': ['-mllvm', '-polly']
# msvc sosat :(
}
cflags += conf.get_flags_by_compiler(polly_cflags, conf.env.COMPILER_CC)
# And here C++ flags starts to be treated separately
cxxflags = list(cflags)
if conf.env.COMPILER_CC != 'msvc':
conf.check_cc(cflags=cflags, msg= 'Checking for required C flags')
conf.check_cxx(cxxflags=cflags, msg= 'Checking for required C++ flags')
conf.env.append_unique('CFLAGS', cflags + conf.filter_cflags(compiler_optional_flags + c_compiler_optional_flags, cflags, False))
conf.env.append_unique('CXXFLAGS', cflags + conf.filter_cflags(compiler_optional_flags, cflags, True))
cflags += conf.filter_cflags(compiler_optional_flags + c_compiler_optional_flags, cflags, False)
cxxflags += conf.filter_cflags(compiler_optional_flags, cflags, True)
if conf.options.LTO:
if conf.env.COMPILER_CC == 'gcc' or conf.env.COMPILER_CC == 'clang':
conf.env.append_unique('CFLAGS', '-flto')
conf.env.append_unique('LINKFLAGS', '-flto')
elif conf.env.COMPILER_CC == 'msvc':
conf.env.append_unique('CFLAGS', '/GL')
conf.env.append_unique('LINKFLAGS', '/LTCG')
conf.env.append_unique('CFLAGS', cflags)
conf.env.append_unique('CXXFLAGS', cxxflags)
conf.env.append_unique('LINKFLAGS', linkflags)
conf.env.DEDICATED = conf.options.DEDICATED
# we don't need game launcher on dedicated