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 <noreply+kokoro@google.com>
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
This commit is contained in:
Gabe Black
2021-02-07 23:58:57 -08:00
parent 978bd8759a
commit 41ccb6099b
2 changed files with 6 additions and 18 deletions

View File

@@ -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,

View File

@@ -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" ]