diff -r 2332df8332f7 -r d0e979f2644c SConstruct --- a/SConstruct Mon Jul 02 18:21:04 2012 +0100 +++ b/SConstruct Mon Jul 02 18:33:25 2012 +0100 @@ -167,6 +167,8 @@ help='Disable style checking hooks') AddLocalOption('--lto', dest='lto', action='store_true', help='Enable Link-Time Optimization') +AddLocalOption('--native', dest='native', action='store_true', + help='Automatically optimise for native CPU features') AddLocalOption('--update-ref', dest='update_ref', action='store_true', help='Update test reference outputs') AddLocalOption('--verbose', dest='verbose', action='store_true', @@ -504,6 +506,18 @@ not compareVersions(gcc_version, '4.4.2'): print 'Info: Tree vectorizer in GCC 4.4.1 & 4.4.2 is buggy, disabling.' main.Append(CCFLAGS=['-fno-tree-vectorize']) + + if compareVersions(gcc_version, '4.2') >= 0: + # If using native optimisation, append the appropriate + # flag. Note that support was only added in gcc 4.2. + if GetOption('native'): + # Append the flag to the compiler flags + main.Append(CCFLAGS = ['-march=native']) + else: + print termcap.Yellow + termcap.Bold + \ + "Assuming you are compiling and executing on homogenous "\ + "architectures, using --native may speed up execution." + \ + termcap.Normal if compareVersions(gcc_version, '4.6') >= 0: main.Append(CXXFLAGS=['-std=c++0x']) # Determine the appropriate Link-Time Optimization (LTO) flags @@ -555,6 +569,18 @@ if compareVersions(clang_version, "3") >= 0: main.Append(CXXFLAGS=['-std=c++0x']) + + # If using native optimisation, append the appropriate + # flag. Versions pre-dating 3.0 has known issues, so restrict + # it to >= 3. + if GetOption('native'): + # Append the flag to the compiler flags + main.Append(CCFLAGS = ['-march=native']) + else: + print termcap.Yellow + termcap.Bold + \ + "Assuming you are compiling and executing on homogenous "\ + "architectures, using --native may speed up execution." + \ + termcap.Normal else: print termcap.Yellow + termcap.Bold + 'Error' + termcap.Normal, print "Don't know what compiler options to use for your compiler."