Re: next: zip.c:35:8: error: packed attribute causes inefficient alignment for 'magic' [-Werror=attributes]

From: Andrii Nakryiko
Date: Tue Mar 14 2023 - 19:56:34 EST


On Tue, Mar 14, 2023 at 1:01 PM Ian Rogers <irogers@xxxxxxxxxx> wrote:
>
> On Tue, Mar 14, 2023 at 11:52 AM Andrii Nakryiko
> <andrii.nakryiko@xxxxxxxxx> wrote:
> >
> > On Mon, Mar 13, 2023 at 11:38 PM Naresh Kamboju
> > <naresh.kamboju@xxxxxxxxxx> wrote:
> > >
> > > perf builds failing from Linux next-20230307..next-20230314 but pass on
> > > Linux mainline v6.3-rc2.
> > >
> > > Reported-by: Linux Kernel Functional Testing <lkft@xxxxxxxxxx>
> >
> > Thanks for the report, but I'm not sure what's wrong here. We added
> > __attribute__((packed)) attribute intentionally and want to keep it
> > this way. It seems like perf itself is using packed structs (e.g.,
> > struct debug_line_header in util/genelf_debug.c), so I'm wondering why
> > that code doesn't cause any problems.
> >
> > Any hints from perf folks?
>
> We use a #pragma to disable the warnings in at least one place:
> https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/tree/tools/lib/perf/include/perf/event.h?h=perf-tools#n194
>

Ok, let's do the same here. Daniel, can you please send a follow up
patch to silence this warning?

> Thanks,
> Ian
>
> > >
> > > Build log:
> > > ---
> > > libbpf/staticobjs/zip.o
> > > zip.c:35:8: error: packed attribute causes inefficient alignment for
> > > 'magic' [-Werror=attributes]
> > > 35 | __u32 magic;
> > > | ^~~~~
> > > zip.c:40:8: error: packed attribute causes inefficient alignment for
> > > 'this_disk' [-Werror=attributes]
> > > 40 | __u16 this_disk;
> > > | ^~~~~~~~~
> > > zip.c:45:8: error: packed attribute causes inefficient alignment for
> > > 'cd_disk' [-Werror=attributes]
> > > 45 | __u16 cd_disk;
> > > | ^~~~~~~
> > > zip.c:50:8: error: packed attribute causes inefficient alignment for
> > > 'cd_records' [-Werror=attributes]
> > > 50 | __u16 cd_records;
> > > | ^~~~~~~~~~
> > > zip.c:55:8: error: packed attribute causes inefficient alignment for
> > > 'cd_records_total' [-Werror=attributes]
> > > 55 | __u16 cd_records_total;
> > > | ^~~~~~~~~~~~~~~~
> > > zip.c:58:8: error: packed attribute causes inefficient alignment for
> > > 'cd_size' [-Werror=attributes]
> > > 58 | __u32 cd_size;
> > > | ^~~~~~~
> > > zip.c:63:8: error: packed attribute causes inefficient alignment for
> > > 'cd_offset' [-Werror=attributes]
> > > 63 | __u32 cd_offset;
> > > | ^~~~~~~~~
> > > zip.c:66:8: error: packed attribute causes inefficient alignment for
> > > 'comment_length' [-Werror=attributes]
> > > 66 | __u16 comment_length;
> > > | ^~~~~~~~~~~~~~
> > > zip.c:79:8: error: packed attribute causes inefficient alignment for
> > > 'magic' [-Werror=attributes]
> > > 79 | __u32 magic;
> > > | ^~~~~
> > > zip.c:80:8: error: packed attribute causes inefficient alignment for
> > > 'version' [-Werror=attributes]
> > > 80 | __u16 version;
> > > | ^~~~~~~
> > > zip.c:82:8: error: packed attribute causes inefficient alignment for
> > > 'min_version' [-Werror=attributes]
> > > 82 | __u16 min_version;
> > > | ^~~~~~~~~~~
> > > zip.c:83:8: error: packed attribute causes inefficient alignment for
> > > 'flags' [-Werror=attributes]
> > > 83 | __u16 flags;
> > > | ^~~~~
> > > zip.c:84:8: error: packed attribute causes inefficient alignment for
> > > 'compression' [-Werror=attributes]
> > > 84 | __u16 compression;
> > > | ^~~~~~~~~~~
> > > zip.c:85:8: error: packed attribute causes inefficient alignment for
> > > 'last_modified_time' [-Werror=attributes]
> > > 85 | __u16 last_modified_time;
> > > | ^~~~~~~~~~~~~~~~~~
> > > zip.c:86:8: error: packed attribute causes inefficient alignment for
> > > 'last_modified_date' [-Werror=attributes]
> > > 86 | __u16 last_modified_date;
> > > | ^~~~~~~~~~~~~~~~~~
> > > zip.c:87:8: error: packed attribute causes inefficient alignment for
> > > 'crc' [-Werror=attributes]
> > > 87 | __u32 crc;
> > > | ^~~
> > > zip.c:88:8: error: packed attribute causes inefficient alignment for
> > > 'compressed_size' [-Werror=attributes]
> > > 88 | __u32 compressed_size;
> > > | ^~~~~~~~~~~~~~~
> > > zip.c:89:8: error: packed attribute causes inefficient alignment for
> > > 'uncompressed_size' [-Werror=attributes]
> > > 89 | __u32 uncompressed_size;
> > > | ^~~~~~~~~~~~~~~~~
> > > zip.c:90:8: error: packed attribute causes inefficient alignment for
> > > 'file_name_length' [-Werror=attributes]
> > > 90 | __u16 file_name_length;
> > > | ^~~~~~~~~~~~~~~~
> > > zip.c:91:8: error: packed attribute causes inefficient alignment for
> > > 'extra_field_length' [-Werror=attributes]
> > > 91 | __u16 extra_field_length;
> > > | ^~~~~~~~~~~~~~~~~~
> > > zip.c:92:8: error: packed attribute causes inefficient alignment for
> > > 'file_comment_length' [-Werror=attributes]
> > > 92 | __u16 file_comment_length;
> > > | ^~~~~~~~~~~~~~~~~~~
> > > zip.c:94:8: error: packed attribute causes inefficient alignment for
> > > 'disk' [-Werror=attributes]
> > > 94 | __u16 disk;
> > > | ^~~~
> > > zip.c:95:8: error: packed attribute causes inefficient alignment for
> > > 'internal_attributes' [-Werror=attributes]
> > > 95 | __u16 internal_attributes;
> > > | ^~~~~~~~~~~~~~~~~~~
> > > zip.c:108:8: error: packed attribute causes inefficient alignment for
> > > 'magic' [-Werror=attributes]
> > > 108 | __u32 magic;
> > > | ^~~~~
> > > zip.c:110:8: error: packed attribute causes inefficient alignment for
> > > 'min_version' [-Werror=attributes]
> > > 110 | __u16 min_version;
> > > | ^~~~~~~~~~~
> > > zip.c:111:8: error: packed attribute causes inefficient alignment for
> > > 'flags' [-Werror=attributes]
> > > 111 | __u16 flags;
> > > | ^~~~~
> > > zip.c:112:8: error: packed attribute causes inefficient alignment for
> > > 'compression' [-Werror=attributes]
> > > 112 | __u16 compression;
> > > | ^~~~~~~~~~~
> > > zip.c:113:8: error: packed attribute causes inefficient alignment for
> > > 'last_modified_time' [-Werror=attributes]
> > > 113 | __u16 last_modified_time;
> > > | ^~~~~~~~~~~~~~~~~~
> > > zip.c:114:8: error: packed attribute causes inefficient alignment for
> > > 'last_modified_date' [-Werror=attributes]
> > > 114 | __u16 last_modified_date;
> > > | ^~~~~~~~~~~~~~~~~~
> > > zip.c:118:8: error: packed attribute causes inefficient alignment for
> > > 'file_name_length' [-Werror=attributes]
> > > 118 | __u16 file_name_length;
> > > | ^~~~~~~~~~~~~~~~
> > > zip.c:119:8: error: packed attribute causes inefficient alignment for
> > > 'extra_field_length' [-Werror=attributes]
> > > 119 | __u16 extra_field_length;
> > > | ^~~~~~~~~~~~~~~~~~
> > > cc1: all warnings being treated as errors
> > >
> > > Build links,
> > > https://storage.tuxsuite.com/public/linaro/lkft/builds/2MfXEyvgh4ba9y3rkt6KPf6sUMR/
> > >
> > >
> > > History link,
> > > https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20230314/testrun/15564056/suite/build/test/gcc-10-lkftconfig-perf/history/
> > >
> > >
> > > --
> > > Linaro LKFT
> > > https://lkft.linaro.org