Don't force CFLAGS="-O3"
I wound up adding this patch in Gentoo but forgot to mention it here. The tl;dr is that we want users to be able to set CFLAGS
in the environment and have it be respected by the build systems of all C
packages. With an autotools package, this patch would look something like
--- a/Makefile.am
+++ b/Makefile.am
...
- CFLAGS = -O3
+ CFLAGS ?= -O3
but to keep the patch small, I just deleted -O3
in a few places within sympow's Configure
script.
diff --git a/Configure b/Configure
index 1ef9756..fd5555c 100755
--- a/Configure
+++ b/Configure
@@ -104,15 +104,12 @@ CFLAGS=''
# return 2 if we did not add $FLAG.
try_add_CFLAG()
{
- # We use -O3 here to really force generation of fused
- # multiply-add instructions and to keep floats as much as
- # possible in registers.
# We compile in the fpu.c which only does
# something if the macro x86 is defined.
local flag=$1 # first argument: C FLAG to test
local bypassfputest=${2:-nobypass} # second argument: whether or not bypass the numerical test (default: not)
local status=0
- if $CC $ORIGINALCFLAGS -Werror $CFLAGS -O3 $flag config/fpubits1.c config/fpubits2.c fpu.c -o config/fpubits 2>/dev/null; then
+ if $CC $ORIGINALCFLAGS -Werror $CFLAGS $flag config/fpubits1.c config/fpubits2.c fpu.c -o config/fpubits 2>/dev/null; then
# Compiled successfully, now run it
config/fpubits >/dev/null 2>/dev/null
status=$?
@@ -166,7 +163,7 @@ for FLAG in '' '-ffloat-store' '-O0'; do
done
# Check the actual FPU precision with our new flags.
-CC_ARGS="$ORIGINALCFLAGS -O3 $CFLAGS config/fpubits1.c config/fpubits2.c fpu.c -o config/fpubits"
+CC_ARGS="$ORIGINALCFLAGS $CFLAGS config/fpubits1.c config/fpubits2.c fpu.c -o config/fpubits"
$CC $CC_ARGS
if [ $? -ne 0 ]; then
echo >&2 "Error: the command below failed:"
@@ -256,7 +253,7 @@ echo "CONFEXE = config/endiantuple config/fpubits" >> $FILE
##
##echo "DEFS = $DEFS" >> $FILE
-OPT="-O3 ${CFLAGS}" && echo "OPT = $OPT" >> $FILE
+OPT="${CFLAGS}" && echo "OPT = $OPT" >> $FILE
echo "H2MFLAGS = \\" >> $FILE
echo " --manual=\"SYMPOW package\" \\" >> $FILE
--
Any other solution that lets the user's CFLAGS
take precedence would be fine as well.