-
Notifications
You must be signed in to change notification settings - Fork 96
Debugging
Sometimes breakages happen when you emerge new packages or update existing ones. There are a number of potential ways that an emerge might not work. Below is a comprehensive list of problems that have been observed.
Some packages don't fully respect LDFLAGS, for various reasons. These tend to manifest around link time with unresolved symbol errors. My first strategy for dealing with these is to try building the package with -ffat-lto-objects
enabled (*FLAGS+=-ffat-lto-objects
). If the unresolved symbols belong to an external library, I usually rebuild that one with -ffat-lto-objects
too, because the current package being emerged isn't properly handling the LTO flags and it wants to link against the non LTOed symbols. Sometimes, however, the package itself just doesn't like LTO for some reason, and you have to disable it entirely (*FLAGS-=-flto*
)
The default linker used by sys-devel/binutils
is ld.bfd
. This linker is older but generally has been considered
more reliable than ld.gold
, which is newer and generally faster, but also is not really maintainedi (#351). It has been observed that ld.gold
enables certain packages to
build that ld.bfd
has trouble with, however. Try switching to ld.gold
if the package fails to build if you haven't already.
In the future, it is likely GentooLTO will begin mandating ld.gold
as the default linker. You can switch to ld.gold
by running binutils-config --linker ld.gold
.
I've never actually yet emerged a package that causes the Graphite optimizations to emit bad code with, but sometimes the Graphite optimizer itself crashes during compilation. If this is the case, I'll usually use the "LTO-with-no-Graphite" configuration: *FLAGS-="${GRAPHITE}"
. Please consider making a bug report in GCC if you get an ICE.
These are rare, but they do happen. When this happens, I usually force down to -O2
(which disables Graphite implicitly in this configuration) using package.cflags
.
-fipa-pta
was broken until GCC 9.1.0. As we are on the latest GCC, this is now a part of the GentooLTO default
configuration.
- First try adding
-ffat-lto-objects
- If that doesn't work, try removing Graphite:
*FLAGS-="${GRAPHITE}"
- If that doesn't work, try removing -fipa-pta (if in use):
*FLAGS-="-fipa-pta
- If that doesn't work, try removing -fno-semantic-interposition:
*FLAGS-="-fno-semantic-interposition"
- If that doesn't work, try removing -fno-plt (if in use):
*FLAGS-="-fno-plt"
- If that doesn't work, try removing -fdevirtualize-at-ltrans (if in use):
*FLAGS-="-fdevirtualize-at-ltrans"
- If that doesn't work, try removing -O3:
/-O3/-O2
- If that doesn't work, try removing LTO:
*FLAGS-=-flto*
- If that doesn't work, try adding
-fcommon
(not an LTO bug, but of interest anyways) - If that doesn't work, try switching linkers (from ld.bfd to ld.gold or backwards)
- If that doesn't work, it's probably not an LTO error, but submit it anyway and we'll take a look.
Once you get a package building with one or more of the above workarounds, work backwards and try and see what the minimum number of workarounds are for the package. If you're having trouble, don't hesitate to file an issue.