* [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/, sys-devel/binutils-config/files/
@ 2015-12-15 19:49 Fabian Groffen
0 siblings, 0 replies; 10+ messages in thread
From: Fabian Groffen @ 2015-12-15 19:49 UTC (permalink / raw
To: gentoo-commits
commit: 0e83584b43e98eaeed13e30fb6f90391214b0b06
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 15 19:48:38 2015 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Dec 15 19:48:38 2015 +0000
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=0e83584b
sys-devel/binutils-config: sync version 5-r2
Package-Manager: portage-2.2.20-prefix
.../binutils-config/binutils-config-5-r2.ebuild | 76 ++++
sys-devel/binutils-config/files/binutils-config-5 | 494 +++++++++++++++++++++
sys-devel/binutils-config/files/binutils.eselect | 45 ++
3 files changed, 615 insertions(+)
diff --git a/sys-devel/binutils-config/binutils-config-5-r2.ebuild b/sys-devel/binutils-config/binutils-config-5-r2.ebuild
new file mode 100644
index 0000000..3af562d
--- /dev/null
+++ b/sys-devel/binutils-config/binutils-config-5-r2.ebuild
@@ -0,0 +1,76 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit eutils prefix
+
+DESCRIPTION="Utility to change the binutils version being used"
+HOMEPAGE="https://www.gentoo.org/"
+W_VER="0.3.1723"
+SRC_URI="http://dev.gentoo.org/~grobian/distfiles/toolchain-prefix-wrapper-${W_VER}.tar.xz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~ppc-aix ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~ia64-linux ~x86-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE="sunld"
+
+# We also RDEPEND on sys-apps/findutils which is in base @system
+RDEPEND="sys-apps/gentoo-functions
+ !<app-admin/eselect-1.4.5"
+
+S=${WORKDIR}/toolchain-prefix-wrapper-${W_VER}
+
+# NOTE: the ld wrapper is only enabled on rpath versions of prefix.
+src_prepare() {
+ cp "${FILESDIR}"/${PN}-${PV} ./${PN} || die
+ if use prefix-guest; then
+ epatch "${FILESDIR}/${PN}-4-ldwrapper.patch"
+ fi
+ eprefixify ${PN}
+
+ # fix configure stupidity, until next release
+ sed -i -e 's/x10\.\[3456789\]/x10.*/' configure
+ epatch "${FILESDIR}"/${PN}-4-no-macosx-version-min.patch
+ epatch "${FILESDIR}"/${PN}-4-aix-ld-svr4.patch
+}
+
+src_configure() {
+ if use prefix-guest; then
+ econf --with-macosx-version-min=${MACOSX_DEPLOYMENT_TARGET} \
+ $(use_with sunld native-ld)
+ fi
+}
+
+src_install() {
+ if use prefix-guest; then
+ emake install DESTDIR="${D}"
+ fi
+
+ newbin "${S}"/${PN} ${PN}
+ doman "${FILESDIR}"/${PN}.8
+
+ insinto /usr/share/eselect/modules
+ doins "${FILESDIR}"/binutils.eselect
+}
+
+pkg_preinst() {
+ # Force a refresh when upgrading from an older version that symlinked
+ # in all the libs & includes that binutils-libs handles. #528088
+ if has_version "<${CATEGORY}/${PN}-5" ; then
+ local bc current
+ bc="${ED}/usr/bin/binutils-config"
+ if current=$("${bc}" -c) ; then
+ "${bc}" "${current}"
+ fi
+ fi
+}
+
+pkg_postinst() {
+ # refresh all links and the wrapper
+ if [[ ${ROOT%/} == "" ]] ; then
+ [[ -f ${EROOT}/etc/env.d/binutils/config-${CHOST} ]] \
+ && binutils-config $(binutils-config --get-current-profile)
+ fi
+}
diff --git a/sys-devel/binutils-config/files/binutils-config-5 b/sys-devel/binutils-config/files/binutils-config-5
new file mode 100755
index 0000000..3052a85
--- /dev/null
+++ b/sys-devel/binutils-config/files/binutils-config-5
@@ -0,0 +1,494 @@
+#!/bin/bash
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# Format of /etc/env.d/binutils/:
+# config-TARGET: CURRENT=version for TARGET
+# TARGET-VER: has a TARGET and VER variable
+
+: ${EPREFIX:="@GENTOO_PORTAGE_EPREFIX@"}
+[[ ${EPREFIX} = */ ]] && EPREFIX="${EPREFIX%/}"
+[[ -n ${EPREFIX} && ${EPREFIX} != /* ]] && EPREFIX="${PWD%/}/${EPREFIX}"
+
+: ${ROOT:=/}
+[[ ${ROOT} != */ ]] && ROOT="${ROOT}/"
+[[ ${ROOT} != /* ]] && ROOT="${PWD%/}/${ROOT}"
+
+EROOT="${ROOT%/}${EPREFIX}/"
+
+cd "${EPREFIX}/"
+
+trap ":" INT QUIT TSTP
+
+argv0=${0##*/}
+FUNCTIONS_SH="@GENTOO_PORTAGE_EPREFIX@/lib/gentoo/functions.sh"
+source ${FUNCTIONS_SH} || {
+ echo "${argv0}: Could not source ${FUNCTIONS_SH}!" 1>&2
+ exit 1
+}
+esyslog() { :; }
+die() { eerror "${argv0}: $*"; exit 1; }
+umask 022
+
+usage() {
+cat << USAGE_END
+Usage: ${HILITE}binutils-config${NORMAL} ${GOOD}[options]${NORMAL} ${BRACKET}[binutils profile]${NORMAL}
+
+${HILITE}General Options:${NORMAL}
+ ${GOOD}-c, --get-current-profile${NORMAL} Print current profile
+ ${GOOD}-l, --list-profiles${NORMAL} Print a list of available profiles
+ ${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}
+
+For more info, please see ${HILITE}binutils-config${NORMAL}(8).
+USAGE_END
+
+ exit ${1:-1}
+}
+
+mv_if_diff() {
+ if cmp -s "$1" "$2" ; then
+ rm -f "$1"
+ else
+ mv -f "$1" "$2"
+ fi
+}
+atomic_ln() {
+ local target=$1 linkdir=$2 linkname=$3 linktmp linkfull
+ linktmp="${linkdir}/.binutils-config.tmp.${linkname}"
+ linkfull="${linkdir}/${linkname}"
+ if [[ -d ${linkfull} ]] ; then
+ # if linking to a dir, we need a little magic to
+ # make it atomic since `mv -T` is not portable
+ rm -rf "${linktmp}"
+ mkdir -p "${linktmp}"
+ ln -sf "${target}" "${linktmp}/${linkname}"
+ mv "${linktmp}/${linkname}" "${linktmp}/../"
+ rmdir "${linktmp}"
+ else
+ # `ln` will expand into unlink();symlink(); which
+ # is not atomic for a small amount of time, but
+ # `mv` is a single rename() call
+ ln -sf "${target}" "${linktmp}"
+ mv "${linktmp}" "${linkfull}"
+ fi
+}
+
+setup_env() {
+ unset TARGET VER LIBPATH
+ source "${ENV_D}/${PROFILE}"
+ if [[ -z ${TARGET} ]] ; then
+ eerror "${PROFILE} is invalid (no \$TARGET defined) :("
+ return 1
+ fi
+ if [[ -z ${VER} ]] ; then
+ eerror "${PROFILE} is invalid (no \$VER defined) :("
+ return 1
+ fi
+
+ #
+ # Generate binary symlinks
+ #
+ BINPATH=""
+ BINPATH_LINKS=""
+ if [[ ${TARGET} != ${HOST} ]] ; then
+ #
+ # Newer paths: /usr/${HOST}/${TARGET}/...
+ # Older paths: /usr/${TARGET}/...
+ #
+ if [[ -d ${ROOT}${EPREFIX}/usr/${HOST}/${TARGET}/binutils-bin/${VER} ]] ; then
+ BINPATH="${EPREFIX}"/usr/${HOST}/${TARGET}/binutils-bin/${VER}
+ BINPATH_LINKS="${EPREFIX}"/usr/libexec/gcc/${TARGET}
+ fi
+ fi
+ if [[ -z ${BINPATH} ]] ; then
+ BINPATH="${EPREFIX}"/usr/${TARGET}/binutils-bin/${VER}
+ BINPATH_LINKS="${EPREFIX}"/usr/${TARGET}/bin
+ fi
+}
+
+# Lists of headers that various versions have installed.
+HEADERS=(
+ ansidecl.h bfd.h bfdlink.h demangle.h dis-asm.h dyn-string.h
+ fibheap.h hashtab.h libiberty.h objalloc.h plugin-api.h
+ splay-tree.h symcat.h
+)
+
+switch_profile() {
+ local x
+
+ ebegin "Switching to ${PROFILE}"
+
+ setup_env || return 1
+
+ cd "${ROOT}/${BINPATH}" || exit 1
+ mkdir -p "${ROOT}/${BINPATH_LINKS}" "${EROOT}/usr/bin"
+ for x in * ; do
+ atomic_ln "${BINPATH}/${x}" "${ROOT}/${BINPATH_LINKS}" "${x}"
+ atomic_ln "${BINPATH_LINKS}/${x}" "${EROOT}/usr/bin" "${TARGET}-${x}"
+ if [[ ${TARGET} == ${HOST} ]] ; then
+ atomic_ln "${TARGET}-${x}" "${EROOT}/usr/bin" "${x}"
+ fi
+ done
+
+ #
+ # Generate library / ldscripts symlinks
+ #
+ : ${LIBPATH:=${EPREFIX}/usr/lib/binutils/${TARGET}/${VER}}
+ cd "${ROOT}/${LIBPATH}" || exit 1
+ if [[ ${TARGET} == ${HOST} ]] ; then
+ dstlib=${EROOT}/usr/${HOST}/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.
+ mkdir -p "${dstlib}"
+ rm -rf "${ROOT}/${BINPATH_LINKS}"/ldscripts
+ atomic_ln "${LIBPATH}/ldscripts" "${dstlib}" "ldscripts"
+ 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
+ #
+ INCPATH=${LIBPATH}/include
+ if [[ -d ${ROOT}/${INCPATH} ]] ; then
+ cd "${ROOT}/${INCPATH}" || exit 1
+ if [[ ${HOST} == ${TARGET} ]] ; then
+ # The binutils-lib package handles these files now.
+ for x in libiberty "${HEADERS[@]}" ; do
+ x="${EROOT}/usr/include/${x}"
+ if [[ -L ${x} ]] ; then
+ rm "${x}"
+ fi
+ done
+ else
+ # Clean out old path -- cannot use '-exec {} +' syntax here
+ find . -type f -exec rm -f "${EROOT}/usr/${TARGET}/usr/include/{}" \;
+ rmdir "${EROOT}/usr/${TARGET}/usr/include" >& /dev/null
+ rmdir "${EROOT}/usr/${TARGET}/usr" >& /dev/null
+ rmdir "${EROOT}/usr/${TARGET}" >& /dev/null
+ fi
+ fi
+
+ #
+ # Make sure proper paths get updated
+ #
+ local env_update_flag="--no-ldconfig"
+ if [[ ${TARGET} == ${HOST} ]] ; then
+ # Delete old config now that binutils-libs installs these files.
+ # Note: This skips ldconfig update if env.d had LDPATH, but meh.
+ # Most people have upgraded to ld.so.conf.d, and someone else will
+ # eventually re-run ldconfig for us.
+ x="${EROOT}"/etc/ld.so.conf.d/05binutils.conf
+ if [[ -e ${x} ]]; then
+ rm -f "${x}"
+ env_update_flag=""
+ fi
+
+ DATAPATH="${EPREFIX}"/usr/share/binutils-data/${TARGET}/${VER}
+ local e="${EROOT}"/etc/env.d/05binutils
+ local ee="${e}.tmp"
+ rm -f "${ee}"
+ [[ -d ${ROOT}/${DATAPATH}/man ]] && echo "MANPATH=${DATAPATH}/man" >> "${ee}"
+ [[ -d ${ROOT}/${DATAPATH}/info ]] && echo "INFOPATH=${DATAPATH}/info" >> "${ee}"
+ mv_if_diff "${ee}" "${e}"
+ fi
+
+ local c="${ENV_D}/config-${TARGET}"
+ local cc="${c}.tmp"
+ echo "CURRENT=${VER}" > "${cc}"
+ mv_if_diff "${cc}" "${c}"
+
+ eend 0
+
+ #
+ # Regen env.d if need/can be
+ #
+ if [[ ${ROOT} == "/" ]] && [[ ${TARGET} == ${HOST} ]] ; then
+ env-update ${env_update_flag}
+ echo
+ ewarn "Please remember to run:"
+ echo
+ ewarn " # . ${EPREFIX}/etc/profile"
+ echo
+ fi
+
+ return 0
+}
+
+uninstall_target() {
+ : ${TARGET:=${UARG}}
+
+ if [[ ${TARGET} == ${HOST} ]] ; then
+ die "refusing to uninstall native binutils"
+ fi
+
+ shopt -s nullglob
+ PROFILE=""
+
+ for PROFILE in "${ENV_D}"/${TARGET}-* ; do
+ ewarn "Removing all signs of ${PROFILE##*/}"
+ rm -f "${ENV_D}"/${PROFILE}
+ done
+ if [[ -z ${PROFILE} ]] && [[ ! -e ${ENV_D}/config-${TARGET} ]] ; then
+ die "no profiles exist for '${TARGET}'"
+ fi
+
+ rm -f "${ENV_D}"/config-${TARGET}
+
+ local x
+ for x in \
+ addr2line ar as c++filt dwp elf2flt elfedit flthdr gprof \
+ ld ld.{bfd,gold,real} \
+ nm objcopy objdump ranlib readelf size strings strip
+ do
+ x=(
+ "${EROOT}"/usr/bin/${TARGET}-${x}
+ "${EROOT}"/usr/{${HOST}/,}${TARGET}/bin/${x}
+ "${EROOT}"/usr/libexec/gcc/${TARGET}/${x}
+ )
+ rm -f "${x[@]}"
+ done
+ for x in "${HEADERS[@]}" ; do
+ rm -f "${EROOT}"/usr/{${HOST}/,}${TARGET}/{usr/,}include/${x}
+ done
+ for x in bfd iberty opcodes ; do
+ rm -f "${EROOT}"/usr/${HOST}/${TARGET}/lib/lib${x}{{-*,}.so,.a,.la}
+ done
+ # Delete broken symlinks
+ local destdir="${EROOT}/usr/${HOST}/${TARGET}"
+ rm -f "${destdir}"/lib/ldscripts
+ find -L "${destdir}"/lib -type l -exec rm {} +
+ rmdir \
+ "${destdir}"/{bin,include,lib,usr} \
+ "${destdir}" \
+ "${EROOT}"/var/db/pkg/cross-${TARGET} \
+ "${EROOT}"/usr/{${HOST}/,}${TARGET}/bin \
+ "${EROOT}"/usr/libexec/gcc/${TARGET} \
+ 2>/dev/null
+
+ rm -f "${ENV_D}"/${TARGET}-*
+}
+
+set_current_profile() {
+ if [[ ! -f ${ENV_D}/config-${TARGET} ]] ; then
+ eerror "${argv0}: unable to locate a profile for target: ${TARGET}"
+ return 1
+ fi
+
+ source "${ENV_D}/config-${TARGET}"
+
+ if [[ -z ${CURRENT} ]] ; then
+ eerror "${argv0}: no binutils profile is active!"
+ return 1
+ fi
+
+ echo "${TARGET}-${CURRENT}"
+
+ return 0
+}
+get_current_profile() { echo "${PROFILE}" ; }
+
+list_profiles() {
+ local x i target
+
+ if [[ ${ROOT} != / ]] ; then
+ echo "Using binutils-config info in ${ROOT}"
+ fi
+
+ set -- "${ENV_D}"/*
+ target=
+ i=1
+
+ for x ; do
+ # skip broken links and config files
+ [[ -f ${x} ]] || continue
+ [[ ${x} == */config-* ]] && continue
+
+ source "${x}"
+ if [[ ${target} != ${TARGET} ]] ; then
+ [[ -n ${target} ]] && echo
+ target=${TARGET}
+ fi
+
+ x=${x##*/}
+ if [[ -e ${ENV_D}/config-${TARGET} ]] ; then
+ source "${ENV_D}/config-${TARGET}"
+ if [[ ${VER} == ${CURRENT} ]] ; then
+ [[ ${TARGET} == ${HOST} ]] \
+ && x="${x} ${GOOD}*${NORMAL}" \
+ || x="${x} ${HILITE}*${NORMAL}"
+ fi
+ fi
+
+ # We would align the [...] field like so:
+ #printf ' [%*ss] %s\n' ${##} "${i}" "${x}"
+ # but this breaks simple scripting: `binutils -l | awk '{print $2}'`
+
+ # Or we could align the target col like so:
+ #printf ' [%s]%*s %s\n' "${i}" $(( ${##} - ${#i} )) "" "${x}"
+ # but i'm not sold that it looks better
+
+ # So keep it simple ... only makes a diff anyways for crazy people
+ # like me which have 100+ binutils packages installed ...
+ echo " [$i] ${x}"
+ ((++i))
+ 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)}}
+}
+
+ENV_D="${EROOT}etc/env.d/binutils"
+
+DEBUG="no"
+NEED_ACTION="yes"
+DOIT="switch_profile"
+PROFILE="current"
+HOST=""
+TARGET=""
+unset UARG
+
+select_action() {
+ if [[ ${NEED_ACTION} != "no" ]] ; then
+ NEED_ACTION="no"
+ DOIT=$1
+ else
+ die "one action at a time!"
+ fi
+}
+
+while [[ $# -gt 0 ]] ; do
+ x=$1
+ shift
+ case ${x} in
+ -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)
+ unset Header
+ cvsver="$Id$"
+ cvsver=${cvsver##*binutils-config-}
+ bver=${cvsver%%,v *}
+ cvsver=${cvsver#* }
+ echo "binutils-config-${bver} (r${cvsver%% *})"
+ exit 0
+ ;;
+ -*)
+ die "invalid switch! Try '--help'."
+ ;;
+ *)
+ if [[ ${UARG+set} == "set" ]] ; then
+ die "only one profile/target at a time please"
+ fi
+ NEED_ACTION="maybe"
+ UARG=${x}
+ ;;
+ esac
+done
+
+[[ ${NEED_ACTION} == "yes" ]] && usage 1
+[[ ${DEBUG} == "yes" ]] && set -x
+
+# All operations need to know the current HOST to figure out
+# what is a native target and what is a cross target
+set_HOST
+
+# All operations need to know the profile the user wants
+case ${DOIT} in
+switch_profile|switch_linker_*)
+ # decode user's profile choice
+ x=${UARG:-$(TARGET=${HOST} set_current_profile)}
+ PROFILE=""
+ if [[ -z $(echo ${x} | tr -d '[:digit:]') ]] ; then
+ # User gave us a # representing the profile
+ i=1
+ for y in "${ENV_D}"/* ; do
+ [[ ${y/config-} != ${y} ]] && continue
+
+ if [[ -f ${y} ]] && [[ ${x} -eq ${i} ]] ; then
+ PROFILE=${y##*/}
+ break
+ fi
+ ((++i))
+ done
+ fi
+
+ if [[ -z ${PROFILE} ]] ; then
+ # User gave us a full HOST-ver
+ x=${x##*/}
+ if [[ -f ${ENV_D}/${x} ]] ; then
+ # Valid HOST-ver yeah!
+ PROFILE=${x}
+ else
+ # Not a valid HOST-ver ...
+ if [[ ! -f ${ENV_D}/config-${x} ]] ; then
+ # Maybe they just gave us a ver ...
+ if [[ -f ${ENV_D}/${HOST}-${x} ]] ; then
+ x=${HOST}-${x}
+ else
+ die "could not locate '$x' in '${ENV_D}/'!"
+ fi
+ PROFILE=${x}
+ else
+ # Maybe they just gave us a target ... pick active profile
+ PROFILE=$(TARGET=${x} set_current_profile)
+ fi
+ fi
+ fi
+ ;;
+*)
+ # lookup current profile as the user gave us a target
+ PROFILE=$(TARGET=${UARG:-${HOST}} set_current_profile) || exit 1
+ ;;
+esac
+
+eval ${DOIT}
+
+# vim:ts=4
diff --git a/sys-devel/binutils-config/files/binutils.eselect b/sys-devel/binutils-config/files/binutils.eselect
new file mode 100644
index 0000000..a89655a
--- /dev/null
+++ b/sys-devel/binutils-config/files/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="toolchain@gentoo.org"
+
+### 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
+}
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/, sys-devel/binutils-config/files/
@ 2017-11-25 18:33 Fabian Groffen
0 siblings, 0 replies; 10+ messages in thread
From: Fabian Groffen @ 2017-11-25 18:33 UTC (permalink / raw
To: gentoo-commits
commit: 508ee40a45b3f911bfcbf335236906eb032ab13a
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 25 17:26:58 2017 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Nov 25 17:26:58 2017 +0000
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=508ee40a
sys-devel/binutils-config: don't add runpaths for builddir searchpaths
Package-Manager: Portage-2.3.13-prefix, Repoman-2.3.4
sys-devel/binutils-config/binutils-config-5-r02.1.ebuild | 1 -
sys-devel/binutils-config/files/ldwrapper.c | 11 +++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/sys-devel/binutils-config/binutils-config-5-r02.1.ebuild b/sys-devel/binutils-config/binutils-config-5-r02.1.ebuild
index 3c1bc7e44d..07c6b494dc 100644
--- a/sys-devel/binutils-config/binutils-config-5-r02.1.ebuild
+++ b/sys-devel/binutils-config/binutils-config-5-r02.1.ebuild
@@ -1,6 +1,5 @@
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Id$
EAPI=5
diff --git a/sys-devel/binutils-config/files/ldwrapper.c b/sys-devel/binutils-config/files/ldwrapper.c
index fda6e9b603..84431fb3ac 100644
--- a/sys-devel/binutils-config/files/ldwrapper.c
+++ b/sys-devel/binutils-config/files/ldwrapper.c
@@ -149,6 +149,8 @@ main(int argc, char *argv[])
char **newargv = NULL;
char *wrapper = argc > 0 ? argv[0] : "ld-wrapper";
char verbose = getenv("BINUTILS_CONFIG_VERBOSE") != NULL;
+ char *builddir = getenv("PORTAGE_BUILDDIR");
+ size_t builddirlen;
char *p;
int i;
int j;
@@ -161,6 +163,11 @@ main(int argc, char *argv[])
if (strncmp(wrapper, p, strlen(p)) == 0)
wrapper += strlen(p);
+ /* ensure builddir is something useful */
+ if (builddir != NULL && *builddir != '/')
+ builddir = NULL;
+ builddirlen = builddir == NULL ? 0 : strlen(builddir);
+
/* walk over the arguments to see if there's anything interesting
* for us and calculate the final number of arguments */
for (i = 1; i < argc; i++) {
@@ -254,6 +261,10 @@ main(int argc, char *argv[])
if (*path != '/')
continue;
+ /* does it refer to the build directory? skip */
+ if (builddir != NULL && strncmp(builddir, path, builddirlen) != 0)
+ continue;
+
len = 2 + strlen(path) + 1;
newargv[k] = malloc(sizeof(char) * len);
if (newargv[k] == NULL) {
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/, sys-devel/binutils-config/files/
@ 2017-11-25 18:33 Fabian Groffen
0 siblings, 0 replies; 10+ messages in thread
From: Fabian Groffen @ 2017-11-25 18:33 UTC (permalink / raw
To: gentoo-commits
commit: a4196f18f658bc8e244b906344e0fdcdb5160277
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 25 18:33:29 2017 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Nov 25 18:33:29 2017 +0000
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=a4196f18
sys-devel/binutils-config: sync
Package-Manager: Portage-2.3.13-prefix, Repoman-2.3.4
...-5-r02.1.ebuild => binutils-config-5-r3.ebuild} | 17 ++++-----
sys-devel/binutils-config/files/binutils-config-5 | 41 +++++++++-------------
sys-devel/binutils-config/files/binutils-config.8 | 14 +++-----
sys-devel/binutils-config/files/ldwrapper.c | 6 ++--
4 files changed, 31 insertions(+), 47 deletions(-)
diff --git a/sys-devel/binutils-config/binutils-config-5-r02.1.ebuild b/sys-devel/binutils-config/binutils-config-5-r3.ebuild
similarity index 87%
rename from sys-devel/binutils-config/binutils-config-5-r02.1.ebuild
rename to sys-devel/binutils-config/binutils-config-5-r3.ebuild
index 07c6b494dc..5d03556928 100644
--- a/sys-devel/binutils-config/binutils-config-5-r02.1.ebuild
+++ b/sys-devel/binutils-config/binutils-config-5-r3.ebuild
@@ -1,16 +1,18 @@
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-EAPI=5
+EAPI="5"
inherit eutils prefix
DESCRIPTION="Utility to change the binutils version being used"
HOMEPAGE="https://www.gentoo.org/"
+SRC_URI=""
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~ppc-aix ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE=""
# We also RDEPEND on sys-apps/findutils which is in base @system
RDEPEND="sys-apps/gentoo-functions
@@ -43,6 +45,7 @@ src_compile() {
-DEPREFIX=\"${EPREFIX}\"
-DCHOST=\"${CHOST}\"
$([[ ${CHOST} == *-darwin* ]] && echo -DTARGET_DARWIN)
+ $([[ ${CHOST} == *-aix* ]] && echo -DTARGET_AIX)
${LDFLAGS}
)
echo ${args[*]}
@@ -50,7 +53,9 @@ src_compile() {
}
src_install() {
- newbin "${S}"/${PN} ${PN}
+ newbin "${FILESDIR}"/${PN}-${PV} ${PN}
+ use prefix && eprefixify "${ED}"/usr/bin/${PN}
+ sed -i "s:@PV@:${PVR}:g" "${ED}"/usr/bin/${PN} || die
doman "${FILESDIR}"/${PN}.8
dodir /usr/$(get_libdir)/misc/binutils-config
@@ -71,11 +76,3 @@ pkg_preinst() {
fi
fi
}
-
-pkg_postinst() {
- # refresh all links and the wrapper
- if [[ ${ROOT%/} == "" ]] ; then
- [[ -f ${EROOT}/etc/env.d/binutils/config-${CHOST} ]] \
- && binutils-config $(binutils-config --get-current-profile)
- fi
-}
diff --git a/sys-devel/binutils-config/files/binutils-config-5 b/sys-devel/binutils-config/files/binutils-config-5
index 3052a8593d..e6c5fac002 100755
--- a/sys-devel/binutils-config/files/binutils-config-5
+++ b/sys-devel/binutils-config/files/binutils-config-5
@@ -1,15 +1,15 @@
#!/bin/bash
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Id$
# Format of /etc/env.d/binutils/:
# config-TARGET: CURRENT=version for TARGET
# TARGET-VER: has a TARGET and VER variable
-: ${EPREFIX:="@GENTOO_PORTAGE_EPREFIX@"}
-[[ ${EPREFIX} = */ ]] && EPREFIX="${EPREFIX%/}"
-[[ -n ${EPREFIX} && ${EPREFIX} != /* ]] && EPREFIX="${PWD%/}/${EPREFIX}"
+EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
+if [[ ${EPREFIX} == "@"GENTOO_PORTAGE_EPREFIX"@" ]] ; then
+ EPREFIX=""
+fi
: ${ROOT:=/}
[[ ${ROOT} != */ ]] && ROOT="${ROOT}/"
@@ -22,7 +22,7 @@ cd "${EPREFIX}/"
trap ":" INT QUIT TSTP
argv0=${0##*/}
-FUNCTIONS_SH="@GENTOO_PORTAGE_EPREFIX@/lib/gentoo/functions.sh"
+FUNCTIONS_SH="${EPREFIX}/lib/gentoo/functions.sh"
source ${FUNCTIONS_SH} || {
echo "${argv0}: Could not source ${FUNCTIONS_SH}!" 1>&2
exit 1
@@ -103,7 +103,7 @@ setup_env() {
# Newer paths: /usr/${HOST}/${TARGET}/...
# Older paths: /usr/${TARGET}/...
#
- if [[ -d ${ROOT}${EPREFIX}/usr/${HOST}/${TARGET}/binutils-bin/${VER} ]] ; then
+ if [[ -d "${EROOT}"/usr/${HOST}/${TARGET}/binutils-bin/${VER} ]] ; then
BINPATH="${EPREFIX}"/usr/${HOST}/${TARGET}/binutils-bin/${VER}
BINPATH_LINKS="${EPREFIX}"/usr/libexec/gcc/${TARGET}
fi
@@ -145,26 +145,21 @@ 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.
+ # TODO: Stop requiring even the ldscripts symlink, except
+ # we can't for bare-metal toolchains, so... bug #147155
mkdir -p "${dstlib}"
rm -rf "${ROOT}/${BINPATH_LINKS}"/ldscripts
atomic_ln "${LIBPATH}/ldscripts" "${dstlib}" "ldscripts"
- 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
+ find -L "${dstlib}" -xtype l -name 'lib*' -exec rm -f {} +
#
# Clean out old generated include symlinks
@@ -257,7 +252,7 @@ uninstall_target() {
local x
for x in \
- addr2line ar as c++filt dwp elf2flt elfedit flthdr gprof \
+ addr2line ar as c++filt elf2flt elfedit flthdr gprof \
ld ld.{bfd,gold,real} \
nm objcopy objdump ranlib readelf size strings strip
do
@@ -412,12 +407,8 @@ while [[ $# -gt 0 ]] ; do
-d|--debug) DEBUG="yes" ;;
-h|--help) usage 0 ;;
-V|--version)
- unset Header
- cvsver="$Id$"
- cvsver=${cvsver##*binutils-config-}
- bver=${cvsver%%,v *}
- cvsver=${cvsver#* }
- echo "binutils-config-${bver} (r${cvsver%% *})"
+ ver="@PV@"
+ echo "binutils-config-${ver/@'PV'@/git}"
exit 0
;;
-*)
diff --git a/sys-devel/binutils-config/files/binutils-config.8 b/sys-devel/binutils-config/files/binutils-config.8
index 0d8adb5a70..52cf7101e6 100644
--- a/sys-devel/binutils-config/files/binutils-config.8
+++ b/sys-devel/binutils-config/files/binutils-config.8
@@ -48,16 +48,12 @@ This is really for internal use only. Used to remove all traces of the
\fITARGET\fR binutils from your system.
.SH "CRUFTY OPTIONS"
.TP
-\fB\-\-gold\fR
-Change the default linker for the specified \fIPROFILE\fR to the [newer] gold
-linker. This only works if the binutils actually supports gold. Note that
-not all options supported by the bfd linker are supportd by the gold linker.
-.TP
-\fB\-\-bfd\fR
-Change the default linker for the specified \fIPROFILE\fR to the [older but
-stable] bfd linker. If unsure, stick to this one.
+\fB\-\-linker\fR \fB<linker>\fR
+Change the default linker for the specified \fIPROFILE\fR to the \fB<linker>\fR.
+Common names are \fBld.gold\fR for the newer gold linker and \fBld.bfd\fR for
+the classic linker. Note that not all targets support the gold linker.
.SH "REPORTING BUGS"
-Please report bugs via http://bugs.gentoo.org/
+Please report bugs via https://bugs.gentoo.org/
.SH "SEE ALSO"
.BR ar (1),
.BR as (1),
diff --git a/sys-devel/binutils-config/files/ldwrapper.c b/sys-devel/binutils-config/files/ldwrapper.c
index 84431fb3ac..88f93a8602 100644
--- a/sys-devel/binutils-config/files/ldwrapper.c
+++ b/sys-devel/binutils-config/files/ldwrapper.c
@@ -189,7 +189,7 @@ main(int argc, char *argv[])
/* add the 4 paths we want (-L + -R) and a null-terminator */
newargc += 8 + 1;
#endif
-#ifdef _AIX
+#ifdef TARGET_AIX
/* AIX ld accepts -R only with -bsvr4 */
newargc++; /* -bsvr4 */
#endif
@@ -222,7 +222,7 @@ main(int argc, char *argv[])
/* position k right after the original arguments */
k = j - 1 + argc;
for (i = 1; i < argc; i++, j++) {
-#ifdef _AIX
+#ifdef TARGET_AIX
/* AIX ld has this problem:
* $ /usr/ccs/bin/ld -bsvr4 -bE:xx.exp -bnoentry xx.o
* ld: 0706-005 Cannot find or open file: l
@@ -291,7 +291,7 @@ main(int argc, char *argv[])
newargv[k++] = "-L" EPREFIX "/lib";
newargv[k++] = "-R" EPREFIX "/lib";
#endif
-#ifdef _AIX
+#ifdef TARGET_AIX
newargv[k++] = "-bsvr4"; /* last one, see above */
#endif
newargv[k] = NULL;
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/, sys-devel/binutils-config/files/
@ 2017-12-25 19:47 Fabian Groffen
0 siblings, 0 replies; 10+ messages in thread
From: Fabian Groffen @ 2017-12-25 19:47 UTC (permalink / raw
To: gentoo-commits
commit: 548521db9b370ac42d6497a4bdcc9fe73ce25019
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 25 19:47:01 2017 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Dec 25 19:47:01 2017 +0000
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=548521db
sys-devel/binutils-config: rework cross-support
This is on top of previous commit which is Michael Weiser's work from
bug #583202. This rework avoids some mallocs, and tries to optimise the
path needed for a run.
Closes: https://bugs.gentoo.org/583202
Package-Manager: Portage-2.3.18-prefix, Repoman-2.3.6
sys-devel/binutils-config/Manifest | 1 +
.../binutils-config/binutils-config-5-r03.1.ebuild | 8 +-
...r03.1.ebuild => binutils-config-5-r03.2.ebuild} | 6 +-
sys-devel/binutils-config/files/ldwrapper.c | 334 +++++++++------------
4 files changed, 156 insertions(+), 193 deletions(-)
diff --git a/sys-devel/binutils-config/Manifest b/sys-devel/binutils-config/Manifest
new file mode 100644
index 0000000000..03c89e40d2
--- /dev/null
+++ b/sys-devel/binutils-config/Manifest
@@ -0,0 +1 @@
+DIST binutils-config-ldwrapper-5.3.1.c 8342 BLAKE2B 18658a8188acfcd7494981bd60f53590f5610c7ffd9173f223da740c09acd9ed40aaf911faa6f9a517e5e8779cbaaea9d4398679b7a3037655a7994d9c319345 SHA512 af21c1b9bb465990e8490641023403ec27e31bd69f94fc86572392285a540ddc25d59fd8f682c0cb2d2a84c5e33fea08bd0ec2cb52861147075ccfd5e18067b0
diff --git a/sys-devel/binutils-config/binutils-config-5-r03.1.ebuild b/sys-devel/binutils-config/binutils-config-5-r03.1.ebuild
index dc74595d72..142a1e62ee 100644
--- a/sys-devel/binutils-config/binutils-config-5-r03.1.ebuild
+++ b/sys-devel/binutils-config/binutils-config-5-r03.1.ebuild
@@ -7,7 +7,9 @@ inherit eutils prefix
DESCRIPTION="Utility to change the binutils version being used"
HOMEPAGE="https://www.gentoo.org/"
-SRC_URI=""
+GIT_REV="d469b099b5e8aed45ff2edf78f91822b805440d3"
+WRAPPER_REV="${PV}.3.1"
+SRC_URI="https://gitweb.gentoo.org/repo/proj/prefix.git/plain/sys-devel/binutils-config/files/ldwrapper.c?id=${GIT_REV} -> ${PN}-ldwrapper-${WRAPPER_REV}.c"
LICENSE="GPL-2"
SLOT="0"
@@ -27,8 +29,6 @@ src_prepare() {
epatch "${FILESDIR}/${PN}-5-ldwrapper.patch"
fi
eprefixify ${PN}
-
- cp "${FILESDIR}"/ldwrapper.c . || die
}
src_configure() {
@@ -41,7 +41,7 @@ src_compile() {
$(tc-getCC)
${CPPFLAGS}
${CFLAGS}
- -o ldwrapper ldwrapper.c
+ -o ldwrapper "${S}"/${PN}-ldwrapper-${WRAPPER_REV}.c
-DEPREFIX=\"${EPREFIX}\"
-DCHOST=\"${CHOST}\"
$([[ ${CHOST} == *-darwin* ]] && echo -DTARGET_DARWIN)
diff --git a/sys-devel/binutils-config/binutils-config-5-r03.1.ebuild b/sys-devel/binutils-config/binutils-config-5-r03.2.ebuild
similarity index 90%
copy from sys-devel/binutils-config/binutils-config-5-r03.1.ebuild
copy to sys-devel/binutils-config/binutils-config-5-r03.2.ebuild
index dc74595d72..942065aee5 100644
--- a/sys-devel/binutils-config/binutils-config-5-r03.1.ebuild
+++ b/sys-devel/binutils-config/binutils-config-5-r03.2.ebuild
@@ -27,8 +27,6 @@ src_prepare() {
epatch "${FILESDIR}/${PN}-5-ldwrapper.patch"
fi
eprefixify ${PN}
-
- cp "${FILESDIR}"/ldwrapper.c . || die
}
src_configure() {
@@ -41,11 +39,9 @@ src_compile() {
$(tc-getCC)
${CPPFLAGS}
${CFLAGS}
- -o ldwrapper ldwrapper.c
+ -o ldwrapper "${FILESDIR}"/ldwrapper.c
-DEPREFIX=\"${EPREFIX}\"
-DCHOST=\"${CHOST}\"
- $([[ ${CHOST} == *-darwin* ]] && echo -DTARGET_DARWIN)
- $([[ ${CHOST} == *-aix* ]] && echo -DTARGET_AIX)
${LDFLAGS}
)
echo ${args[*]}
diff --git a/sys-devel/binutils-config/files/ldwrapper.c b/sys-devel/binutils-config/files/ldwrapper.c
index 81b78adf20..bf9f00728b 100644
--- a/sys-devel/binutils-config/files/ldwrapper.c
+++ b/sys-devel/binutils-config/files/ldwrapper.c
@@ -12,9 +12,9 @@
#include <string.h>
#include <ctype.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <errno.h>
-#include <glob.h>
-#include <stdarg.h>
+#include <dirent.h>
/**
* ldwrapper: Prefix helper to inject -L and -R flags to the invocation
@@ -40,89 +40,65 @@
# error CHOST must be defined!
#endif
-static inline int is_cross(const char *ctarget) {
- return strcmp(ctarget, CHOST);
-}
-
-static inline int is_darwin(const char *ctarget) {
- return (strstr(ctarget, "-darwin") != NULL);
-}
-
-static inline int is_aix(const char *ctarget) {
- return (strstr(ctarget, "-aix") != NULL);
-}
+#define ESIZ 1024 /* POSIX_MAX_PATH */
-static inline char *
-find_real_ld(const char verbose, const char *wrapper, const char *ctarget)
+static inline char
+find_real_ld(char **ld, size_t ldlen, const char verbose, const char is_cross,
+ const char *wrapper, const char *ctarget)
{
FILE *f = NULL;
- char *ldoveride;
+ char *ldoverride;
char *path;
-#define ESIZ 1024 /* POSIX_MAX_PATH */
char *ret;
struct stat lde;
- char *config;
- const char *config_prefix;
- size_t configlen;
+ char config[ESIZ];
+ size_t len;
/* respect the override in environment */
- ldoveride = getenv("BINUTILS_CONFIG_LD");
- if (ldoveride != NULL && *ldoveride != '\0') {
+ ldoverride = getenv("BINUTILS_CONFIG_LD");
+ if (ldoverride != NULL && *ldoverride != '\0') {
if (verbose)
fprintf(stdout, "%s: using BINUTILS_CONFIG_LD=%s "
- "from environment\n", wrapper, ldoveride);
- return ldoveride;
+ "from environment\n", wrapper, ldoverride);
+ snprintf(*ld, ldlen, "%s", ldoverride);
+ return 0;
}
if (verbose)
fprintf(stdout, "%s: BINUTILS_CONFIG_LD not found in environment\n",
wrapper);
- ret = malloc(sizeof(char) * ESIZ);
- if (ret == NULL) {
- fprintf(stderr, "%s: out of memory allocating string for path to ld\n",
- wrapper);
- exit(1);
- }
-
- /* find ld in PATH, allowing easy PATH overrides. strdup it because
- * modifying it would otherwise corrupt the actual PATH environment
- * variable which we might need to be intact later on to call
- * binutils-config via popen. */
- path = strdup(getenv("PATH"));
+ /* Find ld in PATH, allowing easy PATH overrides.
+ * Remember NOT to modify the from getenv returned string, as we need
+ * an untampered PATH for popen calls later. */
+ path = getenv("PATH");
if (path != NULL && *path != '\0') {
char *p;
char *q;
- char *match;
- const char *match_anchor = "/binutils-bin/";
- size_t matchlen = 1 + strlen(ctarget) +
- strlen(match_anchor) + 1;
-
- match = malloc(sizeof(char) * matchlen);
- if (match == NULL) {
- fprintf(stderr, "%s: out of memory allocating "
- "buffer for path matching\n",
- wrapper);
- exit(1);
+ char match[ESIZ];
+
+ /* construct /CTARGET/binutils-bin/ for matching against PATH */
+ snprintf(match, sizeof(match), "/%s/binutils-bin/", ctarget);
+
+ for (; (p = strstr(path, match)) != NULL; path = q) {
+ q = p;
+ /* find start of PATH component */
+ for (; p >= path && *p != ':'; p--)
+ ;
+ p++;
+ /* now see to the end */
+ for (q += strlen(match); *q != '\0' && *q != ':'; q++)
+ ;
+ if (*q == ':')
+ q--;
+
+ /* glue it together */
+ snprintf(*ld, ldlen, "%.*s/%s", (int)(q - p), p, wrapper);
+ if (verbose)
+ fprintf(stdout, "%s: trying from PATH: %s\n",
+ wrapper, *ld);
+ if (stat(*ld, &lde) == 0)
+ return 0;
}
-
- /* construct /CTARGET/binutils-bin/ for matchin against PATH */
- snprintf(match, matchlen, "/%s%s", ctarget, match_anchor);
-
- for (p = path; (q = strchr(p, ':')) != NULL; p = q + 1) {
- if (q)
- *q = '\0';
- if (strstr(p, match) != NULL) {
- snprintf(ret, ESIZ, "%s/%s", p, wrapper);
- if (stat(ret, &lde) == 0) {
- free(match);
- return ret;
- }
- }
- if (!q)
- break;
- }
-
- free(match);
}
if (verbose)
fprintf(stdout, "%s: linker not found in PATH\n", wrapper);
@@ -130,125 +106,115 @@ find_real_ld(const char verbose, const char *wrapper, const char *ctarget)
/* parse EPREFIX/etc/env.d/binutils/config-CTARGET to get CURRENT, then
* consider $EPREFIX/usr/CTARGET/binutils-bin/CURRENT where we should
* be able to find ld */
- config_prefix = EPREFIX "/etc/env.d/binutils/config-";
- configlen = strlen(config_prefix) + strlen(ctarget) + 1;
- config = malloc(sizeof(char) * configlen);
- if (config == NULL) {
- fprintf(stderr, "%s: out of memory allocating "
- "buffer for configuration file name\n",
- wrapper);
- exit(1);
- }
-
- snprintf(config, configlen, "%s%s", config_prefix, ctarget);
+ snprintf(config, sizeof(config), EPREFIX "/etc/env.d/binutils/config-%s",
+ ctarget);
if ((f = fopen(config, "r")) != NULL) {
char p[ESIZ];
char *q;
while (fgets(p, ESIZ, f) != NULL) {
- if (strncmp(p, "CURRENT=", strlen("CURRENT=")) != 0)
+ len = strlen("CURRENT=");
+ if (strncmp(p, "CURRENT=", len) != 0)
continue;
q = p + strlen(p);
- /* strip trailing whitespace (fgets at least includes
- * the \n) */
+ /* strip trailing whitespace (fgets at least includes the \n) */
for (q--; isspace(*q); q--)
*q = '\0';
- q = p + strlen("CURRENT=");
- if (is_cross(ctarget)) {
- snprintf(ret, ESIZ, EPREFIX "/usr/" CHOST "/%s/binutils-bin/%s/%s",
+ q = p + len;
+ if (verbose)
+ fprintf(stdout, "%s: %s defines CURRENT=%s\n",
+ wrapper, config, q);
+ if (is_cross) {
+ snprintf(*ld, ldlen,
+ EPREFIX "/usr/" CHOST "/%s/binutils-bin/%s/%s",
ctarget, q, wrapper);
} else {
- snprintf(ret, ESIZ, EPREFIX "/usr/" CHOST "/binutils-bin/%s/%s",
+ snprintf(*ld, ldlen,
+ EPREFIX "/usr/" CHOST "/binutils-bin/%s/%s",
q, wrapper);
}
break;
}
fclose(f);
- if (stat(ret, &lde) == 0) {
- free(config);
- return ret;
- }
+ if (verbose)
+ fprintf(stdout, "%s: trying from %s: %s\n",
+ wrapper, config, *ld);
+ if (stat(*ld, &lde) == 0)
+ return 0;
}
if (verbose)
fprintf(stdout, "%s: linker not found via %s\n", wrapper, config);
- free(config);
-
- /* last try, call binutils-config to tell us what the linker is
- * supposed to be */
- config_prefix = "binutils-config -c ";
- configlen = strlen(config_prefix) + strlen(ctarget) + 1;
- config = malloc(sizeof(char) * configlen);
- if (config == NULL) {
- fprintf(stderr, "%s: out of memory allocating "
- "buffer for binutils-config command\n",
- wrapper);
- exit(1);
- }
- snprintf(config, configlen, "%s%s", config_prefix, ctarget);
+ /* last try, shell out to binutils-config to tell us what the linker
+ * is supposed to be */
+ snprintf(config, sizeof(config), "binutils-config -c %s", ctarget);
if ((f = popen(config, "r")) != NULL) {
char p[ESIZ];
char *q = fgets(p, ESIZ, f);
fclose(f);
if (q != NULL) {
- size_t ctargetlen = strlen(ctarget);
+ len = strlen(ctarget);
/* binutils-config should report CTARGET-<version> */
- if (strncmp(p, ctarget, ctargetlen) == 0 &&
- strlen(p) > ctargetlen &&
- p[ctargetlen] == '-') {
+ if (strncmp(p, ctarget, len) == 0 &&
+ strlen(p) > len && p[len] == '-')
+ {
/* strip trailing whitespace (fgets at least includes
* the \n) */
q = p + strlen(p);
for (q--; isspace(*q); q--)
*q = '\0';
- q = p + ctargetlen + 1;
- if (is_cross(ctarget)) {
- snprintf(ret, ESIZ, EPREFIX "/usr/" CHOST
- "/%s/binutils-bin/%s/%s",
+ q = p + len + 1;
+ if (is_cross) {
+ snprintf(*ld, ldlen,
+ EPREFIX "/usr/" CHOST "/%s/binutils-bin/%s/%s",
ctarget, q, wrapper);
} else {
- snprintf(ret, ESIZ, EPREFIX "/usr/" CHOST
- "/binutils-bin/%s/%s",
+ snprintf(*ld, ldlen,
+ EPREFIX "/usr/" CHOST "/binutils-bin/%s/%s",
q, wrapper);
}
- if (stat(ret, &lde) == 0) {
- free(config);
- return ret;
- }
+ if (verbose)
+ fprintf(stdout, "%s: trying from %s: %s\n",
+ wrapper, config, *ld);
+ if (stat(*ld, &lde) == 0)
+ return 0;
}
}
}
if (verbose)
fprintf(stdout, "%s: linker not found via %s\n",
wrapper, config);
- free(config);
/* we didn't succeed finding the linker */
- return NULL;
+ return 1;
}
int
main(int argc, char *argv[])
{
- char *ld = NULL;
int newargc = 0;
char **newargv = NULL;
- char *wrapper = argc > 0 ? argv[0] : "ld-wrapper";
- char *wrapperdir = NULL;
+ char *wrapper = argv[0];
+ char *wrapperctarget = NULL;
char verbose = getenv("BINUTILS_CONFIG_VERBOSE") != NULL;
char *builddir = getenv("PORTAGE_BUILDDIR");
- size_t builddirlen;
+ char ldbuf[ESIZ];
+ char *ld = ldbuf;
+ char ctarget[128];
+ char is_cross = 0;
+ char is_darwin = 0;
+ char is_aix = 0;
char *p;
+ size_t len;
int i;
int j;
int k;
- glob_t m;
- char *ctarget = CHOST;
- size_t ctargetlen;
+ DIR *dirp;
+ struct dirent *dp;
/* two ways to determine CTARGET from argv[0]:
* 1. called as <CTARGET>-ld (manually)
@@ -258,61 +224,59 @@ main(int argc, char *argv[])
* work when added to PATH (which shouldn't happen in the wild, but
* eh!?). */
if ((p = strrchr(wrapper, '/')) != NULL) {
- /* cannonicanise wrapper step 1: strip path */
- wrapper = p + 1;
+ char *q;
- /* remember directory to see if it's CTARGET but only
- * if parent is /gcc/ */
+ /* see to case 2 first */
*p = '\0';
- if ((p = strrchr(argv[0], '/')) != NULL) {
- char *q;
-
- *p = '\0';
- if ((q = strrchr(argv[0], '/')) != NULL &&
- strncmp(q + 1, "gcc", strlen("gcc")) == 0) {
- wrapperdir = p + 1;
- }
+ if ((q = strrchr(p - 1, '/')) != NULL) {
+ /* q points to "/<CTARGET>" now */
+ len = strlen("/gcc");
+ if (q - len > wrapper && strncmp(q - len, "/gcc", len))
+ wrapperctarget = q + 1;
}
+
+ /* cannonicanise wrapper step 1: strip path */
+ wrapper = p + 1;
}
+ /* default to "ld" when called directly */
+ if (strcmp(wrapper, "ldwrapper") == 0)
+ wrapper = "ld";
+
/* see if we have a known CTARGET prefix */
- i = glob(EPREFIX "/etc/env.d/binutils/config-*", GLOB_NOSORT, NULL, &m);
- if (i == GLOB_NOSPACE) {
- fprintf(stderr, "%s: out of memory when inspecting "
- "binutils configuration\n", wrapper);
- exit(1);
- }
- if (i == 0) {
- for (i = 0; i < m.gl_pathc; i++) {
- p = strrchr(m.gl_pathv[i], '/');
- if (p == NULL || strncmp(p, "/config-", strlen("/config-")) != 0)
+ ctarget[0] = '\0';
+ if ((dirp = opendir(EPREFIX "/etc/env.d/binutils")) != NULL) {
+ while ((dp = readdir(dirp)) != NULL) {
+ len = strlen("config-");
+ if (strncmp(dp->d_name, "config-", len) != 0)
continue;
-
- /* EPREFIX/etc/env.d/binutils/config-arm-something-or-other
- * move here ^ */
- p += strlen("/config-");
- if (strncmp(wrapper, p, strlen(p)) == 0 ||
- (wrapperdir != NULL && strcmp(wrapperdir, p) == 0)) {
- /* this is us! (MEMLEAK) */
- ctarget = strdup(p);
+ p = dp->d_name + len;
+ if (strncmp(p, wrapper, strlen(p)) == 0 ||
+ (wrapperctarget != NULL &&
+ strcmp(p, wrapperctarget) == 0))
+ {
+ /* this is us! */
+ snprintf(ctarget, sizeof(ctarget), "%s", p);
+ is_cross = strcmp(ctarget, CHOST) != 0;
break;
}
}
}
- /* ignore GLOB_NOMATCH and (possibly) GLOB_ABORTED */
- globfree(&m);
-
- /* cannonicanise wrapper step2: strip CTARGET */
- ctargetlen = strlen(ctarget);
- if (strncmp(wrapper, ctarget, ctargetlen) == 0 &&
- wrapper[ctargetlen] == '-') {
- wrapper += ctargetlen + 1;
- }
+ if (ctarget[0] == '\0')
+ snprintf(ctarget, sizeof(ctarget), "%s", CHOST);
+
+ is_darwin = strstr(ctarget, "-darwin") != NULL;
+ is_aix = strstr(ctarget, "-aix") != NULL;
+
+ /* cannonicanise wrapper step2: strip CTARGET from wrapper */
+ len = strlen(ctarget);
+ if (strncmp(wrapper, ctarget, len) == 0 && wrapper[len] == '-')
+ wrapper += len + 1;
/* ensure builddir is something useful */
if (builddir != NULL && *builddir != '/')
builddir = NULL;
- builddirlen = builddir == NULL ? 0 : strlen(builddir);
+ len = builddir == NULL ? 0 : strlen(builddir);
/* walk over the arguments to see if there's anything interesting
* for us and calculate the final number of arguments */
@@ -326,14 +290,15 @@ main(int argc, char *argv[])
}
}
/* account the original arguments */
- newargc += argc > 0 ? argc : 1;
- /* we always add a null-terminator */
- newargc ++;
+ newargc += argc;
+ /* we always add a sentinel */
+ newargc++;
+
/* If a package being cross-compiled injects standard directories, it's
* non-cross-compilable on any platform, prefix or no prefix. So no
* need to add PREFIX- or CTARGET-aware libdirs. */
- if (!is_cross(ctarget)) {
- if (is_darwin(ctarget)) {
+ if (!is_cross) {
+ if (is_darwin) {
/* add the 2 prefix paths (-L) and -search_paths_first */
newargc += 2 + 1;
} else {
@@ -341,15 +306,16 @@ main(int argc, char *argv[])
newargc += 8;
}
- if (is_aix(ctarget)) {
+ if (is_aix) {
/* AIX ld accepts -R only with -bsvr4 */
newargc++; /* -bsvr4 */
}
}
/* let's first try to find the real ld */
- ld = find_real_ld(verbose, wrapper, ctarget);
- if (ld == NULL) {
+ if (find_real_ld(&ld, sizeof(ldbuf), verbose, is_cross,
+ wrapper, ctarget) != 0)
+ {
fprintf(stderr, "%s: failed to locate the real ld!\n", wrapper);
exit(1);
}
@@ -369,7 +335,7 @@ main(int argc, char *argv[])
* own call path derived from its argv[0] */
newargv[j++] = ld;
- if (!is_cross(ctarget) && is_darwin(ctarget)) {
+ if (!is_cross && is_darwin) {
/* inject this first to make the intention clear */
newargv[j++] = "-search_paths_first";
}
@@ -377,7 +343,7 @@ main(int argc, char *argv[])
/* position k right after the original arguments */
k = j - 1 + argc;
for (i = 1; i < argc; i++, j++) {
- if (is_aix(ctarget)) {
+ if (is_aix) {
/* AIX ld has this problem:
* $ /usr/ccs/bin/ld -bsvr4 -bE:xx.exp -bnoentry xx.o
* ld: 0706-005 Cannot find or open file: l
@@ -392,13 +358,13 @@ main(int argc, char *argv[])
newargv[j] = argv[i];
- if (is_cross(ctarget) || is_darwin(ctarget))
+ if (is_cross || is_darwin)
continue;
/* on ELF targets we add runpaths for all found search paths */
if (argv[i][0] == '-' && argv[i][1] == 'L') {
char *path;
- size_t len;
+ size_t sze;
/* arguments can be in many ways here:
* -L<path>
@@ -421,23 +387,23 @@ main(int argc, char *argv[])
continue;
/* does it refer to the build directory? skip */
- if (builddir != NULL && strncmp(builddir, path, builddirlen) != 0)
+ if (builddir != NULL && strncmp(builddir, path, len) != 0)
continue;
- len = 2 + strlen(path) + 1;
- newargv[k] = malloc(sizeof(char) * len);
+ sze = 2 + strlen(path) + 1;
+ newargv[k] = malloc(sizeof(char) * sze);
if (newargv[k] == NULL) {
fprintf(stderr, "%s: failed to allocate memory for "
"'%s' -R argument\n", wrapper, argv[i]);
exit(1);
}
- snprintf(newargv[k], len, "-R%s", path);
+ snprintf(newargv[k], sze, "-R%s", path);
k++;
}
}
/* add the custom paths */
- if (!is_cross(ctarget)) {
- if (is_darwin(ctarget)) {
+ if (!is_cross) {
+ if (is_darwin) {
/* FIXME: no support for cross-compiling *to* Darwin */
newargv[k++] = "-L" EPREFIX "/usr/lib";
newargv[k++] = "-L" EPREFIX "/lib";
@@ -452,7 +418,7 @@ main(int argc, char *argv[])
newargv[k++] = "-R" EPREFIX "/lib";
}
- if (is_aix(ctarget))
+ if (is_aix)
newargv[k++] = "-bsvr4"; /* last one, see above */
}
newargv[k] = NULL;
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/, sys-devel/binutils-config/files/
@ 2019-05-30 9:13 Fabian Groffen
0 siblings, 0 replies; 10+ messages in thread
From: Fabian Groffen @ 2019-05-30 9:13 UTC (permalink / raw
To: gentoo-commits
commit: 82c2c71837628069aeb9484d295d304b3387d91c
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu May 30 09:13:34 2019 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu May 30 09:13:34 2019 +0000
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=82c2c718
sys-devel/binutils-config: sync (remove interrevisions)
Package-Manager: Portage-2.3.62-prefix, Repoman-2.3.13
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
.../binutils-config/binutils-config-5-r03.5.ebuild | 77 ----
...-r03.4.ebuild => binutils-config-5.1-r1.ebuild} | 6 +-
.../binutils-config/files/binutils-config-5.1 | 486 +++++++++++++++++++++
3 files changed, 489 insertions(+), 80 deletions(-)
diff --git a/sys-devel/binutils-config/binutils-config-5-r03.5.ebuild b/sys-devel/binutils-config/binutils-config-5-r03.5.ebuild
deleted file mode 100644
index a00860e6b2..0000000000
--- a/sys-devel/binutils-config/binutils-config-5-r03.5.ebuild
+++ /dev/null
@@ -1,77 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="6"
-
-inherit eutils prefix
-
-DESCRIPTION="Utility to change the binutils version being used"
-HOMEPAGE="https://www.gentoo.org/"
-GIT_REV="edc0d44f70c27daebcc080ac5d08e8e191bccd95"
-WRAPPER_REV="${PV}.3.4"
-SRC_URI="https://gitweb.gentoo.org/repo/proj/prefix.git/plain/sys-devel/binutils-config/files/ldwrapper.c?id=${GIT_REV} -> ${PN}-ldwrapper-${WRAPPER_REV}.c"
-
-LICENSE="GPL-2"
-SLOT="0"
-KEYWORDS="~ppc-aix ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
-IUSE=""
-
-# We also RDEPEND on sys-apps/findutils which is in base @system
-RDEPEND="sys-apps/gentoo-functions
- !<app-admin/eselect-1.4.5"
-
-S=${WORKDIR}
-
-# NOTE: the ld wrapper is only enabled on rpath versions of prefix.
-src_prepare() {
- cp "${FILESDIR}"/${PN}-${PV} ./${PN} || die
- if use prefix-guest; then
- epatch "${FILESDIR}/${PN}-5-ldwrapper.patch"
- fi
- eprefixify ${PN}
- eapply_user
-}
-
-src_configure() {
- :
-}
-
-src_compile() {
- use prefix-guest || return
- local args=(
- $(tc-getCC)
- ${CPPFLAGS}
- ${CFLAGS}
- -o ldwrapper "${DISTDIR}"/${PN}-ldwrapper-${WRAPPER_REV}.c
- -DEPREFIX=\"${EPREFIX}\"
- -DCHOST=\"${CHOST}\"
- ${LDFLAGS}
- )
- echo ${args[*]}
- "${args[@]}" || die
-}
-
-src_install() {
- dobin ${PN}
- use prefix && eprefixify "${ED}"/usr/bin/${PN}
- sed -i "s:@PV@:${PVR}:g" "${ED}"/usr/bin/${PN} || die
- doman "${FILESDIR}"/${PN}.8
-
- dodir /usr/$(get_libdir)/misc/binutils-config
- mv "${S}"/ldwrapper "${ED}"/usr/$(get_libdir)/misc/binutils-config/
-
- insinto /usr/share/eselect/modules
- doins "${FILESDIR}"/binutils.eselect
-}
-
-pkg_preinst() {
- # Force a refresh when upgrading from an older version that symlinked
- # in all the libs & includes that binutils-libs handles. #528088
- if has_version "<${CATEGORY}/${PN}-5" ; then
- local bc current
- bc="${ED}/usr/bin/binutils-config"
- if current=$("${bc}" -c) ; then
- "${bc}" "${current}"
- fi
- fi
-}
diff --git a/sys-devel/binutils-config/binutils-config-5-r03.4.ebuild b/sys-devel/binutils-config/binutils-config-5.1-r1.ebuild
similarity index 96%
rename from sys-devel/binutils-config/binutils-config-5-r03.4.ebuild
rename to sys-devel/binutils-config/binutils-config-5.1-r1.ebuild
index a00860e6b2..5cae4a9223 100644
--- a/sys-devel/binutils-config/binutils-config-5-r03.4.ebuild
+++ b/sys-devel/binutils-config/binutils-config-5.1-r1.ebuild
@@ -1,14 +1,14 @@
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
-EAPI="6"
+EAPI=6
inherit eutils prefix
DESCRIPTION="Utility to change the binutils version being used"
HOMEPAGE="https://www.gentoo.org/"
GIT_REV="edc0d44f70c27daebcc080ac5d08e8e191bccd95"
-WRAPPER_REV="${PV}.3.4"
+WRAPPER_REV="${PV%%.*}.3.4"
SRC_URI="https://gitweb.gentoo.org/repo/proj/prefix.git/plain/sys-devel/binutils-config/files/ldwrapper.c?id=${GIT_REV} -> ${PN}-ldwrapper-${WRAPPER_REV}.c"
LICENSE="GPL-2"
diff --git a/sys-devel/binutils-config/files/binutils-config-5.1 b/sys-devel/binutils-config/files/binutils-config-5.1
new file mode 100644
index 0000000000..f55d529c93
--- /dev/null
+++ b/sys-devel/binutils-config/files/binutils-config-5.1
@@ -0,0 +1,486 @@
+#!/bin/bash
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# Format of /etc/env.d/binutils/:
+# config-TARGET: CURRENT=version for TARGET
+# TARGET-VER: has a TARGET and VER variable
+
+EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
+if [[ ${EPREFIX} == "@"GENTOO_PORTAGE_EPREFIX"@" ]] ; then
+ EPREFIX=""
+fi
+
+: ${ROOT:=/}
+[[ ${ROOT} != */ ]] && ROOT="${ROOT}/"
+[[ ${ROOT} != /* ]] && ROOT="${PWD%/}/${ROOT}"
+
+EROOT="${ROOT%/}${EPREFIX}/"
+
+cd "${EPREFIX}/"
+
+trap ":" INT QUIT TSTP
+
+argv0=${0##*/}
+FUNCTIONS_SH="${EPREFIX}/lib/gentoo/functions.sh"
+source ${FUNCTIONS_SH} || {
+ echo "${argv0}: Could not source ${FUNCTIONS_SH}!" 1>&2
+ exit 1
+}
+esyslog() { :; }
+die() { eerror "${argv0}: $*"; exit 1; }
+umask 022
+
+usage() {
+cat << USAGE_END
+Usage: ${HILITE}binutils-config${NORMAL} ${GOOD}[options]${NORMAL} ${BRACKET}[binutils profile]${NORMAL}
+
+${HILITE}General Options:${NORMAL}
+ ${GOOD}-c, --get-current-profile${NORMAL} Print current profile
+ ${GOOD}-l, --list-profiles${NORMAL} Print a list of available profiles
+ ${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}
+
+For more info, please see ${HILITE}binutils-config${NORMAL}(8).
+USAGE_END
+
+ exit ${1:-1}
+}
+
+mv_if_diff() {
+ if cmp -s "$1" "$2" ; then
+ rm -f "$1"
+ else
+ mv -f "$1" "$2"
+ fi
+}
+atomic_ln() {
+ local target=$1 linkdir=$2 linkname=$3 linktmp linkfull
+ linktmp="${linkdir}/.binutils-config.tmp.${linkname}"
+ linkfull="${linkdir}/${linkname}"
+ if [[ -d ${linkfull} ]] ; then
+ # if linking to a dir, we need a little magic to
+ # make it atomic since `mv -T` is not portable
+ rm -rf "${linktmp}"
+ mkdir -p "${linktmp}"
+ ln -sf "${target}" "${linktmp}/${linkname}"
+ mv "${linktmp}/${linkname}" "${linktmp}/../"
+ rmdir "${linktmp}"
+ else
+ # `ln` will expand into unlink();symlink(); which
+ # is not atomic for a small amount of time, but
+ # `mv` is a single rename() call
+ ln -sf "${target}" "${linktmp}"
+ mv "${linktmp}" "${linkfull}"
+ fi
+}
+
+setup_env() {
+ unset TARGET VER LIBPATH
+ source "${ENV_D}/${PROFILE}"
+ if [[ -z ${TARGET} ]] ; then
+ eerror "${PROFILE} is invalid (no \$TARGET defined) :("
+ return 1
+ fi
+ if [[ -z ${VER} ]] ; then
+ eerror "${PROFILE} is invalid (no \$VER defined) :("
+ return 1
+ fi
+
+ #
+ # Generate binary symlinks
+ #
+ BINPATH=""
+ BINPATH_LINKS=""
+ if [[ ${TARGET} != ${HOST} ]] ; then
+ #
+ # Newer paths: /usr/${HOST}/${TARGET}/...
+ # Older paths: /usr/${TARGET}/...
+ #
+ if [[ -d "${EROOT}"/usr/${HOST}/${TARGET}/binutils-bin/${VER} ]] ; then
+ BINPATH="${EPREFIX}"/usr/${HOST}/${TARGET}/binutils-bin/${VER}
+ BINPATH_LINKS="${EPREFIX}"/usr/libexec/gcc/${TARGET}
+ fi
+ fi
+ if [[ -z ${BINPATH} ]] ; then
+ BINPATH="${EPREFIX}"/usr/${TARGET}/binutils-bin/${VER}
+ BINPATH_LINKS="${EPREFIX}"/usr/${TARGET}/bin
+ fi
+}
+
+# Lists of headers that various versions have installed.
+HEADERS=(
+ ansidecl.h bfd.h bfdlink.h demangle.h dis-asm.h dyn-string.h
+ fibheap.h hashtab.h libiberty.h objalloc.h plugin-api.h
+ splay-tree.h symcat.h
+)
+
+switch_profile() {
+ local x
+
+ ebegin "Switching to ${PROFILE}"
+
+ setup_env || return 1
+
+ cd "${ROOT}/${BINPATH}" || exit 1
+ mkdir -p "${ROOT}/${BINPATH_LINKS}" "${EROOT}/usr/bin"
+ for x in * ; do
+ atomic_ln "${BINPATH}/${x}" "${ROOT}/${BINPATH_LINKS}" "${x}"
+ atomic_ln "${BINPATH_LINKS}/${x}" "${EROOT}/usr/bin" "${TARGET}-${x}"
+ if [[ ${TARGET} == ${HOST} ]] ; then
+ atomic_ln "${TARGET}-${x}" "${EROOT}/usr/bin" "${x}"
+ fi
+ done
+
+ #
+ # Generate library / ldscripts symlinks
+ #
+ : ${LIBPATH:=${EPREFIX}/usr/lib/binutils/${TARGET}/${VER}}
+ cd "${ROOT}/${LIBPATH}" || exit 1
+ if [[ ${TARGET} == ${HOST} ]] ; then
+ dstlib=${EROOT}/usr/${HOST}/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.
+ mkdir -p "${dstlib}"
+ rm -rf "${ROOT}/${BINPATH_LINKS}"/ldscripts
+ atomic_ln "${LIBPATH}/ldscripts" "${dstlib}" "ldscripts"
+ # PREFIX LOCAL: we have gcc under dstlib here, and wiping symlinks
+ # is a very bad idea there, or our symlinked sonames disappear!
+ #find -L "${dstlib}" -xtype l -name 'lib*' -delete
+ find -L "${dstlib}"/ldscripts -xtype l -name 'lib*' -delete
+ # END PREFIX LOCAL
+ # 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
+ #
+ INCPATH=${LIBPATH}/include
+ if [[ -d ${ROOT}/${INCPATH} ]] ; then
+ cd "${ROOT}/${INCPATH}" || exit 1
+ if [[ ${HOST} != ${TARGET} ]] ; then
+ # Clean out old path -- cannot use '-exec {} +' syntax here
+ find . -type f -exec rm -f "${EROOT}/usr/${TARGET}/usr/include/{}" \;
+ rmdir "${EROOT}/usr/${TARGET}/usr/include" >& /dev/null
+ rmdir "${EROOT}/usr/${TARGET}/usr" >& /dev/null
+ rmdir "${EROOT}/usr/${TARGET}" >& /dev/null
+ fi
+ fi
+
+ #
+ # Make sure proper paths get updated
+ #
+ local env_update_flag="--no-ldconfig"
+ if [[ ${TARGET} == ${HOST} ]] ; then
+ # Delete old config now that binutils-libs installs these files.
+ # Note: This skips ldconfig update if env.d had LDPATH, but meh.
+ # Most people have upgraded to ld.so.conf.d, and someone else will
+ # eventually re-run ldconfig for us.
+ x="${EROOT}"/etc/ld.so.conf.d/05binutils.conf
+ if [[ -e ${x} ]]; then
+ rm -f "${x}"
+ env_update_flag=""
+ fi
+
+ DATAPATH="${EPREFIX}"/usr/share/binutils-data/${TARGET}/${VER}
+ local e="${EROOT}"/etc/env.d/05binutils
+ local ee="${e}.tmp"
+ rm -f "${ee}"
+ [[ -d ${ROOT}/${DATAPATH}/man ]] && echo "MANPATH=${DATAPATH}/man" >> "${ee}"
+ [[ -d ${ROOT}/${DATAPATH}/info ]] && echo "INFOPATH=${DATAPATH}/info" >> "${ee}"
+ mv_if_diff "${ee}" "${e}"
+ fi
+
+ local c="${ENV_D}/config-${TARGET}"
+ local cc="${c}.tmp"
+ echo "CURRENT=${VER}" > "${cc}"
+ mv_if_diff "${cc}" "${c}"
+
+ eend 0
+
+ #
+ # Regen env.d if need/can be
+ #
+ if [[ ${ROOT} == "/" ]] && [[ ${TARGET} == ${HOST} ]] ; then
+ env-update ${env_update_flag}
+ echo
+ ewarn "Please remember to run:"
+ echo
+ ewarn " # . ${EPREFIX}/etc/profile"
+ echo
+ fi
+
+ return 0
+}
+
+uninstall_target() {
+ : ${TARGET:=${UARG}}
+
+ if [[ ${TARGET} == ${HOST} ]] ; then
+ die "refusing to uninstall native binutils"
+ fi
+
+ shopt -s nullglob
+ PROFILE=""
+
+ for PROFILE in "${ENV_D}"/${TARGET}-* ; do
+ ewarn "Removing all signs of ${PROFILE##*/}"
+ rm -f "${ENV_D}"/${PROFILE}
+ done
+ if [[ -z ${PROFILE} ]] && [[ ! -e ${ENV_D}/config-${TARGET} ]] ; then
+ die "no profiles exist for '${TARGET}'"
+ fi
+
+ rm -f "${ENV_D}"/config-${TARGET}
+
+ local x
+ for x in \
+ addr2line ar as c++filt dwp elf2flt elfedit flthdr gprof \
+ ld ld.{bfd,gold,real} \
+ nm objcopy objdump ranlib readelf size strings strip
+ do
+ x=(
+ "${EROOT}"/usr/bin/${TARGET}-${x}
+ "${EROOT}"/usr/{${HOST}/,}${TARGET}/bin/${x}
+ "${EROOT}"/usr/libexec/gcc/${TARGET}/${x}
+ )
+ rm -f "${x[@]}"
+ done
+ for x in "${HEADERS[@]}" ; do
+ rm -f "${EROOT}"/usr/{${HOST}/,}${TARGET}/{usr/,}include/${x}
+ done
+ for x in bfd iberty opcodes ; do
+ rm -f "${EROOT}"/usr/${HOST}/${TARGET}/lib/lib${x}{{-*,}.so,.a,.la}
+ done
+ # Delete broken symlinks
+ local destdir="${EROOT}/usr/${HOST}/${TARGET}"
+ rm -f "${destdir}"/lib/ldscripts
+ find -L "${destdir}"/lib -type l -exec rm {} +
+ rmdir \
+ "${destdir}"/{bin,include,lib,usr} \
+ "${destdir}" \
+ "${EROOT}"/var/db/pkg/cross-${TARGET} \
+ "${EROOT}"/usr/{${HOST}/,}${TARGET}/bin \
+ "${EROOT}"/usr/libexec/gcc/${TARGET} \
+ 2>/dev/null
+
+ rm -f "${ENV_D}"/${TARGET}-*
+}
+
+set_current_profile() {
+ if [[ ! -f ${ENV_D}/config-${TARGET} ]] ; then
+ eerror "${argv0}: unable to locate a profile for target: ${TARGET}"
+ return 1
+ fi
+
+ source "${ENV_D}/config-${TARGET}"
+
+ if [[ -z ${CURRENT} ]] ; then
+ eerror "${argv0}: no binutils profile is active!"
+ return 1
+ fi
+
+ echo "${TARGET}-${CURRENT}"
+
+ return 0
+}
+get_current_profile() { echo "${PROFILE}" ; }
+
+list_profiles() {
+ local x i target
+
+ if [[ ${ROOT} != / ]] ; then
+ echo "Using binutils-config info in ${ROOT}"
+ fi
+
+ set -- "${ENV_D}"/*
+ target=
+ i=1
+
+ for x ; do
+ # skip broken links and config files
+ [[ -f ${x} ]] || continue
+ [[ ${x} == */config-* ]] && continue
+
+ source "${x}"
+ if [[ ${target} != ${TARGET} ]] ; then
+ [[ -n ${target} ]] && echo
+ target=${TARGET}
+ fi
+
+ x=${x##*/}
+ if [[ -e ${ENV_D}/config-${TARGET} ]] ; then
+ source "${ENV_D}/config-${TARGET}"
+ if [[ ${VER} == ${CURRENT} ]] ; then
+ [[ ${TARGET} == ${HOST} ]] \
+ && x="${x} ${GOOD}*${NORMAL}" \
+ || x="${x} ${HILITE}*${NORMAL}"
+ fi
+ fi
+
+ # We would align the [...] field like so:
+ #printf ' [%*ss] %s\n' ${##} "${i}" "${x}"
+ # but this breaks simple scripting: `binutils -l | awk '{print $2}'`
+
+ # Or we could align the target col like so:
+ #printf ' [%s]%*s %s\n' "${i}" $(( ${##} - ${#i} )) "" "${x}"
+ # but i'm not sold that it looks better
+
+ # So keep it simple ... only makes a diff anyways for crazy people
+ # like me which have 100+ binutils packages installed ...
+ echo " [$i] ${x}"
+ ((++i))
+ 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)}}
+}
+
+ENV_D="${EROOT}etc/env.d/binutils"
+
+DEBUG="no"
+NEED_ACTION="yes"
+DOIT="switch_profile"
+PROFILE="current"
+HOST=""
+TARGET=""
+unset UARG
+
+select_action() {
+ if [[ ${NEED_ACTION} != "no" ]] ; then
+ NEED_ACTION="no"
+ DOIT=$1
+ else
+ die "one action at a time!"
+ fi
+}
+
+while [[ $# -gt 0 ]] ; do
+ x=$1
+ shift
+ case ${x} in
+ -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)
+ ver="@PV@"
+ echo "binutils-config-${ver/@'PV'@/git}"
+ exit 0
+ ;;
+ -*)
+ die "invalid switch! Try '--help'."
+ ;;
+ *)
+ if [[ ${UARG+set} == "set" ]] ; then
+ die "only one profile/target at a time please"
+ fi
+ NEED_ACTION="maybe"
+ UARG=${x}
+ ;;
+ esac
+done
+
+[[ ${NEED_ACTION} == "yes" ]] && usage 1
+[[ ${DEBUG} == "yes" ]] && set -x
+
+# All operations need to know the current HOST to figure out
+# what is a native target and what is a cross target
+set_HOST
+
+# All operations need to know the profile the user wants
+case ${DOIT} in
+switch_profile|switch_linker_*)
+ # decode user's profile choice
+ x=${UARG:-$(TARGET=${HOST} set_current_profile)}
+ PROFILE=""
+ if [[ -z $(echo ${x} | tr -d '[:digit:]') ]] ; then
+ # User gave us a # representing the profile
+ i=1
+ for y in "${ENV_D}"/* ; do
+ [[ ${y/config-} != ${y} ]] && continue
+
+ if [[ -f ${y} ]] && [[ ${x} -eq ${i} ]] ; then
+ PROFILE=${y##*/}
+ break
+ fi
+ ((++i))
+ done
+ fi
+
+ if [[ -z ${PROFILE} ]] ; then
+ # User gave us a full HOST-ver
+ x=${x##*/}
+ if [[ -f ${ENV_D}/${x} ]] ; then
+ # Valid HOST-ver yeah!
+ PROFILE=${x}
+ else
+ # Not a valid HOST-ver ...
+ if [[ ! -f ${ENV_D}/config-${x} ]] ; then
+ # Maybe they just gave us a ver ...
+ if [[ -f ${ENV_D}/${HOST}-${x} ]] ; then
+ x=${HOST}-${x}
+ else
+ die "could not locate '$x' in '${ENV_D}/'!"
+ fi
+ PROFILE=${x}
+ else
+ # Maybe they just gave us a target ... pick active profile
+ PROFILE=$(TARGET=${x} set_current_profile)
+ fi
+ fi
+ fi
+ ;;
+*)
+ # lookup current profile as the user gave us a target
+ PROFILE=$(TARGET=${UARG:-${HOST}} set_current_profile) || exit 1
+ ;;
+esac
+
+eval ${DOIT}
+
+# vim:ts=4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/, sys-devel/binutils-config/files/
@ 2021-01-13 19:41 Fabian Groffen
0 siblings, 0 replies; 10+ messages in thread
From: Fabian Groffen @ 2021-01-13 19:41 UTC (permalink / raw
To: gentoo-commits
commit: 14e6d6149b2e104b5446052340d20d6880ca50a5
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 13 19:40:56 2021 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 13 19:40:56 2021 +0000
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=14e6d614
sys-devel/binutils-config-5.1-r4: revbump for BigSur sdk_version fix
Package-Manager: Portage-3.0.12.0.2-prefix, Repoman-3.0.2
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
...5.1-r3.ebuild => binutils-config-5.1-r4.ebuild} | 5 ++++-
sys-devel/binutils-config/files/ldwrapper.c | 24 ++++++++++++++++++----
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/sys-devel/binutils-config/binutils-config-5.1-r3.ebuild b/sys-devel/binutils-config/binutils-config-5.1-r4.ebuild
similarity index 95%
rename from sys-devel/binutils-config/binutils-config-5.1-r3.ebuild
rename to sys-devel/binutils-config/binutils-config-5.1-r4.ebuild
index 02468e2b1a..36bc85a317 100644
--- a/sys-devel/binutils-config/binutils-config-5.1-r3.ebuild
+++ b/sys-devel/binutils-config/binutils-config-5.1-r4.ebuild
@@ -44,7 +44,10 @@ src_compile() {
# macOS Big Sur has an empty /usr/lib, so the linker really has
# to look into the SDK, for which it needs to be told where it
# is (symlinked right into our EPREFIX root as MacOSX.sdk)
- extraargs+=( -DDARWIN_LD_SYSLIBROOT=1 )
+ extraargs+=(
+ -DDARWIN_LD_SYSLIBROOT=1
+ -DDARWIN_LD_DEFAULT_TARGET='"'${MACOSX_DEPLOYMENT_TARGET}'"'
+ )
fi
local args=(
$(tc-getCC)
diff --git a/sys-devel/binutils-config/files/ldwrapper.c b/sys-devel/binutils-config/files/ldwrapper.c
index 7410afd334..6bcb2a5e72 100644
--- a/sys-devel/binutils-config/files/ldwrapper.c
+++ b/sys-devel/binutils-config/files/ldwrapper.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2019 Gentoo Foundation
+ * Copyright 1999-2021 Gentoo Authors
* Distributed under the terms of the GNU General Public License v2
* Authors: Fabian Groffen <grobian@gentoo.org>
* Michael Haubenwallner <haubi@gentoo.org>
@@ -218,6 +218,11 @@ main(int argc, char *argv[])
DIR *dirp;
struct dirent *dp;
+#ifdef DARWIN_LD_DEFAULT_TARGET
+ if (darwin_dt == NULL)
+ darwin_dt = DARWIN_LD_DEFAULT_TARGET;
+#endif
+
/* two ways to determine CTARGET from argv[0]:
* 1. called as <CTARGET>-ld (manually)
* 2. called as EPREFIX/usr/libexec/gcc/<CTARGET>/ld (by gcc's collect2)
@@ -340,8 +345,8 @@ main(int argc, char *argv[])
newargc += 2 + 1;
#ifdef DARWIN_LD_SYSLIBROOT
- /* add -syslibroot <path> */
- newargc += 2;
+ /* add -syslibroot <path> -sdk_version <ver> */
+ newargc += 4;
#endif
} else {
/* add the 4 paths we want (-L + -R) */
@@ -378,11 +383,22 @@ main(int argc, char *argv[])
newargv[j++] = ld;
if (!is_cross && is_darwin) {
- /* inject this first to make the intention clear */
+ char target[ESIZ];
+ ssize_t trglen;
+
+ /* ld64 will try to infer sdk version when -syslibroot is used
+ * from the path given, unfortunately this searches for the
+ * first numbers it finds, which means anything random in
+ * EPREFIX, causing errors. Explicitly set the deployment
+ * version here, for the sdk link can be versionless when set to
+ * CommandLineTools */
#ifdef DARWIN_LD_SYSLIBROOT
+ newargv[j++] = "-sdk_version";
+ newargv[j++] = darwin_dt;
newargv[j++] = "-syslibroot";
newargv[j++] = EPREFIX "/MacOSX.sdk";
#endif
+ /* inject this first to make the intention clear */
newargv[j++] = "-search_paths_first";
}
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/, sys-devel/binutils-config/files/
@ 2023-12-16 8:19 Fabian Groffen
0 siblings, 0 replies; 10+ messages in thread
From: Fabian Groffen @ 2023-12-16 8:19 UTC (permalink / raw
To: gentoo-commits
commit: 55996b02c62a3f77b97ad2d3e0a0bb5a4604263f
Author: Ryan Qian <i <AT> bitbili <DOT> net>
AuthorDate: Sat Dec 16 08:18:10 2023 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Dec 16 08:18:10 2023 +0000
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=55996b02
sys-devel/binutils-config-5.1-r7: fix argument suppression logic for macOS
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
.../{binutils-config-5.1-r6.ebuild => binutils-config-5.1-r7.ebuild} | 0
sys-devel/binutils-config/files/ldwrapper.c | 4 +++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/sys-devel/binutils-config/binutils-config-5.1-r6.ebuild b/sys-devel/binutils-config/binutils-config-5.1-r7.ebuild
similarity index 100%
rename from sys-devel/binutils-config/binutils-config-5.1-r6.ebuild
rename to sys-devel/binutils-config/binutils-config-5.1-r7.ebuild
diff --git a/sys-devel/binutils-config/files/ldwrapper.c b/sys-devel/binutils-config/files/ldwrapper.c
index 16932af5d6..a1639ca5aa 100644
--- a/sys-devel/binutils-config/files/ldwrapper.c
+++ b/sys-devel/binutils-config/files/ldwrapper.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2021 Gentoo Authors
+ * Copyright 1999-2023 Gentoo Authors
* Distributed under the terms of the GNU General Public License v2
* Authors: Fabian Groffen <grobian@gentoo.org>
* Michael Haubenwallner <haubi@gentoo.org>
@@ -430,6 +430,7 @@ main(int argc, char *argv[])
{
i++;
j--;
+ k -= 2;
continue;
}
if (strcmp(argv[i], "-platform_version") == 0 &&
@@ -437,6 +438,7 @@ main(int argc, char *argv[])
{
i += 3;
j--;
+ k -= 4;
continue;
}
}
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/, sys-devel/binutils-config/files/
@ 2024-01-20 20:05 Fabian Groffen
0 siblings, 0 replies; 10+ messages in thread
From: Fabian Groffen @ 2024-01-20 20:05 UTC (permalink / raw
To: gentoo-commits
commit: eed086f02edce039c035459b92ac606175e8f888
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 20 20:04:47 2024 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan 20 20:04:47 2024 +0000
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=eed086f0
sys-devel/binutils-config: determine linker behaviour dynamically on Darwin
Whether or not we need to use a syslibroot, platform version or whatnot
depends on the platform and linker being in use. Since the linker version can
differ from the macOS version, don't assume they are the same.
On Darwin, call the linker to establish its version prior to
constructing the final linker call arguments. This is unfortunate, but
the only way it can somewhat reliably work with multiple linker versions
(as available from binutils-config) updating targets, and different
macOS versions.
Tested on:
Darwin 9, PPC, xtools-2.2.4 ld64-274.2
Darwin 17, X64, xtools-2.2.4 ld64-274.2
Darwin 23, X64, xtools-2.2.4 ld64-274.2
Darwin 23, M1, native-5 ld64-650.9
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
...5.1-r7.ebuild => binutils-config-5.1-r8.ebuild} | 9 +-
sys-devel/binutils-config/files/ldwrapper.c | 97 +++++++++++++++-------
2 files changed, 68 insertions(+), 38 deletions(-)
diff --git a/sys-devel/binutils-config/binutils-config-5.1-r7.ebuild b/sys-devel/binutils-config/binutils-config-5.1-r8.ebuild
similarity index 86%
rename from sys-devel/binutils-config/binutils-config-5.1-r7.ebuild
rename to sys-devel/binutils-config/binutils-config-5.1-r8.ebuild
index a26ff944b0..38f82d40b5 100644
--- a/sys-devel/binutils-config/binutils-config-5.1-r7.ebuild
+++ b/sys-devel/binutils-config/binutils-config-5.1-r8.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=6
@@ -39,12 +39,8 @@ src_configure() {
src_compile() {
use prefix-guest || return
local extraargs=( )
- if [[ ${CHOST} == *-darwin* && ${CHOST##*-darwin} -ge 20 ]] ; then
- # macOS Big Sur has an empty /usr/lib, so the linker really has
- # to look into the SDK, for which it needs to be told where it
- # is (symlinked right into our EPREFIX root as MacOSX.sdk)
+ if [[ ${CHOST} == *-darwin* ]] ; then
extraargs+=(
- -DDARWIN_LD_SYSLIBROOT=1
-DDARWIN_LD_DEFAULT_TARGET='"'${MACOSX_DEPLOYMENT_TARGET}'"'
)
fi
@@ -52,6 +48,7 @@ src_compile() {
$(tc-getCC)
${CPPFLAGS}
${CFLAGS}
+ -Wall
-o ldwrapper ${PN}-ldwrapper-${WRAPPER_REV}.c
-DEPREFIX=\"${EPREFIX}\"
-DCHOST=\"${CHOST}\"
diff --git a/sys-devel/binutils-config/files/ldwrapper.c b/sys-devel/binutils-config/files/ldwrapper.c
index df29b04c96..c9fe7e4bb3 100644
--- a/sys-devel/binutils-config/files/ldwrapper.c
+++ b/sys-devel/binutils-config/files/ldwrapper.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2023 Gentoo Authors
+ * Copyright 1999-2024 Gentoo Authors
* Distributed under the terms of the GNU General Public License v2
* Authors: Fabian Groffen <grobian@gentoo.org>
* Michael Haubenwallner <haubi@gentoo.org>
@@ -18,7 +18,7 @@
/**
* ldwrapper: Prefix helper to inject -L and -R flags to the invocation
- * of ld.
+ * of ld, and many more necessary linker flags/tweaks.
*
* On Darwin it adds -search_paths_first to make sure the given paths are
* searched before the default search path, and sets -syslibroot
@@ -50,7 +50,6 @@ find_real_ld(char **ld, size_t ldlen, const char verbose, const char is_cross,
FILE *f = NULL;
char *ldoverride;
char *path;
- char *ret;
struct stat lde;
char config[ESIZ];
size_t len;
@@ -203,12 +202,11 @@ main(int argc, char *argv[])
char *wrapperctarget = NULL;
char verbose = getenv("BINUTILS_CONFIG_VERBOSE") != NULL;
char *builddir = getenv("PORTAGE_BUILDDIR");
- char ldbuf[ESIZ];
+ char ldbuf[ESIZ * 2];
char *ld = ldbuf;
char ctarget[128];
char *darwin_dt = getenv("MACOSX_DEPLOYMENT_TARGET");
int darwin_dt_ver = 0;
- int darwin_ld_trg_ver = 0;
char is_cross = 0;
char is_darwin = 0;
char darwin_use_rpath = 1;
@@ -223,9 +221,6 @@ main(int argc, char *argv[])
#ifdef DARWIN_LD_DEFAULT_TARGET
if (darwin_dt == NULL)
darwin_dt = DARWIN_LD_DEFAULT_TARGET;
- darwin_ld_trg_ver = (int)strtol(DARWIN_LD_DEFAULT_TARGET, &p, 10) * 100;
- if (*p == '.')
- darwin_ld_trg_ver += (int)strtol(p + 1, &p, 10);
#endif
/* two ways to determine CTARGET from argv[0]:
@@ -327,8 +322,6 @@ main(int argc, char *argv[])
* non-cross-compilable on any platform, prefix or no prefix. So no
* need to add PREFIX- or CTARGET-aware libdirs. */
if (!is_cross) {
- struct stat st;
-
if (is_darwin) {
/* check deployment target if nothing prevents us from
* using -rpath as of yet
@@ -356,10 +349,8 @@ main(int argc, char *argv[])
/* add the 2 prefix paths (-L) and -search_paths_first */
newargc += 2 + 1;
-#ifdef DARWIN_LD_SYSLIBROOT
/* add -syslibroot <path> -platform_version macos <ver> 0.0 */
newargc += 6;
-#endif
} else {
/* add the 4 paths we want (-L + -R) */
newargc += 8;
@@ -395,38 +386,81 @@ main(int argc, char *argv[])
newargv[j++] = ld;
if (!is_cross && is_darwin) {
- char target[ESIZ];
- ssize_t trglen;
-
- /* ld64 will try to infer sdk version when -syslibroot is used
- * from the path given, unfortunately this searches for the
- * first numbers it finds, which means anything random in
- * EPREFIX, causing errors. Explicitly set the deployment
- * version here, for the sdk link can be versionless when set to
- * CommandLineTools */
-#ifdef DARWIN_LD_SYSLIBROOT
- /* bug #910277: transform into platform_version arg for newer
- * targets */
- if (darwin_ld_trg_ver >= 1200) {
+ char target[(2 * ESIZ) + 16];
+ FILE *ld64out;
+ int ld64ver = 0;
+
+ /* call the linker to figure out what options we can use :(
+ * some Developer Tools ld64 versions:
+ * 12.0: 609 Big Sur, requirement for sdk_version
+ * 13.0: 711
+ * 13.3.1: 762
+ * 14.0: 819.6
+ * 14.2: 820.1
+ * 14.3.1: 857.1
+ * 15.0: 907 Sanoma, platform_version argument
+ * all to be found from the PROJECT:ld64-650.9 bit from 1st line
+ * NOTE: e.g. my Sanoma mac with CommandLineTools has 650.9
+ * which is not a version from any Developer Tools ?!?
+ * Currently we need to distinguish XCode 15 according to
+ * bug #910277, so we look for 907 and old targets before 12 */
+#define LD64_12_0 60900
+#define LD64_15_0 90700
+ snprintf(target, sizeof(target), "%s -v 2>&1", ld);
+ ld64out = popen(target, "r");
+ if (ld64out != NULL) {
+ char *proj;
+ long comp;
+ if (fgets(target, sizeof(target), ld64out) != 0 &&
+ (proj = strstr(target, "PROJECT:ld64-")) != NULL)
+ {
+ proj += sizeof("PROJECT:ld64-") - 1;
+ comp = strtol(proj, &proj, 10);
+ /* we currently have no need to parse fractions, the
+ * major version is significant enough, so just stop */
+ ld64ver = (int)comp * 100;
+ }
+ pclose(ld64out);
+ }
+
+ /* macOS Big Sur (Darwin 20) has an empty /usr/lib, so the
+ * linker really has to look into the SDK, for which it needs to
+ * be told where it is (symlinked right into our EPREFIX root as
+ * MacOSX.sdk) via the -syslibroot argument, older targets also
+ * get this SDK path setup, old bootstraps would break, but that
+ * would be easy to resolve -- there's unlikely to be many old
+ * bootstraps out there that don't have the SDK path symlink */
+ newargv[j++] = "-syslibroot";
+ newargv[j++] = EPREFIX "/MacOSX.sdk";
+
+ /* ld64 will try to infer sdk version when -syslibroot is
+ * used from the path given, unfortunately this searches for
+ * the first numbers it finds, which means anything random
+ * in EPREFIX, causing errors. Explicitly set the
+ * deployment version here, for the sdk link can be
+ * versionless when set to CommandLineTools
+ * macOS Sanoma however needs a new way to set this version,
+ * so do the right thing */
+ if (ld64ver >= LD64_15_0) {
newargv[j++] = "-platform_version";
newargv[j++] = "macos";
newargv[j++] = darwin_dt;
newargv[j++] = "0.0";
- } else {
+ } else if (ld64ver >= LD64_12_0) {
newargv[j++] = "-sdk_version";
newargv[j++] = darwin_dt;
+ } else {
+ newargv[j++] = "-macosx_version_min";
+ newargv[j++] = darwin_dt;
}
- newargv[j++] = "-syslibroot";
- newargv[j++] = EPREFIX "/MacOSX.sdk";
-#endif
- /* inject this first to make the intention clear */
+
+ /* inject this before -L args to make the intention clear */
newargv[j++] = "-search_paths_first";
}
/* position k right after the original arguments */
k = j - 1 + argc;
for (i = 1; i < argc; i++, j++) {
-#ifdef DARWIN_LD_SYSLIBROOT
if (is_darwin) {
/* skip platform version stuff, we already pushed it out */
if ((strcmp(argv[i], "-macosx_version_min") == 0 ||
@@ -446,7 +480,6 @@ main(int argc, char *argv[])
continue;
}
}
-#endif
newargv[j] = argv[i];
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/, sys-devel/binutils-config/files/
@ 2024-03-08 21:13 Fabian Groffen
0 siblings, 0 replies; 10+ messages in thread
From: Fabian Groffen @ 2024-03-08 21:13 UTC (permalink / raw
To: gentoo-commits
commit: 81985363c3e3d01321ab75291d7c827ffff4dcab
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 8 16:03:27 2024 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 8 21:13:17 2024 +0000
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=81985363
sys-devel/binutils-config: revbump for CLT 15.3 ld fix
Possibly this problem existed longer before, but it's a bit shady when
what ld is used.
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
...utils-config-5.1-r9.ebuild => binutils-config-5.1-r10.ebuild} | 0
sys-devel/binutils-config/files/ldwrapper.c | 9 ++++++---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/sys-devel/binutils-config/binutils-config-5.1-r9.ebuild b/sys-devel/binutils-config/binutils-config-5.1-r10.ebuild
similarity index 100%
rename from sys-devel/binutils-config/binutils-config-5.1-r9.ebuild
rename to sys-devel/binutils-config/binutils-config-5.1-r10.ebuild
diff --git a/sys-devel/binutils-config/files/ldwrapper.c b/sys-devel/binutils-config/files/ldwrapper.c
index 00d4a69f73..c799b4cdd9 100644
--- a/sys-devel/binutils-config/files/ldwrapper.c
+++ b/sys-devel/binutils-config/files/ldwrapper.c
@@ -405,8 +405,9 @@ main(int argc, char *argv[])
* 14.2: 820.1
* 14.3.1: 857.1
* 15.0: 907 1022.1 Sanoma 23, platform_version iso sdk_version
+ * 15.3 1053.12 called ld
* all to be found from the PROJECT:ld64-650.9 or
- * PROJECT:dyld-1022.1 bit from the first line
+ * PROJECT:dyld-1022.1 or PROJECT:ld-1053.12 bit from the first line
* NOTE: e.g. my Sanoma mac with CommandLineTools has 650.9
* which is not a version from any Developer Tools ?!?
* Currently we need to distinguish XCode 15 according to
@@ -423,11 +424,13 @@ main(int argc, char *argv[])
long comp;
if (fgets(target, sizeof(target), ld64out) != 0 &&
((proj = strstr(target, "PROJECT:ld64-")) != NULL ||
- (proj = strstr(target, "PROJECT:dyld-")) != NULL))
+ (proj = strstr(target, "PROJECT:dyld-")) != NULL ||
+ (proj = strstr(target, "PROJECT:ld-")) != NULL))
{
/* we don't distinguish between ld64 and dyld here, for
* now it seems the numbers line up for our logic */
- proj += sizeof("PROJECT:ld64-") - 1;
+ proj += sizeof("PROJECT:ld") - 1;
+ proj += *proj == '-' ? 1 : 3;
comp = strtol(proj, &proj, 10);
/* we currently have no need to parse fractions, the
* major version is significant enough, so just stop */
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/, sys-devel/binutils-config/files/
@ 2024-04-04 20:29 Fabian Groffen
0 siblings, 0 replies; 10+ messages in thread
From: Fabian Groffen @ 2024-04-04 20:29 UTC (permalink / raw
To: gentoo-commits
commit: e3536efbe87342ead017157e0cc359dead73d9dd
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 4 20:27:06 2024 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Apr 4 20:29:39 2024 +0000
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=e3536efb
sys-devel/binutils-config: remove duplicate -L and -rpath entries
Ever since CLT15.3 duplicate -L or -rpath entries result in warnings.
These warnings, albeit just ugly, make that some packages croak or
worse: abort, claiming the linker is broken (such as Ruby). This is
nonsense, but cater for this by removing any duplicate paths, and not
adding any paths that are already added.
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
...1-r10.ebuild => binutils-config-5.1-r11.ebuild} | 0
sys-devel/binutils-config/files/ldwrapper.c | 198 ++++++++++++++++-----
2 files changed, 150 insertions(+), 48 deletions(-)
diff --git a/sys-devel/binutils-config/binutils-config-5.1-r10.ebuild b/sys-devel/binutils-config/binutils-config-5.1-r11.ebuild
similarity index 100%
rename from sys-devel/binutils-config/binutils-config-5.1-r10.ebuild
rename to sys-devel/binutils-config/binutils-config-5.1-r11.ebuild
diff --git a/sys-devel/binutils-config/files/ldwrapper.c b/sys-devel/binutils-config/files/ldwrapper.c
index c799b4cdd9..22fbf9aba8 100644
--- a/sys-devel/binutils-config/files/ldwrapper.c
+++ b/sys-devel/binutils-config/files/ldwrapper.c
@@ -197,7 +197,10 @@ int
main(int argc, char *argv[])
{
int newargc = 0;
+ int rpathcnt = 0;
char **newargv = NULL;
+ char **rpaths = NULL;
+ char **lpaths = NULL;
char *wrapper = argv[0];
char *wrapperctarget = NULL;
char verbose = getenv("BINUTILS_CONFIG_VERBOSE") != NULL;
@@ -214,7 +217,6 @@ main(int argc, char *argv[])
size_t len;
int i;
int j;
- int k;
DIR *dirp;
struct dirent *dp;
@@ -287,10 +289,12 @@ main(int argc, char *argv[])
/* walk over the arguments to see if there's anything interesting
* for us and calculate the final number of arguments */
for (i = 1; i < argc; i++) {
- /* -L: account space for the matching -R */
if (argv[i][0] == '-') {
+ /* -L: account space for the matching -R */
if (argv[i][1] == 'L')
newargc++;
+ if (argv[i][1] == 'R' || strcmp(argv[i], "-rpath") == 0)
+ rpathcnt++;
if (argv[i][1] == 'v' || argv[i][1] == 'V')
verbose = 1;
if ((strcmp(argv[i], "-macosx_version_min") == 0 ||
@@ -316,8 +320,6 @@ main(int argc, char *argv[])
darwin_dt_ver += (int)strtol(p + 1, &p, 10);
}
- /* Note: Code below assumes that newargc is the count of -L arguments. */
-
/* If a package being cross-compiled injects standard directories, it's
* non-cross-compilable on any platform, prefix or no prefix. So no
* need to add PREFIX- or CTARGET-aware libdirs. */
@@ -341,13 +343,15 @@ main(int argc, char *argv[])
* -rpath and the path itself */
newargc *= 2;
- /* and we will be adding two for the each of
- * the two system paths as well */
- newargc += 4;
+ /* PREFIX rpaths */
+ newargc += 2 * 2;
}
- /* add the 2 prefix paths (-L) and -search_paths_first */
- newargc += 2 + 1;
+ /* PREFIX paths */
+ newargc += 3;
+
+ /* add -search_paths_first */
+ newargc += 1;
/* add -syslibroot <path> -platform_version macos <ver> 0.0 */
newargc += 6;
@@ -357,6 +361,27 @@ main(int argc, char *argv[])
}
}
+ /* Note: Code below assumes that newargc is the count of -L arguments. */
+
+ /* allocate space for -L lookups/uniqueifying */
+ lpaths = malloc(sizeof(lpaths[0]) * (newargc + 1));
+ if (lpaths == NULL) {
+ fprintf(stderr, "%s: failed to allocate memory for new arguments\n",
+ wrapper);
+ exit(1);
+ }
+ lpaths[0] = NULL;
+
+ if (!is_darwin || darwin_use_rpath) {
+ rpaths = malloc(sizeof(rpaths[0]) * (rpathcnt + 1));
+ if (rpaths == NULL) {
+ fprintf(stderr, "%s: failed to allocate memory for new arguments\n",
+ wrapper);
+ exit(1);
+ }
+ rpaths[0] = NULL;
+ }
+
/* account the original arguments */
newargc += argc;
/* we always add a sentinel */
@@ -476,8 +501,6 @@ main(int argc, char *argv[])
newargv[j++] = "-search_paths_first";
}
- /* position k right after the original arguments */
- k = j - 1 + argc;
for (i = 1; i < argc; i++, j++) {
if (is_darwin) {
/* skip platform version stuff, we already pushed it out */
@@ -486,7 +509,6 @@ main(int argc, char *argv[])
{
i++;
j--;
- k -= 2;
continue;
}
if (strcmp(argv[i], "-platform_version") == 0 &&
@@ -494,7 +516,6 @@ main(int argc, char *argv[])
{
i += 3;
j--;
- k -= 4;
continue;
}
}
@@ -504,10 +525,12 @@ main(int argc, char *argv[])
if (is_cross || (is_darwin && !darwin_use_rpath))
continue;
- /* on ELF targets we add runpaths for all found search paths */
- if (argv[i][0] == '-' && argv[i][1] == 'L') {
+ /* on ELF/Mach-O targets we add runpaths for all found search paths */
+ if (argv[i][0] == '-' && (argv[i][1] == 'L' || argv[i][1] == 'R')) {
char *path;
- size_t sze;
+ int pth;
+ char duplicate;
+ int before = j - 1;
/* arguments can be in many ways here:
* -L<path>
@@ -533,50 +556,129 @@ main(int argc, char *argv[])
if (builddir != NULL && strncmp(builddir, path, len) == 0)
continue;
- if (is_darwin) {
- newargv[k] = "-rpath";
- newargv[++k] = path;
- } else {
- sze = 2 + strlen(path) + 1;
- newargv[k] = malloc(sizeof(char) * sze);
- if (newargv[k] == NULL) {
- fprintf(stderr, "%s: failed to allocate memory for "
- "'%s' -R argument\n", wrapper, argv[i]);
- exit(1);
+ /* loop-search for this path, if it was emitted already,
+ * suppress it -- this is not just some fancy beautification!
+ * CLT15.3 on macOS warns about duplicate paths, and
+ * any project that triggers on these warnings causes
+ * problems, such as Ruby claiming the linker is broken */
+ duplicate = 0;
+ if (argv[i][1] == 'L') {
+ for (pth = 0; lpaths[pth] != NULL; pth++) {
+ if (strcmp(lpaths[pth], path) == 0) {
+ duplicate = 1;
+ break;
+ }
}
-
- snprintf(newargv[k], sze, "-R%s", path);
+ if (duplicate) {
+ j = before;
+ continue;
+ }
+ /* record path */
+ lpaths[pth++] = path;
+ lpaths[pth] = NULL;
+ } else if (!is_darwin || darwin_use_rpath) {
+ for (pth = 0; rpaths[pth] != NULL; pth++) {
+ if (strcmp(rpaths[pth], path) == 0) {
+ duplicate = 1;
+ break;
+ }
+ }
+ if (duplicate) {
+ j = before;
+ continue;
+ }
+ /* record path */
+ rpaths[pth++] = path;
+ rpaths[pth] = NULL;
}
+ } else if ((!is_darwin || darwin_use_rpath) &&
+ strcmp(argv[i], "-rpath") == 0)
+ {
+ char *path;
+ int pth;
+ char duplicate;
- k++;
+ path = argv[i + 1];
+ while (*path != '\0' && isspace(*path))
+ path++;
+ /* not absolute (or empty)?!? skip */
+ if (*path != '/')
+ continue;
+
+ /* does it refer to the build directory? skip */
+ if (builddir != NULL && strncmp(builddir, path, len) == 0)
+ continue;
+
+ duplicate = 0;
+ for (pth = 0; rpaths[pth] != NULL; pth++) {
+ if (strcmp(rpaths[pth], path) == 0) {
+ duplicate = 1;
+ break;
+ }
+ }
+ if (duplicate) {
+ j -= 2;
+ continue;
+ }
+ /* record path */
+ rpaths[pth++] = path;
+ rpaths[pth] = NULL;
}
}
/* add the custom paths */
if (!is_cross) {
+ int pth;
+#define path_not_exists(W,P) \
+ for (pth = 0; W[pth] != NULL; pth++) { \
+ if (strcmp(W[pth], P) == 0) \
+ break; \
+ } \
+ if (W[pth] == NULL)
+#define add_path(P) \
+ path_not_exists(lpaths, P) newargv[j++] = "-L" P
+#define add_path_rpath(P) \
+ path_not_exists(lpaths, P) { \
+ lpaths[pth++] = P; \
+ lpaths[pth] = NULL; \
+ newargv[j++] = "-L" P; \
+ }
+
if (is_darwin) {
/* FIXME: no support for cross-compiling *to* Darwin */
- newargv[k++] = "-L" EPREFIX "/usr/" CHOST "/lib/gcc";
- newargv[k++] = "-L" EPREFIX "/usr/lib";
- newargv[k++] = "-L" EPREFIX "/lib";
-
- if (darwin_use_rpath) {
- newargv[k++] = "-rpath";
- newargv[k++] = EPREFIX "/usr/lib";
- newargv[k++] = "-rpath";
- newargv[k++] = EPREFIX "/lib";
- }
+ add_path(EPREFIX "/usr/" CHOST "/lib/gcc");
+ add_path_rpath(EPREFIX "/usr/lib");
+ add_path_rpath(EPREFIX "/lib");
} else {
- newargv[k++] = "-L" EPREFIX "/usr/" CHOST "/lib/gcc";
- newargv[k++] = "-R" EPREFIX "/usr/" CHOST "/lib/gcc";
- newargv[k++] = "-L" EPREFIX "/usr/" CHOST "/lib";
- newargv[k++] = "-R" EPREFIX "/usr/" CHOST "/lib";
- newargv[k++] = "-L" EPREFIX "/usr/lib";
- newargv[k++] = "-R" EPREFIX "/usr/lib";
- newargv[k++] = "-L" EPREFIX "/lib";
- newargv[k++] = "-R" EPREFIX "/lib";
+ add_path_rpath(EPREFIX "/usr/" CHOST "/lib/gcc");
+ add_path_rpath(EPREFIX "/usr/" CHOST "/lib");
+ add_path_rpath(EPREFIX "/usr/lib");
+ add_path_rpath(EPREFIX "/lib");
+ }
+ }
+ /* add rpaths for -L entries */
+ if (!is_darwin || darwin_use_rpath) {
+ for (i = 0; lpaths[i] != NULL; i++) {
+ int pth;
+ path_not_exists(rpaths, lpaths[i]) {
+ size_t sze;
+ if (is_darwin && darwin_use_rpath) {
+ newargv[j++] = "-rpath";
+ newargv[j++] = lpaths[i];
+ } else if (!is_darwin) {
+ sze = 2 + strlen(lpaths[i]) + 1;
+ newargv[j] = malloc(sizeof(char) * sze);
+ if (newargv[j] == NULL) {
+ fprintf(stderr, "%s: failed to allocate memory for "
+ "'%s' -R argument\n", wrapper, argv[i]);
+ exit(1);
+ }
+
+ snprintf(newargv[j++], sze, "-R%s", lpaths[i]);
+ }
+ }
}
}
- newargv[k] = NULL;
+ newargv[j] = NULL;
if (verbose) {
fprintf(stderr, "%s: invoking %s with arguments:\n", wrapper, ld);
^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-04-04 20:29 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-25 18:33 [gentoo-commits] repo/proj/prefix:master commit in: sys-devel/binutils-config/, sys-devel/binutils-config/files/ Fabian Groffen
-- strict thread matches above, loose matches on Subject: below --
2024-04-04 20:29 Fabian Groffen
2024-03-08 21:13 Fabian Groffen
2024-01-20 20:05 Fabian Groffen
2023-12-16 8:19 Fabian Groffen
2021-01-13 19:41 Fabian Groffen
2019-05-30 9:13 Fabian Groffen
2017-12-25 19:47 Fabian Groffen
2017-11-25 18:33 Fabian Groffen
2015-12-15 19:49 Fabian Groffen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox