As discussed at [1]. The attached patch might very well clash with your coding standards, but parts of it may prove useful generally.
[1] https://bugs.gentoo.org/show_bug.cgi?id=295165
Bug watches keep track of this bug in other bug trackers.