[clang] [clang] Stub out gcc_struct attribute (PR #71148)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 29 11:44:50 PST 2023


MaskRay wrote:

I am now confused by the subject "[clang] Stub out gcc_struct attribute".
Do you mean "Implement gcc_struct attribute"? But the description isn't clear that this patch changes `-mms-bitfields` and `ms_struct` to be respected for windows-msvc targets.

SerenityOS is an OS, independent from Windows. What does porting it to Windows mean? Build some SerenityOS components on Windows targeting the PE object file format.
I don't know how this works but the test portability seems a weak argument to add an ABI variant for windows-msvc.

I am sure there are many other differences between ELF/PE struct layouts other than those controlled by `-mms-bitfields`/`-mno-ms-bitfields`.
If SerenityOS tests want to be portable with ELF and PE, you likely need to provide two sets of golden values.

---

https://gitlab.com/qemu-project/qemu/-/issues/1782#note_1495842591 seems like ignored `gcc_struct` for windows-gnu targets (feature request https://github.com/llvm/llvm-project/issues/24757).
I agree that if there are real needs and the needs seem genuine, Clang should support `gcc_struct`.

---

`-mms-bitfields` is a GCC x86 specific option. Darwin targets have some work recently in 2018 (https://reviews.llvm.org/D42660), but I am unsure whether 
`-mms-bitfields` wants to be supported by all architectures, or just x86 Darwin targets.
For ELF targets, I think we want to make `-mms-bitfields` x86-specific and issue a `error: unsupported option '-mms-bitfields' for target 'aarch64'`-style error (https://maskray.me/blog/2023-08-25-clang-wunused-command-line-argument)


https://github.com/llvm/llvm-project/pull/71148


More information about the cfe-commits mailing list