I'm seeing a variation of this bug in python 2.5.
As far as I can tell in python 2.4.3 on linux it passes BASECFLAGS and OPT, appending CFLAGS from the environment to that if set. In python 2.5 it passes CFLAGS from the Makefile (which is defined as $(BASECFLAGS) $(OPT) $(EXTRA_CFLAGS)), or OPT and the CFLAGS from the environment if CFLAGS is set there (this change was made in revision 45232). That means that if you run setup.py with CFLAGS set they must include -fno-strict-aliasing if using python 2.5.
I think it would be preferable to prepend BASECFLAGS instead of OPT if CFLAGS is set in the environment. On my linux machine after building python 2.5 with CFLAGS set to "-O2 -march=athlon-xp" the Makefile has:
OPT= -DNDEBUG -g -O3 -Wall -Wstrict-prototypes
BASECFLAGS= -fno-strict-aliasing
CFLAGS= $(BASECFLAGS) $(OPT) $(EXTRA_CFLAGS)
If I run a setup.py with CFLAGS unset it runs:
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC ...
Which is reasonable. If I run it with CFLAGS="-O2 -march=athlon-xp":
gcc -pthread -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -O2 -march=athlon-xp -fPIC ...
Which misses -fno-strict-aliasing and still includes all the general flags that I'm trying to set through CFLAGS.
If it used BASECFLAGS from the Makefile instead of OPT it would be:
gcc -pthread -fno-strict-aliasing -O2 -march=athlon-xp -fPIC ...
Which is what I think is the desired result here. |