[Clfs-support] Need help building the cross toolchain
Jon Dufresne
jon.dufresne at gmail.com
Thu Nov 6 13:16:31 PST 2008
Hi,
I am attempting to build a cross toolchain in order to create a custom
embedded system. Through the advice of the book "Building Embedded Linux
Systems" I found the CLFS website and guide.
Now I am not using the CLFS guide verbatim, but I am taking _heavy_
inspiration from it. That is, I'm mostly following it except where I believe
I don't need to. Apparently my assumptions are wrong as I can not
successfully build glibc. I have created a script that more or less follows
your guide, so that my results are reproducible. I will attach the script
inline to the bottom of this email so you can understand my process and
where I diverge from the guide.
I got all the packages from the urls in the script except glibc, which I got
from the clfs website at the following url:
http://cross-lfs.org/files/packages/svn/glibc-2.8.tar.bz2
When I run this script I get the following error during what looks like the
linking phase of glibc:
i686-pc-linux-gnu-gcc -nostdlib -nostartfiles -r -o
/home/jdufresne/devel/trunk/crosstools/build/glibc-build/elf/librtld.map.o
'-Wl,-('
/home/jdufresne/devel/trunk/crosstools/build/glibc-build/elf/dl-allobjs.os
/home/jdufresne/devel/trunk/crosstools/build/glibc-build/libc_pic.a -lgcc
'-Wl,-)'
-Wl,-Map,/home/jdufresne/devel/trunk/crosstools/build/glibc-build/elf/librtld.mapT
/home/jdufresne/devel/trunk/crosstools/toolchain/lib/gcc/i686-pc-linux-gnu/4.3.2/../../../../i686-pc-linux-gnu/bin/ld:
cannot find -lgcc
collect2: ld returned 1 exit status
The key error being: cannot find -lgcc
I have done extensive googling on this error and have not found much.
Now, if I look look for libgcc.a I do _not_ find it. So it appears that ld
is telling the truth. If I look for libgcc.a this is all I see:
$ find . -name \*gcc\*
./toolchain/man/man1/i686-pc-linux-gnu-gcc.1
./toolchain/lib/gcc
./toolchain/bin/i686-pc-linux-gnu-gccbug
./toolchain/bin/i686-pc-linux-gnu-gcc-4.3.2
./toolchain/bin/i686-pc-linux-gnu-gcc
./toolchain/libexec/gcc
./toolchain/i686-pc-linux-gnu/bin/gcc
./toolchain/info/gcc.info
./toolchain/info/gccinstall.info
./toolchain/info/gccint.info
./build/gcc-4.3.2.tar.bz2
./build/gcc-static-build
./build/gcc-static-build/gcc
./build/gcc-static-build/gcc/gcc-options.o
./build/gcc-static-build/gcc/gcc.o
./build/gcc-static-build/gcc/xgcc
./build/gcc-static-build/gcc/gcc-vers.texi
./build/gcc-static-build/gcc/libgcc.mvars
./build/gcc-static-build/gcc/gccspec.o
./build/gcc-static-build/gcc/gccbug
./build/gcc-static-build/gcc/gcc-cross
./build/gcc-static-build/gcc/doc/gcc.info
./build/gcc-static-build/gcc/doc/gccinstall.info
./build/gcc-static-build/gcc/doc/gccint.info
./build/glibc-2.8/sysdeps/s390/gccframe.h
./build/glibc-2.8/sysdeps/sparc/gccframe.h
./build/glibc-2.8/sysdeps/powerpc/gccframe.h
./build/glibc-2.8/sysdeps/powerpc/powerpc32/libgcc-compat.S
./build/glibc-2.8/sysdeps/ia64/gccframe.h
./build/glibc-2.8/sysdeps/ia64/ia64libgcc.S
./build/glibc-2.8/sysdeps/i386/gccframe.h
./build/glibc-2.8/sysdeps/generic/gccframe.h
./build/glibc-2.8/sysdeps/alpha/gccframe.h
./build/glibc-2.8/sysdeps/sh/gccframe.h
./build/glibc-2.8/gnulib/tst-gcc.c
My question is, why is the build_gcc_static stage of my script not building
and installing libgcc.a? Where should this end up after compilation? Do I
need a new configure flag on gcc?
Thanks for any help,
Jon
-----
#!/bin/bash
unset CFLAGS
unset CXXFLAGS
KERNEL_ARCH=i386
HOST=i686-cross-linux-gnu
TARGET=i686-pc-linux-gnu
ROOTFS=`pwd`/rootfs
BUILD=`pwd`/build
PREFIX=`pwd`/toolchain
# latest
KERNEL_VERSION=2.6.27.4
BINUTILS_VERSION=2.19
GCC_VERSION=4.3.2
#GLIBC_VERSION=2.8-20081103
GLIBC_VERSION=2.8
PATH=${PREFIX}/bin:${PATH}
export PATH
mkdirs()
{
if [ ! -d ${BUILD} ]; then
echo "creating ${BUILD}"
mkdir -pv ${BUILD}
fi
rm -rf \
${BUILD}/linux-${KERNEL_VERSION} \
${BUILD}/binutils-${BINUTILS_VERSION} \
${BUILD}/binutils-build \
${BUILD}/gcc-${GCC_VERSION} \
${BUILD}/gcc-static-build \
${BUILD}/gcc-build \
${BUILD}/glibc-${GLIBC_VERSION} \
${BUILD}/glibc-headers-build \
${BUILD}/glibc-build \
${PREFIX} \
${ROOTFS}
}
download_packages()
{
if [ ! -f linux-${KERNEL_VERSION}.tar.bz2 ]; then
wget http://kernel.org/pub/linux/kernel/v2.6/linux-${KERNEL_VERSION}.tar.bz2
fi
if [ ! -f binutils-${BINUTILS_VERSION}.tar.bz2 ]; then
wget
http://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.bz2
fi
if [ ! -f gcc-${GCC_VERSION}.tar.bz2 ]; then
wget
http://gcc-ca.internet.bs/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2
fi
if [ ! -f glibc-${GLIBC_VERSION}.tar.bz2 ]; then
wget http://ftp.gnu.org/gnu/glibc/glibc-${GLIBC_VERSION}.tar.bz2
fi
}
build_kernel_headers()
{
echo "Building linux-${KERNEL_VERSION} headers ARCH=${KERNEL_ARCH}"
tar xvjf linux-${KERNEL_VERSION}.tar.bz2
cd linux-${KERNEL_VERSION}
make ARCH=${KERNEL_ARCH} headers_check || exit
make ARCH=${KERNEL_ARCH} INSTALL_HDR_PATH=${ROOTFS}/usr headers_install
|| exit
cd ..
rm -rf linux-${KERNEL_VERSION}
}
build_binutils()
{
echo "Building binutils-${BINUTILS_VERSION} HOST=${HOST}
TARGET=${TARGET}"
tar xjvf binutils-${BINUTILS_VERSION}.tar.bz2
mkdir -v binutils-build
cd binutils-build
../binutils-${BINUTILS_VERSION}/configure \
--prefix=${PREFIX} \
--build=${HOST} \
--host=${HOST} \
--target=${TARGET} \
--with-sysroot=${ROOTFS} \
--disable-nls \
--enable-shared \
--disable-multilib \
|| exit
make configure-host || exit
make || exit
make install || exit
cd ..
rm -rf binutils-build binutils-${BINUTILS_VERSION}
}
build_gcc_static()
{
echo "Building gcc-${GCC_VERSION} stage1 TARGET=${PREFIX}"
tar xjvf gcc-${GCC_VERSION}.tar.bz2
mkdir -v gcc-static-build
cd gcc-static-build
../gcc-${GCC_VERSION}/configure \
--prefix=${PREFIX} \
--build=${HOST} \
--host=${HOST} \
--target=${TARGET} \
--with-sysroot=${ROOTFS} \
--disable-multilib \
--disable-nls \
--disable-shared \
--disable-libgomp \
--disable-libmudflap \
--disable-libssp \
--enable-languages=c \
|| exit
make all-gcc || exit
make install-gcc || exit
cd ..
#rm -rf gcc-static-build gcc-${GCC_VERSION}
rm -rf gcc-${GCC_VERSION}
}
build_glibc()
{
echo "Building glibc-${GLIBC_VERSION}"
tar xjvf glibc-${GLIBC_VERSION}.tar.bz2
mkdir -v glibc-build
cd glibc-build
echo "libc_cv_forced_unwind=yes" > config.cache
echo "libc_cv_c_cleanup=yes" >> config.cache
BUILD_CC=gcc \
CC=${TARGET}-gcc \
AR=${TARGET}-ar \
RANLIB=${TARGET}-ranlib \
../glibc-${GLIBC_VERSION}/configure \
--prefix=/usr \
--build=${HOST} \
--host=${TARGET} \
--disable-profile \
--enable-add-ons \
--with-tls \
--enable-kernel=2.6.0 \
--with-__thread \
--with-binutils=${PREFIX}/bin \
--with-headers=${ROOTFS}/usr/include \
--cache-file=config.cache \
|| exit
make || exit
make install_root=${ROOTFS} install || exit
cd ..
rm -rf glibc-build glibc-${GLIBC_VERSION}
}
build_gcc()
{
echo "Building gcc-${GCC_VERSION} final TARGET=${PREFIX}"
tar xjvf gcc-${GCC_VERSION}.tar.bz2
mkdir -v gcc-build
cd gcc-build
../gcc-${GCC_VERSION}/configure \
--prefix=${PREFIX} \
--build=${HOST} \
--host=${HOST} \
--target=${TARGET} \
--with-sysroot=${ROOTFS} \
--disable-multilib \
--disable-nls \
--enable-shared \
--enable-threads=posix \
--enable-languages=c,c++ \
--enable-__cxa_atexit \
--enable-c99 \
--enable-long-long \
|| exit
make || exit
make install || exit
cd ..
#rm -rf gcc-build gcc-${GCC_VERSION}
rm -rf gcc-${GCC_VERSION}
}
mkdirs
cd $BUILD
download_packages
build_kernel_headers
build_binutils
build_gcc_static
build_glibc
build_gcc
cd ..
----
$ toolchain/bin/i686-pc-linux-gnu-gcc -dumpspecs
*asm:
%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}
*asm_debug:
%{gstabs*:--gstabs}%{!gstabs*:%{g*:--gdwarf2}}
%{fdebug-prefix-map=*:--debug-prefix-map %*}
*asm_final:
*asm_options:
%{--target-help:%:print-asm-header()} %a %Y %{c:%W{o*}%{!o*:-o
%w%b%O}}%{!c:-o %d%w%u%O}
*invoke_as:
%{!S:-o %|.s |
as %(asm_options) %|.s %A }
*cpp:
%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}
*cpp_options:
%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}
%{f*} %{g*:%{!g0:%{!fno-working-directory:-fworking-directory}}} %{O*}
%{undef} %{save-temps:-fpch-preprocess}
*cpp_debug_options:
%{d*}
*cpp_unique_options:
%{C|CC:%{!E:%eGCC does not support -C or -CC without -E}} %{!Q:-quiet}
%{nostdinc*} %{C} %{CC} %{v} %{I*&F*} %{P} %I %{MD:-MD
%{!o:%b.d}%{o*:%.d%*}} %{MMD:-MMD %{!o:%b.d}%{o*:%.d%*}} %{M} %{MM} %{MF*}
%{MG} %{MP} %{MQ*} %{MT*} %{!E:%{!M:%{!MM:%{!MT:%{!MQ:%{MD|MMD:%{o*:-MQ
%*}}}}}}} %{remap} %{g3|ggdb3|gstabs3|gcoff3|gxcoff3|gvms3:-dD} %{H} %C
%{D*&U*&A*} %{i*} %Z %i %{fmudflap:-D_MUDFLAP -include mf-runtime.h}
%{fmudflapth:-D_MUDFLAP -D_MUDFLAPTH -include mf-runtime.h} %{E|M|MM:%W{o*}}
*trad_capable_cpp:
cc1 -E %{traditional|ftraditional|traditional-cpp:-traditional-cpp}
*cc1:
%(cc1_cpu) %{profile:-p}
*cc1_options:
%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}
%1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*} %{c|S:%{o*:-auxbase-strip
%*}%{!o*:-auxbase %b}}%{!c:%{!S:-auxbase %b}} %{g*} %{O*} %{W*&pedantic*}
%{w} %{std*&ansi&trigraphs} %{v:-version} %{pg:-p} %{p} %{f*} %{undef}
%{Qn:-fno-ident} %{--help:--help} %{--target-help:--target-help}
%{--help=*:--help=%(VALUE)} %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}}
%{fsyntax-only:-o %j} %{-param*} %{fmudflap|fmudflapth:-fno-builtin
-fno-merge-constants} %{coverage:-fprofile-arcs -ftest-coverage}
*cc1plus:
*link_gcc_c_sequence:
%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}
*link_ssp:
%{fstack-protector|fstack-protector-all:-lssp_nonshared -lssp}
*endfile:
%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}
%{mpc32:crtprec32.o%s} %{mpc64:crtprec64.o%s}
%{mpc80:crtprec80.o%s} %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s
*link:
%{!static:--eh-frame-hdr} -m %(link_emulation) %{shared:-shared}
%{!shared: %{!ibcs: %{!static: %{rdynamic:-export-dynamic}
%{!dynamic-linker:-dynamic-linker %(dynamic_linker)}}
%{static:-static}}}
*lib:
%{pthread:-lpthread} %{shared:-lc} %{!shared:%{mieee-fp:-lieee}
%{profile:-lc_p}%{!profile:-lc}}
*mfwrap:
%{static: %{fmudflap|fmudflapth: --wrap=malloc --wrap=free --wrap=calloc
--wrap=realloc --wrap=mmap --wrap=munmap --wrap=alloca} %{fmudflapth:
--wrap=pthread_create}} %{fmudflap|fmudflapth: --wrap=main}
*mflib:
%{fmudflap|fmudflapth: -export-dynamic}
*link_gomp:
*libgcc:
-lgcc
*startfile:
%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} crti.o%s
%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}
*switches_need_spaces:
*cross_compile:
1
*version:
4.3.2
*multilib:
. ;
*multilib_defaults:
*multilib_extra:
*multilib_matches:
*multilib_exclusions:
*multilib_options:
*linker:
collect2
*link_libgcc:
%D
*md_exec_prefix:
*md_startfile_prefix:
*md_startfile_prefix_1:
*startfile_prefix_spec:
*sysroot_spec:
--sysroot=%R
*sysroot_suffix_spec:
*sysroot_hdrs_suffix_spec:
*cc1_cpu:
%{mcpu=*:-mtune=%* %n`-mcpu=' is deprecated. Use `-mtune=' or '-march='
instead.
} %<mcpu=* %{mintel-syntax:-masm=intel %n`-mintel-syntax' is deprecated. Use
`-masm=intel' instead.
} %{mno-intel-syntax:-masm=att %n`-mno-intel-syntax' is deprecated. Use
`-masm=att' instead.
}%{march=native:%<march=native %:local_cpu_detect(arch)
%{!mtune=*:%<mtune=native %:local_cpu_detect(tune)}}
%{mtune=native:%<mtune=native %:local_cpu_detect(tune)}
*link_emulation:
elf_i386
*dynamic_linker:
%{muclibc:%{mglibc:%e-mglibc and -muclibc used
together}/lib/ld-uClibc.so.0;:/lib/ld-linux.so.2}
*link_command:
%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S: %(linker) %l %{pie:-pie} %X
%{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r} %{s} %{t} %{u*} %{x} %{z} %{Z}
%{!A:%{!nostdlib:%{!nostartfiles:%S}}} %{static:} %{L*} %(mfwrap)
%(link_libgcc) %o
%{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}
%(mflib) %{fprofile-arcs|fprofile-generate|coverage:-lgcov}
%{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}
%{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}
----
$ toolchain/bin/i686-pc-linux-gnu-gcc -print-libgcc-file-name
libgcc.a
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clfs.org/pipermail/clfs-support-clfs.org/attachments/20081106/064e5cfb/attachment.html>
More information about the Clfs-support
mailing list