Gentoo Archives: gentoo-commits

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/gdb/files/, sys-devel/gdb/
Date: Sun, 21 Oct 2018 16:27:52
Message-Id: 1540139256.63d949769e25176de0d879cbef2b7cd80348ad0f.slyfox@gentoo
1 commit: 63d949769e25176de0d879cbef2b7cd80348ad0f
2 Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
3 AuthorDate: Sun Oct 21 16:26:47 2018 +0000
4 Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
5 CommitDate: Sun Oct 21 16:27:36 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=63d94976
7
8 sys-devel/gdb: link against tinfow first, then tinfo. bug #669096
9
10 In bug #669096 gdb was directly linked both
11 to libtinfo.so.6 and libncursesw.so.6:
12 $ lddtree /usr/bin/gdb
13 /usr/bin/gdb (interpreter => /lib64/ld-linux-x86-64.so.2)
14 libtinfo.so.6 => /lib64/libtinfo.so.6
15 libncursesw.so.6 => /lib64/libncursesw.so.6
16 libtinfow.so.6 => /lib64/libtinfow.so.6
17 ...
18 and caused gdb to SIGSEGV at start.
19
20 Let's consistently link against *w libraries when both available.
21
22 Note: the fix on it's own is not enough:
23 - we don't pass include paths to ncursesw libraries
24 - libreadline.so.7 is still linked against libtinfo.so.6 in Gentoo
25 and needs a separate fix.
26
27 But it's enough to make immediate SIGSEGV to go away.
28
29 Reported-by: Michał Górny
30 Bug: https://bugs.gentoo.org/669096
31 Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
32 Package-Manager: Portage-2.3.51, Repoman-2.3.11
33
34 sys-devel/gdb/files/gdb-8.2-tinfow.patch | 44 ++++++
35 sys-devel/gdb/gdb-8.2-r1.ebuild | 261 +++++++++++++++++++++++++++++++
36 2 files changed, 305 insertions(+)
37
38 diff --git a/sys-devel/gdb/files/gdb-8.2-tinfow.patch b/sys-devel/gdb/files/gdb-8.2-tinfow.patch
39 new file mode 100644
40 index 00000000000..48f6109664a
41 --- /dev/null
42 +++ b/sys-devel/gdb/files/gdb-8.2-tinfow.patch
43 @@ -0,0 +1,44 @@
44 +Try to link gdb against tinfow first, then tinfo.
45 +
46 +In bug #669096 gdb was directly linked both
47 +to libtinfo.so.6 and libncursesw.so.6:
48 + $ lddtree /usr/bin/gdb
49 + /usr/bin/gdb (interpreter => /lib64/ld-linux-x86-64.so.2)
50 + libtinfo.so.6 => /lib64/libtinfo.so.6
51 + libncursesw.so.6 => /lib64/libncursesw.so.6
52 + libtinfow.so.6 => /lib64/libtinfow.so.6
53 + ...
54 +and caused gdb to SIGSEGV at start.
55 +
56 +Let's consistently link against *w libraries.
57 +
58 +Note: the fix on it's own is not enough:
59 +- we don't pass include paths to ncursesw libraries
60 +- libreadline.so.7 is still linked against libtinfo.so.6 in Gentoo
61 + and needs a separate fix.
62 +
63 +But it's enough to make immediate SIGSEGV to go away.
64 +
65 +Reported-by: Michał Górny
66 +Bug: https://bugs.gentoo.org/669096
67 +--- a/gdb/configure.ac
68 ++++ b/gdb/configure.ac
69 +@@ -616,4 +616,4 @@ esac
70 +
71 +-# These are the libraries checked by Readline.
72 +-AC_SEARCH_LIBS(tgetent, [termcap tinfo curses ncursesw ncurses])
73 ++# These are the libraries checked by Readline. Not really: readline does not know about *w libs.
74 ++AC_SEARCH_LIBS(tgetent, [termcap tinfow tinfo curses ncursesw ncurses])
75 +
76 +--- a/gdb/configure
77 ++++ b/gdb/configure
78 +@@ -8984,3 +8984,3 @@ esac
79 +
80 +-# These are the libraries checked by Readline.
81 ++# These are the libraries checked by Readline. Not really: readline does not know about *w libs.
82 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5
83 +@@ -9009,3 +9009,3 @@ return tgetent ();
84 + _ACEOF
85 +-for ac_lib in '' termcap tinfo curses ncursesw ncurses; do
86 ++for ac_lib in '' termcap tinfow tinfo curses ncursesw ncurses; do
87 + if test -z "$ac_lib"; then
88
89 diff --git a/sys-devel/gdb/gdb-8.2-r1.ebuild b/sys-devel/gdb/gdb-8.2-r1.ebuild
90 new file mode 100644
91 index 00000000000..d7f7e1ef262
92 --- /dev/null
93 +++ b/sys-devel/gdb/gdb-8.2-r1.ebuild
94 @@ -0,0 +1,261 @@
95 +# Copyright 1999-2018 Gentoo Authors
96 +# Distributed under the terms of the GNU General Public License v2
97 +
98 +EAPI=6
99 +PYTHON_COMPAT=( python{2_7,3_4,3_5,3_6} )
100 +
101 +inherit epatch eutils flag-o-matic python-single-r1
102 +
103 +export CTARGET=${CTARGET:-${CHOST}}
104 +if [[ ${CTARGET} == ${CHOST} ]] ; then
105 + if [[ ${CATEGORY} == cross-* ]] ; then
106 + export CTARGET=${CATEGORY#cross-}
107 + fi
108 +fi
109 +is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
110 +
111 +RPM=
112 +MY_PV=${PV}
113 +case ${PV} in
114 +9999*)
115 + # live git tree
116 + EGIT_REPO_URI="git://sourceware.org/git/binutils-gdb.git"
117 + inherit git-r3
118 + SRC_URI=""
119 + ;;
120 +*.*.50.2???????)
121 + # weekly snapshots
122 + SRC_URI="ftp://sourceware.org/pub/gdb/snapshots/current/gdb-weekly-${PV}.tar.xz"
123 + ;;
124 +*.*.*.*.*.*)
125 + # fedora versions; note we swap the rpm & fedora core versions.
126 + # gdb-6.8.50.20090302-8.fc11.src.rpm -> gdb-6.8.50.20090302.11.8.ebuild
127 + # gdb-7.9-11.fc23.src.rpm -> gdb-7.9.23.11.ebuild
128 + inherit versionator rpm
129 + gvcr() { get_version_component_range "$@"; }
130 + parse_fedora_ver() {
131 + set -- $(get_version_components)
132 + MY_PV=$(gvcr 1-$(( $# - 2 )))
133 + RPM="${PN}-${MY_PV}-$(gvcr $#).fc$(gvcr $(( $# - 1 ))).src.rpm"
134 + }
135 + parse_fedora_ver
136 + SRC_URI="mirror://fedora-dev/development/rawhide/source/SRPMS/g/${RPM}"
137 + ;;
138 +*)
139 + # Normal upstream release
140 + SRC_URI="mirror://gnu/gdb/${P}.tar.xz
141 + ftp://sourceware.org/pub/gdb/releases/${P}.tar.xz"
142 + ;;
143 +esac
144 +
145 +PATCH_VER="1"
146 +PATCH_DEV="slyfox"
147 +DESCRIPTION="GNU debugger"
148 +HOMEPAGE="https://sourceware.org/gdb/"
149 +SRC_URI="${SRC_URI}
150 + ${PATCH_DEV:+https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${PN}-8.1-patches-${PATCH_VER}.tar.xz}
151 + ${PATCH_VER:+mirror://gentoo/${PN}-8.1-patches-${PATCH_VER}.tar.xz}
152 +"
153 +
154 +LICENSE="GPL-2 LGPL-2"
155 +SLOT="0"
156 +if [[ ${PV} != 9999* ]] ; then
157 + KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~x64-cygwin ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
158 +fi
159 +IUSE="+client lzma multitarget nls +python +server test vanilla xml"
160 +REQUIRED_USE="
161 + python? ( ${PYTHON_REQUIRED_USE} )
162 + || ( client server )
163 +"
164 +
165 +RDEPEND="
166 + server? ( !dev-util/gdbserver )
167 + client? (
168 + dev-libs/mpfr:0=
169 + >=sys-libs/ncurses-5.2-r2:0=
170 + sys-libs/readline:0=
171 + lzma? ( app-arch/xz-utils )
172 + python? ( ${PYTHON_DEPS} )
173 + xml? ( dev-libs/expat )
174 + sys-libs/zlib
175 + )"
176 +DEPEND="${RDEPEND}
177 + app-arch/xz-utils
178 + sys-apps/texinfo
179 + client? (
180 + virtual/yacc
181 + test? ( dev-util/dejagnu )
182 + nls? ( sys-devel/gettext )
183 + )"
184 +
185 +S=${WORKDIR}/${PN}-${MY_PV}
186 +
187 +pkg_setup() {
188 + use python && python-single-r1_pkg_setup
189 +}
190 +
191 +src_prepare() {
192 + [[ -n ${RPM} ]] && rpm_spec_epatch "${WORKDIR}"/gdb.spec
193 +
194 + # upstreamed
195 + EPATCH_EXCLUDE+=" 01_all_ia64-TRAP_HWBKPT.patch"
196 + EPATCH_EXCLUDE+=" 02_all_solaris-no-uuidsys.patch"
197 + ! use vanilla && [[ -n ${PATCH_VER} ]] && EPATCH_SUFFIX="patch" epatch "${WORKDIR}"/patch
198 + eapply "${FILESDIR}"/${P}-tinfow.patch
199 +
200 + default
201 +
202 + strip-linguas -u bfd/po opcodes/po
203 +}
204 +
205 +gdb_branding() {
206 + printf "Gentoo ${PV} "
207 + if ! use vanilla && [[ -n ${PATCH_VER} ]] ; then
208 + printf "p${PATCH_VER}"
209 + else
210 + printf "vanilla"
211 + fi
212 + [[ -n ${EGIT_COMMIT} ]] && printf " ${EGIT_COMMIT}"
213 +}
214 +
215 +src_configure() {
216 + strip-unsupported-flags
217 +
218 + local myconf=(
219 + --with-pkgversion="$(gdb_branding)"
220 + --with-bugurl='https://bugs.gentoo.org/'
221 + --disable-werror
222 + # Disable modules that are in a combined binutils/gdb tree. #490566
223 + --disable-{binutils,etc,gas,gold,gprof,ld}
224 + )
225 + local sysroot="${EPREFIX}/usr/${CTARGET}"
226 + is_cross && myconf+=(
227 + --with-sysroot="${sysroot}"
228 + --includedir="${sysroot}/usr/include"
229 + --with-gdb-datadir="\${datadir}/gdb/${CTARGET}"
230 + )
231 +
232 + if use server && ! use client ; then
233 + # just configure+build in the gdbserver subdir to speed things up
234 + cd gdb/gdbserver
235 + myconf+=( --program-transform-name='' )
236 + else
237 + # gdbserver only works for native targets (CHOST==CTARGET).
238 + # it also doesn't support all targets, so rather than duplicate
239 + # the target list (which changes between versions), use the
240 + # "auto" value when things are turned on.
241 + is_cross \
242 + && myconf+=( --disable-gdbserver ) \
243 + || myconf+=( $(use_enable server gdbserver auto) )
244 + fi
245 +
246 + if ! ( use server && ! use client ) ; then
247 + # if we are configuring in the top level, then use all
248 + # the additional global options
249 + myconf+=(
250 + --enable-64-bit-bfd
251 + --disable-install-libbfd
252 + --disable-install-libiberty
253 + # Disable guile for now as it requires guile-2.x #562902
254 + --without-guile
255 + # This only disables building in the readline subdir.
256 + # For gdb itself, it'll use the system version.
257 + --disable-readline
258 + --with-system-readline
259 + # This only disables building in the zlib subdir.
260 + # For gdb itself, it'll use the system version.
261 + --without-zlib
262 + --with-system-zlib
263 + --with-separate-debug-dir="${EPREFIX}"/usr/lib/debug
264 + $(use_with xml expat)
265 + $(use_with lzma)
266 + $(use_enable nls)
267 + $(use multitarget && echo --enable-targets=all)
268 + $(use_with python python "${EPYTHON}")
269 + )
270 + fi
271 + if use sparc-solaris || use x86-solaris ; then
272 + # disable largefile support
273 + # https://sourceware.org/ml/gdb-patches/2014-12/msg00058.html
274 + myconf+=( --disable-largefile )
275 + fi
276 +
277 + econf "${myconf[@]}"
278 +}
279 +
280 +src_test() {
281 + nonfatal emake check || ewarn "tests failed"
282 +}
283 +
284 +src_install() {
285 + if use server && ! use client; then
286 + cd gdb/gdbserver || die
287 + fi
288 + default
289 + if use client; then
290 + find "${ED}"/usr -name libiberty.a -delete || die
291 + fi
292 + cd "${S}" || die
293 +
294 + # Delete translations that conflict with binutils-libs. #528088
295 + # Note: Should figure out how to store these in an internal gdb dir.
296 + if use nls ; then
297 + find "${ED}" \
298 + -regextype posix-extended -regex '.*/(bfd|opcodes)[.]g?mo$' \
299 + -delete || die
300 + fi
301 +
302 + # Don't install docs when building a cross-gdb
303 + if [[ ${CTARGET} != ${CHOST} ]] ; then
304 + rm -rf "${ED}"/usr/share/{doc,info,locale} || die
305 + local f
306 + for f in "${ED}"/usr/share/man/*/* ; do
307 + if [[ ${f##*/} != ${CTARGET}-* ]] ; then
308 + mv "${f}" "${f%/*}/${CTARGET}-${f##*/}" || die
309 + fi
310 + done
311 + return 0
312 + fi
313 + # Install it by hand for now:
314 + # https://sourceware.org/ml/gdb-patches/2011-12/msg00915.html
315 + # Only install if it exists due to the twisted behavior (see
316 + # notes in src_configure above).
317 + [[ -e gdb/gdbserver/gdbreplay ]] && dobin gdb/gdbserver/gdbreplay
318 +
319 + if use client ; then
320 + docinto gdb
321 + dodoc gdb/CONTRIBUTE gdb/README gdb/MAINTAINERS \
322 + gdb/NEWS gdb/ChangeLog gdb/PROBLEMS
323 + fi
324 + docinto sim
325 + dodoc sim/{ChangeLog,MAINTAINERS,README-HACKING}
326 + if use server ; then
327 + docinto gdbserver
328 + dodoc gdb/gdbserver/{ChangeLog,README}
329 + fi
330 +
331 + if [[ -n ${PATCH_VER} ]] ; then
332 + dodoc "${WORKDIR}"/extra/gdbinit.sample
333 + fi
334 +
335 + # Remove shared info pages
336 + rm -f "${ED}"/usr/share/info/{annotate,bfd,configure,standards}.info*
337 +
338 + # gcore is part of ubin on freebsd
339 + if [[ ${CHOST} == *-freebsd* ]]; then
340 + rm "${ED}"/usr/bin/gcore || die
341 + fi
342 +}
343 +
344 +pkg_postinst() {
345 + # portage sucks and doesnt unmerge files in /etc
346 + rm -vf "${EROOT}"/etc/skel/.gdbinit
347 +
348 + if use prefix && [[ ${CHOST} == *-darwin* ]] ; then
349 + ewarn "gdb is unable to get a mach task port when installed by Prefix"
350 + ewarn "Portage, unprivileged. To make gdb fully functional you'll"
351 + ewarn "have to perform the following steps:"
352 + ewarn " % sudo chgrp procmod ${EPREFIX}/usr/bin/gdb"
353 + ewarn " % sudo chmod g+s ${EPREFIX}/usr/bin/gdb"
354 + fi
355 +}