Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/elfutils/, dev-libs/elfutils/files/
Date: Wed, 08 Sep 2021 03:09:00
Message-Id: 1631070520.388d62376b0d53e78d347ab890e2b8742aea2e23.sam@gentoo
1 commit: 388d62376b0d53e78d347ab890e2b8742aea2e23
2 Author: Adrian Ratiu <adrian.ratiu <AT> collabora <DOT> com>
3 AuthorDate: Tue Aug 31 18:32:41 2021 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Wed Sep 8 03:08:40 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=388d6237
7
8 dev-libs/elfutils: backport patches fixing clang build
9
10 Latest elfutils mainline development branch contains the
11 last two patches required for building elfutils with clang.
12
13 This backports the two patches onto v0.185 so we can get
14 it built with clang and should be dropped when Gentoo
15 eventually upgrades to v0.186 or later.
16
17 Signed-off-by: Adrian Ratiu <adrian.ratiu <AT> collabora.com>
18 Closes: https://github.com/gentoo/gentoo/pull/22173
19 Signed-off-by: Sam James <sam <AT> gentoo.org>
20
21 dev-libs/elfutils/elfutils-0.185.ebuild | 2 +
22 ....ac-rework-gnu99-ext-check-to-allow-clang.patch | 146 +++++++++++++++++++++
23 ...utils-0.185-pull-advance_pc-in-file-scope.patch | 70 ++++++++++
24 3 files changed, 218 insertions(+)
25
26 diff --git a/dev-libs/elfutils/elfutils-0.185.ebuild b/dev-libs/elfutils/elfutils-0.185.ebuild
27 index a4f1cc56536..fd5ccd26159 100644
28 --- a/dev-libs/elfutils/elfutils-0.185.ebuild
29 +++ b/dev-libs/elfutils/elfutils-0.185.ebuild
30 @@ -34,6 +34,8 @@ PATCHES=(
31 "${FILESDIR}"/${PN}-0.177-disable-large.patch
32 "${FILESDIR}"/${PN}-0.180-PaX-support.patch
33 "${FILESDIR}"/${PN}-0.185-static-inline.patch
34 + "${FILESDIR}"/${PN}-0.185-pull-advance_pc-in-file-scope.patch
35 + "${FILESDIR}"/${PN}-0.185-configure.ac-rework-gnu99-ext-check-to-allow-clang.patch
36 )
37
38 src_prepare() {
39
40 diff --git a/dev-libs/elfutils/files/elfutils-0.185-configure.ac-rework-gnu99-ext-check-to-allow-clang.patch b/dev-libs/elfutils/files/elfutils-0.185-configure.ac-rework-gnu99-ext-check-to-allow-clang.patch
41 new file mode 100644
42 index 00000000000..fe0b111ca85
43 --- /dev/null
44 +++ b/dev-libs/elfutils/files/elfutils-0.185-configure.ac-rework-gnu99-ext-check-to-allow-clang.patch
45 @@ -0,0 +1,146 @@
46 +From c9ff5c53c319f963cac34a41c86cd43edf902459 Mon Sep 17 00:00:00 2001
47 +From: Adrian Ratiu <adrian.ratiu@×××××××××.com>
48 +Date: Mon, 30 Aug 2021 18:43:13 +0300
49 +Subject: [PATCH] configure.ac: rework gnu99 ext check to allow clang
50 +
51 +It is true that Clang does not support all gnu99 extensions [1],
52 +but not all of them are used in the codebase and over time there
53 +have been code cleanup efforts to improve Clang support.
54 +
55 +For example after commit 779c57ea ("readelf: Pull advance_pc()
56 +in file scope") there are no more nested function declarations
57 +and elfutils now builds fine with Clang.
58 +
59 +So in the interest of enabling Clang builds we remove the only
60 +remaining blocker: the configure checks for nested functions and
61 +variable length arrays which are also unused.
62 +
63 +Considering mixed decls and code is also part of c99 standard,
64 +the entire check becomes redundant and we can just replace
65 +AC_PROG_CC -> AC_PROG_CC_C99.
66 +
67 +Upstream-Status: Backport [master commit 6eb991a9]
68 +
69 +[1] https://sourceware.org/bugzilla/show_bug.cgi?id=24964
70 +[Adrian: backported to v0.185]
71 +Signed-off-by: Adrian Ratiu <adrian.ratiu@×××××××××.com>
72 +---
73 + configure | 48 ------------------------------------------------
74 + configure.ac | 35 +----------------------------------
75 + 2 files changed, 1 insertion(+), 82 deletions(-)
76 +
77 +diff --git a/configure b/configure
78 +index 4ea75ee..22bda6c 100755
79 +--- a/configure
80 ++++ b/configure
81 +@@ -5162,54 +5162,6 @@ else
82 + fi
83 +
84 +
85 +-# We use -std=gnu99 but have explicit checks for some language constructs
86 +-# and GNU extensions since some compilers claim GNU99 support, but don't
87 +-# really support all language extensions. In particular we need
88 +-# Mixed Declarations and Code
89 +-# https://gcc.gnu.org/onlinedocs/gcc/Mixed-Declarations.html
90 +-# Nested Functions
91 +-# https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html
92 +-# Arrays of Variable Length
93 +-# https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html
94 +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc with GNU99 support" >&5
95 +-$as_echo_n "checking for gcc with GNU99 support... " >&6; }
96 +-if ${ac_cv_c99+:} false; then :
97 +- $as_echo_n "(cached) " >&6
98 +-else
99 +- old_CFLAGS="$CFLAGS"
100 +-CFLAGS="$CFLAGS -std=gnu99"
101 +-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
102 +-/* end confdefs.h. */
103 +-int foo (int a)
104 +-{
105 +- for (int i = 0; i < a; ++i) if (i % 4) break; int s = a; return s;
106 +-}
107 +-
108 +-double bar (double a, double b)
109 +-{
110 +- double square (double z) { return z * z; }
111 +- return square (a) + square (b);
112 +-}
113 +-
114 +-void baz (int n)
115 +-{
116 +- struct S { int x[n]; };
117 +-}
118 +-_ACEOF
119 +-if ac_fn_c_try_compile "$LINENO"; then :
120 +- ac_cv_c99=yes
121 +-else
122 +- ac_cv_c99=no
123 +-fi
124 +-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
125 +-CFLAGS="$old_CFLAGS"
126 +-fi
127 +-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c99" >&5
128 +-$as_echo "$ac_cv_c99" >&6; }
129 +-if test "x$ac_cv_c99" != xyes; then :
130 +- as_fn_error $? "gcc with GNU99 support required" "$LINENO" 5
131 +-fi
132 +-
133 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gcc supports __attribute__((visibility()))" >&5
134 + $as_echo_n "checking whether gcc supports __attribute__((visibility()))... " >&6; }
135 + if ${ac_cv_visibility+:} false; then :
136 +diff --git a/configure.ac b/configure.ac
137 +index b348a71..6298547 100644
138 +--- a/configure.ac
139 ++++ b/configure.ac
140 +@@ -87,7 +87,7 @@ AS_IF([test "$use_locks" = yes],
141 +
142 + AH_TEMPLATE([USE_LOCKS], [Defined if libraries should be thread-safe.])
143 +
144 +-AC_PROG_CC
145 ++AC_PROG_CC_C99
146 + AC_PROG_RANLIB
147 + AC_PROG_YACC
148 + AM_PROG_LEX
149 +@@ -96,39 +96,6 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
150 + AC_CHECK_TOOL([READELF], [readelf])
151 + AC_CHECK_TOOL([NM], [nm])
152 +
153 +-# We use -std=gnu99 but have explicit checks for some language constructs
154 +-# and GNU extensions since some compilers claim GNU99 support, but don't
155 +-# really support all language extensions. In particular we need
156 +-# Mixed Declarations and Code
157 +-# https://gcc.gnu.org/onlinedocs/gcc/Mixed-Declarations.html
158 +-# Nested Functions
159 +-# https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html
160 +-# Arrays of Variable Length
161 +-# https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html
162 +-AC_CACHE_CHECK([for gcc with GNU99 support], ac_cv_c99, [dnl
163 +-old_CFLAGS="$CFLAGS"
164 +-CFLAGS="$CFLAGS -std=gnu99"
165 +-AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
166 +-int foo (int a)
167 +-{
168 +- for (int i = 0; i < a; ++i) if (i % 4) break; int s = a; return s;
169 +-}
170 +-
171 +-double bar (double a, double b)
172 +-{
173 +- double square (double z) { return z * z; }
174 +- return square (a) + square (b);
175 +-}
176 +-
177 +-void baz (int n)
178 +-{
179 +- struct S { int x[[n]]; };
180 +-}])],
181 +- ac_cv_c99=yes, ac_cv_c99=no)
182 +-CFLAGS="$old_CFLAGS"])
183 +-AS_IF([test "x$ac_cv_c99" != xyes],
184 +- AC_MSG_ERROR([gcc with GNU99 support required]))
185 +-
186 + AC_CACHE_CHECK([whether gcc supports __attribute__((visibility()))],
187 + ac_cv_visibility, [dnl
188 + save_CFLAGS="$CFLAGS"
189 +--
190 +2.33.0
191 +
192
193 diff --git a/dev-libs/elfutils/files/elfutils-0.185-pull-advance_pc-in-file-scope.patch b/dev-libs/elfutils/files/elfutils-0.185-pull-advance_pc-in-file-scope.patch
194 new file mode 100644
195 index 00000000000..e0678c9ba73
196 --- /dev/null
197 +++ b/dev-libs/elfutils/files/elfutils-0.185-pull-advance_pc-in-file-scope.patch
198 @@ -0,0 +1,70 @@
199 +From 779c57ea864d104bad88455535df9b26336349fd Mon Sep 17 00:00:00 2001
200 +From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder@××××××.com>
201 +Date: Thu, 18 Mar 2021 10:25:24 +0100
202 +Subject: [PATCH] readelf: Pull advance_pc() in file scope
203 +MIME-Version: 1.0
204 +Content-Type: text/plain; charset=UTF-8
205 +Content-Transfer-Encoding: 8bit
206 +
207 +Make advance_pc() a static function so we can get rid of another nested
208 +function. Rename it to run_advance_pc() and use a local advance_pc()
209 +macro to pass all the local variables. This is similar to what the
210 +equivalent code in libdw/dwarf_getsrclines.c is doing.
211 +
212 +Upstream-Status: Backport [master commit 779c57ea]
213 +
214 +Signed-off-by: Timm Bäder <tbaeder@××××××.com>
215 +[Adrian: backported to v0.185]
216 +Signed-off-by: Adrian Ratiu <adrian.ratiu@×××××××××.com>
217 +---
218 + src/ChangeLog | 7 +++++++
219 + src/readelf.c | 26 +++++++++++++++++++-------
220 + 2 files changed, 26 insertions(+), 7 deletions(-)
221 +
222 +diff --git a/src/readelf.c b/src/readelf.c
223 +index 161d7e65..8191bde2 100644
224 +--- a/src/readelf.c
225 ++++ b/src/readelf.c
226 +@@ -8373,6 +8373,23 @@ print_form_data (Dwarf *dbg, int form, const unsigned char *readp,
227 + return readp;
228 + }
229 +
230 ++/* Only used via run_advance_pc() macro */
231 ++static inline void
232 ++run_advance_pc (unsigned int op_advance,
233 ++ unsigned int minimum_instr_len,
234 ++ unsigned int max_ops_per_instr,
235 ++ unsigned int *op_addr_advance,
236 ++ Dwarf_Word *address,
237 ++ unsigned int *op_index)
238 ++{
239 ++ const unsigned int advanced_op_index = (*op_index) + op_advance;
240 ++
241 ++ *op_addr_advance = minimum_instr_len * (advanced_op_index
242 ++ / max_ops_per_instr);
243 ++ *address = *address + *op_addr_advance;
244 ++ *op_index = advanced_op_index % max_ops_per_instr;
245 ++}
246 ++
247 + static void
248 + print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
249 + Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
250 +@@ -8763,13 +8780,8 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
251 + /* Apply the "operation advance" from a special opcode
252 + or DW_LNS_advance_pc (as per DWARF4 6.2.5.1). */
253 + unsigned int op_addr_advance;
254 +- inline void advance_pc (unsigned int op_advance)
255 +- {
256 +- op_addr_advance = minimum_instr_len * ((op_index + op_advance)
257 +- / max_ops_per_instr);
258 +- address += op_addr_advance;
259 +- op_index = (op_index + op_advance) % max_ops_per_instr;
260 +- }
261 ++#define advance_pc(op_advance) run_advance_pc(op_advance, minimum_instr_len, \
262 ++ max_ops_per_instr, &op_addr_advance, &address, &op_index)
263 +
264 + if (max_ops_per_instr == 0)
265 + {
266 +--
267 +2.32.0
268 +