CROSS COMPILE: gcc 2.95.3 is ok ... but libstc++-2.90.8 fails ... nan()

James Don JDon@spacebridge.com
Mon Feb 10 16:34:00 GMT 2003


Hi all,

I am currently working on compiling gcc-2.95.3 with glibc-2.2.5 ... This
works fine (meaning it compiles) for my target powerpc-linux ... 

But I die compiling libstdc++-2.90.8 with the below build script ... its
seems to have problems with nan() in libstdc++ being different than that in
glibc ... I am really stuck on what I am doing wrong ... I assume my glibc
version is wrong ... or I am simply building things incorrectly ...

Any tips would be great ... I am hoping to clean up this script when it
works and send it out to other ppc embedded developers requiring STL on
there targets ...

Thanks in advance,

Jim

Ps I have modified my script in other ways to get other problems ... like no
target in libstc++ for "make all-target" ... I am really stuck I think and
need some real solid advice ... besides download an rpm ;-)


#!/bin/bash

#
# Get, build and install the latest cross-development tools and libraries
#

#
# Specify the architectures for which the tools are to be built
# To build for multiple targets: ARCHS="m68k ppc i386"
#
ARCHS="powerpc-linux"

#
# Where to install
#
PREFIX=$HOME/ppcgcc/

#
# My kernel includes
#
KERNEL=$HOME/ppclinux/include/

#
# Where to get the GNU tools
#
RTEMS_BINUTILS_URL=ftp://ftp.gnu.org/gnu/binutils/
RTEMS_GCC_URL=ftp://ftp.gnu.org/gnu/gcc/gcc-2.95.3/
RTEMS_NEWLIB_URL=ftp://sources.redhat.com/pub/newlib/
GLIBC_URL=ftp://ftp.gnu.org/gnu/glibc
LIBSTDC_URL=ftp://ftp.gnu.org/gnu/libstdc++

#
# Specify the versions
#
GCC_VER=2.95.3
GCC=gcc-core-$GCC_VER
BINUTILS=binutils-2.13.2.1
NEWLIB=newlib-1.10.0
GLIBC_VER=2.2.5

#
# Get the source
#
getSource() {
    wget --passive-ftp --no-directories --retr-symlinks
$RTEMS_BINUTILS_URL/$BINUTILS.tar.gz
    wget --passive-ftp --no-directories --retr-symlinks
$RTEMS_BINUTILS_URL/$BINUTILS*.diff

    wget --passive-ftp --no-directories --retr-symlinks
$RTEMS_GCC_URL/$GCC.tar.gz
    wget --passive-ftp --no-directories --retr-symlinks
$RTEMS_GCC_URL/$GCC*.diff

    wget --passive-ftp --no-directories --retr-symlinks
$RTEMS_NEWLIB_URL/$NEWLIB.tar.gz
    wget --passive-ftp --no-directories --retr-symlinks
$RTEMS_NEWLIB_URL/$NEWLIB*.diff
}

getSourceGLIBC() {
    wget --passive-ftp --no-directories --retr-symlinks
$GLIBC_URL/glibc-$GLIBC_VER.tar.gz
    wget --passive-ftp --no-directories --retr-symlinks
$GLIBC_URL/glibc-$GLIBC_VER*.diff
    wget --passive-ftp --no-directories --retr-symlinks
$GLIBC_URL/glibc-linuxthreads-$GLIBC_VER.tar.gz

    

}


#
# UnpackGCC
#
unpackGCC() {

   rm -rf gcc-$GCC_VER
    tar xvfz $GCC.tar.gz
    for d in $GCC*.diff
    do
        if [ -r "$d" ]
        then
            cat "$d" | (cd gcc-$GCC_VER ; patch -p1)
        fi
    done
}

#
# Unpack the source
#
unpackSource() {
    rm -rf $BINUTILS
    tar xvfz $BINUTILS.tar.gz 
    for d in $BINUTILS*.diff
    do
        if [ -r "$d" ]
        then
            cat "$d" | (cd $BINUTILS ; patch -p1)
        fi
    done

    unpackGCC

    rm -rf $NEWLIB
    tar xvfz $NEWLIB.tar.gz
    for d in $NEWLIB*.diff
    do
        if [ -r "$d" ]
        then
            cat "$d" | (cd $NEWLIB ; patch -p1)
        fi
    done
    cd gcc-$GCC_VER 
    ln -s ../$NEWLIB/newlib newlib
    ln -s ../$NEWLIB/libgloss libgloss
    cd ..
}

unpackGLIBC() {

   rm -rf glibc-$GLIBC_VER
   tar xvfz glibc-$GLIBC_VER.tar.gz
   for d in glibc-$GLIBC_VER*.diff
   do
      if [ -r "$d" ]
      then
         cat "$d" | (cd glibc-$GLIBC_VER ; patch -p1)
        fi
    done
    cd glibc-$GLIBC_VER
    tar xvfz ../glibc-linuxthreads-$GLIBC_VER.tar.gz
    cd ..

}

#
# Build
#
build() {
    PATH=$PREFIX/bin:$PATH
    export PATH
    for arch in $ARCHS
    do
        rm -rf BINUTILS
        mkdir BINUTILS
        cd BINUTILS
        ../$BINUTILS/configure --target=$arch --prefix=$PREFIX
	make
        make install
        cd ..

        rm -rf GCC
        mkdir  GCC
        cd GCC
        ../gcc-$GCC_VER/configure --target=$arch --prefix=$PREFIX \
            --with-gnu-as --with-gnu-ld --verbose \
            --with-system-zlib --disable-nls \
            --disable-threads \
	    --disable-shared  \
            --with-newlib \
	    --with-headers=$KERNEL \
            --enable-languages=c

	make
        make install
        cd ..
    done
}

build_glibc() {
    PATH=$PREFIX/bin:$PATH
    export PATH
    for arch in $ARCHS
    do
	rm -rf GLIBC
	mkdir GLIBC
	cd GLIBC
	rm -rf $PREFIX/$arch/include $PREFIX/$arch/sys-include
$PREFIX/$arch/lib

        CC=powerpc-linux-gcc AR=powerpc-linux-ar RANLIB=powerpc-linux-ranlib
\
                ../glibc-$GLIBC_VER/configure \
	 	--host=$arch \
                --enable-add-ons=linuxthreads \
                --with-headers=$KERNEL  \
                --prefix=$PREFIX/$arch
	make
	make install
	cd ..
   done
}

build_gcc_glibc() {
    PATH=$PREFIX/bin:$PATH
    export PATH
    for arch in $ARCHS
    do

	
	rm -rf GCC_GLIBC
	mkdir GCC_GLIBC
	cd GCC_GLIBC
        ../gcc-$GCC_VER/configure --target=$arch --prefix=$PREFIX/ \
                 --with-gnu-as --with-gnu-ld \
                 --enable-shared \
                 --enable-threads=posix \
                 --enable-languages=c \
                 --with-headers=$KERNEL
	make
        make install
	cd ..


    done
}

getCPPSource() {
    wget --passive-ftp --no-directories --retr-symlinks
$RTEMS_GCC_URL/gcc-g++-$GCC_VER.tar.gz
    wget --passive-ftp --no-directories --retr-symlinks
$RTEMS_GCC_URL/gcc-g++-$GCC_VER*.diff
    wget --passive-ftp --no-directories --retr-symlinks
$LIBSTDC_URL/libstdc++-2.90.8.tar.gz
}

unpackCPPSource(){
    pwd
    echo UNPACK G++
    tar xfz gcc-g++-$GCC_VER.tar.gz
}

build_g++_glibc() {
    PATH=$PREFIX/bin:$PATH
    export PATH
    for arch in $ARCHS
    do

	
	rm -rf G++_GLIBC
	mkdir G++_GLIBC
	cd G++_GLIBC
        #cd gcc-$GCC_VER
        ../gcc-$GCC_VER/configure --target=$arch --prefix=$PREFIX \
	    --with-gnu-as --with-gnu-ld \
	    --enable-shared \
	    --enable-threads=posix \
	    --enable-languages=c,c++ \
	    --enable-version-specific-runtime-libs \
	    --with-headers=$KERNEL --with-sysroot=$PREFIX/

	make
        #make install
	cd ..


    done
}

unpackStd() {
    pwd
    echo UNPASK STDC
    tar xfz libstdc++-2.90.8.tar.gz
    patch -p0 -b -z.ORIG < libstdc++-2.90.8-compat-gcc-2.95.3.diff
    cd gcc-$GCC_VER
    mv libstdc++ libstdc++ORIG
    mv libio     libioORIG
    cp -rf ../libstdc++-2.90.8 ./
    mv ./libstdc++-2.90.8 ./libstdc++ 
    cd ..
}


#
# Do everything
#
# Comment out any activities you wish to omit
#
#set -ex

export PATH=$PREFIX/bin/:$PATH

echo ====================================
echo BUILD BOOT STRAPPED COMPILER
echo ====================================
#sleep 10
#getSource
#unpackSource
#unpackCPPSource
#build


echo ====================================
echo BUILD GLIBC
echo ====================================
#getSourceGLIBC
unpackGLIBC
build_glibc

echo ====================================
echo BUILD GCC WITH GLIBC
echo ====================================
unpackGCC
build_gcc_glibc

echo =====================================
echo BUILD G++/GCC WITH GLIBC AND LIBSTC++
echo =====================================
#getCPPSource
#unpackGCC
#unpackCPPSource
#unpackStd
#build_g++_glibc



More information about the Gcc-help mailing list