From 5970301a3c0072ef13fea45c03f17df65c9e0883 Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Wed, 20 May 2015 21:08:11 -0700 Subject: [PATCH] Add `USE_SSE` flag to allow build-time choise of SSE instructions for `libimagequant` --- SConstruct | 1 + src/build.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index ba42822be..c591c055c 100644 --- a/SConstruct +++ b/SConstruct @@ -412,6 +412,7 @@ opts.AddVariables( BoolVariable('NIK2IMG', 'Compile and install a utility to generate render a map to an image', 'True'), BoolVariable('COLOR_PRINT', 'Print build status information in color', 'True'), BoolVariable('BIGINT', 'Compile support for 64-bit integers in mapnik::value', 'True'), + EnumVariable('USE_SSE', 'Enable support for SSE vector instructions','yes',['yes','no','platform_default']) ) # variables to pickle after successful configure step diff --git a/src/build.py b/src/build.py index 9e9e81d64..1d613d232 100644 --- a/src/build.py +++ b/src/build.py @@ -346,11 +346,20 @@ source += Split( """) # libimagequant -lib_env.Append(CFLAGS = "-O3 -fno-math-errno -funroll-loops -fomit-frame-pointer -std=c99 -msse -mfpmath=sse") -# As of GCC 4.5, 387 fp math is significantly slower in C99 mode without this. -# Note: CPUs without SSE2 use 387 for doubles, even when SSE fp math is set. -if 'gcc' in env['CC']: +lib_env.Append(CFLAGS = "-O3 -fno-math-errno -funroll-loops -fomit-frame-pointer -std=c99") +if env["USE_SSE"] == "yes": + lib_env.Append(CFLAGS="-msse -mfpmath=sse") + # As of GCC 4.5, 387 fp math is significantly slower in C99 mode without this. + # Note: CPUs without SSE2 use 387 for doubles, even when SSE fp math is set. + if 'gcc' in env['CC']: lib_env.Append(CFLAGS='-fexcess-prevision=fast') +elif env["USE_SSE"] == "no": + lib_env.Append(CFLAGS="-mno-sse") +elif env["USE_SSE"] == "platform_default": + # Let compiler decide + None + + source += glob.glob("../deps/pngquant/" + "*.c") if env['RUNTIME_LINK'] == "static":