SConstruct (9419:54d5c0e5852a) SConstruct (9420:965d857ac791)
1# -*- mode:python -*-
2
3# Copyright (c) 2011 Advanced Micro Devices, Inc.
4# Copyright (c) 2009 The Hewlett-Packard Development Company
5# Copyright (c) 2004-2005 The Regents of The University of Michigan
6# All rights reserved.
7#
8# Redistribution and use in source and binary forms, with or without

--- 502 unchanged lines hidden (view full) ---

511main['GCC'] = CXX_version and CXX_version.find('g++') >= 0
512main['CLANG'] = CXX_version and CXX_version.find('clang') >= 0
513if main['GCC'] + main['CLANG'] > 1:
514 print 'Error: How can we have two at the same time?'
515 Exit(1)
516
517# Set up default C++ compiler flags
518if main['GCC']:
1# -*- mode:python -*-
2
3# Copyright (c) 2011 Advanced Micro Devices, Inc.
4# Copyright (c) 2009 The Hewlett-Packard Development Company
5# Copyright (c) 2004-2005 The Regents of The University of Michigan
6# All rights reserved.
7#
8# Redistribution and use in source and binary forms, with or without

--- 502 unchanged lines hidden (view full) ---

511main['GCC'] = CXX_version and CXX_version.find('g++') >= 0
512main['CLANG'] = CXX_version and CXX_version.find('clang') >= 0
513if main['GCC'] + main['CLANG'] > 1:
514 print 'Error: How can we have two at the same time?'
515 Exit(1)
516
517# Set up default C++ compiler flags
518if main['GCC']:
519 # Check for a supported version of gcc, >= 4.4 is needed for c++0x
520 # support. See http://gcc.gnu.org/projects/cxx0x.html for details
521 gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False)
522 if compareVersions(gcc_version, "4.4") < 0:
523 print 'Error: gcc version 4.4 or newer required.'
524 print ' Installed version:', gcc_version
525 Exit(1)
526
527 main['GCC_VERSION'] = gcc_version
519 main.Append(CCFLAGS=['-pipe'])
520 main.Append(CCFLAGS=['-fno-strict-aliasing'])
521 main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef'])
528 main.Append(CCFLAGS=['-pipe'])
529 main.Append(CCFLAGS=['-fno-strict-aliasing'])
530 main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef'])
522 # Read the GCC version to check for versions with bugs
523 # Note CCVERSION doesn't work here because it is run with the CC
524 # before we override it from the command line
525 gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False)
526 main['GCC_VERSION'] = gcc_version
531 main.Append(CXXFLAGS=['-std=c++0x'])
532
533 # Check for versions with bugs
527 if not compareVersions(gcc_version, '4.4.1') or \
528 not compareVersions(gcc_version, '4.4.2'):
529 print 'Info: Tree vectorizer in GCC 4.4.1 & 4.4.2 is buggy, disabling.'
530 main.Append(CCFLAGS=['-fno-tree-vectorize'])
534 if not compareVersions(gcc_version, '4.4.1') or \
535 not compareVersions(gcc_version, '4.4.2'):
536 print 'Info: Tree vectorizer in GCC 4.4.1 & 4.4.2 is buggy, disabling.'
537 main.Append(CCFLAGS=['-fno-tree-vectorize'])
531 # c++0x support in gcc is useful already from 4.4, see
532 # http://gcc.gnu.org/projects/cxx0x.html for details
533 if compareVersions(gcc_version, '4.4') >= 0:
534 main.Append(CXXFLAGS=['-std=c++0x'])
535
536 # LTO support is only really working properly from 4.6 and beyond
537 if compareVersions(gcc_version, '4.6') >= 0:
538 # Add the appropriate Link-Time Optimization (LTO) flags
539 # unless LTO is explicitly turned off. Note that these flags
540 # are only used by the fast target.
541 if not GetOption('no_lto'):
542 # Pass the LTO flag when compiling to produce GIMPLE
543 # output, we merely create the flags here and only append
544 # them later/
545 main['LTO_CCFLAGS'] = ['-flto=%d' % GetOption('num_jobs')]
546
547 # Use the same amount of jobs for LTO as we are running
548 # scons with, we hardcode the use of the linker plugin
549 # which requires either gold or GNU ld >= 2.21
550 main['LTO_LDFLAGS'] = ['-flto=%d' % GetOption('num_jobs'),
551 '-fuse-linker-plugin']
552
553elif main['CLANG']:
538
539 # LTO support is only really working properly from 4.6 and beyond
540 if compareVersions(gcc_version, '4.6') >= 0:
541 # Add the appropriate Link-Time Optimization (LTO) flags
542 # unless LTO is explicitly turned off. Note that these flags
543 # are only used by the fast target.
544 if not GetOption('no_lto'):
545 # Pass the LTO flag when compiling to produce GIMPLE
546 # output, we merely create the flags here and only append
547 # them later/
548 main['LTO_CCFLAGS'] = ['-flto=%d' % GetOption('num_jobs')]
549
550 # Use the same amount of jobs for LTO as we are running
551 # scons with, we hardcode the use of the linker plugin
552 # which requires either gold or GNU ld >= 2.21
553 main['LTO_LDFLAGS'] = ['-flto=%d' % GetOption('num_jobs'),
554 '-fuse-linker-plugin']
555
556elif main['CLANG']:
557 # Check for a supported version of clang, >= 2.9 is needed to
558 # support similar features as gcc 4.4. See
559 # http://clang.llvm.org/cxx_status.html for details
554 clang_version_re = re.compile(".* version (\d+\.\d+)")
555 clang_version_match = clang_version_re.match(CXX_version)
556 if (clang_version_match):
557 clang_version = clang_version_match.groups()[0]
558 if compareVersions(clang_version, "2.9") < 0:
559 print 'Error: clang version 2.9 or newer required.'
560 print ' Installed version:', clang_version
561 Exit(1)

--- 4 unchanged lines hidden (view full) ---

566 main.Append(CCFLAGS=['-pipe'])
567 main.Append(CCFLAGS=['-fno-strict-aliasing'])
568 main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef'])
569 main.Append(CCFLAGS=['-Wno-tautological-compare'])
570 main.Append(CCFLAGS=['-Wno-self-assign'])
571 # Ruby makes frequent use of extraneous parantheses in the printing
572 # of if-statements
573 main.Append(CCFLAGS=['-Wno-parentheses'])
560 clang_version_re = re.compile(".* version (\d+\.\d+)")
561 clang_version_match = clang_version_re.match(CXX_version)
562 if (clang_version_match):
563 clang_version = clang_version_match.groups()[0]
564 if compareVersions(clang_version, "2.9") < 0:
565 print 'Error: clang version 2.9 or newer required.'
566 print ' Installed version:', clang_version
567 Exit(1)

--- 4 unchanged lines hidden (view full) ---

572 main.Append(CCFLAGS=['-pipe'])
573 main.Append(CCFLAGS=['-fno-strict-aliasing'])
574 main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef'])
575 main.Append(CCFLAGS=['-Wno-tautological-compare'])
576 main.Append(CCFLAGS=['-Wno-self-assign'])
577 # Ruby makes frequent use of extraneous parantheses in the printing
578 # of if-statements
579 main.Append(CCFLAGS=['-Wno-parentheses'])
580 main.Append(CXXFLAGS=['-std=c++0x'])
581 # On Mac OS X/Darwin we need to also use libc++ (part of XCode) as
582 # opposed to libstdc++ to make the transition from TR1 to
583 # C++11. See http://libcxx.llvm.org. However, clang has chosen a
584 # strict implementation of the C++11 standard, and does not allow
585 # incomplete types in template arguments (besides unique_ptr and
586 # shared_ptr), and the libc++ STL containers create problems in
587 # combination with the current gem5 code. For now, we stick with
588 # libstdc++ and use the TR1 namespace.
589 # if sys.platform == "darwin":
590 # main.Append(CXXFLAGS=['-stdlib=libc++'])
574
591
575 # clang 2.9 does not play well with c++0x as it ships with C++
576 # headers that produce errors, this was fixed in 3.0
577 if compareVersions(clang_version, "3") >= 0:
578 main.Append(CXXFLAGS=['-std=c++0x'])
579else:
580 print termcap.Yellow + termcap.Bold + 'Error' + termcap.Normal,
581 print "Don't know what compiler options to use for your compiler."
582 print termcap.Yellow + ' compiler:' + termcap.Normal, main['CXX']
583 print termcap.Yellow + ' version:' + termcap.Normal,
584 if not CXX_version:
585 print termcap.Yellow + termcap.Bold + "COMMAND NOT FOUND!" +\
586 termcap.Normal

--- 119 unchanged lines hidden (view full) ---

706 asm(".globl _x; _x: .byte 0");
707 extern int x;
708 int main() { return x; }
709 ''', extension=".c")
710 context.env.Append(LEADING_UNDERSCORE=ret)
711 context.Result(ret)
712 return ret
713
592else:
593 print termcap.Yellow + termcap.Bold + 'Error' + termcap.Normal,
594 print "Don't know what compiler options to use for your compiler."
595 print termcap.Yellow + ' compiler:' + termcap.Normal, main['CXX']
596 print termcap.Yellow + ' version:' + termcap.Normal,
597 if not CXX_version:
598 print termcap.Yellow + termcap.Bold + "COMMAND NOT FOUND!" +\
599 termcap.Normal

--- 119 unchanged lines hidden (view full) ---

719 asm(".globl _x; _x: .byte 0");
720 extern int x;
721 int main() { return x; }
722 ''', extension=".c")
723 context.env.Append(LEADING_UNDERSCORE=ret)
724 context.Result(ret)
725 return ret
726
714# Test for the presence of C++11 static asserts. If the compiler lacks
715# support for static asserts, base/compiler.hh enables a macro that
716# removes any static asserts in the code.
717def CheckStaticAssert(context):
718 context.Message("Checking for C++11 static_assert support...")
719 ret = context.TryCompile('''
720 static_assert(1, "This assert is always true");
721 ''', extension=".cc")
722 context.env.Append(HAVE_STATIC_ASSERT=ret)
723 context.Result(ret)
724 return ret
725
726# Platform-specific configuration. Note again that we assume that all
727# builds under a given build root run on the same host platform.
728conf = Configure(main,
729 conf_dir = joinpath(build_root, '.scons_config'),
730 log_file = joinpath(build_root, 'scons_config.log'),
727# Platform-specific configuration. Note again that we assume that all
728# builds under a given build root run on the same host platform.
729conf = Configure(main,
730 conf_dir = joinpath(build_root, '.scons_config'),
731 log_file = joinpath(build_root, 'scons_config.log'),
731 custom_tests = { 'CheckLeading' : CheckLeading,
732 'CheckStaticAssert' : CheckStaticAssert,
733 })
732 custom_tests = { 'CheckLeading' : CheckLeading })
734
735# Check for leading underscores. Don't really need to worry either
736# way so don't need to check the return code.
737conf.CheckLeading()
738
733
734# Check for leading underscores. Don't really need to worry either
735# way so don't need to check the return code.
736conf.CheckLeading()
737
739# Check for C++11 features we want to use if they exist
740conf.CheckStaticAssert()
741
742# Check if we should compile a 64 bit binary on Mac OS X/Darwin
743try:
744 import platform
745 uname = platform.uname()
746 if uname[0] == 'Darwin' and compareVersions(uname[2], '9.0.0') >= 0:
747 if int(readCommand('sysctl -n hw.cpu64bit_capable')[0]):
748 main.Append(CCFLAGS=['-arch', 'x86_64'])
749 main.Append(CFLAGS=['-arch', 'x86_64'])

--- 225 unchanged lines hidden (view full) ---

975 BoolVariable('USE_POSIX_CLOCK', 'Use POSIX Clocks', have_posix_clock),
976 BoolVariable('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
977 BoolVariable('CP_ANNOTATE', 'Enable critical path annotation capability', False),
978 EnumVariable('PROTOCOL', 'Coherence protocol for Ruby', 'None',
979 all_protocols),
980 )
981
982# These variables get exported to #defines in config/*.hh (see src/SConscript).
738# Check if we should compile a 64 bit binary on Mac OS X/Darwin
739try:
740 import platform
741 uname = platform.uname()
742 if uname[0] == 'Darwin' and compareVersions(uname[2], '9.0.0') >= 0:
743 if int(readCommand('sysctl -n hw.cpu64bit_capable')[0]):
744 main.Append(CCFLAGS=['-arch', 'x86_64'])
745 main.Append(CFLAGS=['-arch', 'x86_64'])

--- 225 unchanged lines hidden (view full) ---

971 BoolVariable('USE_POSIX_CLOCK', 'Use POSIX Clocks', have_posix_clock),
972 BoolVariable('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
973 BoolVariable('CP_ANNOTATE', 'Enable critical path annotation capability', False),
974 EnumVariable('PROTOCOL', 'Coherence protocol for Ruby', 'None',
975 all_protocols),
976 )
977
978# These variables get exported to #defines in config/*.hh (see src/SConscript).
983export_vars += ['USE_FENV', 'SS_COMPATIBLE_FP',
984 'TARGET_ISA', 'CP_ANNOTATE', 'USE_POSIX_CLOCK', 'PROTOCOL',
985 'HAVE_STATIC_ASSERT', 'HAVE_PROTOBUF']
979export_vars += ['USE_FENV', 'SS_COMPATIBLE_FP', 'TARGET_ISA', 'CP_ANNOTATE',
980 'USE_POSIX_CLOCK', 'PROTOCOL', 'HAVE_PROTOBUF']
986
987###################################################
988#
989# Define a SCons builder for configuration flag headers.
990#
991###################################################
992
993# This function generates a config header file that #defines the

--- 181 unchanged lines hidden ---
981
982###################################################
983#
984# Define a SCons builder for configuration flag headers.
985#
986###################################################
987
988# This function generates a config header file that #defines the

--- 181 unchanged lines hidden ---