Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bugzilla DB migration completed. Please report issues to Infra team via email via infra@gentoo.org or IRC

Bug 271605

Summary: [patch] sys-apps/mkinitrd-4.2.0.3 fails to build with sys-devel/gcc-4.4.0 and sys-libs/glibc-2.10
Product: Gentoo Linux Reporter: hirakendu <hirakendu>
Component: Current packagesAssignee: Gentoo's Team for Core System packages <base-system>
Status: VERIFIED FIXED    
Severity: normal CC: bircoph, esigra, gentoo.bugs, mail, mvolaski, risto
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 249226, 270353    
Attachments: patch for mkinitrd to build with gcc-4.4 and glibc-2.10

Description hirakendu 2009-05-29 06:39:45 UTC
rename the strndup function since it is already in glibc-2.10. plus the usual type conversion errors with gcc-4.4

Reproducible: Always
Comment 1 hirakendu 2009-05-29 06:41:45 UTC
Created attachment 192784 [details, diff]
patch for mkinitrd to build with gcc-4.4 and glibc-2.10
Comment 2 Mike Auty gentoo-dev 2009-05-31 13:55:29 UTC
This is kind of two bugs in one (one for glibc and one for gcc) so you may be asked to split this into two bugs...
Comment 3 Andrew Savchenko gentoo-dev 2009-07-09 06:22:52 UTC
This bug is confirmed on glibc-2.10.1 and gcc-4.3.3-r2.
Proposed patch helps, thanks.

$ emerge --info
Portage 2.2_rc33 (default/linux/x86/2008.0, gcc-4.3.3, glibc-2.10.1-r0, 2.6.29.04-std121 i686)
=================================================================
System uname: Linux-2.6.29.04-std121-i686-Intel-R-_Atom-TM-_CPU_N270_@_1.60GHz-with-gentoo-2.0.1
Timestamp of tree: Wed, 08 Jul 2009 09:45:02 +0000
ccache version 2.4 [enabled]
app-shells/bash:     4.0_p24
dev-java/java-config: 2.1.8-r1
dev-lang/python:     2.5.4-r3, 2.6.2-r1
dev-util/ccache:     2.4-r8
sys-apps/baselayout: 2.0.1
sys-apps/openrc:     0.4.3-r3
sys-apps/sandbox:    2.0
sys-devel/autoconf:  2.13, 2.63-r1
sys-devel/automake:  1.5, 1.8.5-r3, 1.9.6-r2, 1.10.2, 1.11
sys-devel/binutils:  2.19.1-r1
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.6a
virtual/os-headers:  2.6.30
ACCEPT_KEYWORDS="x86 ~x86"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=core2 -m32 --param l1-cache-line-size=64 --param l1-cache-size=32 --param l2-cache-size=512 -O2 -funswitch-loops -fpredictive-commoning -fgcse-after-reload -ftree-vectorize -fomit-frame-pointer -mfpmath=sse -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-march=core2 -m32 --param l1-cache-line-size=64 --param l1-cache-size=32 --param l2-cache-size=512 -O2 -funswitch-loops -fpredictive-commoning -fgcse-after-reload -ftree-vectorize -fomit-frame-pointer -mfpmath=sse -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--with-bdeps y"
FEATURES="ccache collision-protect distlocks fixpackages parallel-fetch preserve-libs protect-owned sandbox sfperms strict unmerge-orphans userfetch userpriv usersandbox"
FFLAGS="-march=core2 -m32 --param l1-cache-line-size=64 --param l1-cache-size=32 --param l2-cache-size=512 -O2 -funswitch-loops -fpredictive-commoning -fgcse-after-reload -ftree-vectorize -fomit-frame-pointer -mfpmath=sse -pipe"
GENTOO_MIRRORS=" ftp://bircoph/distributive/gentoo/portage ftp://ftp.chg.ru/pub/Linux/gentoo http://mirror.yandex.ru/gentoo-distfiles  ftp://ftp.corbina.net/pub/Linux/gentoo http://distfiles.gentoo.org http://www.ibiblio.org/pub/Linux/distributions/gentoo http://mirror.netcologne.de/gentoo"
LANG="en_US.UTF-8"
LC_ALL=""
LDFLAGS="-Wl,-O1"
LINGUAS="ru en ja"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage/layman/science /usr/local/portage/layman/java-overlay /usr/local/portage/layman/sunrise /usr/local/portage"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="X a52 aac aalib acl acpi adns afs aften aim alsa amr amrnb amrwb ao audiofile bash-completion bcmath binfilter blas bluetooth branding bzip2 cairo calendar canna caps ccache cddb cdinstall cdparanoia cdr chasen cjk cli clisp colordiff cracklib crypt cscope css ctype cups curl curlwrappers cvs cxx cyrillic dbus device-mapper dga dia dirac directfb djvu dmx doc dri dts dv dvd dvdr dvdread dvi editor elf encode enscript ermt examples exif expat faac faad fbcon festival ffmpeg fftw firefox flac fontconfig foomaticdb fortran fpx freetds freetype ftp gcj gcrypt gd gdbm geoip ggi gif gimp ginac git glut gmp gnuplot gnutls gpgme gphoto2 gpm gps graphviz gs gsl gsm gtk gucharmap h224 h281 h323 hdf5 hdri iconv icq icu id3tag idn imagemagick imap imlib immqt-bc inkjar ipod iproute2 ipv6 isdnlog jabber jack jadetex java6 javascript jbig jingle jpeg jpeg2k kdehiddenvisibility kerberos keyscrub kpathsea kqemu ladspa lame lapack lash latex lcms ldap libcaca libnotify libsamplerate libwww logrotate lzo mad maildir mailwrapper matroska mbox md5sum mhash midi mikmod mime mjpeg mmap mmx mng modplug mp3 mpeg mplayer mppe-mppc msn mudflap musepack musicbrainz mysql mysqli nas ncurses netcdf network network-cron nls nntp nocd nodrm nptl nptlonly nsplugin nuv objc objc++ offensive ogg openal openexr opengl openmp oscar otr pam pango pch pcntl pcre pda pdf perl pgf plotutils png pop posix postproc postscript ppds pppd pronounce pstricks qt3 qt3support qt4 quicktime raw rdesktop readline recode reflection restrict-javascript rle rrdtool samba scanner schroedinger sdl session sharedmem shorten sip sipim slang slp smi smime smp sms smtp sndfile sockets socks5 soundtouch sox sparse speex spell spl sqlite sqlite3 sse sse2 sse3 ssl ssse3 startup-notification subversion supernodal svg svga sysfs syslog szip t1lib taglib tcpd theora threads tiff timezone timidity tordns truetype twolame type3 unicode usb v4l v4l2 vamp vcd videos vim vim-syntax vnc vorbis wav wavpack wifi win32codecs wireshark wmf x264 x86 xattr xcb xface xft xinerama xorg xosd xpm xprint xrandr xscreensaver xv xvid yahoo yaz ziffy zlib" ALSA_CARDS="hda-intel" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="authz_host dir mime" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="ru en ja" USERLAND="GNU" VIDEO_CARDS="intel vesa fbdev"
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 4 Diego Elio Pettenò (RETIRED) gentoo-dev 2009-07-09 20:37:14 UTC
Comment on attachment 192784 [details, diff]
patch for mkinitrd to build with gcc-4.4 and glibc-2.10

Patch does not look right; please refer to

http://blog.flameeyes.eu/2009/07/08/how-_not_-to-fix-glibc-2-10-function-collisions

and

http://blog.flameeyes.eu/2009/07/02/how-_not_-to-fix-gcc-4-4-bugs
Comment 5 Andrew Savchenko gentoo-dev 2009-07-10 17:34:31 UTC
Yes, this fix is bad, but this is better than nothing.
Comment 6 hirakendu 2009-07-10 18:15:43 UTC
(I am late to the party, as I am busy with my university research these days.) Frankly I was in a hurry that time and just wanted to temporarily fix them to get 'emerge -e world' with gcc-4.4 and glibc-2.10. And at that time I was aware that this is not the right kind of fix and in fact needs to be handled upstream. But I neither have the time to inform each of the upstream guys and more importantly, I don't want to create a thousand bugzilla accounts. In any case, I thought that to anyone having a quick glance at the patches, it would be obvious that these are temporary sloppy fixes and should/will be handled upstream later on, and so I didn't mention. In fact, in some of the bugs, I guess I even described the problem and the workaround.

Meanwhile, back to the bugs. Regarding the gcc-4.4 related type conversion things. Whenever possible, I have tried to change the declaration of the variable itself to const, instead of doing type conversions ad-hoc at the functions (unless I was really in a hurry late in the night). Indeed, many of these constant strings pertain to filename input arguments and can be handled the former way. But quite a few times, they are actually used as variables, and afaik, I only fixed it the latter way whenever it seemed to me that it will require deep changes - possibly introducing new variables and then using them. About memory/runtime errors, I see that it would have caused an error in gcc-4.3, but I don't see how fixing it either way (even the sloppy way) will cause errors in gcc-4.4. Also, when I made these sloppy temporary fixes, I assumed that the code was working in gcc-4.3 and such a fix should make it run without problems. In a way, the changes reflect the way the developer had originally thought the functions would behave.  

Regarding the in-built functions in glibc and renaming the functions - it is more than obvious that it is a sloppy fix and upstream should use these functions instead when possible or use a different name if they have a different functionality. I am sure that they will be fixed over time, if this code is still maintained upstream. So as mentioned above, I don't want to waste time eating their head (it certainly is not educating as this is pretty obvious). What is educational though is that I didn't know about the macros to detect the functions if already defined, example, HAVE_STRNDUP for strndup() as you mentioned in your blog post using autotools. Thanks for that. In fact, at first, I tried to see if there is something that detects glibc versions and use built-in functions if possible.

Hope I didn't offend anyone :D.
Comment 7 Andreas Stangl 2009-07-10 20:55:39 UTC
this workaround helped me out - I was scratching my head during emerge -e world, too :-), thanks hirakendu.
Comment 8 Samuli Suominen gentoo-dev 2009-08-09 16:22:14 UTC
+*mkinitrd-4.2.0.3-r1 (09 Aug 2009)
+
+  09 Aug 2009; Samuli Suominen <ssuominen@gentoo.org>
+  +mkinitrd-4.2.0.3-r1.ebuild, +files/mkinitrd-4.2.0.3-glibc-2.10.patch:
+  Fix building with GLIBC 2.10+ wrt #271605.

vapier, can you check?
Comment 9 Richard Scott 2009-08-11 08:51:48 UTC
this didn't work for me. I get this error:

>>> Compiling source in /var/tmp/portage/sys-apps/mkinitrd-4.2.0.3-r1/work/mkinitrd-4.2.0.3 ...
make -j3 CC=x86_64-pc-linux-gnu-gcc LDFLAGS=-Wl,-O1 -C nash
make: Entering directory `/var/tmp/portage/sys-apps/mkinitrd-4.2.0.3-r1/work/mkinitrd-4.2.0.3/nash'
x86_64-pc-linux-gnu-gcc -march=nocona -O2 -pipe -fomit-frame-pointer -Wall -DVERSION=\"4.2.0.3\"    -c -o nash.o nash.c
x86_64-pc-linux-gnu-gcc -march=nocona -O2 -pipe -fomit-frame-pointer -Wall -DVERSION=\"4.2.0.3\"    -c -o mount_by_label.o mount_by_label.c
x86_64-pc-linux-gnu-gcc -march=nocona -O2 -pipe -fomit-frame-pointer -Wall -DVERSION=\"4.2.0.3\"    -c -o name_to_dev_t.o name_to_dev_t.c
nash.c: In function `runStartup':
nash.c:1494: warning: 'rc' might be used uninitialized in this function
x86_64-pc-linux-gnu-gcc -static -g -Wl,-O1 -o nash nash.o mount_by_label.o name_to_dev_t.o
/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.6/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lc
collect2: ld returned 1 exit status
make: *** [nash] Error 1
make: Leaving directory `/var/tmp/portage/sys-apps/mkinitrd-4.2.0.3-r1/work/mkinitrd-4.2.0.3/nash'
 *
 * ERROR: sys-apps/mkinitrd-4.2.0.3-r1 failed.
Comment 10 Samuli Suominen gentoo-dev 2009-08-11 08:59:15 UTC
(In reply to comment #9)
> this didn't work for me. I get this error:
> 
> >>> Compiling source in /var/tmp/portage/sys-apps/mkinitrd-4.2.0.3-r1/work/mkinitrd-4.2.0.3 ...
> make -j3 CC=x86_64-pc-linux-gnu-gcc LDFLAGS=-Wl,-O1 -C nash
> make: Entering directory
> `/var/tmp/portage/sys-apps/mkinitrd-4.2.0.3-r1/work/mkinitrd-4.2.0.3/nash'
> x86_64-pc-linux-gnu-gcc -march=nocona -O2 -pipe -fomit-frame-pointer -Wall
> -DVERSION=\"4.2.0.3\"    -c -o nash.o nash.c
> x86_64-pc-linux-gnu-gcc -march=nocona -O2 -pipe -fomit-frame-pointer -Wall
> -DVERSION=\"4.2.0.3\"    -c -o mount_by_label.o mount_by_label.c
> x86_64-pc-linux-gnu-gcc -march=nocona -O2 -pipe -fomit-frame-pointer -Wall
> -DVERSION=\"4.2.0.3\"    -c -o name_to_dev_t.o name_to_dev_t.c
> nash.c: In function `runStartup':
> nash.c:1494: warning: 'rc' might be used uninitialized in this function
> x86_64-pc-linux-gnu-gcc -static -g -Wl,-O1 -o nash nash.o mount_by_label.o
> name_to_dev_t.o
> /usr/lib/gcc/x86_64-pc-linux-gnu/3.4.6/../../../../x86_64-pc-linux-gnu/bin/ld:
> cannot find -lc
> collect2: ld returned 1 exit status
> make: *** [nash] Error 1
> make: Leaving directory
> `/var/tmp/portage/sys-apps/mkinitrd-4.2.0.3-r1/work/mkinitrd-4.2.0.3/nash'
>  *
>  * ERROR: sys-apps/mkinitrd-4.2.0.3-r1 failed.
> 

Completely unrelated error to this bug. Either find the correct bug, or open a new one.
Comment 11 Richard Scott 2009-08-11 09:03:09 UTC
(In reply to comment #10)
> Completely unrelated error to this bug. Either find the correct bug, or open a
> new one.
 

But I have v4.2.0.3 installed ok, and the only difference between that and 4.2.0.3-r1 is this patch, see diff:

diff mkinitrd-4.2.0.3-r1.ebuild mkinitrd-4.2.0.3.ebuild
1c1
< # Copyright 1999-2009 Gentoo Foundation
---
> # Copyright 1999-2008 Gentoo Foundation
3c3
< # $Header: /var/cvsroot/gentoo-x86/sys-apps/mkinitrd/mkinitrd-4.2.0.3-r1.ebuild,v 1.1 2009/08/09 16:22:09 ssuominen Exp $
---
> # $Header: /var/cvsroot/gentoo-x86/sys-apps/mkinitrd/mkinitrd-4.2.0.3.ebuild,v 1.3 2008/10/14 15:28:49 flameeyes Exp $
24d23
<       epatch "${FILESDIR}"/${P}-glibc-2.10.patch
35,38d33
<       if has_version ">=sys-libs/glibc-2.10"; then
<               append-flags -Dstrndup=strndup
<       fi
<

Are you sure its not your patch?

Comment 12 Samuli Suominen gentoo-dev 2009-08-11 09:08:36 UTC
Your error seems to indicate the linker can't find can't find libc (glibc), looks like a pretty broken system to me.

My patch changes behaviour only in grubby.c anyway, not the nash.c.
Comment 13 Richard Scott 2009-08-11 09:13:48 UTC
(In reply to comment #12)
> Your error seems to indicate the linker can't find can't find libc (glibc),
> looks like a pretty broken system to me.
> 
> My patch changes behaviour only in grubby.c anyway, not the nash.c.
> 

you could be right... the original (installed) mkinitrd-sys-apps/mkinitrd-4.2.0.3 won't re-compile either! :-(