Gentoo Archives: gentoo-commits

From: Andrew Savchenko <bircoph@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-util/oprofile/, dev-util/oprofile/files/
Date: Sat, 27 Jun 2020 18:23:24
Message-Id: 1593282169.c852a7c84f28fe745437bcddc4d88b9dc44c85f5.bircoph@gentoo
1 commit: c852a7c84f28fe745437bcddc4d88b9dc44c85f5
2 Author: Andrew Savchenko <bircoph <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jun 27 18:19:05 2020 +0000
4 Commit: Andrew Savchenko <bircoph <AT> gentoo <DOT> org>
5 CommitDate: Sat Jun 27 18:22:49 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c852a7c8
7
8 dev-util/oprofile: fix build with binutils-2.34
9
10 Use upstream patch 377610414fb6cd7ac30e4485d9d6482fcf29aca6 to fix
11 build with new binutils api (2.34) while keeping compatibility
12 support with older versions.
13
14 Closes: https://bugs.gentoo.org/707850
15 Closes: https://github.com/gentoo/gentoo/pull/15469
16 Package-Manager: Portage-2.3.82, Repoman-2.3.20
17 Signed-off-by: Andrew Savchenko <bircoph <AT> gentoo.org>
18
19 dev-util/oprofile/files/binutils-2.34.patch | 157 ++++++++++++++++++++++++++++
20 dev-util/oprofile/oprofile-1.3.0.ebuild | 8 +-
21 2 files changed, 164 insertions(+), 1 deletion(-)
22
23 diff --git a/dev-util/oprofile/files/binutils-2.34.patch b/dev-util/oprofile/files/binutils-2.34.patch
24 new file mode 100644
25 index 00000000000..6337191a21d
26 --- /dev/null
27 +++ b/dev-util/oprofile/files/binutils-2.34.patch
28 @@ -0,0 +1,157 @@
29 +commit 377610414fb6cd7ac30e4485d9d6482fcf29aca6
30 +Author: William Cohen <wcohen@××××××.com>
31 +Date: Wed Mar 18 21:19:16 2020 -0400
32 +
33 + Macro wrappers to handle the binutils 2.34 api changes
34 +
35 + Changes in binutils 2.34 API prevented oprofile from compiling with
36 + it. This patch tests for the changes in the binutils API during
37 + configuration and selects the appropiate wrappers to allow oprofile to
38 + compile. This allows oprofile to compile with both older and newer
39 + versions of binutils.
40 +
41 +diff --git a/configure.ac b/configure.ac
42 +index ac2fd35e..df032a78 100644
43 +--- a/configure.ac
44 ++++ b/configure.ac
45 +@@ -224,6 +224,26 @@ if test "$host_cpu" = "powerpc64le" -o "$host_cpu" = "powerpc64"; then
46 + fi
47 + AC_SUBST(PFM_LIB)
48 +
49 ++HAVE_BINUTILS_234='1'
50 ++AC_MSG_CHECKING([whether binutils 2.34 is being used])
51 ++rm -f test-for-BINUTILS
52 ++AC_LANG_CONFTEST(
53 ++ [AC_LANG_PROGRAM([[#include <bfd.h>]],
54 ++ [[asection * sect;
55 ++ bfd_size_type buildid_sect_size = bfd_section_size(sect);
56 ++ return 0;]])
57 ++ ])
58 ++$CC conftest.$ac_ext $CFLAGS $LDFLAGS $LIBS $PERF_EVENT_FLAGS -o test-for-BINUTILS > /dev/null 2>&1
59 ++if test -f test-for-BINUTILS; then
60 ++ echo "yes"
61 ++ HAVE_BINUTILS_234='1'
62 ++else
63 ++ echo "no"
64 ++ HAVE_BINUTILS_234='0'
65 ++fi
66 ++AC_DEFINE_UNQUOTED(HAVE_BINUTILS_234, $HAVE_BINUTILS_234, [Using binutils 2.34])
67 ++rm -f test-for-BINUTILS*
68 ++
69 + AC_ARG_WITH(java,
70 + [ --with-java=java-home Path to Java home directory (default is "no"; "yes" will use /usr as Java home)],
71 + JAVA_HOMEDIR=$with_java, [with_java=no])
72 +diff --git a/libutil++/bfd_support.cpp b/libutil++/bfd_support.cpp
73 +index fa904839..cd0f4f71 100644
74 +--- a/libutil++/bfd_support.cpp
75 ++++ b/libutil++/bfd_support.cpp
76 +@@ -19,6 +19,7 @@
77 + #include "locate_images.h"
78 + #include "op_libiberty.h"
79 + #include "op_exception.h"
80 ++#include "op_bfd_wrappers.h"
81 +
82 + #include <unistd.h>
83 + #include <errno.h>
84 +@@ -137,7 +138,7 @@ static bool get_build_id(bfd * ibfd, unsigned char * build_id)
85 + }
86 + }
87 +
88 +- bfd_size_type buildid_sect_size = bfd_section_size(ibfd, sect);
89 ++ bfd_size_type buildid_sect_size = op_bfd_section_size(ibfd, sect);
90 + char * contents = (char *) xmalloc(buildid_sect_size);
91 + errno = 0;
92 + if (!bfd_get_section_contents(ibfd, sect,
93 +@@ -188,7 +189,7 @@ bool get_debug_link_info(bfd * ibfd, string & filename, unsigned long & crc32)
94 + if (sect == NULL)
95 + return false;
96 +
97 +- bfd_size_type debuglink_size = bfd_section_size(ibfd, sect);
98 ++ bfd_size_type debuglink_size = op_bfd_section_size(ibfd, sect);
99 + char * contents = (char *) xmalloc(debuglink_size);
100 + cverb << vbfd
101 + << ".gnu_debuglink section has size " << debuglink_size << endl;
102 +@@ -346,7 +347,7 @@ void fixup_linenr(bfd * abfd, asection * section, asymbol ** syms,
103 + // first restrict the search on a sensible range of vma, 16 is
104 + // an intuitive value based on epilog code look
105 + size_t max_search = 16;
106 +- size_t section_size = bfd_section_size(abfd, section);
107 ++ size_t section_size = op_bfd_section_size(abfd, section);
108 + if (pc + max_search > section_size)
109 + max_search = section_size - pc;
110 +
111 +@@ -819,10 +820,10 @@ find_nearest_line(bfd_info const & b, op_bfd_symbol const & sym,
112 + else
113 + pc = (sym.value() + offset) - sym.filepos();
114 +
115 +- if ((bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0)
116 ++ if ((op_bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0)
117 + goto fail;
118 +
119 +- if (pc >= bfd_section_size(abfd, section))
120 ++ if (pc >= op_bfd_section_size(abfd, section))
121 + goto fail;
122 +
123 + ret = bfd_find_nearest_line(abfd, section, syms, pc, &cfilename,
124 +diff --git a/libutil/op_bfd_wrappers.h b/libutil/op_bfd_wrappers.h
125 +new file mode 100644
126 +index 00000000..b229cc12
127 +--- /dev/null
128 ++++ b/libutil/op_bfd_wrappers.h
129 +@@ -0,0 +1,28 @@
130 ++/**
131 ++ * @file op_bfd_wrappers.h
132 ++ * Wrappers to hide API changes in binutils 2.34
133 ++ *
134 ++ * @remark Copyright 2020 OProfile authors
135 ++ * @remark Read the file COPYING
136 ++ *
137 ++ * @author William Cohen
138 ++ */
139 ++
140 ++#ifndef OP_BFD_WRAPPERS_H
141 ++#define OP_BFD_WRAPPERS_H
142 ++
143 ++#if HAVE_BINUTILS_234
144 ++#define op_bfd_section_size(ibfd, sec) bfd_section_size(sec)
145 ++#define op_bfd_get_section_flags(abfd, sec) bfd_section_flags(sec)
146 ++#define op_bfd_set_section_flags(abfd, sec, flags) bfd_set_section_flags(sec, flags)
147 ++#define op_bfd_set_section_vma(abfd, sec, vma) bfd_set_section_vma(sec, vma)
148 ++#define op_bfd_set_section_size(abfd, sec, size) bfd_set_section_size(sec, size)
149 ++#else
150 ++#define op_bfd_section_size(ibfd, sec) bfd_section_size(ibfd, sec)
151 ++#define op_bfd_get_section_flags(abfd, sec) bfd_get_section_flags(abfd, sec)
152 ++#define op_bfd_set_section_flags(abfd, sec, flags) bfd_set_section_flags(abfd, sec, flags)
153 ++#define op_bfd_set_section_vma(abfd, sec, vma) bfd_set_section_vma(abfd, sec, vma)
154 ++#define op_bfd_set_section_size(abfd, sec, size) bfd_set_section_size(abfd, sec, size)
155 ++#endif
156 ++
157 ++#endif /* !OP_BFD_WRAPPERS_H */
158 +diff --git a/opjitconv/create_bfd.c b/opjitconv/create_bfd.c
159 +index 48db143b..da1e6d29 100644
160 +--- a/opjitconv/create_bfd.c
161 ++++ b/opjitconv/create_bfd.c
162 +@@ -16,6 +16,7 @@
163 +
164 + #include "opjitconv.h"
165 + #include "op_libiberty.h"
166 ++#include "op_bfd_wrappers.h"
167 +
168 + #include <bfd.h>
169 + #include <assert.h>
170 +@@ -86,12 +87,12 @@ asection * create_section(bfd * abfd, char const * section_name,
171 + bfd_perror("bfd_make_section");
172 + goto error;
173 + }
174 +- bfd_set_section_vma(abfd, section, vma);
175 +- if (bfd_set_section_size(abfd, section, size) == FALSE) {
176 ++ op_bfd_set_section_vma(abfd, section, vma);
177 ++ if (op_bfd_set_section_size(abfd, section, size) == FALSE) {
178 + bfd_perror("bfd_set_section_size");
179 + goto error;
180 + }
181 +- if (bfd_set_section_flags(abfd, section, flags) == FALSE) {
182 ++ if (op_bfd_set_section_flags(abfd, section, flags) == FALSE) {
183 + bfd_perror("bfd_set_section_flags");
184 + goto error;
185 + }
186
187 diff --git a/dev-util/oprofile/oprofile-1.3.0.ebuild b/dev-util/oprofile/oprofile-1.3.0.ebuild
188 index 826af1f43b9..da8d69f7b57 100644
189 --- a/dev-util/oprofile/oprofile-1.3.0.ebuild
190 +++ b/dev-util/oprofile/oprofile-1.3.0.ebuild
191 @@ -2,7 +2,7 @@
192 # Distributed under the terms of the GNU General Public License v2
193
194 EAPI=6
195 -inherit java-pkg-opt-2 linux-info user
196 +inherit autotools java-pkg-opt-2 linux-info user
197
198 DESCRIPTION="A transparent low-overhead system-wide profiler"
199 HOMEPAGE="http://oprofile.sourceforge.net"
200 @@ -39,6 +39,12 @@ pkg_setup() {
201 use java && java-pkg_init
202 }
203
204 +src_prepare() {
205 + eapply "${FILESDIR}/binutils-2.34.patch"
206 + java-pkg-opt-2_src_prepare
207 + eautoreconf
208 +}
209 +
210 src_configure() {
211 econf \
212 --disable-werror \