Summing up the binutils trouble

Let’s sum up the binutils trouble with KDE and with other bugs too.

For a bug in 2.16.92 and 2.16.93 versions of binutils, the –as-needed flag ended up doing something more than is documented, instead of simply skipping DT_NEEDED entries, it also discarded the search path for the libraries passed in command line that get discarded.

If from one side this can be seen as a correct behaviour, this broke with almost every build system, like for instance everything using libtool. It broke in the sense that it ended up looking up the libraries installed in the system rather than the ones just build, failing to find them if they weren’t installed and cross-linking them if they were. The result is not good.

Luckily there is a patch laying in binutils-devel mailing list and it has been committed hopefully for 2.17. In the mean time you have either to cope with the problem or simply use my overlay and use binutils that are there. They are already patched for -Bdirect and -hashvals support (the latter more to avoid breakages).

I might end up closing some bugs pointing to this blog post as it’s boring to repeat the same stuff too many times ;)

Today’s little tricks

So, although I should be in break, also today I ended up doing some kind of work, a part updating the ALSA guide as I told before today, I’ve also taken a deeper look into my backlogs, and I found that I still had a few packages that needed to be fixed because they were stripping binaries.

As I was doing that, I wanted to provide a few useful pointers that might be not that obvious and I found interesting to know.

The first is a bash trick, or better a particular way to use bash that might come handy. Many people often use something like

for file in $(find . -type f); do stuff; done

I seen that used often also in ebuilds. Although it works, there are often better ways to do this (like using sed -i -e on multiple files instead of using a for to get file-by-file and use sed -e > tmpfile and so on). In those cases when the cycle is actually needed, there’s something that might come handy to know tho.

I found this myself when running the cycle that gets the list of files that are installed with stripped debug information (thing that makes my efforts to get the system fully debuggable useless :P). It was a for that used scanelf’s output, and it stuck waiting for scanelf to complete before starting looking at the files, probably because I was invoking a subshell with $().
If instead of doing that I do this:

scanelf -k '!.symtab' -F '#k%F' -qRB /usr/lib/debug 
   | while read file; do qfile -C ${file}; done

and thus use a pipe, I start getting output even if scanelf didn’t complete.
I know this might be obvious to seasoned bash coders, but it’s probably a neat trick to know for the newbies.

The other is not exactly a trick but an information that I should probably add to the backtraces guide. Some time ago I asked to solar about some files that didn’t get the debug info copied in /usr/lib/debug before strip. The problem was difficult to reproduce and he wasn’t actually sure what the cause was.
Well I can say now that the problem was either in GCC or in Binutils, as some packages like procps that had no debug information are now correctly copied. The same happened with some of the gcc’s libraries (although the c++ compiler still has debug information stripped). So if you ever see an “Invalid Operation” error from objcopy during stripping, you have to know that we probably can’t do much about that.

Strictness of the linker

I suppose people do remember my series of blogging about the —as-needed compiler flag, at least looking at the number of bugs I have assigned or CCed to me for that feature. Actually there are more than I can handle lately, with all the stuff I have to keep up with (not counting the personal life problems, too).

For who didn’t notice, the new version of binutils (2.16.92) albeit not segfaulting anymore when building complex software like wxGTK with —as-needed has a few problems with it.

These are not problems difficult to overcome, as they are not actual bugs of the linker, is just that the linker itself became even more stricter than it was before, and thus more packages fail with —as-needed enabled.
An example of that is net-snmp that requires an extra patch I’m going to submit soon.

This means that the work has to continue and I was proved unreliable to be almost the only one taking a look of the bugs without patches, as I don’t have enough time and most of the software is stuff I don’t have installed at all.

So, if you want to have this feature better supported in Gentoo, please take a look to tracker bug #129413 and try to find working solutions at the bug there depending. I’ll try to looking at them as soon as I have time, but I can’t ensure much of my presence on that bug, as I mainly think of SoC and Gentoo/FreeBSD and KDE lately.

Can someone give me some more time a day? :P