commit:     fbe97b8ff249b261bd09b0e90d209bb9cb23b106
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Mon May 23 17:23:55 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Fri Jun 10 01:47:29 2016 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=fbe97b8f

scripts/bootstrap-prefix.sh: support sys-libs/glibc.

  - do not need a linker in stage2 on RAP.
  - binutils-config and ldconfig should be called explicitly
  - lto of gcc should be disabled. ld points to the host dynamic
    loader and gcc points to the RAP one, ld cannot load the gcc
    lto plugin.

 scripts/bootstrap-prefix.sh | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh
index 239aec0..0d209b2 100755
--- a/scripts/bootstrap-prefix.sh
+++ b/scripts/bootstrap-prefix.sh
@@ -1271,7 +1271,7 @@ bootstrap_stage2() {
                sys-devel/flex
                sys-devel/bison
                sys-devel/patch
-               sys-devel/binutils-config
+               $(rapx "" sys-devel/binutils-config)
                $([[ ${CHOST} == *-aix* ]] && echo sys-apps/diffutils ) # gcc 
can't deal with aix diffutils, gcc PR14251
        )
 
@@ -1282,6 +1282,7 @@ bootstrap_stage2() {
        
        # Build a linker and compiler that live in ${ROOT}/tmp, but
        # produce binaries in ${ROOT}.
+       is-rap || \
        USE="${USE} -cxx" \
        TPREFIX="${ROOT}" \
        emerge_pkgs --nodeps ${linker} || return 1
@@ -1291,6 +1292,7 @@ bootstrap_stage2() {
        # package.use to disable in the temporary prefix.  
        echo "dev-libs/gmp -cxx" >> "${ROOT}"/tmp/etc/portage/package.use
 
+       BOOTSTRAP_RAP_STAGE2=yes \
        EXTRA_ECONF="--disable-bootstrap" \
        GCC_MAKE_TARGET=all \
        TPREFIX="${ROOT}" \
@@ -1385,6 +1387,24 @@ bootstrap_stage3() {
        )
        emerge_pkgs --nodeps "${pkgs[@]}" || return 1
 
+       if is-rap ; then
+               binutils-config 1 || return 1
+               # We need ${ROOT}/usr/bin/perl to merge glibc.
+               if [[ ! -x "${ROOT}"/usr/bin/perl ]]; then
+                       # trick "perl -V:apiversion" check of glibc-2.19.
+                       echo -e "#!${ROOT}/bin/sh\necho 'apiversion=9999'" > 
"${ROOT}"/usr/bin/perl
+                       chmod +x "${ROOT}"/usr/bin/perl
+               fi
+               # Tell dynamic loader the path of libgcc_s.so of stage2
+               if [[ ! -f "${ROOT}"/etc/ld.so.conf.d/stage2.conf ]]; then
+                       mkdir -p "${ROOT}"/etc/ld.so.conf.d
+                       dirname $(gcc -print-libgcc-file-name) > 
"${ROOT}"/etc/ld.so.conf.d/stage2.conf
+               fi
+               BOOTSTRAP_RAP=yes \
+               emerge_pkgs --nodeps sys-kernel/linux-headers sys-libs/glibc \
+                       && "${ROOT}"/usr/sbin/ldconfig || return 1
+       fi
+
        # On some hosts, gcc gets confused now when it uses the new linker,
        # see for instance bug #575480.  While we would like to hide that
        # linker, we can't since we want the compiler to pick it up.
@@ -1398,11 +1418,17 @@ bootstrap_stage3() {
        ( cd "${ROOT}"/usr/bin && test ! -e python && ln -s 
"${ROOT}"/tmp/usr/bin/python2.7 )
        # in addition, avoid collisions
        rm -Rf "${ROOT}"/tmp/usr/lib/python2.7/site-packages/clang
+
+       RAP_DLINKER=$(echo "${ROOT}"/$(get_libdir)/ld*.so.[0-9])
        # try to get ourself out of the mudd, bug #575324
-       EXTRA_ECONF="--disable-compiler-version-checks" \
+       EXTRA_ECONF="--disable-compiler-version-checks $(rapx --disable-lto)" \
+       LDFLAGS="${LDFLAGS} $(rapx -Wl,--dynamic-linker=${RAP_DLINKER})" \
        emerge_pkgs --nodeps ${compiler} || return 1
-       ( cd "${ROOT}"/usr/bin && test ! -e python && rm -f python2.7 )
+       # undo libgcc_s.so path of stage2
+       rm -f "${ROOT}"/etc/ld.so.conf.d/stage2.conf
+       "${ROOT}"/usr/sbin/ldconfig || return 1
 
+       ( cd "${ROOT}"/usr/bin && test ! -e python && rm -f python2.7 )
        # Use $ROOT tools where possible from now on.
        rm -f "${ROOT}"/bin/sh
        ln -s bash "${ROOT}"/bin/sh

Reply via email to