Some Eoan GCC (9) errors in my environment:
----
In file included from /usr/include/string.h:494,
from /home/inaddy/work/sources/ubuntu/qemu/include/qemu/osdep.h:101,
from /home/inaddy/work/sources/ubuntu/qemu/util/qemu-sockets.c:18:
In function ‘strncpy’,
inlined from ‘unix_connect_saddr.isra.0’ at /home/inaddy/work/sources/ubuntu/qemu/util/qemu-sockets.c:925:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 108 equals destination size [-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
inlined from ‘unix_listen_saddr.isra.0’ at /home/inaddy/work/sources/ubuntu/qemu/util/qemu-sockets.c:880:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 108 equals destination size [-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
----
Fixed (and tested) by upstream commit:
commit 2d2023c3b99edb33ad4bb9791f70456ea1a1c049
Author: Daniel P. Berrangé <email address hidden>
Date: Wed May 1 11:50:52 2019
sockets: avoid string truncation warnings when copying UNIX path
----
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c: In function ‘init_qxl_ram’:
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c:50:19: error: taking address of packed member of ‘struct QXLReleaseRing_ring_el’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
50 | ret = &(r)->items[prod].el; \
| ^~~~~~~~~~~~~~~~~~~~
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c:429:5: note: in expansion of macro ‘SPICE_RING_PROD_ITEM’
429 | SPICE_RING_PROD_ITEM(d, &d->ram->release_ring, item);
| ^~~~~~~~~~~~~~~~~~~~
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c: In function ‘qxl_push_free_res’:
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c:50:19: error: taking address of packed member of ‘struct QXLReleaseRing_ring_el’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
50 | ret = &(r)->items[prod].el; \
| ^~~~~~~~~~~~~~~~~~~~
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c:762:5: note: in expansion of macro ‘SPICE_RING_PROD_ITEM’
762 | SPICE_RING_PROD_ITEM(d, ring, item);
| ^~~~~~~~~~~~~~~~~~~~
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c: In function ‘interface_release_resource’:
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c:50:19: error: taking address of packed member of ‘struct QXLReleaseRing_ring_el’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
50 | ret = &(r)->items[prod].el; \
| ^~~~~~~~~~~~~~~~~~~~
/home/inaddy/work/sources/ubuntu/qemu/hw/display/qxl.c:795:5: note: in expansion of macro ‘SPICE_RING_PROD_ITEM’
795 | SPICE_RING_PROD_ITEM(qxl, ring, item);
----
Fixed (and tested) by upstream commit:
commit 94932c95c10400acd286fd768a6b411e7ebbec8f
Author: Daniel P. Berrangé <email address hidden>
Date: Fri Apr 12 09:16:26 2019
qxl: avoid unaligned pointer reads/writes
----
/home/inaddy/work/sources/ubuntu/qemu/hw/usb/hcd-xhci.c: In function ‘usb_xhci_realize’:
/home/inaddy/work/sources/ubuntu/qemu/hw/usb/hcd-xhci.c:3339:66: error: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 5 [-Werror=format-truncation=]
3339 | snprintf(port->name, sizeof(port->name), "usb2 port #%d", i+1);
| ^~
/home/inaddy/work/sources/ubuntu/qemu/hw/usb/hcd-xhci.c:3339:54: note: directive argument in the range [1, 2147483647]
3339 | snprintf(port->name, sizeof(port->name), "usb2 port #%d", i+1);
| ^~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:867,
from /home/inaddy/work/sources/ubuntu/qemu/include/qemu/osdep.h:99,
from /home/inaddy/work/sources/ubuntu/qemu/hw/usb/hcd-xhci.c:21:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: ‘__builtin___snprintf_chk’ output between 13 and 22 bytes into a destination of size 16
67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68 | __bos (__s), __fmt, __va_arg_pack ());
----
Fixed (and tested) by upstream commit:
commit ccb799313a5926a6aa49018bbc67fe6165fad7f3
Author: Daniel P. Berrangé <email address hidden>
Date: Fri Apr 12 09:16:25 2019
hw/usb: avoid format truncation warning when formatting port name
----
/home/inaddy/work/sources/ubuntu/qemu/hw/usb/dev-mtp.c: In function ‘usb_mtp_write_metadata’:
/home/inaddy/work/sources/ubuntu/qemu/hw/usb/dev-mtp.c:1715:36: error: taking address of packed member of ‘struct <anonymous>’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
1715 | dataset->filename);
----
Fixed (and tested) by upstream commit:
commit 1259f27ec2113d34e54ee731aac5990d9606d9fa
Author: Daniel P. Berrangé <email address hidden>
Date: Mon Apr 15 12:45:03 2019
usb-mtp: fix alignment of access of ObjectInfo filename field
----
In function ‘strncpy’,
inlined from ‘fill_psinfo’ at /home/inaddy/work/sources/ubuntu/qemu/linux-user/elfload.c:3208:12,
inlined from ‘fill_note_info’ at /home/inaddy/work/sources/ubuntu/qemu/linux-user/elfload.c:3390:5,
inlined from ‘elf_core_dump’ at /home/inaddy/work/sources/ubuntu/qemu/linux-user/elfload.c:3539:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 16 equals destination size [-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
----
Fixed (and tested) by upstream commit:
commit d7eb2b928a855a2e8038e8e75f7edf1a12226bd3
Author: Alistair Francis <email address hidden>
Date: Tue Apr 30 20:29:01 2019
linux-user/elfload: Fix GCC 9 build warnings
----
/home/inaddy/work/sources/ubuntu/qemu/roms/SLOF/lib/libnet/icmpv6.c: In function ‘handle_ra’:
/home/inaddy/work/sources/ubuntu/qemu/roms/SLOF/lib/libnet/icmpv6.c:171:11: error: taking address of packed member of ‘struct ip6hdr’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
171 | rtr_ip = (ip6_addr_t *) &ip6h->src;
| ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/inaddy/work/sources/ubuntu/qemu/roms/SLOF/lib/libnet/icmpv6.c:173:21: error: taking address of packed member of ‘struct ip6hdr’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
173 | rtr = find_router (&(ip6h->src));
| ^~~~~~~~~~~~
----
Need fix in:
https://github.com/qemu/SLOF
continues...
FOUND THE ISSUE!
Whenever compiling from a git (or git-ubuntu) repository:
----
./configure:
....
1868 # Consult white-list to determine whether to enable werror
1869 # by default. Only enable by default for git builds
1870 if test -z "$werror" ; then
1871 if test -e "$source_path/.git" && \
1872 { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
1873 werror="yes"
1874 else
1875 werror="no"
1876 fi
1877 fi
....
# Now we've finished running tests it's OK to add -Werror to the compiler flags CFLAGS= "-Werror $QEMU_CFLAGS"
if test "$werror" = "yes"; then
QEMU_
fi
and then config.log:
QEMU_CFLAGS -I/usr/ include/ pixman- 1 -Werror -DHAS_LIBSSH2_ SFTP_FSYNC -pthread -I/usr/ include/ glib-2. 0 -I/usr/ lib/x86_ 64-linux- gnu/glib- 2.0/include -pthread -I/usr/ include/ glib-2. 0 -I/usr/ lib/x86_ 64-linux- gnu/glib- 2.0/include -fPIE -DPIE -m64 -mcx16 -D_GNU_SOURCE -D_FILE_ OFFSET_ BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing- prototypes -fno-strict- aliasing -fno-common -fwrapv -std=gnu99 -g -O0 -fdebug- prefix- map=/home/ inaddy/ work/sources/ ubuntu/ qemu=. -fstack- protector- strong -Wformat -Werror= format- security -Wdate-time -Wexpansion- to-defined
----
Werror will be configured by default in QEMU_CFLAGS (independently of dpkg-buildflags).
To avoid that we could use:
--disable-werror disable compilation abort on warning
But not exactly sure why this is happening now since the configure changes are old.
Removing the .git directory I got:
QEMU_CFLAGS -I/usr/ include/ pixman- 1 -DHAS_LIBSSH2_ SFTP_FSYNC -pthread -I/usr/ include/ glib-2. 0 -I/usr/ lib/x86_ 64-linux- gnu/glib- 2.0/include -m64 -mcx16 -D_GNU_SOURCE -D_FILE_ OFFSET_ BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing- prototypes -fno-strict- aliasing -fno-common -fwrapv -std=gnu99 -g -O0 -fdebug- prefix- map=/home/ inaddy/ work/sources/ ubuntu/ qemu=. -fstack- protector- strong -Wformat -Werror= format- security -Wdate-time -Wexpansion- to-defined -Wendif-labels -Wno-shift- negative- value -Wno-missing- include- dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored- qualifiers -Wold-style- declaration -Wold-style- definition -Wtype-limits -fstack- protector- strong -I/usr/ include/ p11-kit- 1 -I/usr/ include/ libpng16 -I/usr/ include/ libdrm -I/usr/ include/ capstone
like expected. (No -Werror flag).