File: 0021-add_wchar_t-type-definition.patch

package info (click to toggle)
syslinux 3%3A6.04~git20190206.bf6db5b4%2Bdfsg1-3.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,020 kB
  • sloc: ansic: 189,354; asm: 5,148; pascal: 4,825; makefile: 1,981; perl: 1,980; python: 266; sh: 185; xml: 39
file content (58 lines) | stat: -rw-r--r-- 2,367 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From 063dac55c45d0264671c3463e824ab659e5cbb87 Mon Sep 17 00:00:00 2001
From: Julien Olivain <ju.o@free.fr>
Date: Tue, 27 Feb 2024 21:09:15 +0100
Subject: [PATCH] stddef.h: add wchar_t type definition

Syslinux fail to build with gnu-efi >= 3.0.16 with error:

    In file included from /host/i686-buildroot-linux-gnu/sysroot/usr/include/efi/efi.h:44,
                     from /build/syslinux-6.03/efi/efi.h:23,
                     from /build/syslinux-6.03/efi/adv.h:4,
                     from /build/syslinux-6.03/efi/adv.c:29:
    /host/i686-buildroot-linux-gnu/sysroot/usr/include/efi/ia32/efibind.h:90:9: error: unknown type name 'wchar_t'
     typedef wchar_t CHAR16;
             ^~~~~~~

This is because gnu-efi started to use the "wchar_t" type from the
toolchain's <stddef.h> header, in commit [1]. Before this commit,
gnu-efi was defining the type as "short".

Syslinux is including its own minimal stddef.h file, which masks the
one provided by the toolchain. See [2]. This file does not have a type
definition for "wchar_t".

Finally, the POSIX <stddef.h> header is supposed to provide this
"wchar_t" type definition. See [3].

This commit fixes the issue by adding the "wchar_t" type definition in
the com32/include/stddef.h header. Since Syslinux has "-fshort-wchar"
in its CFLAGS (see [4]), "wchar_t" is simply defined as "short". This
also follow the previous gnu-efi < 3.0.16 behavior.

This issue was seen in Buildroot Linux, in [5].

[1] https://sourceforge.net/p/gnu-efi/code/ci/189200d0b0f6fff473d302880d9569f45d4d8c4d
[2] https://repo.or.cz/syslinux.git/blob/refs/tags/syslinux-6.03:/com32/include/stddef.h
[3] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html
[4] https://repo.or.cz/syslinux.git/blob/refs/tags/syslinux-6.03:/mk/efi.mk#l27
[5] https://lists.buildroot.org/pipermail/buildroot/2024-February/685971.html

Upstream: Proposed: https://www.syslinux.org/archives/2024-February/026903.html
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
 com32/include/stddef.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/com32/include/stddef.h b/com32/include/stddef.h
index f52d62f3..437b11f2 100644
--- a/com32/include/stddef.h
+++ b/com32/include/stddef.h
@@ -29,4 +29,6 @@
  */
 #define container_of(p, c, m) ((c *)((char *)(p) - offsetof(c,m)))
 
+typedef short wchar_t;
+
 #endif /* _STDDEF_H */
-- 
2.44.0