diff options
3 files changed, 178 insertions, 1 deletions
diff --git a/meta-networking/recipes-connectivity/dibbler/dibbler/0001-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch b/meta-networking/recipes-connectivity/dibbler/dibbler/0001-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch new file mode 100644 index 0000000000..d48d7265d4 --- /dev/null +++ b/meta-networking/recipes-connectivity/dibbler/dibbler/0001-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch | |||
@@ -0,0 +1,125 @@ | |||
1 | From 9e9d94566d39eef3e4606f806aa418bf5534fab9 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sun, 15 Jan 2023 22:04:31 -0800 | ||
4 | Subject: [PATCH 1/2] Define alignof using _Alignof when using C11 or newer | ||
5 | |||
6 | WG14 N2350 made very clear that it is an UB having type definitions | ||
7 | within "offsetof" [1]. This patch enhances the implementation of macro | ||
8 | alignof to use builtin "_Alignof" to avoid undefined behavior on | ||
9 | when using std=c11 or newer | ||
10 | |||
11 | clang 16+ has started to flag this [2] | ||
12 | |||
13 | Fixes build when using -std >= gnu11 and using clang16+ | ||
14 | |||
15 | Older compilers gcc < 4.9 or clang < 8 has buggy _Alignof even though it | ||
16 | may support C11, exclude those compilers too | ||
17 | |||
18 | [1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm | ||
19 | [2] https://reviews.llvm.org/D133574 | ||
20 | |||
21 | Upstream-Status: Pending | ||
22 | |||
23 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
24 | --- | ||
25 | Misc/md5-coreutils.c | 12 +++++++++++- | ||
26 | Misc/sha1.c | 12 +++++++++++- | ||
27 | Misc/sha256.c | 12 +++++++++++- | ||
28 | Misc/sha512.c | 12 +++++++++++- | ||
29 | 4 files changed, 44 insertions(+), 4 deletions(-) | ||
30 | |||
31 | diff --git a/Misc/md5-coreutils.c b/Misc/md5-coreutils.c | ||
32 | index d6503e02..2ffb6050 100644 | ||
33 | --- a/Misc/md5-coreutils.c | ||
34 | +++ b/Misc/md5-coreutils.c | ||
35 | @@ -154,7 +154,17 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) | ||
36 | if (len >= 64) | ||
37 | { | ||
38 | #if !_STRING_ARCH_unaligned | ||
39 | -# define alignof(type) offsetof (struct { char c; type x; }, x) | ||
40 | +/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023 | ||
41 | + <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. | ||
42 | + clang versions < 8.0.0 have the same bug. */ | ||
43 | +# if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ | ||
44 | + || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \ | ||
45 | + && !defined __clang__) \ | ||
46 | + || (defined __clang__ && __clang_major__ < 8)) | ||
47 | +# define alignof(type) offsetof (struct { char c; type x; }, x) | ||
48 | +# else | ||
49 | +# define alignof(type) _Alignof(type) | ||
50 | +# endif | ||
51 | # define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) | ||
52 | if (UNALIGNED_P (buffer)) | ||
53 | while (len > 64) | ||
54 | diff --git a/Misc/sha1.c b/Misc/sha1.c | ||
55 | index 18ceb845..a170efe3 100644 | ||
56 | --- a/Misc/sha1.c | ||
57 | +++ b/Misc/sha1.c | ||
58 | @@ -149,7 +149,17 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) | ||
59 | if (len >= 64) | ||
60 | { | ||
61 | #if !_STRING_ARCH_unaligned | ||
62 | -# define alignof(type) offsetof (struct { char c; type x; }, x) | ||
63 | +/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023 | ||
64 | + <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. | ||
65 | + clang versions < 8.0.0 have the same bug. */ | ||
66 | +# if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ | ||
67 | + || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \ | ||
68 | + && !defined __clang__) \ | ||
69 | + || (defined __clang__ && __clang_major__ < 8)) | ||
70 | +# define alignof(type) offsetof (struct { char c; type x; }, x) | ||
71 | +# else | ||
72 | +# define alignof(type) _Alignof(type) | ||
73 | +# endif | ||
74 | # define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) | ||
75 | if (UNALIGNED_P (buffer)) | ||
76 | while (len > 64) | ||
77 | diff --git a/Misc/sha256.c b/Misc/sha256.c | ||
78 | index 68292326..da59e81d 100644 | ||
79 | --- a/Misc/sha256.c | ||
80 | +++ b/Misc/sha256.c | ||
81 | @@ -372,7 +372,17 @@ sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx) | ||
82 | if (len >= 64) | ||
83 | { | ||
84 | #if !_STRING_ARCH_unaligned | ||
85 | -# define alignof(type) offsetof (struct { char c; type x; }, x) | ||
86 | +/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023 | ||
87 | + <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. | ||
88 | + clang versions < 8.0.0 have the same bug. */ | ||
89 | +# if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ | ||
90 | + || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \ | ||
91 | + && !defined __clang__) \ | ||
92 | + || (defined __clang__ && __clang_major__ < 8)) | ||
93 | +# define alignof(type) offsetof (struct { char c; type x; }, x) | ||
94 | +# else | ||
95 | +# define alignof(type) _Alignof(type) | ||
96 | +# endif | ||
97 | # define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) | ||
98 | if (UNALIGNED_P (buffer)) | ||
99 | while (len > 64) | ||
100 | diff --git a/Misc/sha512.c b/Misc/sha512.c | ||
101 | index db86c659..38e162fc 100644 | ||
102 | --- a/Misc/sha512.c | ||
103 | +++ b/Misc/sha512.c | ||
104 | @@ -190,7 +190,17 @@ sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx) | ||
105 | if (len >= 128) | ||
106 | { | ||
107 | #if !_STRING_ARCH_unaligned | ||
108 | -# define alignof(type) offsetof (struct { char c; type x; }, x) | ||
109 | +/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023 | ||
110 | + <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. | ||
111 | + clang versions < 8.0.0 have the same bug. */ | ||
112 | +# if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ | ||
113 | + || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \ | ||
114 | + && !defined __clang__) \ | ||
115 | + || (defined __clang__ && __clang_major__ < 8)) | ||
116 | +# define alignof(type) offsetof (struct { char c; type x; }, x) | ||
117 | +# else | ||
118 | +# define alignof(type) _Alignof(type) | ||
119 | +# endif | ||
120 | # define UNALIGNED_P(p) (((size_t) p) % alignof (uint64_t) != 0) | ||
121 | if (UNALIGNED_P (buffer)) | ||
122 | while (len > 128) | ||
123 | -- | ||
124 | 2.39.0 | ||
125 | |||
diff --git a/meta-networking/recipes-connectivity/dibbler/dibbler/0002-make-Do-not-enforce-c99.patch b/meta-networking/recipes-connectivity/dibbler/dibbler/0002-make-Do-not-enforce-c99.patch new file mode 100644 index 0000000000..8889130a3b --- /dev/null +++ b/meta-networking/recipes-connectivity/dibbler/dibbler/0002-make-Do-not-enforce-c99.patch | |||
@@ -0,0 +1,50 @@ | |||
1 | From e826206c58bbaa1c256f55b103d5eb7b0182f152 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sun, 15 Jan 2023 22:05:53 -0800 | ||
4 | Subject: [PATCH 2/2] make: Do not enforce c99 | ||
5 | |||
6 | Latest gcc/clang from OE defaults to c11 or newer and stickly to c99 | ||
7 | means we can not use _AlignOf | ||
8 | |||
9 | Upstream-Status: Pending | ||
10 | |||
11 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
12 | --- | ||
13 | Misc/Makefile.am | 4 +--- | ||
14 | Port-linux/Makefile.am | 1 - | ||
15 | 2 files changed, 1 insertion(+), 4 deletions(-) | ||
16 | |||
17 | diff --git a/Misc/Makefile.am b/Misc/Makefile.am | ||
18 | index d881525a..8d71d2d4 100644 | ||
19 | --- a/Misc/Makefile.am | ||
20 | +++ b/Misc/Makefile.am | ||
21 | @@ -6,8 +6,6 @@ endif | ||
22 | |||
23 | noinst_LIBRARIES = libMisc.a | ||
24 | |||
25 | -libMisc_a_CFLAGS = -std=c99 | ||
26 | - | ||
27 | libMisc_a_CPPFLAGS = -I$(top_srcdir) | ||
28 | |||
29 | libMisc_a_SOURCES = addrpack.c | ||
30 | @@ -27,4 +25,4 @@ libMisc_a_SOURCES += lowlevel-posix.c | ||
31 | |||
32 | libMisc_a_SOURCES += hmac-sha-md5.h hmac-sha-md5.c | ||
33 | libMisc_a_SOURCES += md5-coreutils.c md5.h | ||
34 | -libMisc_a_SOURCES += sha1.c sha1.h sha256.c sha256.h sha512.c sha512.h | ||
35 | \ No newline at end of file | ||
36 | +libMisc_a_SOURCES += sha1.c sha1.h sha256.c sha256.h sha512.c sha512.h | ||
37 | diff --git a/Port-linux/Makefile.am b/Port-linux/Makefile.am | ||
38 | index 72b0a5e3..635998ea 100644 | ||
39 | --- a/Port-linux/Makefile.am | ||
40 | +++ b/Port-linux/Makefile.am | ||
41 | @@ -1,6 +1,5 @@ | ||
42 | noinst_LIBRARIES = libLowLevel.a | ||
43 | |||
44 | -libLowLevel_a_CFLAGS = -std=c99 | ||
45 | libLowLevel_a_CPPFLAGS = -I$(top_srcdir)/Misc | ||
46 | |||
47 | libLowLevel_a_SOURCES = daemon.cpp daemon.h ethtool-kernel.h ethtool-local.h interface.c interface.h ip_common.h iproute.c libnetlink.c libnetlink.h ll_map.c ll_map.h ll_types.c lowlevel-linux.c lowlevel-linux-link-state.c lowlevel-options-linux.c rtm_map.h rt_names.h utils.c utils.h | ||
48 | -- | ||
49 | 2.39.0 | ||
50 | |||
diff --git a/meta-networking/recipes-connectivity/dibbler/dibbler_git.bb b/meta-networking/recipes-connectivity/dibbler/dibbler_git.bb index f57767e9b8..34f8a7e3e5 100644 --- a/meta-networking/recipes-connectivity/dibbler/dibbler_git.bb +++ b/meta-networking/recipes-connectivity/dibbler/dibbler_git.bb | |||
@@ -10,6 +10,8 @@ SRCREV = "a7c6cf58a88a510cb00841351e75030ce78d36bf" | |||
10 | SRC_URI = "git://github.com/tomaszmrugalski/dibbler;branch=master;protocol=https \ | 10 | SRC_URI = "git://github.com/tomaszmrugalski/dibbler;branch=master;protocol=https \ |
11 | file://dibbler_fix_getSize_crash.patch \ | 11 | file://dibbler_fix_getSize_crash.patch \ |
12 | file://0001-port-linux-Re-order-header-includes.patch \ | 12 | file://0001-port-linux-Re-order-header-includes.patch \ |
13 | file://0001-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch \ | ||
14 | file://0002-make-Do-not-enforce-c99.patch \ | ||
13 | " | 15 | " |
14 | PV = "1.0.1+1.0.2RC1+git${SRCREV}" | 16 | PV = "1.0.1+1.0.2RC1+git${SRCREV}" |
15 | 17 | ||
@@ -30,7 +32,7 @@ inherit autotools | |||
30 | 32 | ||
31 | DEPENDS += "flex-native" | 33 | DEPENDS += "flex-native" |
32 | 34 | ||
33 | CFLAGS += "-D_GNU_SOURCE" | 35 | CPPFLAGS += "-D_GNU_SOURCE -Dregister=''" |
34 | LDFLAGS += "-pthread" | 36 | LDFLAGS += "-pthread" |
35 | 37 | ||
36 | PACKAGES =+ "${PN}-requestor ${PN}-client ${PN}-relay ${PN}-server" | 38 | PACKAGES =+ "${PN}-requestor ${PN}-client ${PN}-relay ${PN}-server" |