Well.. I haven't even gotten configure to run right yet. Issues:
1) WHen testing for sin(), the code uses (basically) this:
char sin();
int main() { sin(); }
Compiling this with '-g' or '-O3' works - you need a -lm to link.
*however*, 'xlc -O3 -qlibansi' tells the compiler that it *knows* about
ANSI-specified side effects for ANSI functions, and to optimize accordingly.
Well - sin() doesn't have side effects, and we don't look at errno, and
we don't assing the return value anyplace. Therefor, it's safe to optimize out.
This ends up convincing 'configure' that we don't need a -lm - so
then other stuff in -lm isn't found.
I seem to remeber some other bad juju involving massive inlining
and discarding of code when I tried -O4 once - it blew the
'checking for main in Xbsd|gdi32' tests because it optimized away
the entire world.
2) "char pow(); int main() { pow();}" blows the compiler up
if using 'xlc -O3 -qlibansi'. (sqrt() and probably a few others
do it as well - unclear why sin() and fmod() don't do this.
Now, all of this could be bypassed by simply not giving -qlibansi -
but it *does* allow a bunch more optimizaions, and only seems
to cause problems in Configure when we misprototype or use
dead code. ;)
Could the template code be changed to something like:
char doodah();
int main() { return (int) doodah();}
This would prevent it from over-optimizing and at least fix issue (1).
Issue 2 is, of course, a compiler bug pure and simple, and needs
to be fixed by IBM.
Off to bed, and hopefully it will go better in the morning. ;)
/Valdis
Show replies by date