Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 368183 - ld ignores --as-needed?
Summary: ld ignores --as-needed?
Status: RESOLVED TEST-REQUEST
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: HPPA Linux
: Normal QA (vote)
Assignee: HPPA Porters
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-20 16:44 UTC by Jeroen Roovers (RETIRED)
Modified: 2022-12-23 07:09 UTC (History)
2 users (show)

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


Attachments
mail-filter:procmail-3.22-r10:20110520-163145.log (20110520-163145.log,30.64 KB, text/plain)
2011-05-20 16:44 UTC, Jeroen Roovers (RETIRED)
Details
Remove -lnet, read my LIBS properly, put LDFLAGS before all objects and libs (procmail-3.22-r10-libnet.patch,1.12 KB, patch)
2011-05-23 00:30 UTC, Jeroen Roovers (RETIRED)
Details | Diff
procmail-3.22-r10 original build log (mail-filter:procmail-3.22-r10:20110523-215419.log,12.64 KB, text/plain)
2011-05-24 21:09 UTC, Eray Aslan
Details
procmail-3.22 build log after the patch (mail-filter:procmail-3.22-r12:20110523-215911.log,12.53 KB, text/plain)
2011-05-24 21:09 UTC, Eray Aslan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeroen Roovers (RETIRED) gentoo-dev 2011-05-20 16:44:55 UTC
Created attachment 274115 [details]
mail-filter:procmail-3.22-r10:20110520-163145.log

Fri May 20 18:43:33 CEST 2011
Portage 2.1.9.49 (default/linux/hppa/10.0, gcc-4.4.5, glibc-2.12.2-r0, 2.6.39-rc7-git12-JeR parisc)
=================================================================
                        System Settings
=================================================================
System uname: Linux-2.6.39-rc7-git12-JeR-parisc-PA8700_-PCX-W2-with-gentoo-2.0.2
Timestamp of tree: Fri, 20 May 2011 15:15:01 +0000
distcc 3.1 hppa2.0-unknown-linux-gnu [enabled]
ccache version 2.4 [disabled]
app-shells/bash:          4.1_p9
dev-lang/python:          2.6.6-r2, 2.7.1-r1, 3.1.3-r1, 3.2
dev-util/ccache:          2.4-r9
dev-util/cmake:           2.8.4-r1
sys-apps/baselayout:      2.0.2
sys-apps/openrc:          0.8.2-r1
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.65-r1
sys-devel/automake:       1.4_p6-r1, 1.8.5-r4, 1.9.6-r3, 1.10.3, 1.11.1
sys-devel/binutils:       2.20.1-r1
sys-devel/gcc:            4.4.4-r2, 4.4.5, 4.5.1-r1
sys-devel/gcc-config:     1.4.1-r1
sys-devel/libtool:        2.2.10
sys-devel/make:           3.82
sys-kernel/linux-headers: 2.6.36.1 (virtual/os-headers)
sys-libs/glibc:           2.12.2
ACCEPT_KEYWORDS="hppa"
ACCEPT_LICENSE="* -@EULA"
CBUILD="hppa2.0-unknown-linux-gnu"
CFLAGS="-mschedule=8000 -march=2.0 -ggdb -pipe -Wall -Wno-comment -O2"
CHOST="hppa2.0-unknown-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib/distcc/bin /usr/share/gnupg/qualified.txt /usr/share/openvpn/easy-rsa /var/bind /var/spool/torque /var/www/localhost/htdocs/wordpress/wp-config.php"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/eselect/postgresql /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.2/ext-active/ /etc/php/apache2-php5.3/ext-active/ /etc/php/cgi-php5.2/ext-active/ /etc/php/cgi-php5.3/ext-active/ /etc/php/cli-php5.2/ext-active/ /etc/php/cli-php5.3/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-mschedule=8000 -march=2.0 -ggdb -pipe -Wall -Wno-comment -O2"
DISTDIR="/aches/distfiles"
FEATURES="assume-digests binpkg-logs buildpkg distcc distlocks fixlafiles fixpackages news notitles parallel-fetch protect-owned sandbox sfperms splitdebug strict test test-fail-continue unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv"
FFLAGS="-mschedule=8000 -march=2.0 -ggdb -pipe -Wall -Wno-comment -O2"
GENTOO_MIRRORS="http://de-mirror.org/distro/gentoo/ http://mirror.netcologne.de/gentoo/ http://ftp.snt.utwente.nl/pub/os/linux/gentoo http://gentoo.tiscali.nl/ "
LC_ALL="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed"
LINGUAS="en nl he"
MAKEOPTS="-j6"
PKGDIR="/keeps/gentoo/packages/elmer"
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="/mnt/alt"
PORTDIR="/keeps/gentoo/portage"
PORTDIR_OVERLAY="/keeps/gentoo/local"
SYNC="rsync://rsync.nl.gentoo.org/gentoo-portage"
USE="7zip X Xaw3d a52 aac aalib abyss accessibility acl ads agg alsa amr amrnb amrwb ao aoss apis ares artist-screen asf ass assistant async asyncns audiofile audit automount avfs bash-completion berkdb bidi bittorrent bittorrent-external bl bluetooth bzip2 c++ cairo caps captury catalogs cblas cdb cdio cdr chardet cjk clarens cleartype cli colors contrast cpath cracklib crypt cue cups curl custom-cflags custom-cxxflags cxx dbi dbtool dbus designer designer-plugin device-mapper dga dia dirac directfb djbfft djvu domainkeys dri drm dts dv dvd dvdr dvdread ebook edl elf emacs enca encode esd examples exceptions exif expat facebook facedetect fam fame fastbuild fastcgi fbcon ffmpeg filter fits flac fluidsynth fontconfig foomaticdb fortran fpx frei0r ftp fts3 gadu galago games gcrypt gd gdbm geant4 geoip ggi gif gimp gimpprint glep glib glut gmp gnokii gnutls gphoto2 gpm gps graphite gs gsl gsm gtk gtk2 gtkhtml guidexml guile hepmc hesiod hotpixels hppa i18n ical icecast iconv icu idea idn imagemagick imlib indi inotify inquisitio ipmi ipv6 isc ithreads jabber jack javascript jbig jingle jpeg jpeg2k judy kpathsea lame lapack lasi lastfmradio latex lcms ldap leim lensfun libass libcaca libffi libmms libotf libsamplerate libwww live logrotate logwatch lto lua lyrics-screen lzma lzo mad manhole matroska mbrola mem-scramble memcache metis mhash midi mikmod mmap mng modplug modules motif mozbranding mp3 mpg123 mpi mplayer mssql mudflap multislot musepack musicbrainz mysql nagios-dns nagios-game nagios-ntp nagios-ping nagios-ssh nas ncurses netpbm nettle network-cron nfconntrack nfs nls nntp nova nptl nptlonly nsplugin ntlm objc objc++ objc-gc offensive ogg openal openexr opengl openmp openssl optimization oss ots overlays pam pango pbs pch pcre pdf pdo-external perl php pipe plasma plotutils plugins png policykit portage portaudio postgres povray ppds pppd pulseaudio python pyzord qalculate qdbm qt3support qt4 quotas raw readline recode rle romio rpc rrdtool rtc rtmp ruby ruby18 samba sasl scale0tilt scanner scim sdl seamonkey secure-delete server session sid skk slang slp smi sms sndfile snmp soap song-screen soundex speex spell spoof-source sqlite srt srtp ssh ssl startup-notification strong-optimization subtitles subversion suhosin supernodal svg swat sysfs syslog system-sqlite talkfilters tcl tcpd test tftp tga theora threads thumbnail thunar-vfs tidy tiff timezone timidity tk tokyocabinet tools truetype tslib tunepimp twolame udev unicode unzip urandom usb userlocales utempter utf v4l v4l2 vanim vcd vidix vim-syntax vorbis watchdog wavpack webdav webinstall webp wildmidi winbind wlan wma wmf xanim xattr xcb xchattext xcomposite xface xlisten xml xml2 xmp xmpi xorg xpm xrandr xscreensaver xsettings xulrunner xv xvid xvmc zip zip-external zlib" ALSA_CARDS="ad1889 usb-audio" 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="braindump flow karbon kexi kpresenter krita tables words" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" 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 joystick keyboard mouse acecad aiptek calcomp citron digitaledge dmc dynapro elo2300 elographics fpit hyperpen jamstudio magellan microtouch mutouch palmax penmount spaceorb summa tek4957 tslib ur98 wacom void" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en nl he" PHP_TARGETS="php5-2 php5-3" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="stifb fbdev none dummy" 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, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

mail-filter/procmail-3.22-r10 was built with the following:
USE="test -mbox (-selinux)"
CFLAGS="-mschedule=8000 -march=2.0 -ggdb -pipe -Wall -Wno-comment -O2 -fno-inline-functions"
CXXFLAGS="-mschedule=8000 -march=2.0 -ggdb -pipe -Wall -Wno-comment -O2 -fno-inline-functions"
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2011-05-20 16:49:10 UTC
elmer ~ # ldd /usr/bin/procmail
        libm.so.6 => /lib/libm.so.6 (0x402d1000)
        libnet.so.1 => /usr/lib/libnet.so.1 (0x40551000)
        libc.so.6 => /lib/libc.so.6 (0x40965000)
        /lib/ld.so.1 (0x4016e000)
elmer ~ # qfile /usr/lib/libnet.so.1
net-libs/libnet (/usr/lib/libnet.so.1)
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2011-05-20 17:04:23 UTC
Looks like it fails to respect LDFLAGS too, because if it doesn't need -lnet, then --as-needed should make sure the procmail binary isn't linked to libnet. Maybe the LDFLAGS should be moved to the front of the linker call, e.g. right after CFLAGS and before all the object files are mentioned.
Comment 3 Jeroen Roovers (RETIRED) gentoo-dev 2011-05-23 00:30:29 UTC
Created attachment 274347 [details, diff]
Remove -lnet, read my LIBS properly, put LDFLAGS before all objects and libs
Comment 4 Eray Aslan gentoo-dev 2011-05-23 06:42:24 UTC
I couldn't get procmail to link against libnet.  But your patch looks good and reasonable.  One question though before I apply it:

sed
[...]
-e '/^LDFLAGS\t=/s:).*:):g' \
[...]
-i Makefile || die "sed failed"

what's that supposed to do?  You are deleting everything after the parantheses.  Fine but there is no ^LDFLAGS\t= in the Makefile.  Am I missing something?
Comment 5 Jeroen Roovers (RETIRED) gentoo-dev 2011-05-23 11:13:38 UTC
(In reply to comment #4)
> I couldn't get procmail to link against libnet. 

Is net-libs/libnet installed on your system?

> But your patch looks good and
> reasonable.  One question though before I apply it:
> 
> sed
> [...]
> -e '/^LDFLAGS\t=/s:).*:):g' \
> [...]
> -i Makefile || die "sed failed"
> 
> what's that supposed to do?  You are deleting everything after the parantheses.
>  Fine but there is no ^LDFLAGS\t= in the Makefile.  Am I missing something?

May have been left over from testing. Since one Makefile is making another Makefile, I couldn't really track where the stuff after the ) was added - since they were the contents of $(LIBS), and since I was inserting $(LIBS) elsewhere already, I just removed the hard-coded linker flags as I found them.
Comment 6 Eray Aslan gentoo-dev 2011-05-24 21:05:15 UTC
(In reply to comment #5)
> Is net-libs/libnet installed on your system?

Yes:

# ls -l /usr/lib64/libnet* /usr/bin/procmail 
-rwsr-s--x 1 root root  88352 May 24 00:50 /usr/bin/procmail
-rw-r--r-- 1 root root 203946 May 22 19:52 /usr/lib64/libnet.a
-rw-r--r-- 1 root root    804 May 22 19:52 /usr/lib64/libnet.la
lrwxrwxrwx 1 root root     15 May 22 19:52 /usr/lib64/libnet.so -> libnet.so.1.6.0
lrwxrwxrwx 1 root root     15 May 22 19:52 /usr/lib64/libnet.so.1 -> libnet.so.1.6.0
-rwxr-xr-x 1 root root  92568 May 22 19:52 /usr/lib64/libnet.so.1.6.0
-rw-r--r-- 1 root root  20766 Nov 26 17:49 /usr/lib64/libnetlink.a
# ldd /usr/bin/procmail 
	linux-vdso.so.1 =>  (0x00007fff731ff000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f0e439fa000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f0e43694000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f0e43c7b000)

> May have been left over from testing. Since one Makefile is making another
> Makefile, I couldn't really track where the stuff after the ) was added - since
> they were the contents of $(LIBS), and since I was inserting $(LIBS) elsewhere
> already, I just removed the hard-coded linker flags as I found them.

Well, here is one example command that is run on my laptop with procmail-3.22-r10:

x86_64-pc-linux-gnu-gcc -O2 -pipe -march=core2 -fno-inline-functions   lockfile.o exopen.o sublib.o acommon.o mcommon.o authenticate.o lastdirsep.o -o lockfile -Wl,-z,now -Wl,-O1 -Wl,--as-needed   -lm -lnet -lnsl -ldl -lc

And here is the same command after your patch:

x86_64-pc-linux-gnu-gcc -O2 -pipe -march=core2 -fno-inline-functions   -s   -lm -lnsl -ldl -lc lockfile.o exopen.o sublib.o acommon.o mcommon.o authenticate.o lastdirsep.o -o lockfile

Not good.  I'll attach both build.logs in case you are interested.
Comment 7 Eray Aslan gentoo-dev 2011-05-24 21:09:02 UTC
Created attachment 274539 [details]
procmail-3.22-r10 original build log
Comment 8 Eray Aslan gentoo-dev 2011-05-24 21:09:42 UTC
Created attachment 274541 [details]
procmail-3.22 build log after the patch
Comment 9 Jeroen Roovers (RETIRED) gentoo-dev 2011-05-25 00:22:41 UTC
Comment on attachment 274347 [details, diff]
Remove -lnet, read my LIBS properly, put LDFLAGS before all objects and libs

Well, skip that last chunk and focus on the first one. We don't want to link against libnet in any case, not because it or something called the same name happens to be there.

I am nearly certain that net-libs/libnet has nothing to do with the -lnet in the Makefiles, but that some libnet library may have existed at some point on some obscure Unix-like OS.
Comment 10 Jeroen Roovers (RETIRED) gentoo-dev 2011-05-25 01:59:34 UTC
OK, I noticed the original problem because on _one_ system, procmail could no longer find libnet.so, since it never needed it in the first place and should never have been linked to it. However, procmail was last emerged on that system (in 2009 when -r10 went stable) before --as-needed got added to the default LDFLAGS.

To test I picked a seemingly random system with libnet installed, which happened to be a PA-RISC one, and tried to reproduce the problem, which succeeded. So I thought I had a case there. It turns out now that I cannot reproduce the problem on any other system than the PA-RISC, which gave us the build log I provided above and the `emerge --info' output in the Description. Apparently it ignores --as-needed for some reason. Let's say then that this is an HPPA problem.
Comment 11 matoro archtester 2022-12-01 02:53:36 UTC
This no longer seems to be an issue.  Installed net-libs/libnet, followed by mail-filter/procmail:

# ldd /usr/bin/procmail
        linux-vdso32.so.1 (0xf7afe000)
        libm.so.6 => /lib/libm.so.6 (0xf7654000)
        libc.so.6 => /lib/libc.so.6 (0xf73c1000)
        /lib/ld.so.1 (0xf77c1000)

Did not link to libnet.  Retest please?