Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 204207 - app-admin/gkrellm-2.3.0 compilation issue (fix included)
Summary: app-admin/gkrellm-2.3.0 compilation issue (fix included)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: High minor (vote)
Assignee: Jim Ramsay (lack) (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-03 17:08 UTC by behd
Modified: 2008-04-26 23:42 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
/usr/include/stdio.h (glibc 2.3.6-r3) (stdio.h,27.28 KB, text/plain)
2008-01-21 09:17 UTC, behd
Details
/usr/include/bits/stdio.h (glibc 2.3.6-r3) (stdio.h,5.15 KB, text/plain)
2008-01-21 09:18 UTC, behd
Details
build log gkrellm-2.3.0 (app-admin:gkrellm-2.3.0:20080128-110829.log,11.83 KB, text/plain)
2008-01-28 11:14 UTC, behd
Details

Note You need to log in before you can comment on or make changes to this bug.
Description behd 2008-01-03 17:08:59 UTC
getline is redefined in client.c while it's already define in stdio.h

### output ###
i686-pc-linux-gnu-gcc -mtune=pentium4 -march=pentium4 -mmmx -msse -msse2 -O2 -pipe -fprefetch-loop-arrays -fomit-frame-pointer -momit-leaf-frame-pointer -Wall -I.. `pkg-config --cflags gtk+-2.0 gthread-2.0`   -DENABLE_NLS -DLOCALEDIR=\"/usr/share/locale\"   -c -o utils.o utils.c
client.c:1610: error: conflicting types for 'getline'
/usr/include/bits/stdio.h:103: error: previous definition of 'getline' was here
client.c:1610: error: conflicting types for 'getline'
/usr/include/bits/stdio.h:103: error: previous definition of 'getline' was here
make[1]: *** [client.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/var/tmp/portage/app-admin/gkrellm-2.3.0/work/gkrellm-2.3.0/src'
make: *** [all] Error 2
 * 
 * ERROR: app-admin/gkrellm-2.3.0 failed.
 * Call stack:
 *              ebuild.sh, line 1701:  Called dyn_compile
 *              ebuild.sh, line 1039:  Called qa_call 'src_compile'
 *              ebuild.sh, line   44:  Called src_compile
 *   gkrellm-2.3.0.ebuild, line   62:  Called die
 * The specific snippet of code:
 *              emake ${TARGET} \
 *                      CC="$(tc-getCC)" \
 *                      INSTALLROOT=/usr \
 *                      INCLUDEDIR=/usr/include/gkrellm2 \
 *                      LOCALEDIR=/usr/share/locale \
 *                      $(use nls || echo enable_nls=0) \
 *                      $(use gnutls || echo without-gnutls=yes) \
 *                      $(use lm_sensors || echo without-libsensors=yes) \
 *                      $(use ssl || echo without-ssl=yes) \
 *                      || die "emake failed"
 *  The die message:
 *   emake failed
 * 
 * If you need support, post the topmost build error, and the call stack if relevant.
 * A complete build log is located at '/var/log/portage/app-admin:gkrellm-2.3.0:20080103-163508.log'.
##############

### fix ###
--- src/client.c        2007-07-19 23:45:18.000000000 +0200
+++ src/client.c        2008-01-03 17:39:41.000000000 +0100
@@ -1606,7 +1606,7 @@
 
 
 static gint
-getline(gint fd, gchar *buf, gint len)
+mygetline(gint fd, gchar *buf, gint len)
        {
        fd_set                  read_fds;
        struct timeval  tv;
##################################


Reproducible: Always

Steps to Reproduce:
1. emerge gkrellm
2.
3.

Actual Results:  
compile failure (see description)

Expected Results:  
compile success :p

(very easy) fix included (see description).
Comment 1 Jim Ramsay (lack) (RETIRED) gentoo-dev 2008-01-03 20:00:45 UTC
Curious - I'm not seeing that error here - What libc version provides your stdio.h?

Ie, run this:

   equery belongs /usr/include/bits/stdio.h

Thanks!
Comment 2 behd 2008-01-04 08:20:06 UTC
# equery b /usr/include/bits/stdio.h
[ Searching for file(s) /usr/include/bits/stdio.h in *... ]
sys-libs/glibc-2.3.6-r3 (/usr/include/bits/stdio.h)
# equery b /usr/include/stdio.h
[ Searching for file(s) /usr/include/stdio.h in *... ]
sys-libs/glibc-2.3.6-r3 (/usr/include/stdio.h)

$ ll /usr/include/stdio.h 
-rw-r--r-- 1 root root 27936 Jun  7  2006 /usr/include/stdio.h
$ ll /usr/include/bits/stdio.h
-rw-r--r-- 1 root root 5277 Jun  7  2006 /usr/include/bits/stdio.h
Comment 3 Jim Ramsay (lack) (RETIRED) gentoo-dev 2008-01-18 14:03:36 UTC
Would you mind attaching a copy of both your stdio.h files?  In more recent glibc, the 'getline' function should only be seen in stdio.h if you have defined '_GNU_SOURCE', but gkrellm should not be doing this.

Also, this patch you submitted doesn't really fix the problem.  In fact, I don't think your gkrellm would work in client mode ("gkrellm -s localhost" after you've started /etc/init.d/gkrellmd), since the 'getline' defined in glibc is very different from the one that gkrellm defines.  Consider gkrellm's function signature:

static gint getline(gint fd, gchar *buf, gint len);

Versus the glibc one (from 'man getline'):

ssize_t getline(char **lineptr, size_t *n, FILE *stream);

So you can't just assume that glibc's version will do what gkrellm is expecting elsewhere in client.c (on lines 1701 and 1717).  You would probably get some ugly compiler warnings with your patch as-is.

If you changed every instance of 'getline' to 'mygetline' in client.c, this would probably be an okay fix.  But I'd rather figure out why your glibc is defining that function when it should not be!
Comment 4 behd 2008-01-21 09:17:30 UTC
Created attachment 141438 [details]
/usr/include/stdio.h (glibc 2.3.6-r3)
Comment 5 behd 2008-01-21 09:18:07 UTC
Created attachment 141440 [details]
/usr/include/bits/stdio.h (glibc 2.3.6-r3)
Comment 6 behd 2008-01-21 09:28:26 UTC
agreed patch was just to get rid of one of the getline... and as I don't use client/serv arch, I didn't bothered further.

NB. just tried gkrellmd + gkrellm to see how it would behave (and of course, gkrellm segfaulted :)
Comment 7 Jim Ramsay (lack) (RETIRED) gentoo-dev 2008-01-23 13:42:19 UTC
Your stdio.h don't look significantly different from mine.

What is the output you get from 'pkg-config --cflags gtk+-2.0 gthread-2.0'?

Also, could you please attach your entire build log?  The snippet in your problem report doesn't show the commandline used to compile 'client.c'.
Comment 8 behd 2008-01-28 10:44:21 UTC
# pkg-config --cflags gtk+-2.0 gthread-2.0
-D_REENTRANT -DPNG_NO_MMX_CODE -D_GNU_SOURCE -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12
Comment 9 behd 2008-01-28 11:14:20 UTC
Created attachment 141988 [details]
build log gkrellm-2.3.0

build log gkrellm-2.3.0
Comment 10 Jim Ramsay (lack) (RETIRED) gentoo-dev 2008-01-28 14:34:29 UTC
Thanks for the further info!

(In reply to comment #8)
> # pkg-config --cflags gtk+-2.0 gthread-2.0
> -D_REENTRANT -DPNG_NO_MMX_CODE -D_GNU_SOURCE -pthread -I/usr/include/gtk-2.0
> -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo
> -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
> -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12

Here is a difference between your system and every other I've tested so far.  No one else has '-D_GNU_SOURCE' in their output of the same command.

Could you please go into the /usr/lib/pkgconfig directory, and do:

  grep D_GNU_SOURCE *

Perhaps we can see which package exactly is at fault.
Comment 11 behd 2008-01-29 16:42:27 UTC
# grep D_GNU_SOURCE *
direct.pc:Cflags: -D_REENTRANT -I${prefix}/include/directfb -D_GNU_SOURCE
directfb-internal.pc:Cflags: -D_GNU_SOURCE  -I${prefix}/include/directfb-internal
sdl.pc:Cflags: -I${includedir}/SDL -D_GNU_SOURCE=1 -D_REENTRANT

$ cat /usr/lib/pkgconfig/sdl.pc 
# sdl pkg-config source file

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: sdl
Description: Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.
Version: 1.2.11
Requires:
Conflicts:
Libs: -L${libdir}  -lSDL  -lpthread
Cflags: -I${includedir}/SDL -D_GNU_SOURCE=1 -D_REENTRANT

$ cat /usr/lib/pkgconfig/gkrellm.pc 
prefix=/usr
Name: GKrellM
Description: Extensible GTK system monitoring application
Version: 2.3.0
Requires: gtk+-2.0 >= 2.0.0
Cflags: -I/usr/include/gkrellm2
Comment 12 Jim Ramsay (lack) (RETIRED) gentoo-dev 2008-03-03 13:34:17 UTC
I suspect the issue is that you have build cairo with USE="directfb", which pulls in the directfb library, which sets the dreaded -D_GNU_SOURCE

That said, gkrellm-2.3.1 was just released - Would you mind giving it a shot?  I'm not that optimistic that it will actually change anything, but I'd like to know if that version is still affected.
Comment 13 behd 2008-03-14 16:07:25 UTC
as is, install of 2.3.1 failed at the same point.

but good investigation ! I upgraded DirectFB to 0.9.25.1 and cairo (still with directfb flag) to 1.5.12, then retried to emerge gkrellm 2.3.1 -> compile flawlessly !

Well done, thanks !
Comment 14 Jim Ramsay (lack) (RETIRED) gentoo-dev 2008-04-26 23:42:33 UTC
I am closing this now, since the fixed version of DirectFB is stable.  Thanks for your help figuring it out!