This Time Self-Hosted
dark mode light mode Search

The case of the missing –as-needed

(Another quote title, although not of the same continuity than the two before, this time it’s Meitantei Conan 😉 )

So seems like the recent breakage due to expat changing soname from to shown to some fellow devs and to other advanced users that –as-needed can be useful. I had a total of 9 files linking to libexpat, and I just needed to rebuild fontconfig to have KDE still working, no rebuild of qt, kdelibs or any kde package at all.

Many people asked me about –as-needed lately, so I started providing more often my –as-needed fixing guide link, as that tries to summarise more or less what you have to know about that flag and the way to fix packages not supporting it. I wish to thanks antarus who cleaned it up, as it used to suck grammatically more than it sucks for the content.

Still there’s who likes to be prissy about these things, wondering why that guide is in qa as “–as-needed is rice”… oh well, if –as-needed is rice, then hardened is rice too, selinux is rice, mips porting is rice..
I don’t see how someone can define rice something that makes the linker work as it should have done rather than following blindly what a developer (that might not even know how a linker work) told it to do.

Anyway, I hope that the attention that –as-needed got recently will help with the efforts to fix the packages that doesn’t work with it so that we can actually start suggesting that to users, as that limits the breakage in case of soname change to the actual packages making use of the changed library, rather than almost the whole system.

Oh a side note, I’m sorry for the wrong patch in drkonqi/kdebase I committed tonight, seems like I was half asleep when I decided to change from the patch full name to ${P}… anyway now with that patch you’re able to get decent backtraces with drkonqi also when using splitdebug, be happy! 🙂

Comments 5
  1. (Sorry for posting here, but is the fastest way…)The mentioned version of binutils in the “–as-needed fixing guide” is wrong. binutils- are not available. The latest version in portage is bintils-

  2. This was a real eye-opener for me, I’d like to give it a shot. Using –as-needed won’t remove (possible) debugging symbols will it?

  3. orbit-0.5.17-r1 does not compile with LDFLAGS=”-Wl,-O1,–as-needed”(does compile with these LDFLAGS turned off)

  4. Here’s another one that doesn’t like LDFLAGS=”-Wl,-O1,–as-needed”cppunit-1.10.2 (needed for kmymoney2)/bin/sh ../../libtool --mode=link i686-pc-linux-gnu-g++ -march=pentium-m -O2 -pipe -Wl,-O1,--as-needed -o DllPlugInTester -ldl DllPlugInTester.o CommandLineParser.o ../../src/cppunit/libcppunit.lamkdir .libsi686-pc-linux-gnu-g++ -march=pentium-m -O2 -pipe -Wl,-O1 -Wl,--as-needed -o .libs/DllPlugInTester DllPlugInTester.o CommandLineParser.o -ldl ../../src/cppunit/.libs/ /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/ -L/usr/i686-pc-linux-gnu/bin -L/usr/i686-pc-linux-gnu/lib -Wl,--rpath -Wl,/usr/lib/gcc/i686-pc-linux-gnu/3.4.6../../src/cppunit/.libs/ undefined reference to `dlclose'../../src/cppunit/.libs/ undefined reference to `dlopen'../../src/cppunit/.libs/ undefined reference to `dlsym'collect2: ld returned 1 exit statusmake[2]: *** [DllPlugInTester] Error 1make[2]: Leaving directory `/var/tmp/portage/portage/cppunit-1.10.2/work/cppunit-1.10.2/src/DllPlugInTester'make[1]: *** [all-recursive] Error 1make[1]: Leaving directory `/var/tmp/portage/portage/cppunit-1.10.2/work/cppunit-1.10.2/src'make: *** [all-recursive] Error 1

  5. Here’s another that doesn’t like –as-needed (with error). This is being compiled on gcc-3.4.6-r1www-misc/htdigs-3.2.0_beta6(cd .libs && rm -f && ln -s cru .libs/libfuzzy.a Endings.o EndingsDB.o Exact.o Fuzzy.o Metaphone.o Soundex.o Accents.o SuffixEntry.o Synonym.o Substring.o Prefix.o Regexp.o Speling.oranlib .libs/libfuzzy.acreating .libs && rm -f && ln -s ../ ../libtool --mode=link g++ -march=pentium-m -O2 -pipe -Wall -fno-rtti -fno-exceptions -Wl,-O1,--as-needed -o htfuzzy htfuzzy.o ../htnet/ ../htcommon/ ../htword/ ../htlib/ ../htcommon/ ../htword/ ../db/ ../htlib/ -lzg++ -march=pentium-m -O2 -pipe -Wall -fno-rtti -fno-exceptions -Wl,-O1 -Wl,--as-needed -o .libs/htfuzzy htfuzzy.o ./.libs/ ../htnet/.libs/ ../htcommon/.libs/ ../htword/.libs/ ../db/.libs/ ../htlib/.libs/ -lz -Wl,--rpath -Wl,/usr/lib/htdig -Wl,--rpath -Wl,/usr/lib/htdig_db../htlib/.libs/ undefined reference to `CDB_db_create'../htlib/.libs/ undefined reference to `CDB_db_strerror'../htlib/.libs/ undefined reference to `CDB_db_env_create'collect2: ld returned 1 exit statusmake[1]: *** [htfuzzy] Error 1make[1]: Leaving directory `/var/tmp/portage/portage/htdig-3.2.0_beta6/work/htdig-3.2.0b6/htfuzzy'make: *** [all-recursive] Error 1

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.