Re: BUG #2162: Same as bug #1679 - finite() - unresolved symbol

From: "F(dot) Laupretre" <flconseil(at)yahoo(dot)fr>
To: <pgsql-bugs(at)postgresql(dot)org>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: BUG #2162: Same as bug #1679 - finite() - unresolved symbol
Date: 2006-01-11 20:42:09
Message-ID: ADECLLACEIPMLMCPIGGAKEACCCAA.flconseil@yahoo.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Thanks for your suggestion. It could have been the include files but I recompiled gcc on the system and it didn't change anything. Actually, I found the solution when I tried to understand why configure detects a finite() function on a system which does not have it.

First, I checked that there is no finite() function on my system: my libm.sl file is a symbolic link to libm.2, which does not contain this function. I don't know if it is the case for every HP-UX 11.11 system or if it is the result of a patch (as there is another file in /usr/lib, named libm.1, which contains the finite() function, probably for compatibility). And this symbol is not contained in any shared library under /usr (I checked them all).

When configure checks to see if we have finite(), it attempts to compile a small program containing 'dummy=finite(1.0)'. On my system, where I am using gcc 4.0.2, this small program is tested with a '-O2' flag, and the gcc optimizer is too smart ! It detects that we are writing to a dummy var, and it removes the line ! You can verify it with 'gcc -S -O2' or with 'nm' applied to the 'conftest' resulting executable file. After the call to finite() has been removed, of course, the program compiles fine (it is empty now) and configure wrongly concludes that we have finite().

In order for the check to be done correctly, we have to provide a program that the compiler cannot optimize, ie where it cannot detect that the call is useless, even if it is very very smart. Here is a patch with such a program. The fact of putting the call in a public function outside of main() forces the compiler to keep it, as it could be referenced from another file at link time.

$ diff configure.in configure.in.new
964c964
< [int dummy=finite(1.0);],
---
> [return 0; } int is_f(number) double number; { return finite(number); ]

After applying this patch on my system, everything works fine, HAVE_FINITE is not defined and float.c correctly switches to the isfinite() macro, defined in <math.h>.

Regards

François

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2006-01-11 20:49:44 Re: BUG #2162: Same as bug #1679 - finite() - unresolved symbol
Previous Message Michael Fuhr 2006-01-11 17:36:03 Re: createlang plpgsql failed