From fd9422077d0e84b6351d11778b9487416086cdaa Mon Sep 17 00:00:00 2001 From: Clemens Schmid Date: Mon, 30 Mar 2026 17:00:22 +0200 Subject: [PATCH 1/2] Add warnings options to scons --- SConstruct | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index a525990..e4b22bb 100644 --- a/SConstruct +++ b/SConstruct @@ -42,6 +42,10 @@ def ftpyflag(flags): pattern = re.compile(r'^(-g|-Wstrict-prototypes|-O\d|-fPIC)$') return [f for f in flags if not (isinstance(f, str) and pattern.match(f))] + +def filter_warning_flags(flags): + return [f for f in flags if not (isinstance(f, str) and f.startswith('-W'))] + # copy system environment variables related to compilation DefaultEnvironment(ENV=subdictionary(os.environ, ''' PATH PYTHONPATH GIT_DIR HOMEPATH HOMEDRIVE @@ -68,6 +72,10 @@ vars.Add(EnumVariable( 'build', 'compiler settings', 'fast', allowed_values=('debug', 'fast'))) +vars.Add(EnumVariable( + 'warnings', + 'warning flags policy', + 'all', allowed_values=('all', 'none', 'default'))) vars.Add(EnumVariable( 'tool', 'C++ compiler toolkit to be used', @@ -172,8 +180,13 @@ else: # not using sysconfig here because of parsing issues env.ParseConfig(f"{pythonconfig} --cflags") env.Replace(CCFLAGS=ftpyflag(env['CCFLAGS'])) + if env['warnings'] != 'all': + env.Replace(CCFLAGS=filter_warning_flags(env['CCFLAGS'])) - env.PrependUnique(CCFLAGS=['-Wextra']) + if env['warnings'] == 'all': + env.PrependUnique(CCFLAGS=['-Wextra']) + elif env['warnings'] == 'none': + env.PrependUnique(CCFLAGS=['-w']) env.PrependUnique(CXXFLAGS=['-std=c++11']) if env['tool'] == 'intelc': From dd67b9eb976d124d50ff38c18f300db98393a2d8 Mon Sep 17 00:00:00 2001 From: Clemens Schmid Date: Mon, 29 Jun 2026 15:44:33 +0200 Subject: [PATCH 2/2] Only print compiler errors, no warnings --- SConstruct | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/SConstruct b/SConstruct index e4b22bb..bc88304 100644 --- a/SConstruct +++ b/SConstruct @@ -75,7 +75,10 @@ vars.Add(EnumVariable( vars.Add(EnumVariable( 'warnings', 'warning flags policy', - 'all', allowed_values=('all', 'none', 'default'))) + 'none', allowed_values=('all', 'none', 'default'))) +vars.Add(BoolVariable( + 'verbose', + 'print build commands', False)) vars.Add(EnumVariable( 'tool', 'C++ compiler toolkit to be used', @@ -84,6 +87,8 @@ vars.Add(BoolVariable( 'profile', 'build with profiling information', False)) vars.Update(env) +SetOption('silent', not env['verbose']) +SetOption('no_progress', not env['verbose']) # Use C++ compiler specified by the 'tool' option. if env['tool'] == 'intelc': @@ -157,7 +162,8 @@ else: # use sysconfig on Windows pythonconfig = None xpython = pjoin(env['prefix'], 'python.exe') -print(f"Using python-config: {pythonconfig} from {xpython}") +if env['verbose']: + print(f"Using python-config: {pythonconfig} from {xpython}") common_cppdefs = ['REAL=double', 'BOOST_ERROR_CODE_HEADER_ONLY'] @@ -166,6 +172,8 @@ env.AppendUnique(CPPDEFINES=common_cppdefs) if env['PLATFORM'] == 'win32': env.AppendUnique(CPPDEFINES=['BOOST_ALL_NO_LIB']) env.AppendUnique(CCFLAGS=['/EHsc', '/MD']) + if env['warnings'] == 'none': + env.PrependUnique(CCFLAGS=['/w']) if env['build'] == 'debug': env.Append(CCFLAGS=['/Zi', '/Od', '/FS']) @@ -187,11 +195,21 @@ else: env.PrependUnique(CCFLAGS=['-Wextra']) elif env['warnings'] == 'none': env.PrependUnique(CCFLAGS=['-w']) + env.PrependUnique(LINKFLAGS=['-w']) + # GCC emits an unconditional warning when LTO objects are linked + # without an explicit parallelization mode. + if ('-flto' in env['CCFLAGS'] and + any(isinstance(f, str) and + f.startswith('-flto-partition=') + for f in env['CCFLAGS'])): + env.PrependUnique(LINKFLAGS=['-flto=auto']) env.PrependUnique(CXXFLAGS=['-std=c++11']) if env['tool'] == 'intelc': # options for Intel C++ compiler on hpc dev-intel07 - env.AppendUnique(CCFLAGS=['-w1', '-fp-model', 'precise']) + if env['warnings'] != 'none': + env.AppendUnique(CCFLAGS=['-w1']) + env.AppendUnique(CCFLAGS=['-fp-model', 'precise']) env.PrependUnique(LIBS=['imf']) fast_opts = ['-fast', '-no-ipo'] else: