Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 265643 - app-admin/syslog-ng-2.1.4: fails with forced --as-needed
Summary: app-admin/syslog-ng-2.1.4: fails with forced --as-needed
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Mr. Bones. (RETIRED)
Depends on:
Blocks: as-needed
  Show dependency tree
Reported: 2009-04-10 12:46 UTC by Stephen Bridges
Modified: 2010-06-29 13:58 UTC (History)
5 users (show)

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

syslog-ng with --as-need linker flag buildlog (build.log,25.55 KB, text/plain)
2009-04-30 18:30 UTC, Steffen 'j0inty' Stollfuß

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen Bridges 2009-04-10 12:46:06 UTC
Compiling syslog-ng v2.1.4 with --as-needed enabled fails to link against librt from glibc

Reproducible: Always

Steps to Reproduce:
1.  Enable LDFLAGS="-Wl,--as-needed"
2.  Possibly linked to glibc?  Version used 2.9_p20081201-r2  USE="gd (multilib) nls -debug -glibc-omitfp (-hardened) -profile (-selinux) -vanilla"
3.  Emerge syslog-ng

Actual Results:  
x86_64-pc-linux-gnu-gcc  -march=athlon64-O2 -pipe -Wall  -Wl,--as-needed -o syslog-ng  main.o libsyslog-ng.a -lnsl -lrt  -Wl,-Bstatic -lfl -pthread -lgthread-2.0 -lrt -lglib-2.0   -levtlog    -lwrap -Wl,-Bdynamic -ldbi   -ldl
                                                           /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.3/../../../../lib64/librt.a(clock_gettime.o): In function `hp_timing_gettime':
                                                           (.text+0x6a): undefined reference to `_dl_cpuclock_offset'
                                                           collect2: ld returned 1 exit status
                                                           make[2]: *** [syslog-ng] Error 1
                                                           make[2]: Leaving directory `/var/tmp/portage/app-admin/syslog-ng-2.1.4/work/syslog-ng-2.1.4/src'
                                                           make[1]: *** [all-recursive] Error 1
                                                           make[1]: Leaving directory `/var/tmp/portage/app-admin/syslog-ng-2.1.4/work/syslog-ng-2.1.4'
                                                           make: *** [all] Error 2

Portage 2.2_rc28 (default/linux/amd64/2008.0/desktop, gcc-4.3.3, glibc-2.9_p20081201-r2, 2.6.29-gentoo x86_64)                                                                                          
System uname: Linux-2.6.29-gentoo-x86_64-AMD_Athlon-tm-_64_X2_Dual_Core_Processor_3800+-with-glibc2.2.5                                                                                                 
Timestamp of tree: Thu, 09 Apr 2009 13:45:01 +0000                                                  
distcc 2.18.3 x86_64-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]                
app-shells/bash:     4.0_p17                                                                        
dev-java/java-config: 1.3.7-r1, 2.1.7                                                               
dev-lang/python:     2.4.4-r15, 2.5.4-r2                                                            
dev-python/pycrypto: 2.0.1-r6                                                                       
dev-util/cmake:      2.6.3-r1                                                                       
sys-apps/baselayout: 2.0.0                                                                          
sys-apps/openrc:     0.4.3-r1                                                                       
sys-apps/sandbox:    1.9                                                                            
sys-devel/autoconf:  2.13, 2.63-r1                                                                  
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.2                       
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.28-r1                                                                      
ACCEPT_KEYWORDS="amd64 ~amd64"                                                                      
CFLAGS="-march=athlon64 -O2 -pipe"                                                                  
CONFIG_PROTECT="/etc /usr/share/config"                                                             
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 /etc/texmf/web2c /etc/udev/rules.d"                                                                                        
CXXFLAGS="-march=athlon64 -O2 -pipe"                                                                
FEATURES="distlocks fixpackages parallel-fetch preserve-libs protect-owned sandbox sfperms strict unmerge-orphans userfetch"                                                                            
LINGUAS="en en_GB"                                                                                  
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"          
PORTDIR_OVERLAY="/usr/local/portage/layman/sunrise /usr/local/portage/layman/java-overlay /usr/local/portage"
USE="3dnow X aac acpi alsa amd64 berkdb blender-game bluetooth branding bzip2 cairo cdinstall cdparanoia cdr cdrom cli consolekit cracklib crypt cvs dbus deprecated divx dvd dvdnav dvdr dvdread emboss encode evo fam ffmpeg fortran gcj gd gif glitz gmedia gphoto2 gpm graphviz gtk hal history htmlhandbook iconv ifp imlib java java6 jpeg kde kpathsea libnotify libsamplerate live lm_sensors mad midi mikmod mjpeg mmx mp3 mpeg mtp mudflap multilib ncurses nfs nls nptl nptlonly nsplugin nvidia ofx oggopenal openexr opengl openmp pam pcre pdf perl plotutils png ppds pppd python qt3 qt3support qt4 quicktime quotes readline realmedia reflection sdl session smp spell spl sql sse sse2 ssl startup-notification subversion svg sysfs tcpd theora threads threadsafe tiff truetype unicode usb visualizationvorbis wmp x264 xcomposite xinerama xml xorg xscreensaver xulrunner xv xvid zeroconf zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci 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_defaultauthz_groupfile authz_host authz_owner authz_user autoindex cache 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" CAMERAS="casio_qv directory spca50x" ELIBC="glibc" INPUT_DEVICES="keyboard mouse joystick evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en en_GB" USERLAND="GNU" VIDEO_CARDS="nvidia"
Comment 1 Dan Reidy 2009-04-15 15:43:11 UTC
same issue here
Comment 2 Mr. Bones. (RETIRED) gentoo-dev 2009-04-15 21:35:43 UTC
Patches welcome.  I don't use --as-needed.
Comment 3 Diego Elio Pettenò (RETIRED) gentoo-dev 2009-04-17 18:07:49 UTC
The problem is with the ordering of the libraries. What is asked to the linker is to:

link librt (why? there is nothing using it, so it's skipped)
move to static linking
link libgthread (that needs librt)
link librt (now there is need for it and is linked, but we're in static linking mode)
return to dynamic linking
(implicitly link the C library).

The _dl_cpuclock_offset symbol is needed by the static rt library and defined in the static C library, but it's neither needed nor defined in the dynamic versions.

This is actually a tricky situation, I guess the easy way out would be to remove the -lrt from the libraries found with libgthread and then append it _after_ returning to dynamic linking.

Or finally decide that glib is important for the system and move everything in /lib using dynamic linking ;)
Comment 4 Steve Kutnar 2009-04-22 00:09:46 UTC
Using the GCC spec to force --as-needed did NOT run into this problem.  I last built syslog-ng-2.1.4 on 4/13.
Comment 5 Steffen 'j0inty' Stollfuß 2009-04-30 18:30:10 UTC
Created attachment 189988 [details]
syslog-ng with --as-need linker flag buildlog


I ran into the same trouble !!!
Comment 6 Steve Kutnar 2009-04-30 21:31:42 UTC
Is this really failing with "forced" --as-needed, as the description says?  I thought it only failed with LDFLAGS="-Wl,--as-needed".

After all, if it really fails with "forced", then I must have been very lucky when it compiled for me on 4/13.  Could someone else please verify this and update the description accordingly?
Comment 7 pankkake 2009-06-11 05:15:36 UTC
It fails on my system with LDFLAGS="-Wl,-O1 -Wl,--as-needed" but not if I remove it.
Comment 8 404 Error 2009-08-10 11:47:26 UTC
The same happens here (glibc 2.10.1).
Comment 9 404 Error 2009-08-10 11:50:36 UTC
My apologies, I forgot to mention that I use GCC 4.4.1... Should this have to be considered as a ld bug and/or be reported ?
Comment 10 Steve Kutnar 2009-08-16 18:46:20 UTC
I recently emerged world after gcc-4.3.4 was released.  Once again, I used Flameeyes' method to generate a forced --as-needed gcc spec file, which is set as my default gcc profile.  This resulted in a successful build.  I suggest anyone playing with --as-needed to try this method instead of using '-Wl,--as-needed'.
Comment 11 Mr. Bones. (RETIRED) gentoo-dev 2009-12-22 04:19:00 UTC
I'll happily take a patch for this but I don't use --as-needed so there's not going to be any progress unless an actual user of that feature steps up.

I assume it's still the same with the 3.0.x series?
Comment 12 Samuli Suominen (RETIRED) gentoo-dev 2010-06-29 13:58:46 UTC
3.1.1 emerged just fine here with forced asneeded (and also got redudant -Wl,--as-needed in LDFLAGS if that matters, it doesn't)

also I can't remember even 2.1.x failing for me, but it's been a while.

so far as I know -> fixed by 3.1.1