diff --git a/SConstruct b/SConstruct index a525990..fd66c23 100644 --- a/SConstruct +++ b/SConstruct @@ -75,6 +75,12 @@ vars.Add(EnumVariable( vars.Add(BoolVariable( 'profile', 'build with profiling information', False)) +vars.Add( + 'arch', + 'target CPU passed to -march in the \'fast\' build, e.g. \'native\' for local ' + 'builds or \'x86-64-v3\' for a portable AVX2 deployment. Empty means no -march. ' + 'Defaults to the OBJCRYST_ARCH environment variable if set.', + os.environ.get('OBJCRYST_ARCH', '')) vars.Update(env) # Use C++ compiler specified by the 'tool' option. @@ -184,6 +190,8 @@ else: else: env.AppendUnique(CCFLAGS=['-fno-strict-aliasing']) fast_opts = ['-ffast-math'] + if env.get('arch'): + fast_opts.append('-march=' + env['arch']) if env['PLATFORM'] == 'darwin': # macOS bundle diff --git a/news/compile_arch.rst b/news/compile_arch.rst new file mode 100644 index 0000000..f1a594d --- /dev/null +++ b/news/compile_arch.rst @@ -0,0 +1,23 @@ +**Added:** + +* Add SCons ``arch`` option to set architecture during compilation. By default, no arch is specified. + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +*