After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 128136 - plugins/fn-math/functions.c doesn't compile on NetBSD/sparc-1.5
plugins/fn-math/functions.c doesn't compile on NetBSD/sparc-1.5
Status: RESOLVED FIXED
Product: Gnumeric
Classification: Applications
Component: Compilation
1.2.x
Other All
: Normal major
: ---
Assigned To: Jody Goldberg
Jody Goldberg
: 128123 128124 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2003-11-28 19:11 UTC by Adrian Bunk
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed fix (3.44 KB, patch)
2003-11-30 01:30 UTC, Adrian Bunk
none Details | Review
updated patch (after discussion on irc with gmorten and JHM) (3.42 KB, patch)
2003-12-01 20:55 UTC, Adrian Bunk
none Details | Review

Description Adrian Bunk 2003-11-28 19:11:49 UTC
This is a followup of bug #124951

I got the following compile error in Gnumeric 1.2.2 on NetBSD/sparc-1.5:

<--  snip  -->

...
-Wall -Wmissing-prototypes -Wsign-compare -Wpointer-arith -Wnested-externs
-Wchar-subscripts -Wwrite-strings -D_POSIX_SOURCE -D__EXTENSIONS__
-D_BSD_SOURCE -c functions.c  -fPIC -DPIC -o .libs/functions.o
functions.c:923: warning: #warning improve error handling.  Relying on
value_new_float to do it is cheesy
functions.c: In function `gnumeric_acosh':
functions.c:338: warning: implicit declaration of function `acosh'
functions.c: In function `gnumeric_asinh':
functions.c:395: warning: implicit declaration of function `asinh'
functions.c: In function `gnumeric_atanh':
functions.c:453: warning: implicit declaration of function `atanh'
functions.c: In function `gnumeric_fact':
functions.c:888: warning: implicit declaration of function `lgamma'
functions.c:889: `signgam' undeclared (first use in this function)
functions.c:889: (Each undeclared identifier is reported only once
functions.c:889: for each function it appears in.)
gmake[3]: *** [functions.lo] Error 1
gmake[3]: Leaving directory `/aux/adrian/build/gnumeric-1.2.2/plugins/fn-math'

<--  snip  -->
Comment 1 Morten Welinder 2003-11-28 23:05:55 UTC
This one looks like your c library is deficient.  Please have a look
at "man lgamma" and see what it says about the sign of the gamma function.
Comment 2 Adrian Bunk 2003-11-29 04:32:12 UTC
The problem is, that the Gnumeric configure script adds
-D_POSIX_SOURCE to the CFLAGS without adding a -D_XOPEN_SOURCE

From /usr/include/math.h (note that on NetBSD 1.5 _POSIX_SOURCE
implicitely defines _POSIX_C_SOURCE):

<--  snip  -->

...
/*
 * XOPEN/SVID
 */
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) || \
    defined(_XOPEN_SOURCE)
#define M_E             2.7182818284590452354   /* e */
#define M_LOG2E         1.4426950408889634074   /* log 2e */
#define M_LOG10E        0.43429448190325182765  /* log 10e */
#define M_LN2           0.69314718055994530942  /* log e2 */
#define M_LN10          2.30258509299404568402  /* log e10 */
#define M_PI            3.14159265358979323846  /* pi */
#define M_PI_2          1.57079632679489661923  /* pi/2 */
#define M_PI_4          0.78539816339744830962  /* pi/4 */
#define M_1_PI          0.31830988618379067154  /* 1/pi */
#define M_2_PI          0.63661977236758134308  /* 2/pi */
#define M_2_SQRTPI      1.12837916709551257390  /* 2/sqrt(pi) */
#define M_SQRT2         1.41421356237309504880  /* sqrt(2) */
#define M_SQRT1_2       0.70710678118654752440  /* 1/sqrt(2) */

#define MAXFLOAT        ((float)3.40282346638528860e+38)
extern int signgam;
#endif /* !_ANSI_SOURCE && !_POSIX_C_SOURCE || _XOPEN_SOURCE */
...
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) || \
    defined(_XOPEN_SOURCE)
double  erf __P((double));
double  erfc __P((double));
double  gamma __P((double));
double  hypot __P((double, double));
int     isnan __P((double));
int     finite __P((double));
double  j0 __P((double));
double  j1 __P((double));
double  jn __P((int, double));
double  lgamma __P((double));
double  y0 __P((double));
double  y1 __P((double));
double  yn __P((int, double));
...

<--  snip  -->
Comment 3 Morten Welinder 2003-11-29 15:54:45 UTC
This might become ugly...

In configure.in, try adding this before line 214:

	# That, unfortunately, turns off stuff on NETBSD.
	AC_MSG_CHECKING([whether -D_XOPEN_SOURCE is needed for signgam])
	AC_TRY_COMPILE([#include <math.h>], [if ((lgamma(-1.5),signgam) ==
0);], need_xopen=no, need_xopen=yes)
	AC_MSG_RESULT($need_xopen)
	if test $need_xopen = yes ; then
		CFLAGS="$CFLAGS -D_XOPEN_SOURCE"
	fi

jody: have a look around current line 214.  Isn't that an awful mess
between need_ext and need_posix?
Comment 4 Adrian Bunk 2003-11-29 16:19:18 UTC
This would most likely work, but let me point to a problem in this code:

if test $need_xopen = yes ; then
	CFLAGS="$CFLAGS -D_XOPEN_SOURCE"
fi


If the sgngam test fails for a different reason, -D_XOPEN_SOURCE is
defined without being needed.

This needs to be something like

if test $need_xopen = yes ; then
	CFLAGS="$CFLAGS -D_XOPEN_SOURCE"
else
	AC_MSG_ERROR([sgngam is not available])
fi


After thinking about it, it seems a similar bug causes the
-D_POSIX_SOURCE that is the source of the NetBSD problems:

Look at the fdopen check in configure.in and the following from my
config.log:

<--  snip  -->

...
configure:20727: checking whether -D_POSIX_SOURCE is needed for fdopen
configure:20747: gcc -c -O2 -mcpu=v8 -Wall -Wmissing-prototypes 
-Wsign-compare 
-Wpointer-arith -Wnested-externs -Wchar-subscripts -Wwrite-strings
-Werror  conf
test.c >&5
cc1: warnings being treated as errors
conftest.c: In function `main':
conftest.c:28: warning: unused variable `f'
configure:20753: $? = 1
configure: failed program was:
| /* confdefs.h.  */
| 
| #define PACKAGE_NAME "gnumeric"
| #define PACKAGE_TARNAME "gnumeric"
| #define PACKAGE_VERSION "1.2.2"
| #define PACKAGE_STRING "gnumeric 1.2.2"
| #define PACKAGE_BUGREPORT
"http://bugzilla.gnome.org/enter_bug.cgi?product=gnu
meric"
| #define PACKAGE "gnumeric"
| #define VERSION "1.2.2"
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_DLFCN_H 1
| #define STDC_HEADERS 1
| #define WITH_BONOBO 1
| #define HAVE_LIBGNOMEDB 1
| /* end confdefs.h.  */
| #include <stdio.h>
| int
| main ()
| {
| FILE *f = fdopen(1, "r")
|   ;
|   return 0;
| }
configure:20776: result: yes
...

<--  snip  -->



WTF does the fdopen test add a -Werror to the CFLAGS, and then this
test fails because of an unused variable???


A check whether the same compilation works with -D_POSIX_SOURCE and an  
AC_MSG_ERROR if it doesn't would have caught this bug.


Would you accept a patch to remove the -Werror from the fdopen check
and to add some AC_MSG_ERRORs?
Comment 5 Morten Welinder 2003-11-29 18:57:41 UTC
That -Werror probably comes from deep inside autoconf code.  Don't
try to mess with that -- it's messy.  However, you might get away
with adding "(void)f;" after the declaration to make gcc see it as
used.

(And you're right that my proposed patch is too simplistic, but fixing
it would require another compilation test with -D_XOPEN_SOURCE.)
Comment 6 Adrian Bunk 2003-11-29 19:06:24 UTC
No, the -Werror is explicitely added in configure.in:

<--  snip  -->
...
AC_MSG_CHECKING([whether -D_POSIX_SOURCE is needed for fdopen])
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
AC_TRY_COMPILE([#include <stdio.h>], [FILE *f = fdopen(1, "r")],
need_posix=no, need_posix=yes)
...

<--  snip  -->


I'm currenttly working on a patch that should fix all these issues
properly.
Comment 7 Morten Welinder 2003-11-29 19:19:44 UTC
Hmm..., so it is.  That's bogus as the compiler might not understand
-Werror.  CC might not be gcc.

However, be careful!  The test needs to fail if there is no prototype
for fdopen.  It is not enough that the library has the function.
Thus simply removing "-Werror" will not work right.
Comment 8 Adrian Bunk 2003-11-30 01:30:33 UTC
Created attachment 21931 [details] [review]
proposed fix
Comment 9 Adrian Bunk 2003-11-30 01:34:53 UTC
My proposed fix does the following:
- use AC_CHECK_DECL for the fdopen check
- AC_MSG_ERROR if we don't know how to compile one of
    fdopen, struct timeval, M_PI, caddr_t
Comment 10 Morten Welinder 2003-11-30 01:43:22 UTC
Visually looks good.  I'll test Solaris in a few days.  Someone
else needs to test Linux.
Comment 11 Morten Welinder 2003-11-30 21:44:33 UTC
*** Bug 128123 has been marked as a duplicate of this bug. ***
Comment 12 Morten Welinder 2003-11-30 21:45:18 UTC
*** Bug 128124 has been marked as a duplicate of this bug. ***
Comment 13 Andreas J. Guelzow 2003-12-01 15:27:17 UTC
Patch tested on linux. Works fine
Comment 14 Morten Welinder 2003-12-01 15:31:50 UTC
Not so fast:

<JHM> checking whether fdopen is declared... no
<JHM> configure: adding -D_POSIX_SOURCE to CFLAGS
<JHM> checking whether fdopen is declared... (cached) no
<JHM> configure: error: fdopen is not available
<JHM> make: *** [configure-stamp] Error 1
<JHM> The patch is a no-go on Linux.
Comment 15 Adrian Bunk 2003-12-01 19:51:03 UTC
I can't reproduce this problem on Linux.

Could you post the relevant parts of the config.log?
Comment 16 Adrian Bunk 2003-12-01 20:55:48 UTC
Created attachment 21997 [details] [review]
updated patch (after discussion on irc with gmorten and JHM)
Comment 17 Andreas J. Guelzow 2003-12-01 23:24:15 UTC
this patch works for me on linux too
Comment 18 Morten Welinder 2003-12-02 15:25:00 UTC
Confirmed on solaris.

Fixed in cvs.