Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 399323 - glibc? built with gcc-4.6? issues with: /lib/libdl.so.2: undefined reference to `__environ@GLIBC_2.0' (when stripping .note.ABI-tag)
Summary: glibc? built with gcc-4.6? issues with: /lib/libdl.so.2: undefined reference ...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: x86 Linux
: Normal major (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-18 21:49 UTC by Piotr Szymaniak
Modified: 2012-08-11 18:02 UTC (History)
1 user (show)

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


Attachments
Build.log.bz2 (Build.log.bz2,179.25 KB, text/plain)
2012-02-17 06:34 UTC, Piotr Szymaniak
Details
sdl-mixer-Build.log (sdl-mixer-Build.log,33.59 KB, text/plain)
2012-04-11 05:53 UTC, Piotr Szymaniak
Details
irssi-Build.log (irssi-Build.log,8.64 KB, text/plain)
2012-04-11 06:03 UTC, Piotr Szymaniak
Details
irssi-config.log (irssi-config.log,46.16 KB, text/plain)
2012-04-11 06:03 UTC, Piotr Szymaniak
Details
vim-Build.log (vim-Build.log,18.99 KB, text/plain)
2012-04-11 06:04 UTC, Piotr Szymaniak
Details
vim-config.log (vim-config.log,106.97 KB, text/plain)
2012-04-11 06:05 UTC, Piotr Szymaniak
Details
output.log (output.log,17.86 KB, text/plain)
2012-04-11 19:52 UTC, Piotr Szymaniak
Details
readelf output (comment12.log,2.85 KB, text/plain)
2012-04-12 05:59 UTC, Piotr Szymaniak
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Szymaniak 2012-01-18 21:49:22 UTC
First of all i don't know if this is related to any other arch (or my broken Gentoo?). Also, i'm not sure if it is related to x86 or to some specific x86 environment. I had similar issue some time ago with unmasked glibc-2.14 and i used my system backup thinking "maybe it's too bleeding edge right now". But it seems that this bleeding edge hits me again after rebuilding glibc-2.13-4 today (glibc ChangeLog: 17 Jan 2012 *snip* drop USE=nls).

So, what happend? There was sdl-mixer rebuild right after glibc that ended with this:
/lib/libdl.so.2: undefined reference to `__environ@GLIBC_2.0'
collect2: ld returned 1 exit status
make: *** [build/playwave] Błąd 1
make: *** Oczekiwanie na niezakończone zadania....
/lib/libdl.so.2: undefined reference to `__environ@GLIBC_2.0'
collect2: ld returned 1 exit status
make: *** [build/playmus] Błąd 1


Like i said, i saw something similar before. I search around but found nothing usefull. So i tried to get something (hopefully) usefull from the libdl and i did this from a machine with working glibc (still with the "older" build with nls):
wloczykij ~ # readelf -a /lib/libdl-2.13.so | grep environ
00003fe8  00001506 R_386_GLOB_DAT    00000000   __environ
    15: 00000000     0 OBJECT  WEAK   DEFAULT  UND environ@GLIBC_2.0 (8)
    17: 00000000     0 OBJECT  WEAK   DEFAULT  UND _environ@GLIBC_2.0 (8)
    21: 00000000     0 OBJECT  GLOBAL DEFAULT  UND __environ@GLIBC_2.0 (8)


Here's the output of the same command with _broken_ (?!) glibc:
maszyn ~ # readelf -a /lib/libdl-2.13.so | grep environ
00003fcc  00000206 R_386_GLOB_DAT    00000000   __environ
     2: 00000000     0 OBJECT  GLOBAL DEFAULT  UND __environ@GLIBC_2.0 (7)
    15: 00000000     0 OBJECT  WEAK   DEFAULT  UND _environ@GLIBC_2.0 (7)
    21: 00000000     0 OBJECT  WEAK   DEFAULT  UND environ@GLIBC_2.0 (7)


And, output of the same command with two or three day old backup (before the nls rebuild):
maszyn ~ # readelf -a /mnt/md1/lib/libdl-2.13.so | grep enviro
00003fe8  00001506 R_386_GLOB_DAT    00000000   __environ
    15: 00000000     0 OBJECT  WEAK   DEFAULT  UND environ@GLIBC_2.0 (8)
    17: 00000000     0 OBJECT  WEAK   DEFAULT  UND _environ@GLIBC_2.0 (8)
    21: 00000000     0 OBJECT  GLOBAL DEFAULT  UND __environ@GLIBC_2.0 (8)


maszyn ~ # emerge --info
Portage 2.2.0_alpha84 (default/linux/x86/10.0/desktop, gcc-4.6.2, glibc-2.13-r4, 3.2.1 i686)
=================================================================
System uname: Linux-3.2.1-i686-Pentium-R-_Dual-Core_CPU_E5400_@_2.70GHz-with-gentoo-2.1
Timestamp of tree: Wed, 18 Jan 2012 19:00:01 +0000
distcc 3.1 i686-pc-linux-gnu [disabled]
ccache version 3.1.7 [disabled]
app-shells/bash:          4.2_p20
dev-java/java-config:     2.1.11-r3
dev-lang/python:          2.7.2-r3, 3.2.2
dev-util/ccache:          3.1.7
dev-util/cmake:           2.8.6-r4
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.1
sys-apps/openrc:          0.9.8.1
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.68
sys-devel/automake:       1.9.6-r3, 1.11.2
sys-devel/binutils:       2.22-r1
sys-devel/gcc:            4.6.2
sys-devel/gcc-config:     1.5-r2
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r3
sys-kernel/linux-headers: 3.2 (virtual/os-headers)
sys-libs/glibc:           2.13-r4
Repositories: gentoo multimedia x11 sunrise mgorny roslin gamerlay-stable
Installed sets: @system
ACCEPT_KEYWORDS="x86 ~x86"
ACCEPT_LICENSE="*"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
DISTDIR="/var/tmp/distfiles"
EMERGE_DEFAULT_OPTS="--quiet-build=n"
FEATURES="assume-digests binpkg-logs distlocks ebuild-locks fixlafiles news parallel-fetch preserve-libs protect-owned sandbox sfperms sign strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://distfiles.ift.uni.wroc.pl/"
LANG="pl_PL.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="pl"
MAKEOPTS="-j3"
PKGDIR="/home/p/binpkgs"
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="/var/lib/layman/multimedia /var/lib/layman/x11 /var/lib/layman/sunrise /var/lib/layman/mgorny /home/lazy_bum/uberlay/roslin /home/lazy_bum/uberlay/gamerlay"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X a52 aac acl acpi alsa bash-completion bzip2 cairo cdda cdr cli consolekit cracklib crypt cups custom-cflags custom-cxxflags cxx dbus dri dts dvd dvdr emboss encode exif fam firefox flac fortran gdbm gdu gif gpm gtk iconv ipv6 jabber jpeg lcms libnotify mad mmx mmxext mng modules mp3 mp4 mpeg mudflap ncurses nls nptl nptlonly ogg opengl openmp pam pango pcre pdf png policykit ppds pppd qt3support qt4 readline sdl session spell sse sse2 ssl ssse3 svg sysfs tcpd tiff truetype udev unicode usb vim-syntax vorbis x264 x86 xcb xml xorg xulrunner xv xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" 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="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog cpu cpufreq disk hddtemp network uptime users" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="pl" PHP_TARGETS="php5-3" QEMU_SOFTMMU_TARGETS="i386" QEMU_USER_TARGETS="i386" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="nouveau" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

Reproducible: Always
Comment 1 Piotr Szymaniak 2012-02-10 23:12:40 UTC
On other ~x86 machine and newer glibc the mentioned command looks like this:
rekowered ~ # readelf -a /lib/libdl-2.14.1.so | grep environ
00003fcc  00000206 R_386_GLOB_DAT    00000000   __environ
     2: 00000000     0 OBJECT  GLOBAL DEFAULT  UND __environ@GLIBC_2.0 (7)
    15: 00000000     0 OBJECT  WEAK   DEFAULT  UND _environ@GLIBC_2.0 (7)
    21: 00000000     0 OBJECT  WEAK   DEFAULT  UND environ@GLIBC_2.0 (7)

and yeah, it works fine… would be nice to give me some more ideas about this issue.
Comment 2 SpanKY gentoo-dev 2012-02-15 03:48:36 UTC
the symbol is supposed to be defined in libc.so.6:
$ readelf -s /lib32/libc.so.6 | grep environ
   299: 0019ae00     4 OBJECT  WEAK   DEFAULT   30 _environ@@GLIBC_2.0
  1018: 0019ae00     4 OBJECT  WEAK   DEFAULT   30 environ@@GLIBC_2.0
  1363: 0019ae00     4 OBJECT  GLOBAL DEFAULT   30 __environ@@GLIBC_2.0

is it not being defined that way on your system ?  please post the full glibc build log as an attachment (compress it if need be).
Comment 3 Piotr Szymaniak 2012-02-17 06:34:17 UTC
Created attachment 302231 [details]
Build.log.bz2

Build.log

output of above command on glibc with issues:
maszyn ~ (: readelf -s /lib/libc.so.6 | grep environ
   298: 00178d80     4 OBJECT  WEAK   DEFAULT   31 _environ@@GLIBC_2.0
  1012: 00178d80     4 OBJECT  WEAK   DEFAULT   31 environ@@GLIBC_2.0
  1351: 00178d80     4 OBJECT  GLOBAL DEFAULT   31 __environ@@GLIBC_2.0
Comment 4 SpanKY gentoo-dev 2012-04-10 19:53:13 UTC
also post the full build log of the sdl-mixer package as an attachment
Comment 5 Piotr Szymaniak 2012-04-11 05:53:57 UTC
Created attachment 308489 [details]
sdl-mixer-Build.log
Comment 6 Piotr Szymaniak 2012-04-11 06:03:10 UTC
Created attachment 308493 [details]
irssi-Build.log

Got also other packages that fail _after_ glibc was merged:

maszyn ~ # emerge -pqv ncurses glib
[ebuild   R   ] sys-libs/ncurses-5.9-r2  USE="cxx gpm unicode -ada -debug -doc -minimal -profile -static-libs -trace" 
[ebuild   R   ] dev-libs/glib-2.30.3  USE="fam static-libs -debug -doc (-selinux) -systemtap -test -utils -xattr" 

(ncurses as a reference to vim-Build.log)
Comment 7 Piotr Szymaniak 2012-04-11 06:03:25 UTC
Created attachment 308495 [details]
irssi-config.log
Comment 8 Piotr Szymaniak 2012-04-11 06:04:00 UTC
Created attachment 308497 [details]
vim-Build.log
Comment 9 Piotr Szymaniak 2012-04-11 06:05:08 UTC
Created attachment 308499 [details]
vim-config.log
Comment 10 SpanKY gentoo-dev 2012-04-11 14:44:58 UTC
(In reply to comment #5)

ok, now go into the sdl-mixer build dir:
  cd /tmp/portage/media-libs/sdl-mixer-1.2.12/work/SDL_mixer-1.2.12

and run:
  i686-pc-linux-gnu-gcc -o build/.libs/playmus build/.libs/playmus.o -D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL  build/.libs/libSDL_mixer.so -lSDL -lpthread -lvorbisfile -lvorbis -logg -lFLAC -lmad -lm

if that still fails, then run:
i686-pc-linux-gnu-gcc -o build/.libs/playmus build/.libs/playmus.o -D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL  build/.libs/libSDL_mixer.so -lSDL -lpthread -lvorbisfile -lvorbis -logg -lFLAC -lmad -lm -v -Wl,--verbose

and post the full output of that last command as an attachment
Comment 11 Piotr Szymaniak 2012-04-11 19:52:56 UTC
Created attachment 308561 [details]
output.log

(In reply to comment #10)
> (In reply to comment #5)
> if that still fails, then run:

It failed.
Comment 12 SpanKY gentoo-dev 2012-04-12 00:38:45 UTC
what does `readelf -d /lib/libdl.so.2 /usr/lib/libglib-2.0.so` show ?
Comment 13 Piotr Szymaniak 2012-04-12 05:59:06 UTC
Created attachment 308615 [details]
readelf output

Output of readelf from comment #12.
Comment 14 Piotr Szymaniak 2012-04-26 13:15:17 UTC
*bump*

I would love to solve this issue one way or another. If not here i will try with glibc package from some other machine.
Comment 15 Piotr Szymaniak 2012-05-03 18:11:40 UTC
Just noticing that I tried glibc-2.15-r1 and same thing happend.
Comment 16 Piotr Szymaniak 2012-05-08 08:39:57 UTC
I'm not sure if this is glibc issue anymore. Tried to install glibc from binhost [1] and after glibc re-emerge it's exacly the same (vim won't find terminal lib, irssi won't find glib and sdl-mixer has the undefined reference).

As suggested by one of the devs (Amadeusz Żołnowski / aidecoe [2]) I went through emerge -e @system and emerge -e @world (both with --exclude=glibc) and nothing changes.


[1] http://tinderbox.dev.gentoo.org/default-linux/x86/
[2] he hit the same "undefined reference" bug, used his system backup, but after few days/weeks and another try everything went fine for his glibc (or wherever the bug is)
Comment 17 Piotr Szymaniak 2012-05-23 08:54:22 UTC
I can see this is not included in emerge --info. Also, don't even know if this is still used, but in my /etc/make.conf (i think on all my Gentoo boxes) i have a line:
PORTAGE_STRIP_FLAGS="--strip-unneeded -R .comment -R .note -R .note.ABI-tag"

Yesterday I had some time to do random tests with glibc (removed C{,XX}FLAGS and added debug options, added USE="debug", made MAKEOPTS="-j1", #PORTAGE_STRIP_FLAGS) and it seems that everything went fine. Then I reemerged sdl-mixer, irssi and vim without any issues. Then I added/removed some of the flags/optimisations above and it looks like the problem is in the STRIP line.

Here's the current output of "readelf -s /lib/libc.so.6 | grep environ":
   298: 00178d80     4 OBJECT  WEAK   DEFAULT   31 _environ@@GLIBC_2.0
  1012: 00178d80     4 OBJECT  WEAK   DEFAULT   31 environ@@GLIBC_2.0
  1351: 00178d80     4 OBJECT  GLOBAL DEFAULT   31 __environ@@GLIBC_2.0

I will keep sys-libs/glibc-2.13-r4 for a few days and check if everything works without some random issues (maybe even -e @world, who knows ;) and then update to ~arch glibc.
Comment 18 SpanKY gentoo-dev 2012-08-11 18:02:31 UTC
pretty sure .note.ABI-tag is not something you can safely throw away.  it contains bits used by the link-time linker (`ld`) and the runtime linker (`ldso`).  so if removing that flag is causing you problems, then don't do that.

the other flags you specified we already use as the default strip flags.