Gentoo Archives: gentoo-commits

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/binutils-config:master commit in: src/
Date: Thu, 21 May 2020 18:06:50
Message-Id: 1590084390.a0bd7f579bc77f7b1d6b1fa2a1afedcd71bbb0d0.slyfox@gentoo
1 commit: a0bd7f579bc77f7b1d6b1fa2a1afedcd71bbb0d0
2 Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
3 AuthorDate: Thu May 21 18:06:30 2020 +0000
4 Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
5 CommitDate: Thu May 21 18:06:30 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=a0bd7f57
7
8 add binutils-config sources as-is
9
10 Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
11
12 src/binutils-config | 49 +++++++++++--------------------------
13 src/binutils-config.8 | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++
14 src/binutils.eselect | 45 ++++++++++++++++++++++++++++++++++
15 3 files changed, 126 insertions(+), 35 deletions(-)
16
17 diff --git a/src/binutils-config b/src/binutils-config
18 index 945295c..69ca530 100644
19 --- a/src/binutils-config
20 +++ b/src/binutils-config
21 @@ -1,5 +1,5 @@
22 #!/bin/bash
23 -# Copyright 1999-2017 Gentoo Foundation
24 +# Copyright 1999-2019 Gentoo Authors
25 # Distributed under the terms of the GNU General Public License v2
26
27 # Format of /etc/env.d/binutils/:
28 @@ -41,9 +41,6 @@ ${HILITE}General Options:${NORMAL}
29 ${GOOD}-u, --uninstall${NORMAL} Remove all signs of specified target
30 ${GOOD}-d, --debug${NORMAL} Execute with debug output
31
32 -${HILITE}General Cruft:${NORMAL}
33 - ${GOOD}--linker${NORMAL} <linker> Switch to specified linker (if supported)
34 -
35 Profile names are of the form: ${BRACKET}<CTARGET>-<binutils version>${NORMAL}
36 For example: ${BRACKET}i686-pc-linux-gnu-2.15.92.0.2${NORMAL}
37
38 @@ -145,21 +142,26 @@ switch_profile() {
39 cd "${ROOT}/${LIBPATH}" || exit 1
40 if [[ ${TARGET} == ${HOST} ]] ; then
41 dstlib=${EROOT}/usr/${HOST}/lib
42 - elif [[ -d ${EROOT}/usr/${TARGET}/lib ]] ; then
43 - # true for at least avr and msp targets
44 - dstlib=${EROOT}/usr/${TARGET}/lib
45 else
46 dstlib=${EROOT}/usr/${HOST}/${TARGET}/lib
47 fi
48 # When upgrading, we need to clean up ldscripts and libs.
49 # Don't symlink back in the libs -- the binutils-lib package handles
50 # these now.
51 - # TODO: Stop requiring even the ldscripts symlink, except
52 - # we can't for bare-metal toolchains, so... bug #147155
53 + # TODO: Stop requiring even the ldscripts symlink.
54 mkdir -p "${dstlib}"
55 rm -rf "${ROOT}/${BINPATH_LINKS}"/ldscripts
56 atomic_ln "${LIBPATH}/ldscripts" "${dstlib}" "ldscripts"
57 - find -L "${dstlib}" -xtype l -name 'lib*' -exec rm -f {} +
58 + find -L "${dstlib}" -xtype l -name 'lib*' -delete
59 + # Detect older binutils w/broken rpaths. #562460
60 + # We can hardcode the "/lib" part since that's what the binutils
61 + # configure scripts have. They did not include any other path.
62 + if [[ $(scanelf -qF '%r#F' "${ROOT}/${BINPATH}/as") == */lib ]] ; then
63 + ewarn "Old cross-binutils detected; please re-emerge to fix (see bug #562460)."
64 + for x in lib* ; do
65 + atomic_ln "${LIBPATH}/${x}" "${dstlib}" "${x}"
66 + done
67 + fi
68
69 #
70 # Clean out old generated include symlinks
71 @@ -244,7 +246,7 @@ uninstall_target() {
72
73 local x
74 for x in \
75 - addr2line ar as c++filt elf2flt elfedit flthdr gprof \
76 + addr2line ar as c++filt dwp elf2flt elfedit flthdr gprof \
77 ld ld.{bfd,gold,real} \
78 nm objcopy objdump ranlib readelf size strings strip
79 do
80 @@ -342,28 +344,6 @@ list_profiles() {
81 done
82 }
83
84 -switch_linker() {
85 - local bpath ld=$1
86 -
87 - case ${ld} in
88 - ld.*) ;;
89 - *) die "not supported: linker must start with 'ld.'" ;;
90 - esac
91 -
92 - setup_env || return 1
93 - bpath="${ROOT}/${BINPATH}"
94 -
95 - # does this binutils even support the requested linker ?
96 - if [[ ! -e ${bpath}/${ld} ]] ; then
97 - die "sorry, but ${PROFILE} doesn't support the ${ld} linker"
98 - fi
99 -
100 - # switch it up
101 - ebegin "Setting default linker to ${ld} for ${PROFILE}"
102 - atomic_ln ${ld} "${bpath}" ld
103 - eend $?
104 -}
105 -
106 set_HOST() {
107 # Set HOST to CHOST if it isn't already set
108 : ${HOST:=${CHOST:-$(portageq envvar CHOST)}}
109 @@ -395,7 +375,6 @@ while [[ $# -gt 0 ]] ; do
110 -c|--get-current-profile) select_action get_current_profile ;;
111 -l|--list|--list-profiles) select_action list_profiles ;;
112 -u|--uninstall) select_action uninstall_target ;;
113 - --linker) select_action "switch_linker $1"; shift ;;
114 -d|--debug) DEBUG="yes" ;;
115 -h|--help) usage 0 ;;
116 -V|--version)
117 @@ -425,7 +404,7 @@ set_HOST
118
119 # All operations need to know the profile the user wants
120 case ${DOIT} in
121 -switch_profile|switch_linker_*)
122 +switch_profile)
123 # decode user's profile choice
124 x=${UARG:-$(TARGET=${HOST} set_current_profile)}
125 PROFILE=""
126
127 diff --git a/src/binutils-config.8 b/src/binutils-config.8
128 new file mode 100644
129 index 0000000..e8e64de
130 --- /dev/null
131 +++ b/src/binutils-config.8
132 @@ -0,0 +1,67 @@
133 +.TH "BINUTILS-CONFIG" "8" "Jan 2005" "Gentoo" "Gentoo"
134 +.SH "NAME"
135 +binutils-config \- manage active versions of the binutils programs
136 +.SH "DESCRIPTION"
137 +The \fBbinutils-config\fR script allows you to switch between different
138 +versions of binutils when you have installed multiple copies (see
139 +USE=multislot). It also allows you to manage multiple cross-compiling
140 +targets simultaneously.
141 +
142 +Remember, you may have one version of binutils active per \fICTARGET\fR,
143 +and changing the version for one target has no bearing on any other. So
144 +changing an active cross-compiler will not break your native compiler
145 +(i.e. \fICHOST\fR).
146 +.SH "SYNOPSIS"
147 +\fBbinutils-config\fR [\fIcrufty options\fR] \fIPROFILE\fR
148 +
149 +\fBbinutils-config\fR \fB--get-current-profile\fR \fI[TARGET]\fR
150 +
151 +\fBbinutils-config\fR \fB--list-profiles\fR
152 +
153 +\fBbinutils-config\fR \fB--uninstall\fR \fITARGET\fR
154 +.SH "GENERIC OPTIONS"
155 +.TP
156 +\fBPROFILE\fR
157 +Change the system to use the specified binutils version. This may take the
158 +form of the list index number (the number shown on the left in the
159 +\fB\-\-list\-profiles\fR output), a full \fITARGET-VERSION\fR (useful when
160 +working with cross-compilers), just a \fITARGET\fR where the \fIVERSION\fR
161 +is picked from the active, or just a binutils \fIVERSION\fR where the
162 +\fITARGET\fR is assumed to be the native \fIHOST\fR value.
163 +.TP
164 +\fBTARGET\fR
165 +Similiar to \fBPROFILE\fR, but this is only the target and no version info
166 +(i.e. \fICTARGET\fR or \fICHOST\fR).
167 +.TP
168 +\fB\-c\fR, \fB\-\-get\-current\-profile\fR \fI[TARGET]\fR
169 +Display the active profile for \fITARGET\fR. If none is specified, the
170 +host system's \fITARGET\fR will be shown (i.e. \fICHOST\fR).
171 +.TP
172 +\fB\-l\fR, \fB\-\-list\-profiles\fR
173 +Show all the profiles that your system currently has installed and what
174 +versions are active. The active native version is noted with a bright green
175 +asterisk while the active cross-compiler versions are noted with a light blue
176 +asterisk.
177 +.TP
178 +\fB-u\fR, \fB\-\-uninstall\fR \fITARGET\fR
179 +This is really for internal use only. Used to remove all traces of the
180 +\fITARGET\fR binutils from your system.
181 +.SH "REPORTING BUGS"
182 +Please report bugs via https://bugs.gentoo.org/
183 +.SH "SEE ALSO"
184 +.BR ar (1),
185 +.BR as (1),
186 +.BR ld (1),
187 +.BR nm (1),
188 +.BR objcopy (1),
189 +.BR ranlib (1),
190 +.BR readelf (1),
191 +.BR strings (1),
192 +.BR strip (1)
193 +.SH "FILES"
194 +.nf
195 +.BR /usr/bin/binutils-config
196 +.BR /etc/env.d/binutils/*
197 +.fi
198 +.SH "AUTHORS"
199 +Mike Frysinger <vapier@g.o>
200
201 diff --git a/src/binutils.eselect b/src/binutils.eselect
202 new file mode 100644
203 index 0000000..a89655a
204 --- /dev/null
205 +++ b/src/binutils.eselect
206 @@ -0,0 +1,45 @@
207 +# -*-eselect-*- vim: ft=eselect
208 +# Copyright 2005-2015 Gentoo Foundation
209 +# Distributed under the terms of the GNU GPL version 2 or later
210 +
211 +DESCRIPTION="Manage installed versions of sys-devel/binutils"
212 +MAINTAINER="toolchain@g.o"
213 +
214 +### list action
215 +
216 +describe_list() {
217 + echo "List all installed version of binutils"
218 +}
219 +
220 +do_list() {
221 + binutils-config -l
222 +}
223 +
224 +### set action
225 +
226 +describe_set() {
227 + echo "Activate one of the installed binutils"
228 +}
229 +
230 +describe_set_parameters() {
231 + echo "<target>"
232 +}
233 +
234 +describe_set_options() {
235 + echo "target : Target name or number (from 'list' action)"
236 +}
237 +
238 +do_set() {
239 + [[ $# -eq 1 ]] || die -q "Please specify exactly one version to activate!"
240 + binutils-config "$1"
241 +}
242 +
243 +### show action
244 +
245 +describe_show() {
246 + echo "Print the currently active binutils version"
247 +}
248 +
249 +do_show() {
250 + binutils-config -c
251 +}