Skip to content
Snippets Groups Projects

configure: remove no bitfields flag

Open Steve Lhomme requested to merge robUx4/libdvdnav:no-packing-changes into master
1 unresolved thread

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

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
    • https://gcc.gnu.org/onlinedocs/gcc/x86-Variable-Attributes.html

      The ms_struct and gcc_struct attributes correspond to the -mms-bitfields and -mno-ms-bitfields command-line options, respectively

      Edited by Jean-Baptiste Kempf
    • Author Contributor

      Yes, 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.

    • Author Contributor

      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.

    • Author Contributor

      See libdvdread#19 for the proper structure packing to use.

    • Author Contributor

      After doing some tests it seems that we need to keep the flag.

      • gcc builds pick the -mno-ms-bitfields option and the gcc_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 including ifo_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.

    • Author Contributor

      This patch makes sense when/if libdvdread!28 is merged.

    • Please register or sign in to reply
  • Steve Lhomme mentioned in merge request !51 (closed)

    mentioned in merge request !51 (closed)

Please register or sign in to reply
Loading