diff options
author | Khem Raj <raj.khem@gmail.com> | 2023-01-19 15:18:17 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-24 22:06:51 +0000 |
commit | 22fbee4f127b073f19bc434d1b2ea891772dd6c7 (patch) | |
tree | ad313b61acbc6248e6c378df37edca9da26ee0a0 /meta/recipes-devtools | |
parent | 1c42439dcabbd6f0ccb6c7a4720e99a1e52e6b0f (diff) | |
download | poky-22fbee4f127b073f19bc434d1b2ea891772dd6c7.tar.gz |
ruby: Use C11 _Alignof to define ALIGN_OF when possible
(From OE-Core rev: 5f01957c596673604516df42008b91551915967f)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r-- | meta/recipes-devtools/ruby/ruby/0001-fiddle-Use-C11-_Alignof-to-define-ALIGN_OF-when-poss.patch | 52 | ||||
-rw-r--r-- | meta/recipes-devtools/ruby/ruby_3.2.0.bb | 1 |
2 files changed, 53 insertions, 0 deletions
diff --git a/meta/recipes-devtools/ruby/ruby/0001-fiddle-Use-C11-_Alignof-to-define-ALIGN_OF-when-poss.patch b/meta/recipes-devtools/ruby/ruby/0001-fiddle-Use-C11-_Alignof-to-define-ALIGN_OF-when-poss.patch new file mode 100644 index 0000000000..30caf2c2de --- /dev/null +++ b/meta/recipes-devtools/ruby/ruby/0001-fiddle-Use-C11-_Alignof-to-define-ALIGN_OF-when-poss.patch | |||
@@ -0,0 +1,52 @@ | |||
1 | From 6b3c202b46b9312c5bb0789145f13d8086e70948 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sun, 15 Jan 2023 02:34:17 -0800 | ||
4 | Subject: [PATCH] fiddle: Use C11 _Alignof to define ALIGN_OF when possible | ||
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 | ALIGN_OF to use builtin "_Alignof" to avoid undefined behavior | ||
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 compiler versions | ||
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: Submitted [https://ml.ruby-lang.org/mailman3/hyperkitty/list/ruby-core@ml.ruby-lang.org/thread/DLES4EPPXSPCHQMWJPPWMWXXS42AVPFA/] | ||
22 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
23 | --- | ||
24 | ext/fiddle/fiddle.h | 12 +++++++++++- | ||
25 | 1 file changed, 11 insertions(+), 1 deletion(-) | ||
26 | |||
27 | diff --git a/ext/fiddle/fiddle.h b/ext/fiddle/fiddle.h | ||
28 | index 10eb9ce..ffb395e 100644 | ||
29 | --- a/ext/fiddle/fiddle.h | ||
30 | +++ b/ext/fiddle/fiddle.h | ||
31 | @@ -196,7 +196,17 @@ | ||
32 | #endif | ||
33 | #define TYPE_UINTPTR_T (-TYPE_INTPTR_T) | ||
34 | |||
35 | -#define ALIGN_OF(type) offsetof(struct {char align_c; type align_x;}, align_x) | ||
36 | +/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023 | ||
37 | + <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. | ||
38 | + clang versions < 8.0.0 have the same bug. */ | ||
39 | +#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ | ||
40 | + || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \ | ||
41 | + && !defined __clang__) \ | ||
42 | + || (defined __clang__ && __clang_major__ < 8)) | ||
43 | +# define ALIGN_OF(type) offsetof(struct {char align_c; type align_x;}, align_x) | ||
44 | +#else | ||
45 | +# define ALIGN_OF(type) _Alignof(type) | ||
46 | +#endif | ||
47 | |||
48 | #define ALIGN_VOIDP ALIGN_OF(void*) | ||
49 | #define ALIGN_CHAR ALIGN_OF(char) | ||
50 | -- | ||
51 | 2.39.0 | ||
52 | |||
diff --git a/meta/recipes-devtools/ruby/ruby_3.2.0.bb b/meta/recipes-devtools/ruby/ruby_3.2.0.bb index 1981a7524c..0e1336f5b0 100644 --- a/meta/recipes-devtools/ruby/ruby_3.2.0.bb +++ b/meta/recipes-devtools/ruby/ruby_3.2.0.bb | |||
@@ -30,6 +30,7 @@ SRC_URI = "http://cache.ruby-lang.org/pub/ruby/${SHRT_VER}/ruby-${PV}.tar.gz \ | |||
30 | file://0005-Mark-Gemspec-reproducible-change-fixing-784225-too.patch \ | 30 | file://0005-Mark-Gemspec-reproducible-change-fixing-784225-too.patch \ |
31 | file://0006-Make-gemspecs-reproducible.patch \ | 31 | file://0006-Make-gemspecs-reproducible.patch \ |
32 | file://0001-vm_dump.c-Define-REG_S1-and-REG_S2-for-musl-riscv.patch \ | 32 | file://0001-vm_dump.c-Define-REG_S1-and-REG_S2-for-musl-riscv.patch \ |
33 | file://0001-fiddle-Use-C11-_Alignof-to-define-ALIGN_OF-when-poss.patch \ | ||
33 | " | 34 | " |
34 | UPSTREAM_CHECK_URI = "https://www.ruby-lang.org/en/downloads/" | 35 | UPSTREAM_CHECK_URI = "https://www.ruby-lang.org/en/downloads/" |
35 | 36 | ||