Subject: ledmon: ftbfs with LTO (link time optimization) enabled

From: Matthias Klose <[email-masked]>
Date: Tue, 19 Jul 2022 16:54:20 +0000

Package: src:ledmon
Version: 0.95-2
Severity: minor
Tags: sid bookworm
User: [email-masked]
Usertags: ftbfs-lto

This package currently fails to build (at least on the amd64
architecture) with link time optimizations enabled.  For a background
for LTO please see

https://wiki.debian.org/ToolChain/LTO

The goal is to enable this optimization by default in an upcoming
Debian release in dpkg-buildflags for 64bit architectures.  The goal
is to get this package to build with link time optimizations, or to
explicitly disable link time optimizations for this package build.

To reproduce the build failure, enable the lto optimization in
testing/unstable by adding "optimize=+lto" to DEB_BUILD_MAINT_OPTIONS
in the debian/rules file, or if this macro is unset, just set it:

export DEB_BUILD_MAINT_OPTIONS = optimize=+lto

Please try to fix the build with lto enabled, fixing the packaging or
forwarding the issue upstream. If the issue cannot be fixed,
explicitly disallow building the package with lto by adding to your
rules file:

export DEB_BUILD_MAINT_OPTIONS = optimize=-lto

or adding that string to your existing setting of DEB_BUILD_MAINT_OPTIONS.

The full build log can be found at:
http://qa-logs.debian.net/2022/06/09/dpkglto/ledmon_0.95-2_unstable_dpkglto.log
The last lines of the build log are at the end of this report.

[...]
   71 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^
amd_sgpio.c: In function ‘_get_amd_sgpio_drive’:
utils.c:74:38: error: ‘%s’ directive output may be truncated writing 7 bytes into a region of size between 0 and 4095 [-Werror=format-truncation=]
   74 |         snprintf(temp, sizeof(temp), "%s/%s", path, name);
      |                                      ^
/usr/include/x86_64-linux-gnu/bits/stdio2.h:71:10: note: ‘__builtin___snprintf_chk’ output between 9 and 4104 bytes into a destination of size 4096
   71 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^
sysfs.c: In function ‘_check_cntrl’:
utils.c:74:38: error: ‘%s’ directive output may be truncated writing 6 bytes into a region of size between 0 and 4095 [-Werror=format-truncation=]
   74 |         snprintf(temp, sizeof(temp), "%s/%s", path, name);
      |                                      ^
/usr/include/x86_64-linux-gnu/bits/stdio2.h:71:10: note: ‘__builtin___snprintf_chk’ output between 8 and 4103 bytes into a destination of size 4096
   71 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^
utils.c:74:38: error: ‘%s’ directive output may be truncated writing 20 bytes into a region of size between 0 and 4095 [-Werror=format-truncation=]
   74 |         snprintf(temp, sizeof(temp), "%s/%s", path, name);
      |                                      ^
/usr/include/x86_64-linux-gnu/bits/stdio2.h:71:10: note: ‘__builtin___snprintf_chk’ output between 22 and 4117 bytes into a destination of size 4096
   71 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^
utils.c:74:38: error: ‘%s’ directive output may be truncated writing 14 bytes into a region of size between 0 and 4095 [-Werror=format-truncation=]
   74 |         snprintf(temp, sizeof(temp), "%s/%s", path, name);
      |                                      ^
/usr/include/x86_64-linux-gnu/bits/stdio2.h:71:10: note: ‘__builtin___snprintf_chk’ output between 16 and 4111 bytes into a destination of size 4096
   71 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^
sysfs.c: In function ‘_check_cntrl’:
utils.c:74:38: error: ‘%s’ directive output may be truncated writing 6 bytes into a region of size between 0 and 4095 [-Werror=format-truncation=]
   74 |         snprintf(temp, sizeof(temp), "%s/%s", path, name);
      |                                      ^
/usr/include/x86_64-linux-gnu/bits/stdio2.h:71:10: note: ‘__builtin___snprintf_chk’ output between 8 and 4103 bytes into a destination of size 4096
   71 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^
utils.c:74:38: error: ‘%s’ directive output may be truncated writing 20 bytes into a region of size between 0 and 4095 [-Werror=format-truncation=]
   74 |         snprintf(temp, sizeof(temp), "%s/%s", path, name);
      |                                      ^
/usr/include/x86_64-linux-gnu/bits/stdio2.h:71:10: note: ‘__builtin___snprintf_chk’ output between 22 and 4117 bytes into a destination of size 4096
   71 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^
utils.c:74:38: error: ‘%s’ directive output may be truncated writing 14 bytes into a region of size between 0 and 4095 [-Werror=format-truncation=]
   74 |         snprintf(temp, sizeof(temp), "%s/%s", path, name);
      |                                      ^
/usr/include/x86_64-linux-gnu/bits/stdio2.h:71:10: note: ‘__builtin___snprintf_chk’ output between 16 and 4111 bytes into a destination of size 4096
   71 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^
lto1: some warnings being treated as errors
make[4]: *** [/tmp/ccQQD4bG.mk:2: /tmp/ccR4E4tR.ltrans0.ltrans.o] Error 1
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:449: ledctl] Error 1
make[3]: *** Waiting for unfinished jobs....
lto1: some warnings being treated as errors
make[4]: *** [/tmp/ccN3VuqE.mk:2: /tmp/ccuLy8sc.ltrans0.ltrans.o] Error 1
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:453: ledmon] Error 1
make[3]: Leaving directory '/<<PKGBUILDDIR>>/src'
make[2]: *** [Makefile:448: all-recursive] Error 1
make[2]: Leaving directory '/<<PKGBUILDDIR>>'
make[1]: *** [Makefile:368: all] Error 2
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
dh_auto_build: error: make -j8 returned exit code 2
make: *** [debian/rules:8: binary] Error 25
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2