From 41ccb6099bd50a9ca41971f049ee6a145bf682f3 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Sun, 7 Feb 2021 23:58:57 -0800 Subject: [PATCH] scons: Use SCons' built in CXXVERSION instead of detecting our own. It's not guaranteed that every compiler will set CXXVERSION, but both gcc and clang do, and for any check of CXXVERSION to be meaningful, we have to first check which compiler we're talking about. Change-Id: Icd15e12832920fec6fa8634bc0fde16cc48e3f41 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/41596 Tested-by: kokoro Reviewed-by: Gabe Black Maintainer: Gabe Black --- SConstruct | 22 +++++----------------- src/systemc/dt/int/SConscript | 2 +- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/SConstruct b/SConstruct index c5dac008a0..ed27e5861f 100755 --- a/SConstruct +++ b/SConstruct @@ -79,9 +79,6 @@ import atexit import itertools import os -import re -import shutil -import subprocess import sys from os import mkdir, environ @@ -353,14 +350,11 @@ else: "src/SConscript to support that compiler."))) if main['GCC']: - gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False) - if compareVersions(gcc_version, "5") < 0: + if compareVersions(main['CXXVERSION'], "5") < 0: error('gcc version 5 or newer required.\n' - 'Installed version:', gcc_version) + 'Installed version:', main['CXXVERSION']) Exit(1) - main['GCC_VERSION'] = gcc_version - # Add the appropriate Link-Time Optimization (LTO) flags # unless LTO is explicitly turned off. if not GetOption('no_lto'): @@ -387,15 +381,9 @@ if main['GCC']: '-fno-builtin-realloc', '-fno-builtin-free']) elif main['CLANG']: - clang_version_re = re.compile(".* version (\d+\.\d+)") - clang_version_match = clang_version_re.search(CXX_version) - if (clang_version_match): - clang_version = clang_version_match.groups()[0] - if compareVersions(clang_version, "3.9") < 0: - error('clang version 3.9 or newer required.\n' - 'Installed version:', clang_version) - else: - error('Unable to determine clang version.') + if compareVersions(main['CXXVERSION'], "3.9") < 0: + error('clang version 3.9 or newer required.\n' + 'Installed version:', main['CXXVERSION']) # clang has a few additional warnings that we disable, extraneous # parantheses are allowed due to Ruby's printing of the AST, diff --git a/src/systemc/dt/int/SConscript b/src/systemc/dt/int/SConscript index 92c0f07112..b052f0407a 100644 --- a/src/systemc/dt/int/SConscript +++ b/src/systemc/dt/int/SConscript @@ -28,7 +28,7 @@ Import('*') from m5.util import compareVersions if env['USE_SYSTEMC']: - if main['GCC'] and compareVersions(main['GCC_VERSION'], '10.0') >= 0: + if main['GCC'] and compareVersions(main['CXXVERSION'], '10.0') >= 0: disable_false_positives = { "CCFLAGS": [ "-Wno-array-bounds", "-Wno-stringop-overflow" ]