[Clfs-support] Need help building the cross toolchain

Binghoo Dang dangbinghoo at gmail.com
Fri Nov 7 18:19:50 PST 2008


Jon Dufresne 写道:
>> If I'm successful tomorrow I'll post a new (hopefully) working script.
>>     
>
> I was able to successfully build the toolchain. For anyone that is
> following this, has similar problems, or needs inspiration for their
> system, please feel free to learn from my script below. Thanks for all
> the help.
>
> #!/bin/bash
>
> unset CFLAGS
> unset CXXFLAGS
>
> LINUX_ARCH=i386
> HOST=i686-cross-linux-gnu
> TARGET=i686-pc-linux-gnu
>
> PRJROOT=`pwd`
> PACKAGES=${PRJROOT}/packages
> BUILD=${PRJROOT}/build
> TOOLS=${PRJROOT}/tools
> ROOTFS=${PRJROOT}/rootfs
>
> LINUX_VERSION=2.6.27.4
> BINUTILS_VERSION=2.19
> GCC_VERSION=4.3.2
> GLIBC_VERSION=2.8
>
> PATH=${TOOLS}/bin:${PATH}
> export PATH
>
> download_packages()
> {
> 	if [ ! -f ${PACKAGES}/linux-${LINUX_VERSION}.tar.bz2 ]; then
> 		wget --directory-prefix=${PACKAGES} \
> 			http://kernel.org/pub/linux/kernel/v2.6/linux-${LINUX_VERSION}.tar.bz2
> 	fi
>
> 	if [ ! -f ${PACKAGES}/binutils-${BINUTILS_VERSION}.tar.bz2 ]; then
> 		wget --directory-prefix=${PACKAGES} \
> 			http://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.bz2
> 	fi
>
> 	if [ ! -f ${PACKAGES}/gcc-${GCC_VERSION}.tar.bz2 ]; then
> 		wget --directory-prefix=${PACKAGES} \
> 			http://gcc-ca.internet.bs/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2
> 	fi
>
> 	if [ ! -f ${PACKAGES}/glibc-${GLIBC_VERSION}.tar.bz2 ]; then
> 		wget --directory-prefix=${PACKAGES} \
> 			http://ftp.gnu.org/gnu/glibc/glibc-${GLIBC_VERSION}.tar.bz2
> 	fi
> }
>
> build_linux_headers()
> {
> 	echo "Building linux-${LINUX_VERSION} headers"
>
> 	tar -xjf ${PACKAGES}/linux-${LINUX_VERSION}.tar.bz2 -C ${BUILD}
>
> 	cd ${BUILD}/linux-${LINUX_VERSION}
> 	make ARCH=${LINUX_ARCH} headers_check || exit
> 	make ARCH=${LINUX_ARCH} INSTALL_HDR_PATH=${ROOTFS}/usr headers_install || exit
> 	cd ${PRJROOT}
> }
>
> build_binutils()
> {
> 	echo "Building binutils-${BINUTILS_VERSION} HOST=${HOST} TARGET=${TARGET}"
>
> 	tar -xjf ${PACKAGES}/binutils-${BINUTILS_VERSION}.tar.bz2 -C ${BUILD}
>
> 	mkdir -p ${BUILD}/binutils-build
> 	cd ${BUILD}/binutils-build
>
> 	${BUILD}/binutils-${BINUTILS_VERSION}/configure \
> 		--prefix=${TOOLS} \
> 		--build=${HOST} \
> 		--host=${HOST} \
> 		--target=${TARGET} \
> 		--with-sysroot=${ROOTFS} \
> 		--disable-multilib \
> 		--disable-nls \
> 		--enable-shared \
> 		|| exit
>
> 	make configure-host || exit
> 	make || exit
> 	make install || exit
>
> 	cd ${PRJROOT}
> }
>
> build_glibc_headers()
> {
> 	echo "Building glibc-${GLIBC_VERSION} headers"
>
> 	tar xjf ${PACKAGES}/glibc-${GLIBC_VERSION}.tar.bz2 -C ${BUILD}
>
> 	mkdir -p ${BUILD}/glibc-headers-build
> 	cd ${BUILD}/glibc-headers-build
>
> 	echo "libc_cv_forced_unwind=yes" > config.cache
> 	echo "libc_cv_c_cleanup=yes" >> config.cache
>
> 	CC=gcc \
> 	${BUILD}/glibc-${GLIBC_VERSION}/configure \
> 		--prefix=/usr \
> 		--build=${HOST} \
> 		--host=${TARGET} \
> 		--with-headers=${ROOTFS}/usr/include \
> 		|| exit
>
> 	make install_root=${ROOTFS} install-headers || exit
>
> 	#TODO: change cp to install
> 	cp bits/stdio_lim.h ${ROOTFS}/usr/include/bits
> 	touch ${ROOTFS}/usr/include/gnu/stubs.h
> 	cp ../glibc-2.6.1/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h \
> 		${ROOTFS}/usr/include/bits
>
> 	cd ${PRJROOT}
> }
>
> build_gcc_static()
> {
> 	echo "Building gcc-${GCC_VERSION} static"
>
> 	tar xjf ${PACKAGES}/gcc-${GCC_VERSION}.tar.bz2 -C ${BUILD}
>
> 	mkdir -p ${BUILD}/gcc-static-build
> 	cd ${BUILD}/gcc-static-build
>
> 	${BUILD}/gcc-${GCC_VERSION}/configure \
> 		--prefix=${TOOLS} \
> 		--build=${HOST} \
> 		--host=${HOST} \
> 		--target=${TARGET} \
> 		--with-sysroot=${ROOTFS} \
> 		--disable-multilib \
> 		--disable-nls \
> 		--disable-shared \
> 		--enable-languages=c \
> 		|| exit
>
> 	make all-gcc|| exit
> 	make install-gcc || exit
> 	make all-target-libgcc || exit
> 	make install-target-libgcc || exit
>
> 	ln -s libgcc.a ${TOOLS}/lib/gcc/${TARGET}/${GCC_VERSION}/libgcc_eh.a
>
> 	cd ${PRJROOT}
> }
>
> build_glibc()
> {
> 	echo "Building glibc-${GLIBC_VERSION}"
>
> 	mkdir -p ${BUILD}/glibc-build
> 	cd ${BUILD}/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 \
> 	CFLAGS="-march=$(cut -d- -f1 <<< ${TARGET}) -mtune=generic -g -O2" \
> 	${BUILD}/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=${TOOLS}/bin \
> 		--with-headers=${ROOTFS}/usr/include \
> 		--cache-file=config.cache \
> 		|| exit
>
> 	make || exit
> 	make install_root=${ROOTFS} install || exit
>
> 	cd ${PRJROOT}
> }
>
> build_gcc()
> {
> 	echo "Building gcc-${GCC_VERSION}"
>
> 	mkdir -p ${BUILD}/gcc-build
> 	cd ${BUILD}/gcc-build
>
> 	${BUILD}/gcc-${GCC_VERSION}/configure \
> 		--prefix=${TOOLS} \
> 		--build=${HOST} \
> 		--host=${HOST} \
> 		--target=${TARGET} \
> 		--with-sysroot=${ROOTFS} \
> 		--disable-multilib \
> 		--disable-nls \
> 		--enable-shared \
> 		--enable-languages=c,c++ \
> 		|| exit
>
> 	make || exit
> 	make install || exit
>
> 	cd ${PRJROOT}
> }
>
> rm -rf ${BUILD} ${TOOLS} ${ROOTFS}
> if [ ! -d ${PACKAGES} ]; then
> 	mkdir -p ${PACKAGES}
> fi
> mkdir -p ${BUILD}
> download_packages
> build_linux_headers
> build_binutils
> build_glibc_headers
> build_gcc_static
> build_glibc
> build_gcc
> _______________________________________________
> Clfs-support mailing list
> Clfs-support at lists.cross-lfs.org
> http://lists.cross-lfs.org/listinfo.cgi/clfs-support-cross-lfs.org
>   
Jon,
Did you have ever built the toolchain with uClibc and for other arch 
besides x86? Did you try arm?
Yesterday I successfully build the toolchain with uClibc for i686-pc,but 
after I changed arch. to
arm, it failed as the same error.



More information about the Clfs-support mailing list