From fe20f4ada60388ceb65b1a503c132bd0e2326ec5 Mon Sep 17 00:00:00 2001 From: Roger Chang Date: Fri, 20 Oct 2023 11:10:25 +0800 Subject: [PATCH 1/3] scons: Explicit the config option HAVE_DEPRECATED_NAMESPACE type bool Currently the type of HAVE_DEPRECATED_NAMESPACE is used to detect if the compiler support gnu::deprecated feature. The return type of conf.TryCompile is int, but HAVE_DEPRECATED_NAMESPACE is used as boolean type. The CL is add bool type caster to ensure the type of it is boolean. Change-Id: Ife7d9716e485a8be8722d58776f064e7c2268a30 --- src/base/SConsopts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/base/SConsopts b/src/base/SConsopts index 8e0661203f..68e40587b9 100644 --- a/src/base/SConsopts +++ b/src/base/SConsopts @@ -69,11 +69,13 @@ werror_env.Append(CCFLAGS=['-Werror']) with gem5_scons.Configure(werror_env) as conf: # Store result in the main environment - main['CONF']['HAVE_DEPRECATED_NAMESPACE'] = conf.TryCompile(''' - int main() {return 0;} - namespace [[gnu::deprecated("Test namespace deprecation")]] - test_deprecated_namespace {} - ''', '.cc') + main['CONF']['HAVE_DEPRECATED_NAMESPACE'] = bool( + conf.TryCompile(''' + int main() {return 0;} + namespace [[gnu::deprecated("Test namespace deprecation")]] + test_deprecated_namespace {} + ''', '.cc') + ) if not main['CONF']['HAVE_DEPRECATED_NAMESPACE']: warning("Deprecated namespaces are not supported by this compiler.\n" From 1a7014c653430786e1e08861311dfbe6f25216da Mon Sep 17 00:00:00 2001 From: Roger Chang Date: Fri, 20 Oct 2023 11:37:59 +0800 Subject: [PATCH 2/3] scons: Explicit the config option HAVE_PKG_CONFIG type boolean The scons function Detect will return the program name if the program is exists in the system. However, the HAVE_PKG_CONFIG is used to check the pkg-config program is exists and it should be the boolean type. Change-Id: I18c4813d36eea68b8851a41db41777bdb2a80b7b --- SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 32e0c36e09..e7fa4b53b7 100755 --- a/SConstruct +++ b/SConstruct @@ -636,7 +636,7 @@ for variant_path in variant_paths: LINKFLAGS=['-Wl,--no-as-needed', '-lprofiler', '-Wl,--as-needed']) - env['HAVE_PKG_CONFIG'] = env.Detect('pkg-config') + env['HAVE_PKG_CONFIG'] = env.Detect('pkg-config') == 'pkg-config' with gem5_scons.Configure(env) as conf: # On Solaris you need to use libsocket for socket ops From 069baed9711a0eff27d2bc6dd7f2308ec62e2cc6 Mon Sep 17 00:00:00 2001 From: Roger Chang Date: Fri, 20 Oct 2023 11:40:24 +0800 Subject: [PATCH 3/3] scons: Explicit the config option HAVE_PROTOBUF type boolean Ensure the type of HAVE_PROTOBUF is boolean Change-Id: I9cf18c52ac290000168f5228b7f4ba3621225a85 --- src/proto/SConsopts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/proto/SConsopts b/src/proto/SConsopts index fab29bc235..6cc4a48642 100644 --- a/src/proto/SConsopts +++ b/src/proto/SConsopts @@ -57,11 +57,13 @@ with gem5_scons.Configure(main) as conf: # automatically added to the LIBS environment variable. After # this, we can use the HAVE_PROTOBUF flag to determine if we have # got both protoc and libprotobuf available. - conf.env['CONF']['HAVE_PROTOBUF'] = conf.env['HAVE_PROTOC'] and ( - (conf.env['HAVE_PKG_CONFIG'] and - conf.CheckPkgConfig('protobuf', '--cflags', '--libs')) or - conf.CheckLibWithHeader('protobuf', 'google/protobuf/message.h', - 'C++', 'GOOGLE_PROTOBUF_VERIFY_VERSION;')) + conf.env['CONF']['HAVE_PROTOBUF'] = bool( + conf.env['HAVE_PROTOC'] and ( + (conf.env['HAVE_PKG_CONFIG'] and + conf.CheckPkgConfig('protobuf', '--cflags', '--libs')) or + conf.CheckLibWithHeader('protobuf', 'google/protobuf/message.h', + 'C++', 'GOOGLE_PROTOBUF_VERIFY_VERSION;')) + ) # If we have the compiler but not the library, print another warning. if main['HAVE_PROTOC'] and not main['CONF']['HAVE_PROTOBUF']: