Solving all your MacPorts problems

Feedreader Screenshot

I just found the reason behind a bug in MacPorts that has been annoying the hell out of me the last few months: Sometimes, when installing new ports, the installation will die at the compilation stage with an error similar to this:

-DNDEBUG -g -O3 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -I/opt/local/include -I/opt/local/include/python2.5 -c _tkinter.c -o build/temp.macosx-10.3-i386-2.5/_tkinter.o
unable to execute -DNDEBUG: No such file or directory
error: command '-DNDEBUG' failed with exit status 1

Seems like the port doesn’t call gcc [args] to compile the binary, but only the [args], which often start with -DNDEBUG. (which, incidentally, is hard to google for, because of the minus sign.)

afb@macports.org has the reason for this:

It seems that those python ports are expecting $CC to be set in build as well as in configure, and fall back to random values such as “” or “cc” or “/usr/bin/gcc-4.0″ when it isn’t. This probably also explains why rerunning the build sometimes succeeds, if something else was adding a $CC to the environment that can be picked up as a lucky guess second time.

A workaround is setting the build.enc environment variable like so:

sudo su
password:
set build.env="CC=gcc"

and then run port. Here’s the ticket for more info.


About this entry