Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

QUICK gcc build question

13 views
Skip to first unread message

Jim

unread,
Jan 31, 2003, 1:20:19 PM1/31/03
to
To build gcc with glibc ... if i want c++ libs as well do i need to
compile stdc++ before gcc as well ?

Jim

J.O. Aho

unread,
Jan 31, 2003, 2:13:00 PM1/31/03
to
Jim wrote:
> To build gcc with glibc ... if i want c++ libs as well do i need to
> compile stdc++ before gcc as well ?

According dependeincies on the mandrake source rpm for gcc you will need the
following things installed before compiling gcc:


* binutils >= 2.9.1.0.21
* zlib-devel
* gcc-gnat >= 3.1
* libgnat1 >= 3.1
* gettext
* bison
* perl >= 5.600-17mdk
* sh-utils
* texinfo
* autoconf
* glibc-devel
* tetex >= 0.9
* tetex-dvips
* dejagnu

Which don't list stdc++


//Aho

Kai Ruottu

unread,
Feb 4, 2003, 8:05:08 AM2/4/03
to
On Fri, 31 Jan 2003 18:20:19 GMT, Jim <REMOVE...@sympatico.caREMOVE> wrote:

>To build gcc with glibc ... if i want c++ libs as well do i need to
>compile stdc++ before gcc as well ?

Too quickly written as a question... So let's try to get the
answer being a little slower...

Ok, people have troubles to understand what things are involved
in building GCC and glibc for Linux, especially when producing
these for cross-compiling.

The native case is easy, people normally accept the old GCC and
old glibc pre-existing, built by RedHat, SuSE, Mandrake, Debian
or something... Meanwhile when trying to do the same for cross-
compiling some people insist that this should be possible without
the old glibc existing at all.

However almost all the Linux-configurations assume the native
situation where the old glibc is already there and the builder
not caring about this 'unpurity'. I haven't seen yet any messages
where someone asks how to build the native GCC and glibc without
first having some NIH-stuff in '/usr/include', '/lib' and '/usr/lib'.

But the instructions for cross-GCCs use all kind of dirty tricks
to avoid any old NIH-target-stuff in '$prefix/$target/include' and
'$prefix/$target/lib'. The net has prebuilt distributions for all
possible Linuxes, Alpha, ARM, ia64, m68k, MIPS, PPC, Sparc, x86,
x86_64,... and getting an old throw-away-later glibc for the GCC-
build should be easy. Fools like the cross-GCC builders, who want
to install Linux/PPC-stuff into a Linux/x86 host (the Linux/PPC
target C-libraries, X11-libraries, GUI-libraries,...), are tried
to disable doing their foolishnesses by packaging the Linux-stuff
into RPMS, weird '.deb' packages and such, so that nobody could
unpack them on alien systems. Fortunately there is one of the
"Murphy's Laws", stating that "nothing can be done foolproof".
So quite many already know 'rpm2cpio' and 'cpio' as the unpack
method for RPMS... The '.deb' packages may still be unbreakable,
but probably some hacker invents how to unpack these anywhere,
sooner or later... It sounds weird that the 'free software' uses
nowadays methods from the 'copyright' world, trying to disable
people using their prebuilt software on 'wrong' platforms...

Okeydokey, usually one builds GCC first against the old 'bootstrap'
glibc, and using the old GCC to produce the executables, besides in
the native case 'building with itself' may be tried too. Then one
builds the new glibc using the new GCC to compile its objects.
If the new glibc could cause some changes in the 'libgcc's,
'libiberty's and 'libstdc++'s, then rebuilding GCC against it
could be necessary. This hasn't suggestested anywhere though, but
if the resulted GCC-libraries have changed somehow, it wasn't vain.
Neither when they didn't change at all, then this proves that there
is some proven stability in the tools...

In the native case it may be motivated to optimize the GCC-binaries.
For instance when starting with a i386-code gcc-2.95.3 on a Linux/x86
and aiming to Athlon-optimized GCC and glibc binaries, it may be
complicated to add the necessary option for 'stage2', '-march=athlon-xp',
when the old GCC don't understand this. Then one builds the GCC-binaries
first with whatever options are available, then builds glibc with all
the optimizations the new GCC can use. And finally one builds GCC
with itself using the same optimizations and against the optimized new
glibc...

Cheers, Kai

Jim

unread,
Feb 7, 2003, 9:18:40 AM2/7/03
to
Wow thanks for that response ...

I appreciate it ...

I so far have go this done for powerpc-linux

1.) build binutils
2.) build gcc strapped with newlib
3.) build glibc
4.) build gcc with glibc (c only)
5.) in a new directory build

wired problem i have is during my build when i got to the
/powerpc/libstdc++ in my build dir ... it dies with "no rule to make
all" ...

I pasted my build script below for your inspection ... maybe you'll see
something wrong (which i really really really hope) ...

Jim


#!/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/ppcgcc3/

#
# 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

}

#
# 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


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


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_root=$arch install
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
#\
# --with-headers=$PREFIX/include/
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++ \
--with-headers=$KERNEL --with-sysroot=$PREFIX/$arch

#mkdir libstdc++
#cd libstdc++
#../gcc-2.95.3/libstdc++/configure
--target=powerpc-linux \
# --prefix=/home/jgdon/ppcgcc3 \
# --enable-shared \
# --enable-threads=posix \
# --enable-languages=c,c++ \
#
--with-headers=/home/jgdon/ppclinux/include/
cd l #cd ..

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
#pwd
#ls
#echo here
mv libstdc++ libstdc++ORIG
mv libio libioORIG
ls -l libstdc++/src/Makefile.in
sleep 10
touch libstdc++/src/Makefile.in
#echo here2
cp -rf ../libstdc++-2.90.8 ./

#echo here3
#cp -rf ./libstdc++-2.90.8/* ./libstdc++/
#rm -rf ./libstdc++
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
#cdbuild_glibc

echo ====================================
echo BUILD GCC WITH GLIBC
echo ====================================
#build_gcc_glibc

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

Jim

unread,
Feb 7, 2003, 1:01:04 PM2/7/03
to
ps if i get this working i am hoping to post the cleaned up script some
where ... and maybe even turn it into a simple make file for building
powerpc x-compiler ;-)
0 new messages