0019-stddef.h-add-wchar_t-type-definition.patch 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. From 063dac55c45d0264671c3463e824ab659e5cbb87 Mon Sep 17 00:00:00 2001
  2. From: Julien Olivain <ju.o@free.fr>
  3. Date: Tue, 27 Feb 2024 21:09:15 +0100
  4. Subject: [PATCH] stddef.h: add wchar_t type definition
  5. Syslinux fail to build with gnu-efi >= 3.0.16 with error:
  6. In file included from /host/i686-buildroot-linux-gnu/sysroot/usr/include/efi/efi.h:44,
  7. from /build/syslinux-6.03/efi/efi.h:23,
  8. from /build/syslinux-6.03/efi/adv.h:4,
  9. from /build/syslinux-6.03/efi/adv.c:29:
  10. /host/i686-buildroot-linux-gnu/sysroot/usr/include/efi/ia32/efibind.h:90:9: error: unknown type name 'wchar_t'
  11. typedef wchar_t CHAR16;
  12. ^~~~~~~
  13. This is because gnu-efi started to use the "wchar_t" type from the
  14. toolchain's <stddef.h> header, in commit [1]. Before this commit,
  15. gnu-efi was defining the type as "short".
  16. Syslinux is including its own minimal stddef.h file, which masks the
  17. one provided by the toolchain. See [2]. This file does not have a type
  18. definition for "wchar_t".
  19. Finally, the POSIX <stddef.h> header is supposed to provide this
  20. "wchar_t" type definition. See [3].
  21. This commit fixes the issue by adding the "wchar_t" type definition in
  22. the com32/include/stddef.h header. Since Syslinux has "-fshort-wchar"
  23. in its CFLAGS (see [4]), "wchar_t" is simply defined as "short". This
  24. also follow the previous gnu-efi < 3.0.16 behavior.
  25. This issue was seen in Buildroot Linux, in [5].
  26. [1] https://sourceforge.net/p/gnu-efi/code/ci/189200d0b0f6fff473d302880d9569f45d4d8c4d
  27. [2] https://repo.or.cz/syslinux.git/blob/refs/tags/syslinux-6.03:/com32/include/stddef.h
  28. [3] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html
  29. [4] https://repo.or.cz/syslinux.git/blob/refs/tags/syslinux-6.03:/mk/efi.mk#l27
  30. [5] https://lists.buildroot.org/pipermail/buildroot/2024-February/685971.html
  31. Upstream: Proposed: https://www.syslinux.org/archives/2024-February/026903.html
  32. Signed-off-by: Julien Olivain <ju.o@free.fr>
  33. ---
  34. com32/include/stddef.h | 2 ++
  35. 1 file changed, 2 insertions(+)
  36. diff --git a/com32/include/stddef.h b/com32/include/stddef.h
  37. index f52d62f3..437b11f2 100644
  38. --- a/com32/include/stddef.h
  39. +++ b/com32/include/stddef.h
  40. @@ -29,4 +29,6 @@
  41. */
  42. #define container_of(p, c, m) ((c *)((char *)(p) - offsetof(c,m)))
  43. +typedef short wchar_t;
  44. +
  45. #endif /* _STDDEF_H */
  46. --
  47. 2.44.0