From 1c436ab541c61eee970bb1bb6da93d48a05d7824 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Wed, 12 Jun 2024 14:59:45 +0200 Subject: stage-0/gcc: use our own sh as interpreter Unfortunately, this does not entirely removes the requirement of a /bin/sh being present, as awk(1) is invoked during the build to use popen(3) in one place, a libc function that has a hard-coded reference to /bin/sh. Nevertheless, using our interpreter wherever possible greatly reduces the dependency on the host system. --- src/bootstrap/stage-0-gcc.TARGETS | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/bootstrap/stage-0-gcc.TARGETS b/src/bootstrap/stage-0-gcc.TARGETS index 33812ef..5f067a3 100644 --- a/src/bootstrap/stage-0-gcc.TARGETS +++ b/src/bootstrap/stage-0-gcc.TARGETS @@ -103,6 +103,9 @@ , "export MAKE=${LOCALBASE}/bin/make" , "export PATH=$(pwd)/binutils/bin:${LOCALBASE}/bin:$PATH" , "export BUILD_ROOT_DIR=${ACTION_DIR}" + , "export SHELL=${LOCALBASE}/bin/sh" + , "export CONFIG_SHELL=${LOCALBASE}/bin/sh" + , "export CXX=no" , "unset LDFLAGS" , "CONF_ARGS=" , "if [ -n \"$HOST_SYSTEM_HDR_DIR\" ]; then" @@ -131,8 +134,16 @@ , "cp -r binutils/. ${DESTDIR}/." , "chmod -R +w ${DESTDIR}/*" , "cd src" + , "for f in $(find . -type f -exec grep -q '#! */bin/sh' {} \\; -print)" + , "do" + , " cp $f $f.__work" + , " rm $f" + , " chmod 755 $f.__work" + , " sed -i 's|#! */bin/sh|#!'\"${SHELL}\"'|g' $f.__work" + , " mv $f.__work $f" + , "done" , "export check_msgfmt=no # do not use system's msgfmt, if available" - , "./configure --prefix=/ --enable-languages=c,c++ --disable-multilib --disable-shared --disable-lto --disable-gcov --disable-libmudflap --disable-libgomp --disable-libssp --disable-nls --disable-libitm ${CONF_ARGS} >configure.log 2>&1 || (cat configure.log && exit 1)" + , "${SHELL} ./configure --prefix=/ --enable-languages=c,c++ --disable-multilib --disable-shared --disable-lto --disable-gcov --disable-libmudflap --disable-libgomp --disable-libssp --disable-nls --disable-libitm ${CONF_ARGS} >configure.log 2>&1 || (cat configure.log && exit 1)" , "${MAKE} -j${NJOBS} >build.log 2>&1 || (cat configure.log build.log && exit 1)" , "${MAKE} -j${NJOBS} DESTDIR=${DESTDIR} install-strip >>build.log 2>&1 || (cat configure.log build.log && exit 1)" , "cd ${DESTDIR}" -- cgit v1.2.3