# -*- mode:python -*-
-# Copyright (c) 2013, 2015-2019 ARM Limited
+# Copyright (c) 2013, 2015-2020 ARM Limited
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
for i in range(len(l)+offs, 0, -1):
if l[i] == elt:
return i
- raise ValueError, "element not found"
+ raise ValueError("element not found")
# Take a list of paths (or SCons Nodes) and return a list with all
# paths made absolute and ~-expanded. Paths will be interpreted
main.Append(CCFLAGS=['-I/usr/local/include'])
main.Append(CXXFLAGS=['-I/usr/local/include'])
+ main.Append(LINKFLAGS='-Wl,--as-needed')
main['FILTER_PSHLINKFLAGS'] = lambda x: str(x).replace(' -shared', '')
main['PSHLINKFLAGS'] = main.subst('${FILTER_PSHLINKFLAGS(SHLINKFLAGS)}')
if GetOption('gold_linker'):
main.Append(LINKFLAGS='-fuse-ld=gold')
- main['PLINKFLAGS'] = main.subst('${LINKFLAGS}')
+ main['PLINKFLAGS'] = main.get('LINKFLAGS')
shared_partial_flags = ['-r', '-nostdlib']
main.Append(PSHLINKFLAGS=shared_partial_flags)
main.Append(PLINKFLAGS=shared_partial_flags)
'-Wno-error=deprecated',
])
else:
- error('\n'.join(
+ error('\n'.join((
"Don't know what compiler options to use for your compiler.",
"compiler: " + main['CXX'],
"version: " + CXX_version.replace('\n', '<nl>') if
"",
"If you are trying to use a compiler other than those listed",
"above you will need to ease fix SConstruct and ",
- "src/SConscript to support that compiler."))
+ "src/SConscript to support that compiler.")))
if main['GCC']:
# Check for a supported version of gcc. >= 4.8 is chosen for its
main.Append(PSHLINKFLAGS='-flinker-output=rel')
main.Append(PLINKFLAGS='-flinker-output=rel')
- # Make sure we warn if the user has requested to compile with the
- # Undefined Benahvior Sanitizer and this version of gcc does not
- # support it.
- if GetOption('with_ubsan') and compareVersions(gcc_version, '4.9') < 0:
- warning('UBSan is only supported using gcc 4.9 and later.')
-
disable_lto = GetOption('no_lto')
if not disable_lto and main.get('BROKEN_INCREMENTAL_LTO', False) and \
not GetOption('force_lto'):
main.Append(TCMALLOC_CCFLAGS=['-fno-builtin-malloc', '-fno-builtin-calloc',
'-fno-builtin-realloc', '-fno-builtin-free'])
- # The address sanitizer is available for gcc >= 4.8
- if GetOption('with_asan'):
- if GetOption('with_ubsan') and \
- compareVersions(main['GCC_VERSION'], '4.9') >= 0:
- main.Append(CCFLAGS=['-fsanitize=address,undefined',
- '-fno-omit-frame-pointer'],
- LINKFLAGS='-fsanitize=address,undefined')
- else:
- main.Append(CCFLAGS=['-fsanitize=address',
- '-fno-omit-frame-pointer'],
- LINKFLAGS='-fsanitize=address')
- # Only gcc >= 4.9 supports UBSan, so check both the version
- # and the command-line option before adding the compiler and
- # linker flags.
- elif GetOption('with_ubsan') and \
- compareVersions(main['GCC_VERSION'], '4.9') >= 0:
- main.Append(CCFLAGS='-fsanitize=undefined')
- main.Append(LINKFLAGS='-fsanitize=undefined')
-
elif main['CLANG']:
# Check for a supported version of clang, >= 3.1 is needed to
# support similar features as gcc 4.8. See
if sys.platform.startswith('freebsd'):
main.Append(LIBS=['thr'])
- # We require clang >= 3.1, so there is no need to check any
- # versions here.
- if GetOption('with_ubsan'):
- if GetOption('with_asan'):
- main.Append(CCFLAGS=['-fsanitize=address,undefined',
- '-fno-omit-frame-pointer'],
- LINKFLAGS='-fsanitize=address,undefined')
- else:
- main.Append(CCFLAGS='-fsanitize=undefined',
- LINKFLAGS='-fsanitize=undefined')
-
- elif GetOption('with_asan'):
- main.Append(CCFLAGS=['-fsanitize=address',
+# Add sanitizers flags
+sanitizers=[]
+if GetOption('with_ubsan'):
+ # Only gcc >= 4.9 supports UBSan, so check both the version
+ # and the command-line option before adding the compiler and
+ # linker flags.
+ if not main['GCC'] or compareVersions(main['GCC_VERSION'], '4.9') >= 0:
+ sanitizers.append('undefined')
+if GetOption('with_asan'):
+ # Available for gcc >= 4.8 or llvm >= 3.1 both a requirement
+ # by the build system
+ sanitizers.append('address')
+if sanitizers:
+ sanitizers = ','.join(sanitizers)
+ if main['GCC'] or main['CLANG']:
+ main.Append(CCFLAGS=['-fsanitize=%s' % sanitizers,
'-fno-omit-frame-pointer'],
- LINKFLAGS='-fsanitize=address')
+ LINKFLAGS='-fsanitize=%s' % sanitizers)
+ else:
+ warning("Don't know how to enable %s sanitizer(s) for your "
+ "compiler." % sanitizers)
# Set up common yacc/bison flags (needed for Ruby)
main['YACCFLAGS'] = '-d'
# verify that this stuff works
if not conf.CheckHeader('Python.h', '<>'):
- error("Check failed for Python.h header in", py_includes, "\n"
+ error("Check failed for Python.h header in",
+ ' '.join(py_includes), "\n"
"Two possible reasons:\n"
"1. Python headers are not installed (You can install the "
"package python-dev on Ubuntu and RedHat)\n"
# Add self to dict
if name in CpuModel.dict:
- raise AttributeError, "CpuModel '%s' already registered" % name
+ raise AttributeError("CpuModel '%s' already registered" % name)
CpuModel.dict[name] = self
Export('CpuModel')