Fails to build with LTO, debug symbols enabled
Environment/Versions
- GIMP version: commit 6919d07b (latest one still using a released version of gegl)
- Package: Building from source
- Operating System: Linux?
Description of the bug
FAILED: libgimp/check-def-files
/usr/bin/python3 /builddir/tools/defcheck.py /builddir
Problem found in /builddir/libgimpbase/gimpbase.def
the following symbols are in the library,
but are not listed in the .def-file:
+ gimpcompatenums.c.33566824
Reproduction
Is the bug reproducible? Always
Reproduction steps:
- Clone the gimp repository
- Try to build it using gcc 13, LTO, fat LTO objects, and debug symbols enabled
- Observe build
Expected result: Build succeeds
Actual result: Build fails
Additional information
When LTO is enabled, GCC creates symbols containing debug info named after the source file. Normally those symbols are made local during linking. However, if the object file contains no other symbols (as is the case with gimpcompatenums.c
, which is empty), the symbol remains external weak hidden.
As the symbol is hidden and is not listed in the dynamic symbols, it is not visible to other objects, so this is not an issue. It is still stored in the debug section, so stripping the library would remove it.
It appears that nm
doesn't have an option to omit hidden symbols. One fix/workaround is to only check the dynamic symbols (the ones resolved at runtime) in defcheck.py
, which is also closer to what we want to actually verify:
--- a/tools/defcheck.py
+++ b/tools/defcheck.py
@@ -81,11 +81,11 @@
unsortindex = i+1
break;
- status, nm = subprocess.getstatusoutput ("nm --defined-only --extern-only " +
+ status, nm = subprocess.getstatusoutput ("nm --dynamic --defined-only --extern-only " +
libname)
if status != 0:
libname_meson = path.join(directory, "lib" + basename + "-*.so")
- status, nm = subprocess.getstatusoutput ("nm --defined-only --extern-only " +
+ status, nm = subprocess.getstatusoutput ("nm --dynamic --defined-only --extern-only " +
libname_meson)
if status != 0:
print("trouble reading {} or {} - has it been compiled?".format(libname, libname_meson))