commit:     d4625ed24127110822a59246fae71513a5b2b1de
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Sat May 28 07:03:25 2016 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Wed Jun 15 08:02:33 2016 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=d4625ed2

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

  - 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.

  - stage tools should be used first in stage3.

  - makeinfo, perl are faked.

  - no need to copy libgcc on RAP.
    ld.so of glibc does that.

  - install texinfo for glibc.

 scripts/bootstrap-prefix.sh | 99 ++++++++++++++++++++++++++++++++++-----------
 1 file changed, 76 insertions(+), 23 deletions(-)

diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh
index 999e3b7..e524b7a 100755
--- a/scripts/bootstrap-prefix.sh
+++ b/scripts/bootstrap-prefix.sh
@@ -1285,9 +1285,11 @@ bootstrap_stage2() {
        emerge_pkgs --nodeps "${pkgs[@]}" || return 1
        
        # Build a linker and compiler that live in ${ROOT}/tmp, but
-       # produce binaries in ${ROOT}.
+       # produce binaries in ${ROOT}. Debian multiarch needs ld to
+       # support sysroot
        USE="${USE} -cxx" \
        TPREFIX="${ROOT}" \
+       EXTRA_ECONF="--with-sysroot=/" \
        emerge_pkgs --nodeps ${linker} || return 1
 
        # gmp has cxx flag enabled by default. When dealing with a host
@@ -1295,6 +1297,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}" \
@@ -1321,7 +1324,7 @@ bootstrap_stage2() {
                # multilib.eclass -- can't blame it at this point really)
                # do it ourselves here to make the bootstrap continue
                ( cd "${ROOT}"/tmp/usr/bin && ln -s clang ${CHOST}-clang && ln 
-s clang++ ${CHOST}-clang++ )
-       else
+       elif ! is-rap ; then
                # make sure the EPREFIX gcc shared libraries are there
                mkdir -p "${ROOT}"/usr/${CHOST}/lib/gcc
                cp "${ROOT}"/tmp/usr/${CHOST}/lib/gcc/* 
"${ROOT}"/usr/${CHOST}/lib/gcc
@@ -1360,6 +1363,8 @@ bootstrap_stage3() {
        unset CC CXX
 
        emerge_pkgs() {
+               # stage3 tools should be used first.
+               DEFAULT_PATH=$(echo "${ROOT}"/{,tmp/}{,usr/}{s,}bin | tr ' ' 
':') \
                EPREFIX="${ROOT}" \
                do_emerge_pkgs "$@"
        }
@@ -1367,25 +1372,65 @@ bootstrap_stage3() {
        # GCC sometimes decides that it needs to run makeinfo to update some
        # info pages from .texi files.  Obviously we don't care at this
        # stage and rather have it continue instead of abort the build
-       export MAKEINFO="echo makeinfo GNU texinfo 4.13"
-       
-       # Build a native compiler.
-       pkgs=(
-               $([[ ${CHOST} == *-aix* ]] && echo dev-libs/libiconv ) # bash 
dependency
-               sys-libs/ncurses
-               sys-libs/readline
-               app-shells/bash
-               sys-apps/sed
-               app-arch/xz-utils
-               sys-apps/gentoo-functions
-               sys-apps/baselayout-prefix
-               sys-devel/m4
-               sys-devel/flex
-               sys-devel/binutils-config
-               sys-libs/zlib
-               ${linker}
-       )
-       emerge_pkgs --nodeps "${pkgs[@]}" || return 1
+       [[ -x "${ROOT}"/usr/bin/makeinfo ]] || cat > "${ROOT}"/usr/bin/makeinfo 
<<EOF
+#!${ROOT}/bin/bash
+echo "makeinfo GNU texinfo 4.13"
+for a in \$@; do
+case \$a in
+--*) f=\$(echo "\$a" | sed -r 's,--.*=(.*),\1,') ;;
+-*) ;;
+*) f=\$a ;;
+esac
+[[ -e \$f ]] || touch \$f
+done
+EOF
+       chmod +x "${ROOT}"/usr/bin/makeinfo
+       export INSTALL_INFO="${ROOT}"/usr/bin/makeinfo
+
+       if is-rap ; then
+               # 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
+
+               pkgs=(
+                       sys-apps/baselayout
+                       sys-apps/gentoo-functions
+                       sys-devel/binutils-config
+                       ${linker}
+                       sys-kernel/linux-headers
+                       sys-libs/glibc
+                       sys-libs/zlib
+               )
+
+               BOOTSTRAP_RAP=yes \
+               emerge_pkgs --nodeps "${pkgs[@]}" || return 1
+       else
+               pkgs=(
+                       $([[ ${CHOST} == *-aix* ]] && echo dev-libs/libiconv ) 
# bash dependency
+                       sys-libs/ncurses
+                       sys-libs/readline
+                       app-shells/bash
+                       sys-apps/sed
+                       app-arch/xz-utils
+                       sys-apps/gentoo-functions
+                       sys-apps/baselayout-prefix
+                       sys-devel/m4
+                       sys-devel/flex
+                       sys-devel/binutils-config
+                       sys-libs/zlib
+                       ${linker}
+               )
+
+               emerge_pkgs --nodeps "${pkgs[@]}" || 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
@@ -1400,11 +1445,16 @@ 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
 
+       ( 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
@@ -1475,6 +1525,9 @@ bootstrap_stage3() {
        CPPFLAGS="-DGNUSTEP_BASE_VERSION" \
        CFLAGS= CXXFLAGS= USE="-git" emerge -u system || return 1
 
+       # TODO, glibc should depend on texinfo
+       is-rap && { emerge sys-apps/texinfo || return 1; }
+
        # remove anything that we don't need (compilers most likely)
        emerge --depclean
 

Reply via email to