From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id F1F971382C5 for ; Mon, 7 Jun 2021 15:23:30 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 46A79E086B; Mon, 7 Jun 2021 15:23:30 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2A991E086B for ; Mon, 7 Jun 2021 15:23:30 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C7BCF340CAC for ; Mon, 7 Jun 2021 15:23:28 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 4B6C227E for ; Mon, 7 Jun 2021 15:23:27 +0000 (UTC) From: "Guilherme Amadio" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Guilherme Amadio" Message-ID: <1623079342.07433fc7688d7b49c29440b995719210bb441d22.amadio@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: profiles/features/prefix/standalone/ X-VCS-Repository: repo/gentoo X-VCS-Files: profiles/features/prefix/standalone/profile.bashrc X-VCS-Directories: profiles/features/prefix/standalone/ X-VCS-Committer: amadio X-VCS-Committer-Name: Guilherme Amadio X-VCS-Revision: 07433fc7688d7b49c29440b995719210bb441d22 X-VCS-Branch: master Date: Mon, 7 Jun 2021 15:23:27 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 147dca8e-3fac-4d6b-a6a9-630ec4238c17 X-Archives-Hash: fb9c40414b1adbcf76c1c8e593ce13bf commit: 07433fc7688d7b49c29440b995719210bb441d22 Author: Alexei Colin isi edu> AuthorDate: Fri Jan 22 05:01:50 2021 +0000 Commit: Guilherme Amadio gentoo org> CommitDate: Mon Jun 7 15:22:22 2021 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=07433fc7 profiles: prefixify dynamic linker for ppc64 Bug: https://bugs.gentoo.org/755551 The issue: prefix stage3 fails because the binaries built by the stage3 GCC toolchain fail to run, because they refer to the host's dynamic linker: $ which gawk /myprefix/usr/bin/gawk $ gawk --version gawk: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by gawk) $ readelf -l $(which gawk) | grep -i 'program [Requesting program interpreter: /lib64/ld64.so.2] The cause is that the toolchain doesn't insert a prefixified path into the binary because the default -dynamic-linker is not prefixified: $ which powerpc64le-unknown-linux-gnu-gcc /myprefix/usr/bin/powerpc64le-unknown-linux-gnu-gcc $ echo 'int main() { return 0; }' > test.c $ powerpc64le-unknown-linux-gnu-gcc -v -o test test.c COLLECT_GCC_OPTIONS='-v' '-o' 'testx' /myprefix/usr/libexec/gcc/powerpc64le-unknown-linux-gnu/10.2.0/collect2 --eh-frame-hdr -V -m elf64lppc -dynamic-linker /libb64/ld64.so.2 ... The root cause: Prefixifying is done by patching the GCC source code with a sed expression in profile.bashrc. The pattern in that sed expression doesn't match the source file for ppc64 (aka. rs6000). The ppc64 file differs from the rest in that it has a macro for the prefix. Notes on fix: I opted to special-case another sed expression to set that unique DYNAMIC_LINKER_PREFIX macro rather than attempt to make a single sed expression that would modify the *_DYNAMIC_LINKER macros in ppc64. Rationale is that if someone happens to look at the patched source file, it would make more sense if the DYNAMIC_LINKER_PREFIX is set to our prefix, instead of if that macro is set to empty but the *_DYNAMIC_LINKER macros have effectively two prefixes, one hardcoded added by sed, one from the DYNAMIC_LINKER_PREFIX macro. Signed-off-by: Alexei Colin alexeicolin.com> Signed-off-by: Guilherme Amadio gentoo.org> profiles/features/prefix/standalone/profile.bashrc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/profiles/features/prefix/standalone/profile.bashrc b/profiles/features/prefix/standalone/profile.bashrc index ff58c68a562..76ef2455b35 100644 --- a/profiles/features/prefix/standalone/profile.bashrc +++ b/profiles/features/prefix/standalone/profile.bashrc @@ -14,7 +14,11 @@ if [[ ${CATEGORY}/${PN} == sys-devel/gcc && ${EBUILD_PHASE} == configure ]]; the einfo "Prefixifying dynamic linkers..." for h in gcc/config/*/*linux*.h; do ebegin " Updating $h" - sed -i -r "/_DYNAMIC_LINKER/s,([\":])(/lib),\1${EPREFIX}\2,g" $h + if [[ "${h}" == gcc/config/rs6000/linux*.h ]]; then + sed -i -r "s,(DYNAMIC_LINKER_PREFIX\s+)\"\",\1\"${EPREFIX}\",g" $h + else + sed -i -r "/_DYNAMIC_LINKER/s,([\":])(/lib),\1${EPREFIX}\2,g" $h + fi eend $? done