SourceForge has been redesigned. Learn more.
Close

#62 build fails because of gsl/gsl_math.h inlines

closed-fixed
None
5
2003-11-02
2003-10-31
No

When compiling bogofilter 0.15.7 or 0.15.8 under
FreeBSD 4.7 (gcc 2.95.4, no GSL installed) or under
Solaris7 (gcc 3.2, no GSL installed), the bogofilter
build fails, and in both cases for the same reason.

Under FreebSD:

gcc -DBOGOFILTER -I/usr/local/include/db4 -Wall -W
-Wstrict-prototypes -Wmissing-prototypes -Wshadow
-Wbad-function-cast -Wcast-qual -Wcast-align
-Wwrite-strings -Waggregate-return
-Wmissing-declarations -Wnested-externs -ggdb
-fno-common -Wchar-subscripts -Wcomment -Wimplicit
-Wreturn-type -Wpointer-arith -L/usr/local/lib -o
bogofilter bogofilter.o main.o method.o graham.o
robinson.o fisher.o libbogofilter.a libbf_gsl.a -lm -ldb4
libbf_gsl.a(libbf_gsl_a-gamma.o): In function
`gammastar_ser':
/tmp/x/bogofilter-0.15.8/src/../gsl/cdf/../specfunc/gamma.c:976:
undefined reference to `GSL_MAX_DBL'
libbf_gsl.a(libbf_gsl_a-exp.o): In function
`gsl_sf_exp_err_e':
/tmp/x/bogofilter-0.15.8/src/../gsl/specfunc/exp.c:547:
undefined reference to `GSL_MAX_DBL'
libbf_gsl.a(libbf_gsl_a-trig.o): In function
`gsl_sf_hypot_e':
/tmp/x/bogofilter-0.15.8/src/../gsl/specfunc/trig.c:324:
undefined reference to`GSL_MIN_DBL'
/tmp/x/bogofilter-0.15.8/src/../gsl/specfunc/trig.c:325:
undefined reference to`GSL_MAX_DBL'
libbf_gsl.a(libbf_gsl_a-elementary.o): In function
`gsl_sf_multiply_e':
/tmp/x/bogofilter-0.15.8/src/../gsl/specfunc/elementary.c:52:
undefined reference to `GSL_MIN_DBL'
/tmp/x/bogofilter-0.15.8/src/../gsl/specfunc/elementary.c:53:
undefined reference to `GSL_MAX_DBL'

Under Solaris:

gcc -DBOGOFILTER -I/usr/local/BerkeleyDB.3.3/include
-Wall -W -Wstrict-prototypes -Wmissing-prototypes
-Wshadow -Wbad-function-cast -Wcast-qual -Wcast-align
-Wwrite-strings -Waggregate-return
-Wmissing-declarations -Wmissing-format-attribute
-Wnested-externs -ggdb -fno-common -Wchar-subscripts
-Wcomment -Wimplicit -Wsequence-point -Wreturn-type
-Wfloat-equal -Wpointer-arith -Wno-system-headers
-L/usr/local/BerkeleyDB.3.3/lib/ -o bogofilter
bogofilter.o main.o method.o graham.o robinson.o
fisher.o libbogofilter.a strlcpy.o strlcat.o
/usr/local/BerkeleyDB.3.3/lib//libdb.so
-R/usr/local/BerkeleyDB.3.3/lib/ libbf_gsl.a -lm
Undefined first referenced
symbol in file
GSL_MAX_DBL
libbf_gsl.a(libbf_gsl_a-gamma.o)
GSL_MIN_DBL
libbf_gsl.a(libbf_gsl_a-trig.o)
ld: fatal: Symbol referencing errors. No output written
to bogofilter
collect2: ld returned 1 exit status

This seems to be a problem related to the use of
inline code in gsl/gsl_math.h.

configure checks for inline support, adds "#define
HAVE_INLINE 1" to src/config.h, and then the build fails.

If I remove this define from config.h, everything
compiles ok.

A simplified example based on gsl/gsl_math.h:
-----8<-----
#define GSL_MAX(a,b) ((a) > (b) ? (a) : (b))

#if HAVE_INLINE
extern inline double GSL_MAX_DBL (double a, double b);

extern inline double
GSL_MAX_DBL (double a, double b)
{
return GSL_MAX (a, b);
}
#else
#define GSL_MAX_DBL(a,b) GSL_MAX(a,b)
#endif /* HAVE_INLINE */

int main()
{
double a,b;
double c = GSL_MAX_DBL(a,b);
return 0;
}
-----8<-----

Compiling with inline:

freebsd$ gcc -DHAVE_INLINE foo.c -o foo
/tmp/ccjP0chh.o: In function `main':
/tmp/ccjP0chh.o(.text+0x19): undefined reference to
`GSL_MAX_DBL'

solaris$ gcc -DHAVE_INLINE foo.c -o foo
Undefined first referenced
symbol in file
GSL_MAX_DBL /tmp/ccP54RB7.o
ld: fatal: Symbol referencing errors. No output written
to foo

Compiling without inline works fine in both cases.

Discussion

  • Matthias Andree

    Matthias Andree - 2003-11-01

    Logged In: YES
    user_id=2788

    env CPPFLAGS=-I/usr/local/include/db4 LIBS=-ldb4
    LDFLAGS=-L/usr/local/lib /bin/sh ./configure && make && make check
    works for me, without GSL installed, with bogofilter 0.15.7, 0.15.8 and
    CVS (VPATH build), on FreeBSD 4.9 (gcc 2.95.4) and Solaris 8 SPARC64
    (gcc 3.2.2 or Sun Workshop 6r1).

    Please see if the following procedure works: "make distclean", then
    configure again, then "make".

     
  • Matthias Andree

    Matthias Andree - 2003-11-01
    • assigned_to: nobody --> m-a
    • status: open --> pending-works-for-me
     
  • Gert-Jan Vons

    Gert-Jan Vons - 2003-11-02
    • status: pending-works-for-me --> open-works-for-me
     
  • Gert-Jan Vons

    Gert-Jan Vons - 2003-11-02

    Logged In: YES
    user_id=855001

    Hmm, if I use "CFLAGS=-I/usr/local/include/db4" the build
    fails. If I use "CPPFLAGS=-I/usr/local/include/db4" the
    build is ok.

    The only difference this makes is that CFLAGS contains -O2
    by default, which is preserved when using
    CPPFLAGS=-I/usr/... but gets lost when using CFLAGS=-I/usr/...

    If I use CFLAGS=-O2 -I/usr/... bogofilter compiles fine again.

    If I compile with CPPFLAGS=-I/usr/... CFLAGS=-g the build
    fails.

    If I compile the short test program above with gcc
    -DHAVE_INLINE foo.c it fails, but when I add -O2 it works.

    Apparently the inline stuff only works when compiling with
    -O2, something configure's "inline" test doesn't notice
    since it doesn't try to link?

     
  • Matthias Andree

    Matthias Andree - 2003-11-02

    Logged In: YES
    user_id=2788

    OK, the problem is that the functions GSL_MIN/MAX_DBL are defined
    "extern inline", which means to GCC in C mode, "do not generate
    implementation if you cannot inline", and the file that provided the library
    implementation, minmax.c, was missing from gsl/sys/.

    Inlining on the other hand DOES require at least -O with GCC, and I see
    no reason for NOT using -O. It's rather fast and it helps code quality a
    lot (at least last time, when I looked at GCC's m68k output, it was a lot
    better with -O).

    The missing minmax.c file has been added to CVS and Makefile.am has
    been adjusted. The next "current" series release should fix the problem.

    I recommend compiling with CFLAGS=-O
    CPPFLAGS=-I/usr/local/include/db4 for now.

     
  • Matthias Andree

    Matthias Andree - 2003-11-02
    • status: open-works-for-me --> closed-fixed
     

Log in to post a comment.