commit:     a0bd7f579bc77f7b1d6b1fa2a1afedcd71bbb0d0
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Thu May 21 18:06:30 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Thu May 21 18:06:30 2020 +0000
URL:        
https://gitweb.gentoo.org/proj/binutils-config.git/commit/?id=a0bd7f57

add binutils-config sources as-is

Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 src/binutils-config   | 49 +++++++++++--------------------------
 src/binutils-config.8 | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/binutils.eselect  | 45 ++++++++++++++++++++++++++++++++++
 3 files changed, 126 insertions(+), 35 deletions(-)

diff --git a/src/binutils-config b/src/binutils-config
index 945295c..69ca530 100644
--- a/src/binutils-config
+++ b/src/binutils-config
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2017 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # Format of /etc/env.d/binutils/:
@@ -41,9 +41,6 @@ ${HILITE}General Options:${NORMAL}
   ${GOOD}-u, --uninstall${NORMAL}            Remove all signs of specified 
target
   ${GOOD}-d, --debug${NORMAL}                Execute with debug output
 
-${HILITE}General Cruft:${NORMAL}
-  ${GOOD}--linker${NORMAL} <linker>          Switch to specified linker (if 
supported)
-
 Profile names are of the form:  ${BRACKET}<CTARGET>-<binutils version>${NORMAL}
 For example:                    
${BRACKET}i686-pc-linux-gnu-2.15.92.0.2${NORMAL}
 
@@ -145,21 +142,26 @@ switch_profile() {
        cd "${ROOT}/${LIBPATH}" || exit 1
        if [[ ${TARGET} == ${HOST} ]] ; then
                dstlib=${EROOT}/usr/${HOST}/lib
-       elif [[ -d ${EROOT}/usr/${TARGET}/lib ]] ; then
-               # true for at least avr and msp targets
-               dstlib=${EROOT}/usr/${TARGET}/lib
        else
                dstlib=${EROOT}/usr/${HOST}/${TARGET}/lib
        fi
        # When upgrading, we need to clean up ldscripts and libs.
        # Don't symlink back in the libs -- the binutils-lib package handles
        # these now.
-       # TODO: Stop requiring even the ldscripts symlink, except
-       # we can't for bare-metal toolchains, so...  bug #147155
+       # TODO: Stop requiring even the ldscripts symlink.
        mkdir -p "${dstlib}"
        rm -rf "${ROOT}/${BINPATH_LINKS}"/ldscripts
        atomic_ln "${LIBPATH}/ldscripts" "${dstlib}" "ldscripts"
-       find -L "${dstlib}" -xtype l -name 'lib*' -exec rm -f {} +
+       find -L "${dstlib}" -xtype l -name 'lib*' -delete
+       # Detect older binutils w/broken rpaths. #562460
+       # We can hardcode the "/lib" part since that's what the binutils
+       # configure scripts have.  They did not include any other path.
+       if [[ $(scanelf -qF '%r#F' "${ROOT}/${BINPATH}/as") == */lib ]] ; then
+               ewarn "Old cross-binutils detected; please re-emerge to fix 
(see bug #562460)."
+               for x in lib* ; do
+                       atomic_ln "${LIBPATH}/${x}" "${dstlib}" "${x}"
+               done
+       fi
 
        #
        # Clean out old generated include symlinks
@@ -244,7 +246,7 @@ uninstall_target() {
 
        local x
        for x in \
-               addr2line ar as c++filt elf2flt elfedit flthdr gprof \
+               addr2line ar as c++filt dwp elf2flt elfedit flthdr gprof \
                ld ld.{bfd,gold,real} \
                nm objcopy objdump ranlib readelf size strings strip
        do
@@ -342,28 +344,6 @@ list_profiles() {
        done
 }
 
-switch_linker() {
-       local bpath ld=$1
-
-       case ${ld} in
-       ld.*) ;;
-       *) die "not supported: linker must start with 'ld.'" ;;
-       esac
-
-       setup_env || return 1
-       bpath="${ROOT}/${BINPATH}"
-
-       # does this binutils even support the requested linker ?
-       if [[ ! -e ${bpath}/${ld} ]] ; then
-               die "sorry, but ${PROFILE} doesn't support the ${ld} linker"
-       fi
-
-       # switch it up
-       ebegin "Setting default linker to ${ld} for ${PROFILE}"
-       atomic_ln ${ld} "${bpath}" ld
-       eend $?
-}
-
 set_HOST() {
        # Set HOST to CHOST if it isn't already set
        : ${HOST:=${CHOST:-$(portageq envvar CHOST)}}
@@ -395,7 +375,6 @@ while [[ $# -gt 0 ]] ; do
                -c|--get-current-profile)  select_action get_current_profile ;;
                -l|--list|--list-profiles) select_action list_profiles ;;
                -u|--uninstall)            select_action uninstall_target ;;
-               --linker)                  select_action "switch_linker $1"; 
shift ;;
                -d|--debug)                DEBUG="yes" ;;
                -h|--help)                 usage 0 ;;
                -V|--version)
@@ -425,7 +404,7 @@ set_HOST
 
 # All operations need to know the profile the user wants
 case ${DOIT} in
-switch_profile|switch_linker_*)
+switch_profile)
        # decode user's profile choice
        x=${UARG:-$(TARGET=${HOST} set_current_profile)}
        PROFILE=""

diff --git a/src/binutils-config.8 b/src/binutils-config.8
new file mode 100644
index 0000000..e8e64de
--- /dev/null
+++ b/src/binutils-config.8
@@ -0,0 +1,67 @@
+.TH "BINUTILS-CONFIG" "8" "Jan 2005" "Gentoo" "Gentoo"
+.SH "NAME"
+binutils-config \- manage active versions of the binutils programs
+.SH "DESCRIPTION"
+The \fBbinutils-config\fR script allows you to switch between different 
+versions of binutils when you have installed multiple copies (see
+USE=multislot).  It also allows you to manage multiple cross-compiling
+targets simultaneously.
+
+Remember, you may have one version of binutils active per \fICTARGET\fR,
+and changing the version for one target has no bearing on any other.  So
+changing an active cross-compiler will not break your native compiler
+(i.e. \fICHOST\fR).
+.SH "SYNOPSIS"
+\fBbinutils-config\fR [\fIcrufty options\fR] \fIPROFILE\fR
+
+\fBbinutils-config\fR \fB--get-current-profile\fR \fI[TARGET]\fR
+
+\fBbinutils-config\fR \fB--list-profiles\fR
+
+\fBbinutils-config\fR \fB--uninstall\fR \fITARGET\fR
+.SH "GENERIC OPTIONS"
+.TP
+\fBPROFILE\fR
+Change the system to use the specified binutils version.  This may take the
+form of the list index number (the number shown on the left in the
+\fB\-\-list\-profiles\fR output), a full \fITARGET-VERSION\fR (useful when
+working with cross-compilers), just a \fITARGET\fR where the \fIVERSION\fR
+is picked from the active, or just a binutils \fIVERSION\fR where the
+\fITARGET\fR is assumed to be the native \fIHOST\fR value.
+.TP
+\fBTARGET\fR
+Similiar to \fBPROFILE\fR, but this is only the target and no version info
+(i.e. \fICTARGET\fR or \fICHOST\fR).
+.TP
+\fB\-c\fR, \fB\-\-get\-current\-profile\fR \fI[TARGET]\fR
+Display the active profile for \fITARGET\fR.  If none is specified, the 
+host system's \fITARGET\fR will be shown (i.e. \fICHOST\fR).
+.TP
+\fB\-l\fR, \fB\-\-list\-profiles\fR
+Show all the profiles that your system currently has installed and what
+versions are active.  The active native version is noted with a bright green
+asterisk while the active cross-compiler versions are noted with a light blue
+asterisk.
+.TP
+\fB-u\fR, \fB\-\-uninstall\fR \fITARGET\fR
+This is really for internal use only.  Used to remove all traces of the 
+\fITARGET\fR binutils from your system.
+.SH "REPORTING BUGS"
+Please report bugs via https://bugs.gentoo.org/
+.SH "SEE ALSO"
+.BR ar (1),
+.BR as (1),
+.BR ld (1),
+.BR nm (1),
+.BR objcopy (1),
+.BR ranlib (1),
+.BR readelf (1),
+.BR strings (1),
+.BR strip (1)
+.SH "FILES"
+.nf
+.BR /usr/bin/binutils-config
+.BR /etc/env.d/binutils/*
+.fi
+.SH "AUTHORS"
+Mike Frysinger <[email protected]>

diff --git a/src/binutils.eselect b/src/binutils.eselect
new file mode 100644
index 0000000..a89655a
--- /dev/null
+++ b/src/binutils.eselect
@@ -0,0 +1,45 @@
+# -*-eselect-*-  vim: ft=eselect
+# Copyright 2005-2015 Gentoo Foundation
+# Distributed under the terms of the GNU GPL version 2 or later
+
+DESCRIPTION="Manage installed versions of sys-devel/binutils"
+MAINTAINER="[email protected]"
+
+### list action
+
+describe_list() {
+       echo "List all installed version of binutils"
+}
+
+do_list() {
+       binutils-config -l
+}
+
+### set action
+
+describe_set() {
+       echo "Activate one of the installed binutils"
+}
+
+describe_set_parameters() {
+       echo "<target>"
+}
+
+describe_set_options() {
+       echo "target : Target name or number (from 'list' action)"
+}
+
+do_set() {
+       [[ $# -eq 1 ]] || die -q "Please specify exactly one version to 
activate!"
+       binutils-config "$1"
+}
+
+### show action
+
+describe_show() {
+       echo "Print the currently active binutils version"
+}
+
+do_show() {
+       binutils-config -c
+}

Reply via email to