From d54c9b4482bdd17f1a603749dfe829707c644054 Mon Sep 17 00:00:00 2001 From: Alexei Colin Date: Thu, 2 Apr 2020 22:20:15 -0400 Subject: [PATCH] stage3: overwrite loader of stage2 gcc; bug #702342 Signed-off-by: Alexei Colin --- scripts/bootstrap-prefix.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh index 25e091c..a82f7a8 100755 --- a/scripts/bootstrap-prefix.sh +++ b/scripts/bootstrap-prefix.sh @@ -938,6 +938,48 @@ bootstrap_gnu() { einfo "${PN}-${PV} successfully bootstrapped" } +bootstrap_autotools_tarball() { + PN="${1}" + PV="${2}" + PEXT="${3}" + A=${PN}-${PV}.${PEXT} + + einfo "Bootstrapping ${A%-*}" + + efetch ${DISTFILES_G_O}/distfiles/${A} || return 1 + + einfo "Unpacking ${A%%-*}" + export S="${PORTAGE_TMPDIR}/${PN}-${PV}" + rm -rf "${S}" + mkdir -p "${S}" + cd "${S}" + if [[ ${PEXT} == "tar.gz" ]] ; then + gzip -dc "${DISTDIR}"/${A} | tar -xf - || return 1 + elif [[ ${PEXT} == "tar.xz" ]] ; then + xz -dc "${DISTDIR}"/${A} | tar -xf - || return 1 + elif [[ ${PEXT} == "tar.bz2" ]] ; then + bzip2 -dc "${DISTDIR}"/${A} | tar -xf - || return 1 + elif [[ ${PEXT} == "tar" ]] ; then + tar -xf "${DISTDIR}"/${A} || return 1 + else + einfo "unhandled extension: $PEXT" + return 1 + fi + S="${S}"/${PN}-${PV} + cd "${S}" + + local makeopts=( ${MAKEOPTS} ) + + einfo "Compiling ${A%-*}" + CHOST= ${CONFIG_SHELL} ./configure --prefix="${ROOT}"/tmp/usr || return 1 + $MAKE "${makeopts[@]}" || return 1 + + einfo "Installing ${A%-*}" + $MAKE "${makeopts[@]}" -j1 install || return 1 + + einfo "${A%-*} bootstrapped" +} + PYTHONMAJMIN=3.6 # keep this number in line with PV below for stage1,2 bootstrap_python() { PV=3.6.10 @@ -1256,6 +1298,10 @@ bootstrap_patch() { bootstrap_gnu patch 2.6.1 } +bootstrap_patchelf() { + bootstrap_autotools_tarball patchelf 0.10 tar.bz2 +} + bootstrap_gawk() { bootstrap_gnu gawk 4.0.1 || bootstrap_gnu gawk 4.0.0 || \ bootstrap_gnu gawk 3.1.8 @@ -1401,6 +1447,9 @@ bootstrap_stage1() { [[ $(tar --version 2>&1) == *GNU* ]] || (bootstrap_tar) || return 1 [[ $(patch --version 2>&1) == *"patch 2."[6-9]*GNU* ]] \ || (bootstrap_patch) || return 1 + [[ $(patchelf --version 2>&1) == *"patchelf 0.10" ]] \ + || [[ $(patchelf --version 2>&1) == *"patchelf 0.9" ]] \ + || (bootstrap_patchelf) || return 1 [[ $(grep --version 2>&1) == *GNU* ]] || (bootstrap_grep) || return 1 [[ $(awk --version < /dev/null 2>&1) == *GNU" Awk "[456789]* ]] \ || bootstrap_gawk || return 1 @@ -1921,6 +1970,24 @@ bootstrap_stage3() { # use the new dynamic linker in place of rpath from now on. RAP_DLINKER=$(echo "${ROOT}"/$(get_libdir)/ld*.so.[0-9]) export LDFLAGS="-L${ROOT}/usr/$(get_libdir) -Wl,--dynamic-linker=${RAP_DLINKER}" + + # Use the new dynamic linker even for the stage2 gcc, so that + # stage2 gcc does not break while building stage3 gcc when + # LD_LIBRARY_PATH starts to override some of the gcc libraries + # (libstdc++.so) from host versions to stage3 versions, which + # may be incompatible with the host versions of the remaining + # non-overriden libraries (libc.so). The alternative to + # changing interpreter now would be to link stage2 gcc + # statically in the first place, so that it is not affected by + # LD_LIBRARY_PATH, but that doesn't (and can't?) happen on + # hosts that do not have libc.a (glibc-static) and libstdc++.a + # (libstdc++-static) installed. Workaround for Bug #702342. + find "${ROOT}"/tmp/usr/bin/${CHOST}-* "${ROOT}"/tmp/usr/libexec/gcc/${CHOST} \ + \( -type f -or -type l \) -executable \ + -not \( -name '*.la' -or -name '*.a' -or -name '*.so.*' -or -name '*.so' \) \ + -exec patchelf --set-interpreter "${RAP_DLINKER}" {} \; \ + || return 1 + BOOTSTRAP_RAP=yes \ with_stack_emerge_pkgs --nodeps "${pkgs[@]}" || return 1 -- 1.8.3.1