2 important facts:
- A test C program, using one of the "undefined" functions (isnan)
compiles with GCC and runs
- I went in by hand and temporarily replaced each version of math.h on
my computer with a version that has the necessary functions defined.
Cabal-install still failed with the same error.
This makes it seem like cabal doesn't have access to _any_ math.h
file, but if this were the case, wouldn't I get many more
undefined-function errors than I do?
Unless you are using an older ghc with -fvia-C, <math.h> is not used or useful. The modern -fasm codegen doesn't know what to do with C-level declarations. If your <math.h> is using macros to define gamma as something else, you will need to find that something else or use a wrapper library.
I note that OS X doesn't have a gamma(). There are lgamma() and tgamma() and variations thereon. (and no related macros in <math.h>, confirming that it is not related.)