configure: remove no bitfields flag
dvdnav depends on dvdread which makes extensive use of packed structures. dvdnav should always have the matching structure sizes from dvdread and thus have the same compilation flags regarding structure packing. It doesn't use any special flag so it should be the same in dvdnav.
Fixes medialibrary!334
Merge request reports
Activity
https://gcc.gnu.org/onlinedocs/gcc/x86-Variable-Attributes.html
The
ms_struct
andgcc_struct
attributes correspond to the-mms-bitfields
and-mno-ms-bitfields
command-line options, respectivelyEdited by Jean-Baptiste KempfYes, it should be the same with clang. But there is no reason to force any particular packing behavior in libdvdnav that is not matching the packing behavior of libdvdread. In fact it should never be the same.
libdvdnav doesn't have any structure packing, so it should not even change such parameters in the first place.
clang doesn't understand the
gcc_struct
part, it always emits this warning (with and without the compilation flag)ifo_types.h:67:3: warning: unknown attribute 'gcc_struct' ignored [-Wunknown-attributes]
If the GCC packing is the one to use, we need to enforce it on libdvdread as well. Right now it's ignored in Clang builds.
See libdvdread#19 for the proper structure packing to use.
After doing some tests it seems that we need to keep the flag.
- gcc builds pick the
-mno-ms-bitfields
option and thegcc_struct
packing which ends up using the shortest size for structures. It should be the same without the-mno-ms-bitfields
option, even on Windows. - clang targeting Windows requires the
-mno-ms-bitfields
to get similar size to gcc, which is what the code requires.
The problem that this setting is not exported by
libdvdread
. So a third party code compiled with Clang for Windows and includingifo_types.h
will encounter the__attribute__ ((packed))
but will use the MS packing type. The only way to have matching sizes between the compiled libdvdread and the third party would be to force that code to use-mno-ms-bitfields
. It can be done via the Cflags in pkg-config.However in VLC all the Windows code is compiled with
-ms-bitfields
so that all Windows SDK includes are using the proper structure sizes. It overrides the value that would be set in pkg-config. And even if it doesn't the gcc packing would be potentially be used when including some Windows headers.Another solution would be to avoid relying on the structure packing for third party code, by providing some getters to structure fields. I tried this solution and it also fixes medialibrary!334.
It's also debatable if there should be any packing at all, reading structures straight to memory is error prone and dangerous.
- gcc builds pick the
This patch makes sense when/if libdvdread!28 is merged.
mentioned in merge request !51 (closed)