main['LTO_CCFLAGS'] = []
main['LTO_LDFLAGS'] = []
+# According to the readme, tcmalloc works best if the compiler doesn't
+# assume that we're using the builtin malloc and friends. These flags
+# are compiler-specific, so we need to set them after we detect which
+# compiler we're using.
+main['TCMALLOC_CCFLAGS'] = []
+
CXX_version = readCommand([main['CXX'],'--version'], exception=False)
CXX_V = readCommand([main['CXX'],'-V'], exception=False)
Exit(1)
# Set up default C++ compiler flags
+if main['GCC'] or main['CLANG']:
+ # As gcc and clang share many flags, do the common parts here
+ main.Append(CCFLAGS=['-pipe'])
+ main.Append(CCFLAGS=['-fno-strict-aliasing'])
+ # Enable -Wall and then disable the few warnings that we
+ # consistently violate
+ main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef'])
+ # We always compile using C++11, but only gcc >= 4.7 and clang 3.1
+ # actually use that name, so we stick with c++0x
+ main.Append(CXXFLAGS=['-std=c++0x'])
+ # Add selected sanity checks from -Wextra
+ main.Append(CXXFLAGS=['-Wmissing-field-initializers',
+ '-Woverloaded-virtual'])
+else:
+ print termcap.Yellow + termcap.Bold + 'Error' + termcap.Normal,
+ print "Don't know what compiler options to use for your compiler."
+ print termcap.Yellow + ' compiler:' + termcap.Normal, main['CXX']
+ print termcap.Yellow + ' version:' + termcap.Normal,
+ if not CXX_version:
+ print termcap.Yellow + termcap.Bold + "COMMAND NOT FOUND!" +\
+ termcap.Normal
+ else:
+ print CXX_version.replace('\n', '<nl>')
+ print " If you're trying to use a compiler other than GCC"
+ print " or clang, there appears to be something wrong with your"
+ print " environment."
+ print " "
+ print " If you are trying to use a compiler other than those listed"
+ print " above you will need to ease fix SConstruct and "
+ print " src/SConscript to support that compiler."
+ Exit(1)
+
if main['GCC']:
# Check for a supported version of gcc, >= 4.4 is needed for c++0x
# support. See http://gcc.gnu.org/projects/cxx0x.html for details
Exit(1)
main['GCC_VERSION'] = gcc_version
- main.Append(CCFLAGS=['-pipe'])
- main.Append(CCFLAGS=['-fno-strict-aliasing'])
- main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef'])
- main.Append(CXXFLAGS=['-Wmissing-field-initializers'])
- main.Append(CXXFLAGS=['-std=c++0x'])
# Check for versions with bugs
if not compareVersions(gcc_version, '4.4.1') or \
main['LTO_LDFLAGS'] = ['-flto=%d' % GetOption('num_jobs'),
'-fuse-linker-plugin']
+ main.Append(TCMALLOC_CCFLAGS=['-fno-builtin-malloc', '-fno-builtin-calloc',
+ '-fno-builtin-realloc', '-fno-builtin-free'])
+
elif main['CLANG']:
# Check for a supported version of clang, >= 2.9 is needed to
# support similar features as gcc 4.4. See
print 'Error: Unable to determine clang version.'
Exit(1)
- main.Append(CCFLAGS=['-pipe'])
- main.Append(CCFLAGS=['-fno-strict-aliasing'])
- main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef'])
- main.Append(CCFLAGS=['-Wno-tautological-compare'])
- main.Append(CCFLAGS=['-Wno-self-assign'])
- # Ruby makes frequent use of extraneous parantheses in the printing
- # of if-statements
- main.Append(CCFLAGS=['-Wno-parentheses'])
- main.Append(CXXFLAGS=['-Wmissing-field-initializers'])
- main.Append(CXXFLAGS=['-std=c++0x'])
+ # clang has a few additional warnings that we disable,
+ # tautological comparisons are allowed due to unsigned integers
+ # being compared to constants that happen to be 0, and extraneous
+ # parantheses are allowed due to Ruby's printing of the AST,
+ # finally self assignments are allowed as the generated CPU code
+ # is relying on this
+ main.Append(CCFLAGS=['-Wno-tautological-compare',
+ '-Wno-parentheses',
+ '-Wno-self-assign'])
+
+ main.Append(TCMALLOC_CCFLAGS=['-fno-builtin'])
+
# On Mac OS X/Darwin we need to also use libc++ (part of XCode) as
# opposed to libstdc++ to make the transition from TR1 to
# C++11. See http://libcxx.llvm.org. However, clang has chosen a
print ' Installed version:', swig_version[2]
Exit(1)
+if swig_version[2] == "2.0.9":
+ print '\n' + termcap.Yellow + termcap.Bold + \
+ 'Warning: SWIG version 2.0.9 sometimes generates broken code.\n' + \
+ termcap.Normal + \
+ 'This problem only affects some platforms and some Python\n' + \
+ 'versions. See the following SWIG bug report for details:\n' + \
+ 'http://sourceforge.net/p/swig/bugs/1297/\n'
+
+
# Set up SWIG flags & scanner
swig_flags=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS')
main.Append(SWIGFLAGS=swig_flags)
# shared library in prefix/lib/.
if not py_getvar('Py_ENABLE_SHARED'):
py_lib_path.append(py_getvar('LIBPL'))
+ # Python requires the flags in LINKFORSHARED to be added the
+ # linker flags when linking with a statically with Python. Failing
+ # to do so can lead to errors from the Python's dynamic module
+ # loader at start up.
+ main.Append(LINKFLAGS=[py_getvar('LINKFORSHARED').split()])
py_libs = []
for lib in py_getvar('LIBS').split() + py_getvar('SYSLIBS').split():
conf.CheckLibWithHeader('rt', 'time.h', 'C',
'clock_nanosleep(0,0,NULL,NULL);')
-if conf.CheckLib('tcmalloc_minimal'):
- have_tcmalloc = True
+if conf.CheckLib('tcmalloc'):
+ main.Append(CCFLAGS=main['TCMALLOC_CCFLAGS'])
+elif conf.CheckLib('tcmalloc_minimal'):
+ main.Append(CCFLAGS=main['TCMALLOC_CCFLAGS'])
else:
- have_tcmalloc = False
print termcap.Yellow + termcap.Bold + \
"You can get a 12% performance improvement by installing tcmalloc "\
"(libgoogle-perftools-dev package on Ubuntu or RedHat)." + \
print "Warning: Header file <fenv.h> not found."
print " This host has no IEEE FP rounding mode control."
+# Check if we should enable KVM-based hardware virtualization
+have_kvm = conf.CheckHeader('linux/kvm.h', '<>')
+if not have_kvm:
+ print "Info: Header file <linux/kvm.h> not found, " \
+ "disabling KVM support."
+
+# Check if the requested target ISA is compatible with the host
+def is_isa_kvm_compatible(isa):
+ isa_comp_table = {
+ "arm" : ( "armv7l" ),
+ }
+ try:
+ import platform
+ host_isa = platform.machine()
+ except:
+ print "Warning: Failed to determine host ISA."
+ return False
+
+ return host_isa in isa_comp_table.get(isa, [])
+
+
######################################################################
#
# Finish the configuration
BoolVariable('USE_POSIX_CLOCK', 'Use POSIX Clocks', have_posix_clock),
BoolVariable('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
BoolVariable('CP_ANNOTATE', 'Enable critical path annotation capability', False),
+ BoolVariable('USE_KVM', 'Enable hardware virtualized (KVM) CPU models', have_kvm),
EnumVariable('PROTOCOL', 'Coherence protocol for Ruby', 'None',
all_protocols),
)
if env['EFENCE']:
env.Append(LIBS=['efence'])
+ if env['USE_KVM']:
+ if not have_kvm:
+ print "Warning: Can not enable KVM, host seems to lack KVM support"
+ env['USE_KVM'] = False
+ elif not is_isa_kvm_compatible(env['TARGET_ISA']):
+ print "Info: KVM support disabled due to unsupported host and " \
+ "target ISA combination"
+ env['USE_KVM'] = False
+
# Save sticky variable settings back to current variables file
sticky_vars.Save(current_vars_file, env)
if env['USE_SSE2']:
env.Append(CCFLAGS=['-msse2'])
- if have_tcmalloc:
- env.Append(LIBS=['tcmalloc_minimal'])
-
# The src/SConscript file sets up the build rules in 'env' according
# to the configured variables. It returns a list of environments,
# one for each variant build (debug, opt, etc.)