This is the mail archive of the
libstdc++@sources.redhat.com
mailing list for the libstdc++ project.
shell script to build gcc with libstdc++-v3
- To: stdc++ <libstdc++ at sourceware dot cygnus dot com>
- Subject: shell script to build gcc with libstdc++-v3
- From: brent verner <brent at rcfile dot org>
- Date: Fri, 7 Jul 2000 10:56:42 -0400
Hi,
As I mentioned, here is a script that will build gcc with libstdc++.
It is nasty. I have run it and successfully built gcc-20000619 with
libstdc++-v3, simply by saying 'mkegcs-sh 20000619'. It ran to
completion without intervention. My environment is as follows:
linux 2.2.16
glibc-2.1.3
binutils-2.10.9 (with patch from
http://sourceware.cygnus.com/ml/libstdc++/2000-06/msg00138.html
gcc-2.95.2 (as bootstrapping compiler)
The script has a handle_error function where you can add error
correcting commands to handle _known_ errors when building in the
gcc cvs tree. Currently, there are two rules to handle errors that
I encountered (at one point in time or another) while building the
sources.
The script will create two directories when run.
./gcc
./gcc-build
If the 'gcc' directory is present, only fresh libstdc++-v3 will
be pulled, but make bootstrap will be run again, meaning this is
not a _fast_ way to rebuild just libstdc++-v3 (right now). I'll
tweak it to be a bit more useful if there is enough interest.
There may be bugs in this script. I would appreciate any feedback/help.
to make this useful in the interim while gcc stabilizes to a point that
libstdc++-v3 can be successfully built as a drop-in replacement.
Cheers! (i'm tired)
Brent
=======================================================================
#!/bin/bash
#
# License: GPL
# Butcher: Brent Verner <brent@rcfile.org>
# Version: if this script stays around long enough to get versioned,
# we've got more problems than it could ever solve :o
#
# OK. this is nasty-a$$ shell scripting at its worst...
# I'm almost ashamed to share it, but if it gets one more user
# on libstdc++-v3, my shame is paid for :)
#
#-=db=-
INSTALL_PREFIX=/usr/local/opt
GCC=gcc
GCC_DATE=$1
BEST_GCC="20000619"
CONFIG_CMD="../${GCC}/configure --prefix=${INSTALL_PREFIX} \
--enable-libstdcxx-v3 --enable-threads=posix \
--enable-long-long --enable-cshadow-headers \
--enable-namespaces --enable-languages=c,c++ "
CVSROOT=":pserver:anoncvs@anoncvs.cygnus.com:/cvs/gcc"
SCRIPT=`basename $0`
TOP=`pwd`
DATE=`date +%Y%m%d`
OUTFILE="${TOP}/mkegcs-${DATE}.out"
export INSTALL_PREFIX
export GCC_DATE
export CONFIG_CMD
export CVSROOT
export SCRIPT
export TOP
function usage {
echo "Usage:"
echo " $SCRIPT <YYYYMMDD>"
echo " - or -"
echo " $SCRIPT current"
echo ""
echo " Hint: the most recent known-working gcc snapshot is $BEST_GCC"
echo ""
echo "Purpose:"
echo " $SCRIPT will check out a specified cvs source tree and the most"
echo " recent libstdc++-v3 tree and build it for you."
echo ""
exit
}
function try_make {
B=`make $* 2>&1 | tee -a $OUTFILE | grep 'Error ' | sed 's/^.*\[\([^[]*\)\].*$/\1/g'`
BROKE_AT=`echo $B | cut -d ' ' -f 1`
if [ "$BROKE_AT" ]; then
if [ "x$LAST_BREAK" = "x$BROKE_AT" ]; then
echo "Fatal: error compiling $BROKE_AT occurred twice. I can't repair it."
echo "(all output from the build can be found in $OUTFILE)"
exit
fi
LAST_BREAK=$BROKE_AT
handle_error $BROKE_AT
try_make
fi
echo $BROKE_AT # success
}
function unrepaired {
echo "Fatal: I was unable to recover from the error encountered"
echo "while building $1. Sorry."
echo "(all output from the build can be found in $OUTFILE)"
exit
}
function handle_error {
A=$1
case "$A" in
locale-inst.lo)
echo "error encountered while building $A"
echo "trying to correct with:"
echo " make CXXFLAGS=\"-g -O1\" locale-inst.lo"
cd */libstdc++-v3/src
RV=`try_make CXXFLAGS="-g -O1" locale-inst.lo`
if [ "$RV" ]; then
unrepaired $A
fi
cd $BUILD_DIR
;;
locale.lo)
echo "Error: while compiling $A"
echo "trying to correct with:"
echo " make WERROR= locale.lo"
cd */libstdc++-v3/src
RV=`try_make WERROR= locale.lo`
if [ "$RV" ]; then
unrepaired $A
fi
cd $BUILD_DIR
;;
*)
echo "Sorry, an unexpected error was encountered compiling $A"
echo "I don't know how to workaround this error."
exit
;;
esac
}
if [ "$GCC_DATE" ]; then
if [ "x${GCC_DATE}" = "xcurrent" ]; then
GCC_TAG=""
UPDATE_LIBSTDCXX=
else
GCC_TAG="-rgcc_ss_${GCC_DATE}"
UPDATE_LIBSTDCXX="cvs co libstdc++-v3"
fi
else
usage
fi
SRC_DIR="${TOP}/${GCC}"
BUILD_DIR="${TOP}/${GCC}-build"
HAVE_GCC_SRC="cvs -z3 co $GCC_TAG $GCC"
echo "Please be patient :)"
echo "Checking out $GCC cvs source..."
if eval $HAVE_GCC_SRC 2>&1 >> $OUTFILE; then
if [ "$UPDATE_LIBSTDCXX" ]; then
echo "Replacing libstdc++-v3 with fresh cvs lovin'..."
cd $SRC_DIR
rm -rf libstdc++-v3
eval $UPDATE_LIBSTDCXX 2>&1 >> $OUTFILE
fi
mkdir $BUILD_DIR
cd $BUILD_DIR
echo "Configuring the build directory..."
echo $CONFIG_CMD 2>&1 >> $OUTFILE
eval $CONFIG_CMD 2>&1 >> $OUTFILE
echo "Running 'make bootstrap' in the build directory..."
if try_make bootstrap; then
echo "Build success!"
echo "You should run 'make check' from within $BUILD_DIR to verify"
echo "that the build is satisfactory."
echo "gcc-${DATE} currently configured to install to $INST_PREFIX"
echo "Enjoy!"
else
echo "Build failed!"
echo "(all output from the build can be found in $OUTFILE)"
fi
fi