commit: ae09a2683a18f7148048d0b037ec80227e1571ce
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 23 13:54:32 2023 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Jun 23 13:54:32 2023 +0000
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=ae09a268
scripts/bootstrap-prefix: provide safe compiler wrappers in stage1
On systems like Ubuntu installing gcc doesn't mean installing g++, so
when PATH isn't set to just host (original) before looking up g++, it
ends up on the wrapper being created, causing an endless loop at
runtime.
Thus, check if gcc/g++ can be found in host PATH, if not, error out
suggesting to install or make them available.
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
scripts/bootstrap-prefix.sh | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh
index c50340fb91..d722e0139f 100755
--- a/scripts/bootstrap-prefix.sh
+++ b/scripts/bootstrap-prefix.sh
@@ -1490,15 +1490,27 @@ bootstrap_stage1() {
# If the version of our binutils an older one,
they may not
# provide what the system gcc is configured to
use.
# We need to direct the system gcc to find the
system binutils.
+ EXEC="$(PATH="${ORIGINAL_PATH}" type -P gcc)"
+ if [[ -z ${EXEC} ]] ; then
+ eerror "could not find 'gcc' in your
PATH!"
+ eerror "please install gcc or provide
access via PATH or symlink"
+ return 1
+ fi
cat >> "${ROOT}"/tmp/usr/local/bin/gcc <<-EOF
#! /bin/sh
PATH="${ORIGINAL_PATH}" export PATH
- exec "$(type -P gcc)" "\$@"
+ exec "${EXEC}" "\$@"
EOF
+ EXEC="$(PATH="${ORIGINAL_PATH}" type -P g++)"
+ if [[ -z ${EXEC} ]] ; then
+ eerror "could not find 'g++' in your
PATH!"
+ eerror "please install g++ or provide
access via PATH or symlink"
+ return 1
+ fi
cat >> "${ROOT}"/tmp/usr/local/bin/g++ <<-EOF
#! /bin/sh
PATH="${ORIGINAL_PATH}" export PATH
- exec "$(type -P g++)" "\$@"
+ exec "${EXEC}" "\$@"
EOF
chmod 755 "${ROOT}"/tmp/usr/local/bin/g{cc,++}
fi