From: Gabe Black Date: Fri, 12 Feb 2021 01:42:36 +0000 (-0800) Subject: scons: Work around a scons bug when calling TryCompile. X-Git-Tag: develop-gem5-snapshot~72 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=de4487f848cc62c6c527707f87efd3ccbb8872a2;p=gem5.git scons: Work around a scons bug when calling TryCompile. When calling TryCompile with an empty string for the source, useful when just testing a build flag, some versions of SCons will apparently create some sort of equivalence between Value('') and Value(0). That shows itself when creating config file headers, where Value(0) is switched with Value(''), and the header defines a macro with which expands to nothing rather than a macro which expands to 0. Later uses of the macro of the form: #if CONFIG_VARIABLE fail because CONFIG_VARIABLE expands to nothing. If it expanded to 0 like it's supposed to, then the guarded block of code would be excluded correctly. Change-Id: Ie324ec5f8dd307c65745b9326a11230e10caa0bd Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/41213 Maintainer: Bobby R. Bruce Tested-by: kokoro Reviewed-by: Gabe Black --- diff --git a/site_scons/gem5_scons/configure.py b/site_scons/gem5_scons/configure.py index 7bf97b2a6..35aa1a99e 100644 --- a/site_scons/gem5_scons/configure.py +++ b/site_scons/gem5_scons/configure.py @@ -47,7 +47,7 @@ def CheckCxxFlag(context, flag, autoadd=True): context.Message("Checking for compiler %s support... " % flag) last_cxxflags = context.env['CXXFLAGS'] context.env.Append(CXXFLAGS=[flag]) - ret = context.TryCompile('', '.cc') + ret = context.TryCompile('// CheckCxxFlag DO NOTHING', '.cc') if not (ret and autoadd): context.env['CXXFLAGS'] = last_cxxflags context.Result(ret)