#!/bin/bash PRGNAME=`basename $0` PS4='+ $PRGNAME: ${FUNCNAME+"$FUNCNAME : "}$LINENO: ' set -u set -e BUILDERROR=9 # Try to avoid timeouts in LSF trap "echo ERROR killed by timeout at ; date ; echo nb of processes/thread ; ps -eLf|wc -l ; top -b -n 1 ; ps -eFH ; /usr/sbin/lsof -u ${USER} ; exit ${BUILDERROR}" SIGUSR2 trap "echo ERROR killed manually at ; date ; echo nb of processes/thread ; ps -eLf|wc -l ; top -b -n 1 ; ps -eFH ; /usr/sbin/lsof -u ${USER} ; exit ${BUILDERROR}" SIGTERM rundir=`pwd -P` mydir="$(dirname $0)" cd "${mydir}" mydir="$(pwd)" languages=c,c++ opt_prev= gcc3_only= nocheck= longcheck= check_only= thumb= noprereq= targetboard=no mode= cpu= fpu= simu= die () { echo "Error: $*" >&2 exit 2 } display_usage () { cat < $0: Build a cross GCC Options are: --linaro GCC source is from a gcc-linaro tree Default: No. --linaro-4.7 GCC source is from a gcc-linaro-4.7 tree Default: No. --git GCC source is from the gcc-fsf-git tree. Default: No. --svn GCC source is from the gcc-svn tree. Default: No. --lp GCC source is from a gcc-lp tree Default: No. --gcc-source Name of GCC directory under source root Default: None. --source-root SOURCE_ROOT Root source directory Default: /work/sources --build-root BUILD_ROOT Root build directory Default: /work/builds/MUNGE --common-build-root COMMON_BUILD_ROOT Root for common built files Default: /work/builds/common --common-prefix COMMON_PREFIX Prefix for common tools Default: /work/local --force-common Force build of common tools Default: No. --target TARGET Target to build Default: arm-none-linux-gnueabi --lang LANGUAGE Add a language to the build Default: c, c++ --no-check Don't run checks --gcc3 Rebuild only the 3rd GCC + make check --longcheck Long validation (several configurations) --check-only Only run the tests, do not rebuild (to save time) --thumb Build with --with-mode=thumb --clean Cleanup before starting --distcc Enable use of DISTCC. --help Display this help --no-prereq Do not expect prerequisites to be available: build them. --target-board BOARD Set the --target-board argument for runtest. --mode MODE Set the --with-mode argument. --cpu CPU Set the --with-cpu argument. --fpu FPU Set the --with-fpu argument. --simu CPU Set the simulated cpu. -x set -x. EOF } while test $# -gt 0 do opt_option="$1" if test -n "${opt_prev}"; then eval "${opt_prev}=\${opt_option}" opt_prev= shift 1 continue fi opt_arg=`expr "x${opt_option}" : 'x[^=]*=\(.*\)'` || true case "${opt_option}" in --target=*) target="${opt_arg}" ;; --target) opt_prev=target ;; --gcc-source=*) gcc_srcdir="${opt_arg}" ;; --gcc-source) opt_prev=gcc_srcdir ;; --source-root=*) source_root="${opt_arg}" ;; --source-root) opt_prev=source_root ;; --build-root=*) build_root="${opt_arg}" ;; --build-root) opt_prev=build_root ;; --common-build-root=*) common_build_root="${opt_arg}" ;; --common-build-root) opt_prev=common_build_root ;; --common-prefix=*) common_prefix="${opt_arg}" ;; --common_prefix) opt_prev=common_prefix ;; --lang=*) languages="${languages},${opt_arg}" ;; --lang) languages="${languages},$2" shift ;; --force-common) build_qemu=yes ;; --linaro) src_top=gcc-linaro ;; --linaro-4.7) src_top=gcc-linaro-4.7 ;; --lp) src_top=gcc-lp-bzr-shared ;; --gcc3) gcc3_only=yes ;; --git) src_top=gcc-fsf-git ;; --svn) src_top=gcc-svn ;; --distcc) distcc=distcc ;; --clean) do_clean=yes ;; --no-check) do_check=no ;; --longcheck) longcheck=yes ;; --check-only) check_only=yes ;; --thumb) thumb=yes mode=thumb ;; --arm) thumb= mode=arm ;; --help | -h) display_usage exit 1 ;; --no-prereq) noprereq=yes ;; --target-board=*) targetboard="${opt_arg}" ;; --target-board) targetboard= if [ $# -gt 1 ] then targetboard="$2" shift fi ;; --mode=*) mode="${opt_arg}" ;; --mode) opt_prev=mode ;; --cpu=*) cpu="${opt_arg}" ;; --cpu) opt_prev=cpu ;; --fpu=*) fpu="${opt_arg}" ;; --fpu) opt_prev=fpu ;; --simu=*) simu="${opt_arg}" ;; --simu) opt_prev=simu ;; -x) set -x ;; *) die "Unknown option ${opt_option}" ;; esac shift done if test -z "${gcc_srcdir:-}"; then die "Please specify --gcc-source" fi target="${target:-arm-none-linux-gnueabi}" distcc="${distcc:-}" src_top="${src_top:-gcc-fsf}" # Set defaults depending on target case ${target} in arm*-*) [ "x$mode" = "x" ] && mode=arm [ "x$cpu" = "x" ] && cpu=cortex-a9 [ "x$fpu" = "x" ] && fpu=neon [ "x$simu" = "x" ] && simu=$cpu ;; aarch64*) [ "x$mode" = "x" ] && mode=default [ "x$cpu" = "x" ] && cpu=default [ "x$fpu" = "x" ] && fpu=default [ "x$simu" = "x" ] && simu=$cpu ;; *) echo ERROR: Unsupported target ${target} exit 1 ;; esac #source_root="$HOME/devel/sources" #default_build_root="$HOME/devel/builds/${linaro_build:+linaro-}${gcc_srcdir}-${target}" #source_root="${source_root:-/work/sources}" #default_build_root="/work/builds/${src_top}-${gcc_srcdir}" source_root=$rundir/sources case ${mode} in thumb) thumb=yes ;; esac default_build_root="$rundir/builds/${src_top}-${gcc_srcdir}${thumb:+-thumb}" build_root="${build_root:-$default_build_root}" # Normalize mode, cpu, fpu options. case ${mode} in default) wmode= ;; *) wmode="--with-mode=${mode}" ;; esac case ${cpu} in default) wcpu= ;; *) wcpu="--with-cpu=${cpu}" ;; esac case ${fpu} in default) wfpu= ;; *) wfpu="--with-fpu=${fpu}" ;; esac case ${simu} in default) simu=any ;; esac case ${target} in arm*-*-linux-gnueabi) additional_gcc_configure_opts="--with-float=soft --enable-build-with-cxx" library=glibc need_qemu=no #yes linuxd=v4.x linuxv=linux-4.20.17 linux_arch=arm ;; arm*-*-linux-gnueabihf) additional_gcc_configure_opts="--with-float=hard --enable-build-with-cxx" library=glibc linuxd=v4.x linuxv=linux-4.20.17 need_qemu=no #yes linux_arch=arm ;; arm*-*-linux-uclibceabi|arm*-*-uclinuxfdpiceabi) additional_gcc_configure_opts="--with-float=soft --enable-build-with-cxx" library=uclibc linuxd=v4.x linuxv=linux-4.20.17 need_qemu=no #yes linux_arch=arm ;; x86_64*-*-linux-gnu) additional_gcc_configure_opts="--disable_bootstrap" library=glibc linuxd=v4.x linuxv=linux-4.20.17 need_qemu=no linux_arch=x86 ;; arm*-*-eabi) additional_gcc_configure_opts="--with-newlib --disable-tls" case "${cpu}:${simu}:${targetboard}" in default:*:*cortex-m*|default:*cortex-m*:*) additional_gcc_configure_opts="${additional_gcc_configure_opts} --enable-multilib --with-multilib-list=rmprofile" ;; default:*:*cortex-a*) additional_gcc_configure_opts="${additional_gcc_configure_opts} --enable-multilib --with-multilib-list=aprofile" ;; # We use 'any' simu when we want to activate tests for new # features. This is helpful to disable multilibs when build # gcc-8 which is broken in arm/cmse.c: we keep arm926 for the # default arm-none-eabi config in gcc-8, and we can use any in # more recent gcc versions. default:any:) additional_gcc_configure_opts="${additional_gcc_configure_opts} --enable-multilib --with-multilib-list=aprofile,rmprofile" ;; esac library=newlib need_qemu=no ;; aarch64*-*-elf) additional_gcc_configure_opts="--with-newlib --disable-tls" library=newlib need_qemu=no ;; aarch64*-*-linux-gnu) additional_gcc_configure_opts= library=glibc case ${src_top} in gcc-linaro-4.7) library=eglibc ;; esac linuxd=v4.x linuxv=linux-4.20.17 need_qemu=no linux_arch=arm64 ;; arm*|aarch64*) echo "Error: unsupported target: ${target}" exit 1 ;; *) echo ERROR: Unsupported target: ${target} exit 1 ;; esac additional_gcc_configure_opts="$additional_gcc_configure_opts ${wmode} ${wcpu} ${wfpu}" if [ "x$noprereq" != "xyes" ] then prereqdir=${rundir}/prereq #additional_gcc_configure_opts="${additional_gcc_configure_opts} --with-gmp=${prereqdir}/gmp-5.0.2/install --with-mpfr=${prereqdir}/mpfr-3.1.0/install --with-mpc=${prereqdir}/mpc-0.9/install --with-ppl=${prereqdir}/ppl-0.11.2/install --with-cloog=${prereqdir}/cloog-0.16.3 --enable-cloog-backend=isl --with-libelf=${prereqdir}/libelf-0.8.13/install" additional_gcc_configure_opts="${additional_gcc_configure_opts} --with-gmp=${prereqdir}/gmp-5.0.2/install --with-mpfr=${prereqdir}/mpfr-3.1.1/install --with-mpc=${prereqdir}/mpc-0.9/install --with-libelf=${prereqdir}/libelf-0.8.13/install" LD_LIBRARY_PATH=${prereqdir}/gmp-5.0.2/install/lib:${prereqdir}/mpfr-3.1.1/install/lib:${prereqdir}/mpc-0.9/install/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} export LD_LIBRARY_PATH fi objs="${build_root}/obj-${target}" prefix="${build_root}/tools" sysroot="${build_root}/sysroot-${target}" common_objs="${common_build_root:-/work/builds/common}" common_prefix="${common_prefix:-/work/local}" # Workaround mkdir -p "${prefix}/info/dir" sourceware_git=git://209.132.180.131/git get_linux () { if test "${linux_arch:-no-linux}" != "no-linux"; then if test ! -d "${source_root}/${linuxv}"; then cd "${source_root}" test -f "${linuxv}".tar.bz2 || wget --no-check-certificate "http://www.kernel.org/pub/linux/kernel/${linuxd}/${linuxv}.tar.bz2" tar xf "${linuxv}.tar.bz2" fi fi } get_binutils () { if test ! -d "${source_root}/binutils"; then build_binutils=yes git clone ${sourceware_git}/binutils.git "${source_root}/binutils" fi } get_newlib () { if test ! -d "${source_root}/newlib"; then git clone ${sourceware_git}/newlib.git "${source_root}/newlib" fi } get_qemu () { if test "x${need_qemu}" = "xyes"; then if test ! -d "${source_root}/qemu-linaro"; then build_qemu=yes git clone git://git.linaro.org/qemu/qemu-linaro.git "${source_root}/qemu-linaro" fi else build_qemu=no fi } get_eglibc () { if test ! -d "${source_root}/eglibc"; then # svn co svn://svn.eglibc.org/trunk "${source_root}/eglibc" svn co svn://67.207.128.95/trunk "${source_root}/eglibc" cd "${source_root}/eglibc/libc" if test ! -e ./ports; then ln -s ../ports . fi fi } get_glibc () { if test ! -d "${source_root}/glibc"; then git clone /prj/compwork2/lyon/Work/mirrors/glibc/ fi } get_uclibc () { if test ! -d "${source_root}/uclibc-ng"; then git clone /prj/compwork2/lyon/Work/mirrors/uclibc/ fi } sync_files () { local dir dir=$1 ssh msgd@172.17.2.7 mkdir -p $dir for i in bin lib libexec; do if test -d $dir/$i; then rsync --progress -a -e "ssh" "$dir/$i" msgd@172.17.2.7:$dir fi done } if test -n "${distcc}"; then new_path=/usr/lib/distcc:$PATH parallelism="-j`distcc -j`" else new_path=$PATH cpus=`cat /proc/cpuinfo |grep processor|wc -l` #parallelism=$(($cpus * 3 / 2)) #parallelism="-j${parallelism} -l${parallelism}" parallelism="-j${cpus}" export | grep MAKE_SLOTS && parallelism="-j$((${MAKE_SLOTS}))" fi #cp /home/lyon/proot-snap_eintr6 ${rundir} #PROOT_FOR_BUILD=${rundir}/proot-snap_eintr6 PROOT_FOR_BUILD= if test "${do_check:-yes}" = "yes"; then # Compute CPU value for QEMU: QEMU_CPU= case ${target} in arm*-*) QEMU_CPU=${cpu} case ${cpu} in cortex-a5) # Cortex-A5 is not supported yet by QEMU QEMU_CPU=cortex-a9 ;; cortex-a57) # Cortex-A57 is not supported yet by QEMU QEMU_CPU=any ;; esac QEMU_CPU=$simu case ${target} in arm-*) QEMU=qemu-arm case ${simu} in *-system) QEMU=qemu-system-arm QEMU_CPU=$(echo ${simu} | sed 's/-system//') ;; esac case $targetboard in *mpure-code*) QEMU=umeq-arm-1.3.1-24-g8109134cab49-dirty ;; esac ;; armeb-*) QEMU=qemu-armeb ;; esac # Copy qemu and proot binaries, proot libs and wrapper to # build dir, to avoid NFS accesses during validation ID=`lsb_release -i` case $ID in *RedHat*) VER=`lsb_release -r | awk '{print $2;}'` case $VER in 4*) QEMU_BIN=`type $QEMU | awk '{print $3;}'` PROOT=`type proot | awk '{print $3;}'` ;; 5*) QEMU_BIN=/sw/st/gnu_compil/gnu/Linux-RH-5-x86_64/.package/qemu-2.0.0/bin/$QEMU PROOT=/sw/st/gnu_compil/gnu/Linux-RH-5-x86_64/bin/proot ;; 6*) QEMU_BIN=/sw/st/gnu_compil/gnu/Linux-RH-6-x86_64/.package/qemu-2.8.1/bin/$QEMU case $QEMU in qemu*) QEMU_BIN=/sw/st/gnu_compil/gnu/Linux-ubuntu-16.04-x86_64/.package/qemu-5.0.0/bin/$QEMU ;; umeq*) QEMU_BIN=/prj/compwork2/lyon/Downloads/$QEMU ;; esac PROOT=/sw/st/gnu_compil/gnu/Linux-RH-5-x86_64/bin/proot ;; esac ;; *) QEMU_BIN=`type $QEMU | awk '{print $3;}'` PROOT=`type proot | awk '{print $3;}'` #QEMU_BIN=/home/christophe.lyon/umeq-arm-1.3.1-23-g0c491e1c9f98 #QEMU=umeq-arm-1.3.1-23-g0c491e1c9f98 #QEMU_BIN=/home/christophe.lyon/umeq-arm-1.3.1-24-g8109134cab49 #QEMU=umeq-arm-1.3.1-24-g8109134cab49 ;; esac ;; aarch64-*linux*) QEMU_CPU=$simu QEMU=qemu-aarch64 # QEMU_BIN=/sw/st/gnu_compil/gnu/Linux-RH-6-x86_64/.package/qemu-2.8.1/bin/$QEMU # PROOT=/sw/st/gnu_compil/gnu/Linux-RH-5-x86_64/bin/proot QEMU_BIN=`type $QEMU | awk '{print $3;}'` PROOT=`type proot | awk '{print $3;}'` ;; aarch64*-*elf) ;; *) echo ERROR: Unsupported target: $target exit 1 ;; esac if [ x$QEMU_CPU != x ]; then mkdir -p ${objs}/gcc3/utils/bin ${objs}/gcc3/utils/lib cp ${QEMU_BIN} ${objs}/gcc3/utils/bin/ QEMU_BIN=${objs}/gcc3/utils/bin/$QEMU cp ${PROOT} ${objs}/gcc3/utils/bin/proot PROOT=${objs}/gcc3/utils/bin/proot PROOT_LIBS=`ldd ${PROOT} | grep sw | awk '{print $3;}'` [ "x${PROOT_LIBS}" != "x" ] && cp ${PROOT_LIBS} ${objs}/gcc3/utils/lib/ LD_LIBRARY_PATH=${objs}/gcc3/utils/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} export LD_LIBRARY_PATH case ${simu} in *-system) case "$target:$cpu:$targetboard" in arm-none-eabi:cortex-m33:*|\ arm-none-eabi:*:*cortex-m33*|\ arm-none-eabi:*:*armv8-m.main*|\ arm-none-eabi:cortex-m55:*|\ arm-none-eabi:*:*cortex-m55*) QEMU_BOARD=musca-b1 STACK=0x1a480000 cat ${mydir}/qemu-system-wrapper.sh | \ sed -e 's/QEMU_CPU/'"${QEMU_CPU}"'/g' \ -e 's/QEMU_BOARD/'"${QEMU_BOARD}"'/g' \ > ${objs}/gcc3/utils/bin/qemu-wrapper.sh ;; *) echo "ERROR: Unsupported QEMU system target: $target:$cpu:$targetboard" exit 1 ;; esac ;; *) cat ${mydir}/qemu-wrapper.sh | \ sed -e 's/QEMU_CPU/'"${QEMU_CPU}"'/g' \ -e 's,WHICHSYSROOT,'"${sysroot}"',g' \ -e 's,BUILDROOT,'"${objs}"',g' \ -e 's,PROOT,'"${PROOT} ${linuxv:+-k ${linuxv#linux-}}"',g' \ -e "s,QEMU_BIN,${QEMU_BIN}," > ${objs}/gcc3/utils/bin/qemu-wrapper.sh ;; esac chmod +x ${objs}/gcc3/utils/bin/qemu-wrapper.sh ${PROOT} --version fi fi case "${languages}" in *gnat*) CC=gcc-4.6 ;; *) CC=gcc ;; esac echo "GCC version: " $CC --version if [ "$gcc3_only" != "yes" -a "$check_only" != "yes" ] then if test ! -e ${common_prefix}/bin/qemu-arm; then build_qemu=yes fi case "${library:-No Library I know of}" in glibc) get_glibc get_linux ;; eglibc) get_eglibc get_linux ;; newlib) get_newlib ;; uclibc) get_uclibc ;; *) die "Unrecognized library: ${library}" ;; esac get_binutils get_qemu if test "${build_qemu:-no}" = "yes"; then mkdir -p "${common_objs}/qemu" cd "${common_objs}/qemu" "${source_root}/qemu-linaro/configure" \ --target-list=arm-linux-user,armeb-linux-user \ --prefix="${common_prefix}" PATH=${new_path} make ${parallelism} PATH=${new_path} make ${parallelism} install fi if test "${do_clean:-no}" = "yes"; then rm -rf "${objs}" rm -rf "${prefix}" rm -rf "${sysroot}" fi echo TRACE: BUILD BINUTILS `date` cwd="$(pwd)" mkdir -p "${objs}/binutils" cd "${objs}/binutils" if test -e "config.status"; then ./config.status else CC=${CC} \ "${source_root}/binutils/configure" \ --target="${target}" \ --prefix="${prefix}" \ --with-sysroot="${sysroot}" || exit ${BUILDERROR} fi PATH=${new_path} ${PROOT_FOR_BUILD} make ${parallelism} all-gas all-ld all-binutils || exit ${BUILDERROR} PATH=${new_path} ${PROOT_FOR_BUILD} make ${parallelism} install-gas install-ld install-binutils || exit ${BUILDERROR} if test -n "${distcc}"; then sync_files "${prefix}" fi # Ensure sources are appropriately up to date. cd ${source_root}/${src_top}/${gcc_srcdir} ./contrib/gcc_update --touch echo TRACE: BUILD GCC1 `date` mkdir -p "${objs}/gcc1" cd "${objs}/gcc1" if test -e "config.status"; then ./config.status else PATH="${prefix}/bin":"${common_prefix}/bin":$PATH \ CC=${CC} \ "${source_root}/${src_top}/${gcc_srcdir}/configure" \ --target="${target}" \ --prefix="${prefix}" \ --disable-nls \ --without-headers --with-newlib \ --disable-shared --disable-threads --disable-libssp \ --disable-libgomp --disable-libmudflap \ --disable-libatomic --disable-libcilkrts \ --without-libquadmath --disable-libquadmath \ --enable-languages=c ${additional_gcc_configure_opts} || exit ${BUILDERROR} fi status=/tmp/status.$$ log=/tmp/log.$$ echo 0 > ${status} (PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} ${PROOT_FOR_BUILD} make $parallelism || echo $? > ${status}) 2>&1 | tee $log this_status=`cat ${status}` separator=`grep "issing separator" ${log} || true` host_wide_int=`grep "HOST_WIDE_INT" ${log} || true` cat ${log} rm -f ${log} rm -f ${status} if [ ${this_status} != 0 ] then # Check if potential parallel make problem: if [ "x${separator}" != "x" ] then echo TRACE: RE-BUILD GCC1 BECAUSE OF MAKE DEPENDENCY PROBLEM `date` PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} ${PROOT_FOR_BUILD} make $parallelism || exit ${BUILDERROR} else if [ "x${host_wide_int}" != "x" ] then echo TRACE: HOST WIDE INT PROBLEM grep INT64_T_IS_LONG gcc/auto-host.h exit ${BUILDERROR} else echo TRACE: RE-BUILD GCC1 at -j1 for better backtrace PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} ${PROOT_FOR_BUILD} make || exit ${BUILDERROR} fi fi fi PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} ${PROOT_FOR_BUILD} make install || exit ${BUILDERROR} if test -n "${distcc}"; then sync_files "${prefix}" fi case "${library}" in eglibc|glibc) echo TRACE: BUILD EGLIBC/GLIBC-HEADERS `date` cp -r "${source_root}/${linuxv}" "${objs}/linux" cd "${objs}/linux" PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} \ ${PROOT_FOR_BUILD} make ${parallelism} headers_install \ ARCH=${linux_arch} CROSS_COMPILE="${distcc} ${target}-" \ INSTALL_HDR_PATH="${sysroot}/usr" || exit ${BUILDERROR} if test -n "${distcc}"; then sync_files "${prefix}" fi case "${library}" in eglibc) mkdir -p "${objs}/eglibc-headers" cd "${objs}/eglibc-headers" ;; glibc) mkdir -p "${objs}/glibc-headers" cd "${objs}/glibc-headers" ;; esac if test -e "config.status"; then ./config.status else case "${library}" in eglibc) PATH="${prefix}/bin":"${common_prefix}/bin":$PATH \ BUILD_CC="${distcc} ${CC}" \ CC="${distcc} ${prefix}/bin/${target}-gcc" \ CXX="${distcc} ${prefix}/bin/${target}-g++" \ AS="${prefix}/bin/${target}-as" \ LD="${prefix}/bin/${target}-ld" \ AR="${prefix}/bin/${target}-ar" \ RANLIB="${prefix}/bin/${target}-ranlib" \ "${source_root}/eglibc/libc/configure" \ --prefix=/usr \ --with-headers="${sysroot}/usr/include" \ --host=${target} \ --disable-profile --without-gd --without-cvs --enable-add-ons=nptl --enable-obsolete-rpc || exit ${BUILDERROR} ;; glibc) PATH="${prefix}/bin":"${common_prefix}/bin":$PATH \ BUILD_CC="${distcc} ${CC}" \ CC="${distcc} ${prefix}/bin/${target}-gcc" \ CXX="${distcc} ${prefix}/bin/${target}-g++" \ AS="${prefix}/bin/${target}-as" \ LD="${prefix}/bin/${target}-ld" \ AR="${prefix}/bin/${target}-ar" \ RANLIB="${prefix}/bin/${target}-ranlib" \ "${source_root}/glibc/configure" \ --prefix=/usr \ --with-headers="${sysroot}/usr/include" \ --host=${target} \ --disable-werror \ --disable-profile --without-gd --without-cvs --enable-obsolete-rpc || exit ${BUILDERROR} mkdir -p ${sysroot}/usr/include/gnu touch ${sysroot}/usr/include/gnu/stubs.h ;; esac fi ${PROOT_FOR_BUILD} make PARALLELMFLAGS="${parallelism}" install-headers install_root="${sysroot}" \ install-bootstrap-headers=yes || exit ${BUILDERROR} if test -n "${distcc}"; then sync_files "${prefix}" fi mkdir -p "${sysroot}/usr/lib" ${PROOT_FOR_BUILD} make ${parallelism} csu/subdir_lib cp csu/crt1.o csu/crti.o csu/crtn.o "${sysroot}/usr/lib" PATH="${prefix}/bin":"${common_prefix}/bin":$PATH \ $distcc ${prefix}/bin/${target}-gcc -nostdlib -nostartfiles -shared -x c /dev/null \ -o "${sysroot}/usr/lib/libc.so" if test -n "${distcc}"; then sync_files "${prefix}" fi echo TRACE: BUILD GCC2 `date` mkdir -p "${objs}/gcc2" cd "${objs}/gcc2" if test -e "config.status"; then ./config.status else PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} \ CC=${CC} \ "${source_root}/${src_top}/${gcc_srcdir}/configure" \ --target="${target}" \ --prefix="${prefix}" \ --with-sysroot="${sysroot}" \ --disable-nls \ --disable-libssp --disable-libgomp --disable-libmudflap --disable-libatomic \ --disable-libcilkrts --disable-libquadmath --without-libquadmath \ --enable-languages=c ${additional_gcc_configure_opts} || exit ${BUILDERROR} fi status=/tmp/status.$$ log=/tmp/log.$$ echo 0 > ${status} (PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} ${PROOT_FOR_BUILD} make $parallelism || echo $? > ${status}) 2>&1 | tee $log this_status=`cat ${status}` separator=`grep "issing separator" ${log} || true` host_wide_int=`grep "HOST_WIDE_INT" ${log} || true` cat ${log} rm -f ${log} rm -f ${status} if [ ${this_status} != 0 ] then # Check if potential parallel make problem: if [ "x${separator}" != "x" ] then echo TRACE: RE-BUILD GCC2 because of make-problem `date` PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} ${PROOT_FOR_BUILD} make $parallelism || exit ${BUILDERROR} else if [ "x${host_wide_int}" != "x" ] then echo TRACE: HOST WIDE INT PROBLEM grep INT64_T_IS_LONG gcc/auto-host.h exit ${BUILDERROR} else echo TRACE: RE-BUILD GCC2 at -j1 for better backtrace PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} ${PROOT_FOR_BUILD} make || exit ${BUILDERROR} fi fi fi PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} ${PROOT_FOR_BUILD} make install || exit ${BUILDERROR} echo TRACE: BUILD EGLIBC/GLIBC-1 `date` if test -n "${distcc}"; then sync_files "${prefix}" fi case "${library}" in eglibc) mkdir -p "${objs}/eglibc-1" cd "${objs}/eglibc-1" ;; glibc) mkdir -p "${objs}/glibc-1" cd "${objs}/glibc-1" ;; esac if test -e "config.status"; then ./config.status else case "${library}" in eglibc) PATH="${prefix}/bin":"${common_prefix}/bin":$PATH \ BUILD_CC="${distcc} ${CC}" \ CC="${distcc} ${prefix}/bin/${target}-gcc" \ CXX="${distcc} ${prefix}/bin/${target}-g++" \ AS="${prefix}/bin/${target}-as" \ LD="${prefix}/bin/${target}-ld" \ AR="${prefix}/bin/${target}-ar" \ RANLIB="${prefix}/bin/${target}-ranlib" \ "${source_root}/eglibc/libc/configure" \ --prefix=/usr \ --with-headers="${sysroot}/usr/include" \ --host="${target}" \ --disable-profile --without-gd --without-cvs --enable-add-ons=nptl --enable-obsolete-rpc || exit ${BUILDERROR} ;; glibc) PATH="${prefix}/bin":"${common_prefix}/bin":$PATH \ BUILD_CC="${distcc} ${CC}" \ CC="${distcc} ${prefix}/bin/${target}-gcc" \ CXX="${distcc} ${prefix}/bin/${target}-g++" \ AS="${prefix}/bin/${target}-as" \ LD="${prefix}/bin/${target}-ld" \ AR="${prefix}/bin/${target}-ar" \ RANLIB="${prefix}/bin/${target}-ranlib" \ "${source_root}/glibc/configure" \ --prefix=/usr \ --with-headers="${sysroot}/usr/include" \ --host="${target}" \ --disable-werror \ --disable-profile --without-gd --without-cvs --enable-obsolete-rpc || exit ${BUILDERROR} ;; esac fi PATH="${prefix}/bin":"${common_prefix}/bin":$new_path ${PROOT_FOR_BUILD} make PARALLELMFLAGS="${parallelism}" || exit ${BUILDERROR} PATH="${prefix}/bin":"${common_prefix}/bin":$new_path ${PROOT_FOR_BUILD} make PARALLELMFLAGS="${parallelism}" install \ install_root="${sysroot}" || exit ${BUILDERROR} case ${src_top} in gcc-linaro-4.7) rm -rf ${sysroot}/usr/lib ln -sf lib64 ${sysroot}/usr/lib ;; esac ;; newlib) echo TRACE: BUILD NEWLIB `date` mkdir -p "${objs}/newlib" cd "${objs}/newlib" if test -e "config.status"; then ./config.status else PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} \ "${source_root}/newlib/configure" \ --target="${target}" \ --prefix="${prefix}" \ --enable-newlib-io-pos-args \ --enable-newlib-io-c99-formats \ --enable-newlib-io-long-long \ --enable-newlib-io-long-double \ --with-sysroot="${sysroot}" fi PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} ${PROOT_FOR_BUILD} make $parallelism all-target-newlib all-target-libgloss PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} ${PROOT_FOR_BUILD} make $parallelism install-target-newlib # Because of missing dependency in libgloss' Makefile, we need to install it after newlib PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} ${PROOT_FOR_BUILD} make $parallelism install-target-libgloss ;; uclibc) echo TRACE: BUILD UCLIBC `date` cp -r "${source_root}/${linuxv}" "${objs}/linux" cd "${objs}/linux" PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} \ ${PROOT_FOR_BUILD} make ${parallelism} headers_install \ ARCH=${linux_arch} CROSS_COMPILE="${distcc} ${target}-" \ INSTALL_HDR_PATH="${sysroot}/usr" || exit ${BUILDERROR} if test -n "${distcc}"; then sync_files "${prefix}" fi mkdir -p "${objs}/uclibc" cd "${objs}/uclibc" rsync -av ${source_root}/uclibc-ng/* . sed "s;__KERNEL_HEADERS__;${sysroot}/usr/include;g" config_template | \ sed "s;__CROSS_COMPILER_PREFIX__;${target}-;g" | \ sed "s;__DODEBUG__;DODEBUG=y;g" | \ sed "s;__DODEBUG_PT__;# DODEBUG_PT is not set;g" | \ sed "s;# COMPILE_IN_THUMB_MODE is not set;COMPILE_IN_THUMB_MODE=y;g" | \ sed "s;__DOSTRIP__;# DOSTRIP is not set;g" > .config PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} ${PROOT_FOR_BUILD} make $parallelism all V=0 PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} ${PROOT_FOR_BUILD} make $parallelism install PREFIX=${sysroot} ;; *) die "Unknown library" ;; esac if test -n "${distcc}"; then sync_files "${prefix}" fi fi # gcc3_only echo TRACE: BUILD GCC3 `date` mkdir -p "${objs}/gcc3" cd "${objs}/gcc3" if [ "$gcc3_only" != "yes" ] then if test -e "config.status"; then ./config.status else case ${target}-${mode}-${cpu}-${fpu} in arm-none-eabi-default-default-default) export CXXFLAGS_FOR_TARGET="-fno-threadsafe-statics -O2 -g" ;; esac PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} \ CC=${CC} \ "${source_root}/${src_top}/$gcc_srcdir/configure" \ --target="${target}" \ --prefix="${prefix}" \ --with-sysroot="${sysroot}" \ --disable-nls \ --disable-libgomp --disable-libmudflap \ --disable-libcilkrts --enable-checking \ --enable-languages=${languages} ${additional_gcc_configure_opts} || exit ${BUILDERROR} fi fi # gcc3_only if [ "$check_only" != "yes" ]; then status=/tmp/status.$$ log=/tmp/log.$$ echo 0 > ${status} (PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} ${PROOT_FOR_BUILD} make $parallelism || echo $? > ${status}) 2>&1 | tee $log this_status=`cat ${status}` separator=`grep "issing separator" ${log} || true` host_wide_int=`grep "HOST_WIDE_INT" ${log} || true` cat ${log} rm -f ${log} rm -f ${status} if [ ${this_status} != 0 ] then # Check if potential parallel make problem: if [ "x${separator}" != "x" ] then echo TRACE: RE-BUILD GCC3 because of make-problem `date` PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} ${PROOT_FOR_BUILD} make $parallelism || exit ${BUILDERROR} else if [ "x${host_wide_int}" != "x" ] then echo TRACE: HOST WIDE INT PROBLEM grep INT64_T_IS_LONG gcc/auto-host.h exit ${BUILDERROR} else echo TRACE: RE-BUILD GCC3 at -j1 for better backtrace PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} ${PROOT_FOR_BUILD} make || exit ${BUILDERROR} fi fi fi PATH="${prefix}/bin":"${common_prefix}/bin":${new_path} ${PROOT_FOR_BUILD} make install || exit ${BUILDERROR} if test -n "${distcc}"; then sync_files "${prefix}" fi rsync -a ${prefix}/${target}/lib* ${sysroot}/ case "${target}" in arm*-*-linux-gnueabihf) cd "${sysroot}/lib" ln -fs ld-linux-armhf.so.3 ld-linux.so.3 cd "${objs}/gcc3" ;; aarch64-*-linux-gnu) case ${src_top} in gcc-linaro-4.7) ;; *) #scp -P9022 "${prefix}/${target}"/lib*/lib[au]san.so* root@armv8model:/lib ;; esac ;; esac case $target in arm*) ;; aarch64*) ;; *) echo "No validation for target $target" exit 0 ;; esac fi # check_only if test "${do_check:-yes}" = "yes"; then echo TRACE: MAKE CHECK `date` set -x # Build and install our own version of Dejagnu mkdir -p "${objs}/dejagnu" pushd "${objs}/dejagnu" if test -e "config.status"; then ./config.status else CC=${CC} \ "${source_root}/dejagnu/configure" \ --prefix="${objs}/gcc3/utils" || exit ${BUILDERROR} fi PATH=${new_path} ${PROOT_FOR_BUILD} make ${parallelism} all || exit ${BUILDERROR} PATH=${new_path} ${PROOT_FOR_BUILD} make ${parallelism} install || exit ${BUILDERROR} popd PATH=${objs}/gcc3/utils/bin:$PATH type runtest runtest --version TARGETDIR=${prefix}/${target} if [ "x$targetboard" = "xno" ] then TARGLIST=",-marm" else TARGLIST=$targetboard fi if [ "$longcheck" = "yes" ] then TARGLIST=",-mthumb,-marm,-march=armv5t" fi case ${simu} in *-system) case "$target:$cpu:$targetboard" in arm-none-eabi:cortex-m33:*|\ arm-none-eabi:*:*cortex-m33*|\ arm-none-eabi:*:*armv8-m.main*|\ arm-none-eabi:cortex-m55:*|\ arm-none-eabi:*:*cortex-m55*) cp ${mydir}/musca-b1.ld ${sysroot}/lib/ cp ${mydir}/musca-b1.specs ${sysroot}/lib/ TARGLIST="$TARGLIST/--specs=musca-b1.specs" ;; esac ;; *) case "$target:$cpu:$targetboard" in arm-none-eabi:cortex-m0:*mpure-code*) cp ${mydir}/umeq.ld ${TARGETDIR}/lib/ TARGLIST="$TARGLIST/-Tumeq.ld/--specs=rdimon.specs" ;; esac ;; esac MYRUNTESTFLAGS=${RUNTESTFLAGS:-} # To avoid problems with 'set -u' RUNTESTFLAGS=$(echo $MYRUNTESTFLAGS | sed 's/:/ /') if [ "x$TARGLIST" != "x" ] then TARGLIST="{"$TARGLIST"}" fi cat ${mydir}/site-qemu.exp | sed \ -e 's|{TARGLIST}|'"$TARGLIST"'|' \ -e 's|TARGETDIR|'"${TARGETDIR}"'|' \ -e 's,QEMU_WRAPPER,'"${objs}"/gcc3/utils/bin/qemu-wrapper.sh',g' \ > "${TARGETDIR}/site-qemu.exp" cat ${mydir}/qemu.exp.in | sed \ -e 's,QEMU_WRAPPER,'"${objs}"/gcc3/utils/bin/qemu-wrapper.sh',g' \ > "${TARGETDIR}/qemu.exp" cp ${mydir}/invoke-foundation-v8-bare-metal.sh ${TARGETDIR}/ cp ${mydir}/aarch64-none-elf-foundation.exp ${TARGETDIR}/ cp ${mydir}/myarm-sim.exp ${TARGETDIR}/ cp ${mydir}/tcwg-local.exp ${TARGETDIR}/ cp ${mydir}/ptimeout ${objs}/gcc3/utils/bin/ cp ${mydir}/ts ${objs}/gcc3/utils/bin/ export DEJAGNU="${prefix}/$target/site-qemu.exp" cat $DEJAGNU export PATH="${prefix}/bin":"${common_prefix}/bin":$PATH date ulimit -a case ${target} in aarch64*linux*) # For AArch64, limit to 80GB, asan uses 48GB ulimit -v 83886080 ;; *) # Limit memory use to 10GB ulimit -v 10485760 ;; esac ulimit -a # Use ptimeout to collect zombie processes, if any (21000s ~= 6h) (time ${objs}/gcc3/utils/bin/ptimeout --debug 21000 ${PROOT_FOR_BUILD} make -C "${objs}/gcc3" -k ${parallelism} check || true) | ${objs}/gcc3/utils/bin/ts -s "%.T" date echo PREFIX=$prefix echo TARGET=$target echo DEJAGNU=$DEJAGNU echo PATH=$PATH echo RUNTESTFLAGS=${RUNTESTFLAGS:-} find $objs/gcc3 -name "qemu*.core" -delete -ls || true fi echo "Finished..."