From fd9422077d0e84b6351d11778b9487416086cdaa Mon Sep 17 00:00:00 2001 From: Clemens Schmid Date: Mon, 30 Mar 2026 17:00:22 +0200 Subject: [PATCH 1/4] Add warnings options to scons --- SConstruct | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index a525990b..e4b22bb5 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/4] Only print compiler errors, no warnings --- SConstruct | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/SConstruct b/SConstruct index e4b22bb5..bc883042 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: From 6efd97fd8d19ddd2a4f09ff65c8b105368faccb1 Mon Sep 17 00:00:00 2001 From: "clemens.schmid@esrf.fr" Date: Tue, 25 Aug 2026 13:34:00 +0200 Subject: [PATCH 3/4] add news file --- news/compile_silent.rst | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 news/compile_silent.rst diff --git a/news/compile_silent.rst b/news/compile_silent.rst new file mode 100644 index 00000000..2ab05721 --- /dev/null +++ b/news/compile_silent.rst @@ -0,0 +1,25 @@ +**Added:** + +* Add SCons ``warnings`` and ``verbose`` options to control compiler warnings + and build-command output. + +**Changed:** + +* Make SCons builds quiet by default by suppressing compiler and linker + warnings and hiding build commands and progress messages. + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* From 78353e41ac45b1f3515bee58f19fd69458493976 Mon Sep 17 00:00:00 2001 From: Clemens Schmid Date: Wed, 26 Aug 2026 16:52:23 +0200 Subject: [PATCH 4/4] show compiler commands and warnings by default --- SConstruct | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index bc883042..92e9482a 100644 --- a/SConstruct +++ b/SConstruct @@ -75,10 +75,10 @@ vars.Add(EnumVariable( vars.Add(EnumVariable( 'warnings', 'warning flags policy', - 'none', allowed_values=('all', 'none', 'default'))) + 'all', allowed_values=('all', 'none', 'default'))) vars.Add(BoolVariable( 'verbose', - 'print build commands', False)) + 'print build commands', True)) vars.Add(EnumVariable( 'tool', 'C++ compiler toolkit to be used',