diff --git a/SConstruct b/SConstruct index 6e56617..cb747f4 100644 --- a/SConstruct +++ b/SConstruct @@ -133,6 +133,14 @@ vars.Add(BoolVariable( vars.Add(BoolVariable( 'with_shared_cctbx', 'compile and link with the shared cctbx library', False)) +vars.Add( + 'arch', + 'target CPU passed to -march in the \'fast\' build. Empty (the default) means ' + 'no -march => maximum portability. Set \'x86-64-v3\' for a portable AVX2/FMA ' + 'build (Intel Haswell 2013+, AMD Zen 2017+), \'native\' for a machine-specific ' + 'build, or \'x86-64-v4\' for AVX-512. Also settable via the OBJCRYST_ARCH ' + 'environment variable.', + os.environ.get('OBJCRYST_ARCH', '')) vars.Update(env) env.Help(MY_SCONS_HELP % vars.GenerateHelpText(env)) diff --git a/src/SConscript b/src/SConscript index 53d5887..98fdde7 100644 --- a/src/SConscript +++ b/src/SConscript @@ -44,6 +44,8 @@ else: # g++ options env.PrependUnique(CCFLAGS=['-Wall']) fast_optimflags = ['-ffast-math'] + if env.get('arch'): + fast_optimflags.append('-march=' + env['arch']) # Configure build variants if env['build'] == 'debug':