Gentoo Archives: gentoo-commits

From: Matt Turner <mattst88@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/gjs/files/
Date: Sat, 28 May 2022 02:17:36
Message-Id: 1653704245.d8566b90d226a1c086bfb359fbdf458b0fc196dd.mattst88@gentoo
1 commit: d8566b90d226a1c086bfb359fbdf458b0fc196dd
2 Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
3 AuthorDate: Sat May 28 02:14:20 2022 +0000
4 Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
5 CommitDate: Sat May 28 02:17:25 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d8566b90
7
8 dev-libs/gjs: Add missing GCC-11 support patch
9
10 Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
11
12 dev-libs/gjs/files/gjs-1.64.5-gcc-11-support.patch | 129 +++++++++++++++++++++
13 1 file changed, 129 insertions(+)
14
15 diff --git a/dev-libs/gjs/files/gjs-1.64.5-gcc-11-support.patch b/dev-libs/gjs/files/gjs-1.64.5-gcc-11-support.patch
16 new file mode 100644
17 index 000000000000..3808b6d7862b
18 --- /dev/null
19 +++ b/dev-libs/gjs/files/gjs-1.64.5-gcc-11-support.patch
20 @@ -0,0 +1,129 @@
21 +From 757d42d87e8a3b52a0782bc9cbd33c788ecc34e4 Mon Sep 17 00:00:00 2001
22 +From: Philip Chimento <philip.chimento@×××××.com>
23 +Date: Mon, 15 Feb 2021 20:40:43 -0800
24 +Subject: [PATCH 1/2] GjsPrivate: Remove volatile from g_once_init_enter flag
25 +
26 +On platforms where g_once_init_enter() is defined to use C11 atomic
27 +builtins, passing a pointer to a volatile value will generate a warning
28 +in GCC 11 and later.
29 +
30 +More info about the GCC change:
31 +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95378
32 +https://gcc.gnu.org/pipermail/gcc-patches/2020-June/548283.html
33 +
34 +More info about changes made in GLib:
35 +https://gitlab.gnome.org/GNOME/glib/-/issues/600
36 +
37 +See: #376
38 +(cherry picked from commit 989ac9ac723dc1c8b6b8961292f236c558f5c0f0)
39 +---
40 + libgjs-private/gjs-util.c | 8 ++++----
41 + 1 file changed, 4 insertions(+), 4 deletions(-)
42 +
43 +diff --git a/libgjs-private/gjs-util.c b/libgjs-private/gjs-util.c
44 +index 20a732d5..f7f3189a 100644
45 +--- a/libgjs-private/gjs-util.c
46 ++++ b/libgjs-private/gjs-util.c
47 +@@ -57,8 +57,8 @@ gjs_format_int_alternative_output(int n)
48 + GType
49 + gjs_locale_category_get_type(void)
50 + {
51 +- static volatile size_t g_define_type_id__volatile = 0;
52 +- if (g_once_init_enter(&g_define_type_id__volatile)) {
53 ++ static size_t gjs_locale_category_get_type = 0;
54 ++ if (g_once_init_enter(&gjs_locale_category_get_type)) {
55 + static const GEnumValue v[] = {
56 + { GJS_LOCALE_CATEGORY_ALL, "GJS_LOCALE_CATEGORY_ALL", "all" },
57 + { GJS_LOCALE_CATEGORY_COLLATE, "GJS_LOCALE_CATEGORY_COLLATE", "collate" },
58 +@@ -72,9 +72,9 @@ gjs_locale_category_get_type(void)
59 + GType g_define_type_id =
60 + g_enum_register_static(g_intern_static_string("GjsLocaleCategory"), v);
61 +
62 +- g_once_init_leave(&g_define_type_id__volatile, g_define_type_id);
63 ++ g_once_init_leave(&gjs_locale_category_get_type, g_define_type_id);
64 + }
65 +- return g_define_type_id__volatile;
66 ++ return gjs_locale_category_get_type;
67 + }
68 +
69 + /**
70 +--
71 +2.35.1
72 +
73 +From dade6ee66e07a1865dc380060abe921eaeeae763 Mon Sep 17 00:00:00 2001
74 +From: Philip Chimento <philip.chimento@×××××.com>
75 +Date: Sun, 14 Feb 2021 12:20:09 -0800
76 +Subject: [PATCH 2/2] maint: Avoid g_once_init_enter error in GCC 11
77 +
78 +On platforms where g_once_init_enter() is defined to use C11 atomic
79 +builtins, passing a pointer to a volatile value is an error in GCC 11 and
80 +later, in C++.
81 +
82 +More info about the GCC change:
83 +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95378
84 +https://gcc.gnu.org/pipermail/gcc-patches/2020-June/548283.html
85 +
86 +However, it's my understanding that in modern C++ there is no longer a
87 +need to guard the initialization of these variables. Since C++11, static
88 +local variables in a function are guaranteed to be initialized only once,
89 +the first time control passes through that function. So we can just remove
90 +the g_once_init_enter guard.
91 +
92 +More info:
93 +https://en.cppreference.com/w/cpp/language/storage_duration#Static_local_variables
94 +
95 +Stack Overflow answers with quotations from the C++ standard:
96 +https://stackoverflow.com/a/58804/172999
97 +https://stackoverflow.com/a/8102145/172999
98 +
99 +Closes: #376
100 +(cherry picked from commit f02eaf3a9d3465915eb849428c2d9615e2184a4c)
101 +---
102 + gjs/error-types.cpp | 32 +++++++++++++-------------------
103 + 1 file changed, 13 insertions(+), 19 deletions(-)
104 +
105 +diff --git a/gjs/error-types.cpp b/gjs/error-types.cpp
106 +index 86cb8789..5eba61b2 100644
107 +--- a/gjs/error-types.cpp
108 ++++ b/gjs/error-types.cpp
109 +@@ -31,24 +31,18 @@ G_DEFINE_QUARK(gjs-js-error-quark, gjs_js_error)
110 + // clang-format on
111 +
112 + GType gjs_js_error_get_type(void) {
113 +- static volatile GType g_type_id;
114 +-
115 +- if (g_once_init_enter(&g_type_id)) {
116 +- static GEnumValue errors[] = {
117 +- { GJS_JS_ERROR_ERROR, "Error", "error" },
118 +- { GJS_JS_ERROR_EVAL_ERROR, "EvalError", "eval-error" },
119 +- { GJS_JS_ERROR_INTERNAL_ERROR, "InternalError", "internal-error" },
120 +- { GJS_JS_ERROR_RANGE_ERROR, "RangeError", "range-error" },
121 +- { GJS_JS_ERROR_REFERENCE_ERROR, "ReferenceError", "reference-error" },
122 +- { GJS_JS_ERROR_STOP_ITERATION, "StopIteration", "stop-iteration" },
123 +- { GJS_JS_ERROR_SYNTAX_ERROR, "SyntaxError", "syntax-error" },
124 +- { GJS_JS_ERROR_TYPE_ERROR, "TypeError", "type-error" },
125 +- { GJS_JS_ERROR_URI_ERROR, "URIError", "uri-error" },
126 +- { 0, nullptr, nullptr }
127 +- };
128 +-
129 +- g_type_id = g_enum_register_static("GjsJSError", errors);
130 +- }
131 +-
132 ++ static const GEnumValue errors[] = {
133 ++ {GJS_JS_ERROR_ERROR, "Error", "error"},
134 ++ {GJS_JS_ERROR_EVAL_ERROR, "EvalError", "eval-error"},
135 ++ {GJS_JS_ERROR_INTERNAL_ERROR, "InternalError", "internal-error"},
136 ++ {GJS_JS_ERROR_RANGE_ERROR, "RangeError", "range-error"},
137 ++ {GJS_JS_ERROR_REFERENCE_ERROR, "ReferenceError", "reference-error"},
138 ++ {GJS_JS_ERROR_STOP_ITERATION, "StopIteration", "stop-iteration"},
139 ++ {GJS_JS_ERROR_SYNTAX_ERROR, "SyntaxError", "syntax-error"},
140 ++ {GJS_JS_ERROR_TYPE_ERROR, "TypeError", "type-error"},
141 ++ {GJS_JS_ERROR_URI_ERROR, "URIError", "uri-error"},
142 ++ {0, nullptr, nullptr}};
143 ++ // Initialization of static local variable guaranteed only once in C++11
144 ++ static GType g_type_id = g_enum_register_static("GjsJSError", errors);
145 + return g_type_id;
146 + }
147 +--
148 +2.35.1
149 +