Bug#1015423: grub2: ftbfs with LTO (link time optimization) enabled

Matthias Klose doko at debian.org
Tue Jul 19 17:52:45 BST 2022


Package: src:grub2
Version: 2.06-2
Severity: minor
Tags: sid bookworm
User: debian-gcc at lists.debian.org
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/grub2_2.06-2_unstable_dpkglto.log
The last lines of the build log are at the end of this report.

[...]
    inlined from ‘grub_memcpy’ at ../../include/grub/misc.h:71:10,
    inlined from ‘configure_ciphers’ at ../../grub-core/disk/geli.c:395:3:
../../grub-core/kern/misc.c:86:12: error: ‘__builtin_memcpy’ reading 72 bytes from a region of size 71 [-Werror=stringop-overflow=]
   86 |       *d++ = *s++;
      |            ^
In function ‘grub_memmove’,
    inlined from ‘grub_memmove’ at ../../grub-core/kern/misc.c:79:1,
    inlined from ‘grub_memcpy’ at ../../include/grub/misc.h:71:10,
    inlined from ‘configure_ciphers’ at ../../grub-core/disk/geli.c:395:3:
../../grub-core/kern/misc.c:93:7: error: ‘__builtin_memcpy’ reading 72 bytes from a region of size 71 [-Werror=stringop-overflow=]
   93 |  *--d = *--s;
      |       ^
lto1: all warnings being treated as errors
make[5]: *** [/tmp/cc0Naxva.mk:23: /tmp/grub-mount.5qucak.ltrans7.ltrans.o] Error 1
gcc-10 -std=gnu99 -Wall -Wno-error=unused-result -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value  -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wcast-align  -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -Werror -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion   -flto=auto -ffat-lto-objects -Wl,-z,relro    -o grub-mklayout util/grub_mklayout-grub-mklayout.o grub-core/kern/emu/grub_mklayout-argp_common.o grub-core/osdep/grub_mklayout-init.o  libgrubmods.a libgrubgcry.a libgrubkern.a grub-core/lib/gnulib/libgnu.a  -ldevmapper     
gcc-10 -std=gnu99 -Wall -Wno-error=unused-result -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value  -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wcast-align  -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -Werror -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -I/usr/include/efivar   -flto=auto -ffat-lto-objects -Wl,-z,relro    -o grub-mkrescue util/grub_mkrescue-grub-mkrescue.o util/grub_mkrescue-render-label.o util/grub_mkrescue-glue-efi.o util/grub_mkrescue-mkimage.o util/grub_mkrescue-grub-mkimage32.o util/grub_mkrescue-grub-mkimage64.o util/grub_mkrescue-grub-install-common.o util/grub_mkrescue-setup_bios.o util/grub_mkrescue-setup_sparc.o grub-core/lib/grub_mkrescue-reed_solomon.o grub-core/osdep/grub_mkrescue-random.o grub-core/osdep/grub_mkrescue-ofpath.o grub-core/osdep/grub_mkrescue-platform.o grub-core/osdep/grub_mkrescue-platform_unix.o grub-core/osdep/grub_mkrescue-compress.o grub-core/osdep/grub_mkrescue-efivar.o util/grub_mkrescue-editenv.o grub-core/osdep/grub_mkrescue-blocklist.o grub-core/osdep/grub_mkrescue-config.o util/grub_mkrescue-config.o grub-core/kern/emu/grub_mkrescue-hostfs.o grub-core/disk/grub_mkrescue-host.o util/grub_mkrescue-resolve.o grub-core/kern/emu/grub_mkrescue-argp_common.o grub-core/osdep/grub_mkrescue-init.o  -llzma libgrubmods.a libgrubgcry.a libgrubkern.a grub-core/lib/gnulib/libgnu.a  -ldevmapper     -lefivar -lefiboot  
gcc-10 -std=gnu99 -Wall -Wno-error=unused-result -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value  -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wcast-align  -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -Werror -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -I/usr/include/efivar   -flto=auto -ffat-lto-objects -Wl,-z,relro    -o grub-mkstandalone util/grub_mkstandalone-grub-mkstandalone.o util/grub_mkstandalone-render-label.o util/grub_mkstandalone-glue-efi.o util/grub_mkstandalone-mkimage.o util/grub_mkstandalone-grub-mkimage32.o util/grub_mkstandalone-grub-mkimage64.o util/grub_mkstandalone-grub-install-common.o util/grub_mkstandalone-setup_bios.o util/grub_mkstandalone-setup_sparc.o grub-core/lib/grub_mkstandalone-reed_solomon.o grub-core/osdep/grub_mkstandalone-random.o grub-core/osdep/grub_mkstandalone-ofpath.o grub-core/osdep/grub_mkstandalone-platform.o grub-core/osdep/grub_mkstandalone-platform_unix.o grub-core/osdep/grub_mkstandalone-compress.o grub-core/osdep/grub_mkstandalone-efivar.o util/grub_mkstandalone-editenv.o grub-core/osdep/grub_mkstandalone-blocklist.o grub-core/osdep/grub_mkstandalone-config.o util/grub_mkstandalone-config.o grub-core/kern/emu/grub_mkstandalone-hostfs.o grub-core/disk/grub_mkstandalone-host.o util/grub_mkstandalone-resolve.o grub-core/kern/emu/grub_mkstandalone-argp_common.o grub-core/osdep/grub_mkstandalone-init.o  -llzma libgrubmods.a libgrubgcry.a libgrubkern.a grub-core/lib/gnulib/libgnu.a  -ldevmapper     -lefivar -lefiboot  
gcc-10 -std=gnu99 -Wall -Wno-error=unused-result -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value  -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wcast-align  -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -Werror -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -I/usr/include/efivar   -flto=auto -ffat-lto-objects -Wl,-z,relro    -o grub-mknetdir util/grub_mknetdir-grub-mknetdir.o util/grub_mknetdir-mkimage.o util/grub_mknetdir-grub-mkimage32.o util/grub_mknetdir-grub-mkimage64.o util/grub_mknetdir-grub-install-common.o util/grub_mknetdir-setup_bios.o util/grub_mknetdir-setup_sparc.o grub-core/lib/grub_mknetdir-reed_solomon.o grub-core/osdep/grub_mknetdir-random.o grub-core/osdep/grub_mknetdir-ofpath.o grub-core/osdep/grub_mknetdir-platform.o grub-core/osdep/grub_mknetdir-platform_unix.o grub-core/osdep/grub_mknetdir-compress.o grub-core/osdep/grub_mknetdir-efivar.o util/grub_mknetdir-editenv.o grub-core/osdep/grub_mknetdir-blocklist.o grub-core/osdep/grub_mknetdir-config.o util/grub_mknetdir-config.o util/grub_mknetdir-resolve.o grub-core/kern/emu/grub_mknetdir-argp_common.o grub-core/osdep/grub_mknetdir-init.o  -llzma libgrubmods.a libgrubgcry.a libgrubkern.a grub-core/lib/gnulib/libgnu.a  -ldevmapper     -lefivar -lefiboot  
gcc-10 -std=gnu99 -Wall -Wno-error=unused-result -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value  -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wcast-align  -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -Werror -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion   -flto=auto -ffat-lto-objects -Wl,-z,relro    -o grub-menulst2cfg util/grub_menulst2cfg-grub-menulst2cfg.o grub-core/lib/grub_menulst2cfg-legacy_parse.o grub-core/lib/i386/pc/grub_menulst2cfg-vesa_modes_table.o grub-core/osdep/grub_menulst2cfg-init.o  libgrubmods.a libgrubgcry.a libgrubkern.a grub-core/lib/gnulib/libgnu.a  -ldevmapper     
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[4]: *** [Makefile:4932: grub-fstest] Error 1
make[4]: *** Waiting for unfinished jobs....
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[4]: *** [Makefile:5347: grub-mount] Error 1
In function ‘grub_memmove’,
    inlined from ‘grub_memcpy’ at ../../include/grub/misc.h:71:10,
    inlined from ‘configure_ciphers’ at ../../grub-core/disk/geli.c:395:3:
../../grub-core/kern/misc.c:86:12: error: ‘__builtin_memcpy’ reading 72 bytes from a region of size 71 [-Werror=stringop-overflow=]
   86 |       *d++ = *s++;
      |            ^
In function ‘grub_memmove’,
    inlined from ‘grub_memmove’ at ../../grub-core/kern/misc.c:79:1,
    inlined from ‘grub_memcpy’ at ../../include/grub/misc.h:71:10,
    inlined from ‘configure_ciphers’ at ../../grub-core/disk/geli.c:395:3:
../../grub-core/kern/misc.c:93:7: error: ‘__builtin_memcpy’ reading 72 bytes from a region of size 71 [-Werror=stringop-overflow=]
   93 |  *--d = *--s;
      |       ^
../../grub-core/fs/zfs/zfsinfo.c: In function ‘grub_cmd_zfs_bootfs’:
../../grub-core/fs/zfs/zfsinfo.c:401:12: error: ‘mdnobj’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  401 |   bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu%s%s%s%s%s%s",
      |            ^
../../grub-core/fs/zfs/zfsinfo.c:355:17: note: ‘mdnobj’ was declared here
  355 |   grub_uint64_t mdnobj;
      |                 ^
lto1: all warnings being treated as errors
make[5]: *** [/tmp/ccG6NqaZ.mk:23: /tmp/grub-mkrescue.GbCkZB.ltrans7.ltrans.o] Error 1
make[5]: *** Waiting for unfinished jobs....
lto1: all warnings being treated as errors
make[5]: *** [/tmp/ccG6NqaZ.mk:32: /tmp/grub-mkrescue.GbCkZB.ltrans10.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[4]: *** [Makefile:5265: grub-mkrescue] Error 1
make[4]: Leaving directory '/<<PKGBUILDDIR>>/obj/grub-pc'
make[3]: *** [Makefile:12129: all-recursive] Error 1
make[3]: Leaving directory '/<<PKGBUILDDIR>>/obj/grub-pc'
make[2]: *** [Makefile:3836: all] Error 2
make[2]: Leaving directory '/<<PKGBUILDDIR>>/obj/grub-pc'
dh_auto_build: error: cd obj/grub-pc && make -j8 returned exit code 2
make[1]: *** [debian/rules:280: debian/stamps/build-grub-pc] Error 25
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
make: *** [debian/rules:137: binary] Error 2
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2



More information about the Pkg-grub-devel mailing list