Cross compile problem (gcc-3.2.1, glibc-2.3.1)
Cross compile problem (gcc-3.2.1, glibc-2.3.1)
Zoltan Csizmadia
zoltan_csizmadia@yahoo.com
Mon, 16 Dec 2002 09:08:25 -0800 (PST)
Hi All,
I try to cross compile a toolchain for ARM (DNP1110).
When It tries to compile glibc, it doesn't find the
headers (stdio.h, unistd.h). It seems there is no
.../arm-linux/include directory
(.../arm-linux/sys-include is created though). When is
it created?
My build-toolchain script is attached.
Regards,
Zoltan
build-toolchain-3.2.1
#!/bin/sh
BINUTILS_VERSION=2.13.1
GCC_VERSION=3.2.1
GLIBC_VERSION=2.3.1
GLIBC_LINUXTHREADS_VERSION=2.3.1
GNU_TARGET_NAME=arm-linux
GNU_BUILD_NAME=i586-linux
TOP_DIR=`pwd`
BUILD_DIR=$TOP_DIR/build
STAGING_DIR=/usr/local/arm/$GCC_VERSION
SOURCE_DIR=$TOP_DIR
ROOT_DIR=$STAGING_DIR/rootfs
KERNEL=/usr/src/arm-linux-2.4.18
HOST=
HOSTCC=gcc
#
----------------------------------------------------------------------------
# There should be nothing to configure below this line
#
# Check if everything is there
#
echo -n "check if sources are available..."
mkdir -p $BUILD_DIR
if [ "$KERNEL" = "" -o ! -f
"$KERNEL/Documentation/arm/README" ]; then
echo "You haven't changed KERNEL to point at a valid
kernel tree"
exit 1
fi
if [ ! -f
$SOURCE_DIR/binutils-$BINUTILS_VERSION.tar.gz ]; then
echo binutils-$BINUTILS_VERSION seems to be missing
exit 1
fi
if [ ! -f $SOURCE_DIR/gcc-$GCC_VERSION.tar.gz ]; then
echo gcc-$GCC_VERSION seems to be missing
exit 1
fi
if [ ! -f $SOURCE_DIR/glibc-$GLIBC_VERSION.tar.gz ];
then
echo glibc-$GLIBC_VERSION seems to be missing
exit 1
fi
if [ ! -f
$SOURCE_DIR/glibc-linuxthreads-$GLIBC_LINUXTHREADS_VERSION.tar.gz
]; then
echo glibc-linuxthreads-$GLIBC_LINUXTHREADS_VERSION
seems to be missing
exit 1
fi
echo "done"
#
# binutils
#
echo -n "binutils..."
[ -d $BUILD_DIR/binutils-$BINUTILS_VERSION ] || {
echo -n "extracting..."
cd $BUILD_DIR
tar zxf $SOURCE_DIR/binutils-$BINUTILS_VERSION.tar.gz
cd binutils-$BINUTILS_VERSION
./configure \
--disable-shared \
--target=$GNU_TARGET_NAME \
--prefix=$STAGING_DIR \
--enable-targets=$GNU_TARGET_NAME
make
make install
}
echo "done"
#
# gcc
#
echo -n "gcc..."
[ -d $BUILD_DIR/gcc-$GCC_VERSION ] || {
echo -n "extracting..."
cd $BUILD_DIR
tar zxf $SOURCE_DIR/gcc-$GCC_VERSION.tar.gz
cd gcc-$GCC_VERSION
# hack to build gcc without glibc
perl -pi -e 's/^(TARGET_LIBGCC2_CFLAGS.*)/$1
-Dinhibit_libc -D__gthr_posix_h/'
gcc/config/arm/t-linux
}
echo "done"
# gcc stage 1
echo -n "gcc-stage 1..."
[ -d $BUILD_DIR/gcc-$GCC_VERSION-stage1-obj ] || {
mkdir $BUILD_DIR/gcc-$GCC_VERSION-stage1-obj
cd $BUILD_DIR/gcc-$GCC_VERSION-stage1-obj
PATH=$PATH:$STAGING_DIR/bin \
AR=$GNU_TARGET_NAME-ar \
RANLIB=$GNU_TARGET_NAME-ranlib \
CC=$HOSTCC \
../gcc-$GCC_VERSION/configure \
--target=$GNU_TARGET_NAME \
--prefix=$STAGING_DIR \
--enable-target-optspace \
--disable-nls \
--with-gnu-ld \
--disable-shared \
--enable-languages=c \
--with-headers=$KERNEL/include
PATH=$PATH:$STAGING_DIR/bin make
PATH=$PATH:$STAGING_DIR/bin make install
}
echo "done"
# glibc-cross
GLIBC=glibc-$GLIBC_VERSION
GLIBC_LINUXTHREADS=glibc-linuxthreads-$GLIBC_LINUXTHREADS_VERSION
echo -n "glibc..."
[ -d $BUILD_DIR/$GLIBC ] || {
cd $BUILD_DIR
gzip -dc $SOURCE_DIR/$GLIBC.tar.gz | tar -xf -
cd $BUILD_DIR/$GLIBC
gzip -dc $SOURCE_DIR/$GLIBC_LINUXTHREADS.tar.gz | tar
-xf -
perl -pi -e
's/i386/arm*)\n\tlibc_cv_gcc_unwind_find_fde=yes\n\tarch_minimum_kernel=2.0.10\n\t;;\n
i386/' sysdeps/unix/sysv/linux/configure
perl -pi -e 's/weak_alias \(__old_sys_nerr/\/\/ $&/'
sysdeps/unix/sysv/linux/arm/errlist.c
cd $BUILD_DIR
mkdir $GLIBC-obj
cd $GLIBC-obj
PATH=$PATH:$STAGING_DIR/bin \
AR=$GNU_TARGET_NAME-ar \
RANLIB=$GNU_TARGET_NAME-ranlib \
CC=$GNU_TARGET_NAME-gcc \
../$GLIBC/configure $GNU_TARGET_NAME \
--build=$GNU_BUILD_NAME \
--host=$GNU_TARGET_NAME \
--prefix=$STAGING_DIR/$GNU_TARGET_NAME \
--enable-add-ons \
--disable-sanity-checks \
--enable-shared \
--with-headers=$KERNEL/include
PATH=$PATH:$STAGING_DIR/bin make
PATH=$PATH:$STAGING_DIR/bin make install
}
echo "done"
# ld.so from glibc-cross: needs to be configured
differently for the
# target system (because of other paths)
echo -n "ld.so..."
[ -d $BUILD_DIR/$GLIBC-ldso ] || {
mkdir $BUILD_DIR/$GLIBC-ldso
cd $BUILD_DIR/$GLIBC-ldso
PATH=$PATH:$STAGING_DIR/bin \
AR=$GNU_TARGET_NAME-ar \
RANLIB=$GNU_TARGET_NAME-ranlib \
CC=$GNU_TARGET_NAME-gcc \
../$GLIBC/configure $GNU_TARGET_NAME \
--build=$GNU_BUILD_NAME \
--host=$GNU_TARGET_NAME \
--prefix= \
--enable-add-ons \
--disable-sanity-checks \
--enable-shared \
--with-headers=$KERNEL/include
PATH=$PATH:$STAGING_DIR/bin make
# CAREFUL: don't never ever make install here without
install_root!!!
mkdir -p $ROOT_DIR/lib
cp elf/ld.so $ROOT_DIR/lib/ld-$GLIBC_VERSION.so
}
echo "done"
# gcc stage 2
echo -n "gcc-stage 2..."
[ -d $BUILD_DIR/gcc-$GCC_VERSION-stage2-obj ] || {
mkdir $BUILD_DIR/gcc-$GCC_VERSION-stage2-obj
cd $BUILD_DIR/gcc-$GCC_VERSION
# remove glibc header hack
perl -pi -e 's/^(TARGET_LIBGCC2_CFLAGS =
-fomit-frame-pointer -fPIC).*/$1/'
gcc/config/arm/t-linux
cd $BUILD_DIR/gcc-$GCC_VERSION-stage2-obj
PATH=$STAGING_DIR/bin:$PATH \
AR=$GNU_TARGET_NAME-ar \
RANLIB=$GNU_TARGET_NAME-ranlib \
CC=$HOSTCC \
../gcc-$GCC_VERSION/configure \
--target=$GNU_TARGET_NAME \
--prefix=$STAGING_DIR \
--enable-target-optspace \
--disable-nls \
--with-gnu-ld \
--disable-shared \
--enable-languages="c,c++" \
--with-headers=$KERNEL/include
PATH=$PATH:$STAGING_DIR/bin make
PATH=$PATH:$STAGING_DIR/bin make install
}
echo "done"
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com