commit:     3e4147bc0c77d9ea192a8eb273bc5926def4c8ca
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 16 03:08:26 2018 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Tue Jan 16 03:27:06 2018 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=3e4147bc

bootstrap-prefix.sh: RAP: bootstrap binutils before gcc in stage3

  The stage2 binutils searches the host by default, and should not be
  used to link stage3 gcc. Stage3 binutils is need by stage3 gcc.

  There were problems to bootstrap binutils before gcc, most notably
  that binutils needs to link to zlib.  If that zlib is from stage2,
  or before glibc in stage3, it results in incompatible glibc symbols.
  If that zlib is from stage3 after glibc, rpath is needed because
  stage2 gcc does not have dynamic linker pointed to stage3 glibc.
  Adding rpath to LDFLAGS triggers glibc runtime failure.

  In this commit:

  1. filter-ldflags has been added to glibc ebuild to filter out
     rpath.  This has been committed to gentoo (a8ba9d20964964e7).

  2. after stage3 binutils is boostrapped, stage2 ld is renamed so
     that stage2 gcc can use stage3 ld.

  By doing so, we achieve a more logic-consistent bootstrap path.

 scripts/bootstrap-prefix.sh | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh
index 7996ccdfae..b85c777174 100755
--- a/scripts/bootstrap-prefix.sh
+++ b/scripts/bootstrap-prefix.sh
@@ -1570,7 +1570,7 @@ bootstrap_stage3() {
        configure_toolchain || return 1
        export CONFIG_SHELL="${ROOT}"/tmp/bin/bash
        export CPPFLAGS="-isystem ${ROOT}/usr/include"
-       export LDFLAGS="-L${ROOT}/usr/$(get_libdir)"
+       export LDFLAGS="-L${ROOT}/usr/$(get_libdir) 
-Wl,-rpath=${ROOT}/usr/$(get_libdir)"
        unset CC CXX
 
        emerge_pkgs() {
@@ -1621,12 +1621,16 @@ bootstrap_stage3() {
                        app-portage/elt-patches
                        sys-kernel/linux-headers
                        sys-libs/glibc
+                       sys-devel/binutils-config
                        sys-libs/zlib
+                       ${linker}
                )
 
                BOOTSTRAP_RAP=yes \
                emerge_pkgs --nodeps "${pkgs[@]}" || return 1
                grep -q 'apiversion=9999' "${ROOT}"/usr/bin/perl && rm 
"${ROOT}"/usr/bin/perl
+               # remove stage2 ld so that stage3 ld is used by stage2 gcc.
+               [[ -f ${ROOT}/tmp/usr/${CHOST}/bin/ld ]] && mv 
${ROOT}/tmp/usr/${CHOST}/bin/ld{,.stage2}
        else
                pkgs=(
                        sys-apps/gentoo-functions
@@ -1687,12 +1691,6 @@ bootstrap_stage3() {
        [[ ${CHOST} == *-darwin* ]] && rm -f 
"${ROOT}"{,/tmp}/usr/bin/{,${CHOST}-}nm
 
        rm -f "${ROOT}"/etc/ld.so.conf.d/stage2.conf
-       if is-rap ; then
-               "${ROOT}"/sbin/ldconfig
-               # should be linked against stage3 zlib, and can only
-               # be compiled after gcc has the headers of Prefix glibc.
-               emerge_pkgs --nodeps sys-devel/binutils-config ${linker} || 
return 1
-       fi
 
        ( cd "${ROOT}"/usr/bin && test ! -e python && rm -f python2.7 )
        # Use $ROOT tools where possible from now on.

Reply via email to