commit:     b023986de7d466d361798bae98f45f8ba7a42e8a
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sat Apr  7 10:40:14 2018 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sat Apr  7 10:42:41 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b023986d

sys-devel/binutils: fix ldscrips ${CTARGET} search path, bug #147155

This change fixes long-standing search path issue in Gentoo's binutils:

Before the change search path was the following:
    /usr/${CTARGET}/lib/ldscripts
Note: it points to $SYSROOT, not to native cross-tools.

After the change search path is the following:
    /usr/${CHOST}/${CTARGET}/lib/ldscripts

Added two notes to the ebuild on how things are supposed to work:
- Note [slotting support]
- Note [tooldir hack for ldscripts]

Applied change to 2.30-r1 and live ebuilds.

Reported-by: Heiko Rosemann
Closes: https://bugs.gentoo.org/147155
Package-Manager: Portage-2.3.28, Repoman-2.3.9

 ...inutils-9999.ebuild => binutils-2.30-r1.ebuild} | 41 +++++++++++++++++++---
 sys-devel/binutils/binutils-9999.ebuild            | 36 +++++++++++++++++--
 2 files changed, 70 insertions(+), 7 deletions(-)

diff --git a/sys-devel/binutils/binutils-9999.ebuild 
b/sys-devel/binutils/binutils-2.30-r1.ebuild
similarity index 85%
copy from sys-devel/binutils/binutils-9999.ebuild
copy to sys-devel/binutils/binutils-2.30-r1.ebuild
index f0c8730c819..145bbe7e290 100644
--- a/sys-devel/binutils/binutils-9999.ebuild
+++ b/sys-devel/binutils/binutils-2.30-r1.ebuild
@@ -19,6 +19,8 @@ IUSE="+cxx doc multitarget +nls static-libs test"
 #                      for the patchsets
 #                      Default: dilfridge :)
 
+PATCH_VER=1
+
 case ${PV} in
        9999)
                BVER="git"
@@ -29,10 +31,11 @@ case ${PV} in
                ;;
        *)
                BVER=${PV}
-               SRC_URI="mirror://gnu/binutils/binutils-${BVER}.tar.xz"
+               SRC_URI="mirror://gnu/binutils/binutils-${BVER}.tar.xz 
https://sourceware.org/pub/binutils/releases/binutils-${BVER}.tar.xz";
                ;;
 esac
 SLOT="${BVER}"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 
~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd"
 
 #
 # The Gentoo patchset
@@ -146,10 +149,11 @@ src_configure() {
        INCPATH=${LIBPATH}/include
        DATAPATH=/usr/share/binutils-data/${CTARGET}/${BVER}
        if is_cross ; then
-               BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${BVER}
+               TOOLPATH=/usr/${CHOST}/${CTARGET}
        else
-               BINPATH=/usr/${CTARGET}/binutils-bin/${BVER}
+               TOOLPATH=/usr/${CTARGET}
        fi
+       BINPATH=${TOOLPATH}/binutils-bin/${BVER}
 
        # Make sure we filter $LINGUAS so that only ones that
        # actually work make it through #42033
@@ -251,7 +255,8 @@ src_configure() {
 
 src_compile() {
        cd "${MY_BUILDDIR}"
-       emake all
+       # see Note [tooldir hack for ldscripts]
+       emake tooldir="${EPREFIX}${TOOLPATH}" all
 
        # only build info pages if the user wants them
        if use doc ; then
@@ -272,6 +277,7 @@ src_install() {
        local x d
 
        cd "${MY_BUILDDIR}"
+       # see Note [tooldir hack for ldscripts]
        emake DESTDIR="${D}" tooldir="${EPREFIX}${LIBPATH}" install
        rm -rf "${ED}"/${LIBPATH}/bin
        use static-libs || find "${ED}" -name '*.la' -delete
@@ -380,3 +386,30 @@ pkg_postrm() {
                binutils-config ${CTARGET}-${BVER}
        fi
 }
+
+# Note [slotting support]
+# -----------------------
+# Gentoo's layout for binutils files is non-standard as Gentoo
+# supports slotted installation for binutils. But many tools
+# still expect binutils to reside in known locations.
+# binutils-config package restores symlinks into known locations,
+# like:
+#    /usr/bin/${CTARGET}-<tool>
+#    /usr/bin/${CHOST}/${CTARGET}/lib/ldscrips
+#    /usr/include/
+#
+# Note [tooldir hack for ldscripts]
+# ---------------------------------
+# Build system does not ./configure to tweak evey location we need
+# for slotting binutils. This note is about SCRIPTDIR define.
+#
+# SCRIPDIR defines 'ldscripts/' directory location. SCRIPDIR value
+# is set at build-time in ld/Makefile.am as: 'scriptdir = $(tooldir)/lib'
+# and hardcoded as -DSCRIPTDIR='"$(scriptdir)"' at compile time.
+# Thus we can't just move files around after compilation finished.
+#
+# Our goal is the following:
+# - at build-time set scriptdir to point to symlinked location:
+#   ${TOOLPATH}: /usr/${CHOST} (or /usr/${CHOST}/${CTARGET} for cross-case)
+# - at install-time set scriptdir to point to slotted location:
+#   ${LIBPATH}: /usr/$(get_libdir)/binutils/${CTARGET}/${BVER}

diff --git a/sys-devel/binutils/binutils-9999.ebuild 
b/sys-devel/binutils/binutils-9999.ebuild
index f0c8730c819..1c3f3623a94 100644
--- a/sys-devel/binutils/binutils-9999.ebuild
+++ b/sys-devel/binutils/binutils-9999.ebuild
@@ -146,10 +146,11 @@ src_configure() {
        INCPATH=${LIBPATH}/include
        DATAPATH=/usr/share/binutils-data/${CTARGET}/${BVER}
        if is_cross ; then
-               BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${BVER}
+               TOOLPATH=/usr/${CHOST}/${CTARGET}
        else
-               BINPATH=/usr/${CTARGET}/binutils-bin/${BVER}
+               TOOLPATH=/usr/${CTARGET}
        fi
+       BINPATH=${TOOLPATH}/binutils-bin/${BVER}
 
        # Make sure we filter $LINGUAS so that only ones that
        # actually work make it through #42033
@@ -251,7 +252,8 @@ src_configure() {
 
 src_compile() {
        cd "${MY_BUILDDIR}"
-       emake all
+       # see Note [tooldir hack for ldscripts]
+       emake tooldir="${EPREFIX}${TOOLPATH}" all
 
        # only build info pages if the user wants them
        if use doc ; then
@@ -272,6 +274,7 @@ src_install() {
        local x d
 
        cd "${MY_BUILDDIR}"
+       # see Note [tooldir hack for ldscripts]
        emake DESTDIR="${D}" tooldir="${EPREFIX}${LIBPATH}" install
        rm -rf "${ED}"/${LIBPATH}/bin
        use static-libs || find "${ED}" -name '*.la' -delete
@@ -380,3 +383,30 @@ pkg_postrm() {
                binutils-config ${CTARGET}-${BVER}
        fi
 }
+
+# Note [slotting support]
+# -----------------------
+# Gentoo's layout for binutils files is non-standard as Gentoo
+# supports slotted installation for binutils. But many tools
+# still expect binutils to reside in known locations.
+# binutils-config package restores symlinks into known locations,
+# like:
+#    /usr/bin/${CTARGET}-<tool>
+#    /usr/bin/${CHOST}/${CTARGET}/lib/ldscrips
+#    /usr/include/
+#
+# Note [tooldir hack for ldscripts]
+# ---------------------------------
+# Build system does not ./configure to tweak evey location we need
+# for slotting binutils. This note is about SCRIPTDIR define.
+#
+# SCRIPDIR defines 'ldscripts/' directory location. SCRIPDIR value
+# is set at build-time in ld/Makefile.am as: 'scriptdir = $(tooldir)/lib'
+# and hardcoded as -DSCRIPTDIR='"$(scriptdir)"' at compile time.
+# Thus we can't just move files around after compilation finished.
+#
+# Our goal is the following:
+# - at build-time set scriptdir to point to symlinked location:
+#   ${TOOLPATH}: /usr/${CHOST} (or /usr/${CHOST}/${CTARGET} for cross-case)
+# - at install-time set scriptdir to point to slotted location:
+#   ${LIBPATH}: /usr/$(get_libdir)/binutils/${CTARGET}/${BVER}

Reply via email to