dosemu2 / fdpp

FreeDOS plus-plus, 64bit DOS
GNU General Public License v3.0
198 stars 18 forks source link

Struct packing fails with clang 16 #216

Closed atsampson closed 1 year ago

atsampson commented 1 year ago

Building fdpp using clang 16 fails with:

..../hdr/sft.h:87:1: error: static assertion failed due to requirement 'sizeof(_sft) == 59': wrong size of sft           
..../hdr/sft.h:87:1: note: expression evaluates to '60 == 59'

The problem is that __DOSFAR(struct dpb) _sft_dcb is being aligned even though the struct is meant to be packed. This appears to be the result of this LLVM change - see this LLVM bug for another example.

Adding -fclang-abi-compat=13.0 to TARGETOPT appears to work as a workaround, but adding explicit PACKED attributes to the appropriate members would be another option.

stsp commented 1 year ago

Thanks! I asked in a bug you referenced, what would be the better fix of the proposed 2. Let's wait.

stsp commented 1 year ago

Would you like to create a PR that adds the needed PACKED, and make sure it builds with clang-16?

stsp commented 1 year ago

I added the basic support for clang-16. Unfortunately its now full of warnings (even on older clangs) and errors out on gcc...

stsp commented 1 year ago

I filled bugs for clang: https://github.com/llvm/llvm-project/issues/62353 https://github.com/llvm/llvm-project/issues/62358 What clang-16 does, seems very inconsistent at best.

stsp commented 1 year ago

Hi @skitt any idea when make-4.4 will make it into debian and ubuntu? Older make does not even support integer comparisons.

skitt commented 1 year ago

Hi @skitt any idea when make-4.4 will make it into debian and ubuntu? Older make does not even support integer comparisons.

Your guess is as good as mine, it seems its maintainer isn’t active any more. At least it won’t happen before the Debian 12 release in mid-June.

stsp commented 1 year ago

Basically it was said to me on clang bugzilla that from now on clang is going to be fully gcc-compatible. Any bugs would be ported to clang from gcc without a hesitation, and any clang-specific code is now invalid by definition. These are the very sad news, if you ask me. The last thing we need is a gcc clone... We can stay at clang-15 abi for some time, but at a larger scale there is a need to drop clang from all our projects, as using it no longer adds any value, which was officially stated by its maintainers.

stsp commented 1 year ago

Well, clang guys went through lots of hoops convincing me this change is not too hostile, and that clang is still suitable for my needs and will remain so. They promised to provide me with alternative solutions as soon as more unpleasant things are ported from gcc (like disallowing an unaligned references). So this needs more thoughts...