qemu fails to compile on gcc 9 `error: taking address of packed member of ‘struct ’ may result in an unaligned pointer value [-Werror=address-of-packed-member]` Qemu compilation fails with below error on ppc64le host with gcc 9(9.0.1 20190328) repo: https://github.com/qemu/qemu.git branch: master commit e1be98540ee672ef93292b65a986055512237c35 CC net/dump.o hw/usb/dev-mtp.c: In function ‘usb_mtp_write_metadata’: hw/usb/dev-mtp.c:1708:36: error: taking address of packed member of ‘struct ’ may result in an unaligned pointer value [-Werror=address-of-packed-member] 1708 | dataset->filename); | ~~~~~~~^~~~~~~~~~ cc1: all warnings being treated as errors CC net/eth.o make: *** [/home/kvmci/qemu-main/rules.mak:69: hw/usb/dev-mtp.o] Error 1 make: *** Waiting for unfinished jobs.... CC net/announce.o Tried to patch as below and it compiles fine, not sure if this is right fix though, # git diff diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index ebf210f..7d512e5 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -231,7 +231,7 @@ typedef struct { char date_modified[0]; /*unused*/ char keywords[0]; /*unused*/ /* string and other data follows */ -} QEMU_PACKED ObjectInfo; +} ObjectInfo; #define TYPE_USB_MTP "usb-mtp" #define USB_MTP(obj) OBJECT_CHECK(MTPState, (obj), TYPE_USB_MTP) This struct represents the MTP protocol wire format so *must* be marked packed. There unfortunately quite a few flaws in this MTP code area, so fixing the gcc warning is not straightforward. https://lists.gnu.org/archive/html/qemu-devel/2019-03/msg07763.html As a workaround, the simplest thing is to configure with --disable-werror, which will reduce these from errors to warnings. (This is the default if you're building from one of our release tarballs, but for builds from git we default to making all warnings into errors so we catch and fix them quickly.) Sure, Thanks, using the workaround to proceed. Good if each commit goes through a automated build test across different platforms vs gcc versions. Regards, -Satheesh. Fixed in https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg02524.html The fixes for this issue in dev-mtp.c are now in QEMU git master and will be in the 4.1 release.