From 3537350143bf59c2c54e72296de592a2073a8915 Mon Sep 17 00:00:00 2001 From: Clemens Schmid Date: Mon, 24 Aug 2026 18:30:34 +0200 Subject: [PATCH] add arch flag to scons build command scons arch=native lib # local scons arch=x86-64-v3 lib # portable AVX2 deploy scons lib # default: no -march (unchanged behaviour) or via $ export OBJCRYST_ARCH=x86-64-v3 --- SConstruct | 8 ++++++++ src/SConscript | 2 ++ 2 files changed, 10 insertions(+) diff --git a/SConstruct b/SConstruct index 6e566173..cb747f49 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 53d58878..98fdde7b 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':