From 567277099a487508fd228a4c56f3583db3fa96c9 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Mon, 29 May 2017 22:32:38 -0700 Subject: Fix the references to old config variables Signed-off-by: Alexey Neyman --- scripts/build/cc/100-gcc.sh | 1178 ------------------------------------------- scripts/build/cc/gcc.sh | 1156 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1156 insertions(+), 1178 deletions(-) delete mode 100644 scripts/build/cc/100-gcc.sh create mode 100644 scripts/build/cc/gcc.sh (limited to 'scripts/build/cc') diff --git a/scripts/build/cc/100-gcc.sh b/scripts/build/cc/100-gcc.sh deleted file mode 100644 index 2ca8e6f3..00000000 --- a/scripts/build/cc/100-gcc.sh +++ /dev/null @@ -1,1178 +0,0 @@ -# This file adds the function to build the gcc C compiler -# Copyright 2007 Yann E. MORIN -# Licensed under the GPL v2. See COPYING in the root of this package - -# Download gcc -do_gcc_get() { - local linaro_version="" - local linaro_series="" - - if [ "${CT_CC_GCC_CUSTOM}" = "y" ]; then - CT_GetCustom "gcc" "${CT_CC_GCC_CUSTOM_VERSION}" \ - "${CT_CC_GCC_CUSTOM_LOCATION}" - else - case "${CT_CC_GCC_VERSION}" in - linaro-*) - CT_GetLinaro "gcc" "${CT_CC_GCC_VERSION}" - ;; - *) - # The official gcc hosts put gcc under a gcc/release/ directory, - # whereas the mirrors put it in the gcc/ directory. - CT_GetFile "gcc-${CT_CC_GCC_VERSION}" \ - {http,ftp,https}://ftp.gnu.org/gnu/gcc/gcc-${CT_CC_GCC_VERSION} \ - ftp://{gcc.gnu.org,sourceware.org}/pub/gcc/releases/gcc-${CT_CC_GCC_VERSION} - ;; - esac - fi # ! custom location - # Starting with GCC 4.3, ecj is used for Java, and will only be - # built if the configure script finds ecj.jar at the top of the - # GCC source tree, which will not be there unless we get it and - # put it there ourselves - if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" ]; then - CT_GetFile ecj-latest .jar http://mirrors.kernel.org/sourceware/java/ \ - http://crosstool-ng.org/pub/java \ - ftp://gcc.gnu.org/pub/java \ - ftp://sourceware.org/pub/java - fi -} - -# Extract gcc -do_gcc_extract() { - CT_Extract "gcc-${CT_CC_GCC_VERSION}" - CT_Patch "gcc" "${CT_CC_GCC_VERSION}" - - # Copy ecj-latest.jar to ecj.jar at the top of the GCC source tree - if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" \ - -a ! -f "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/ecj.jar" \ - ]; then - CT_DoExecLog ALL cp -v "${CT_TARBALLS_DIR}/ecj-latest.jar" "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/ecj.jar" - fi - - if [ -n "${CT_ARCH_XTENSA_CUSTOM_NAME}" ]; then - CT_ConfigureXtensa "gcc" "${CT_CC_GCC_VERSION}" - fi -} - -#------------------------------------------------------------------------------ -# This function builds up the set of languages to enable -# No argument expected, returns the comma-separated language list on stdout -cc_gcc_lang_list() { - local lang_list - - lang_list="c" - [ "${CT_CC_LANG_CXX}" = "y" ] && lang_list+=",c++" - [ "${CT_CC_LANG_FORTRAN}" = "y" ] && lang_list+=",fortran" - [ "${CT_CC_LANG_ADA}" = "y" ] && lang_list+=",ada" - [ "${CT_CC_LANG_JAVA}" = "y" ] && lang_list+=",java" - [ "${CT_CC_LANG_OBJC}" = "y" ] && lang_list+=",objc" - [ "${CT_CC_LANG_OBJCXX}" = "y" ] && lang_list+=",obj-c++" - [ "${CT_CC_LANG_GOLANG}" = "y" ] && lang_list+=",go" - lang_list+="${CT_CC_LANG_OTHERS:+,${CT_CC_LANG_OTHERS}}" - - printf "%s" "${lang_list}" -} - -#------------------------------------------------------------------------------ -# Report the type of a GCC option -cc_gcc_classify_opt() { - # Options present in multiple architectures - case "${1}" in - -march=*) echo "arch"; return;; - -mabi=*) echo "abi"; return;; - -mcpu=*|-mmcu=*) echo "cpu"; return;; - -mtune=*) echo "tune"; return;; - -mfpu=*) echo "fpu"; return;; - -mhard-float|-msoft-float|-mno-soft-float|-mno-float|-mfloat-abi=*|\ - -mfpu|-mno-fpu) echo "float"; return;; - -EB|-EL|-mbig-endian|-mlittle-endian|-mbig|-mlittle|-meb|-mel|-mb|-ml) echo "endian"; return;; - -mthumb|-marm) echo "mode"; return;; - esac - - # Arch-specific options and aliases - case "${CT_ARCH}" in - m68k) - case "${1}" in - -m68881) echo "float"; return;; - -m5[234]*|-mcfv4e) echo "cpu"; return;; - -m68*|-mc68*) echo "arch"; return;; - esac - ;; - mips) - case "${1}" in - -mips[1234]|-mips32|-mips32r*|-mips64|-mips64r*) echo "cpu"; return;; - esac - ;; - sh) - case "${1}" in - -m[12345]*) echo "cpu"; return;; - esac - esac - - # All tried and failed - echo "unknown" -} - -evaluate_multilib_cflags() -{ - local multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_flags multi_index multi_count - local mdir mdir_os dirtop - local f - - for arg in "$@"; do - eval "${arg// /\\ }" - done - - mdir="lib/${multi_dir}" - mdir_os="lib/${multi_os_dir_gcc}" - CT_SanitizeVarDir mdir mdir_os - CT_DoLog EXTRA " '${multi_flags}' --> ${mdir} (gcc) ${mdir_os} (os)" - for f in ${multi_flags}; do - eval ml_`cc_gcc_classify_opt ${f}`=seen - done - if [ "${CT_DEMULTILIB}" = "y" -a "${CT_USE_SYSROOT}" = "y" ]; then - case "${mdir_os}" in - lib/*) - ;; - *) - dirtop="${mdir_os%%/*}" - if [ ! -e "${multi_root}/${mdir_os}" ]; then - CT_DoExecLog ALL ln -sfv lib "${multi_root}/${mdir_os}" - fi - if [ ! -e "${multi_root}/usr/${mdir_os}" ]; then - CT_DoExecLog ALL ln -sfv lib "${multi_root}/usr/${mdir_os}" - fi - ;; - esac - fi -} - -#------------------------------------------------------------------------------ -# This function lists the multilibs configured in the compiler (even if multilib -# is disabled - so that it lists the default GCC/OS directory, which may differ -# from the default 'lib'). It then performs a few multilib checks/quirks: -# -# 1. On MIPS target, gcc (or rather, ld, which it invokes under the hood) chokes -# if supplied with two -mabi=* options. I.e., 'gcc -mabi=n32' and 'gcc -mabi=32' both -# work, but 'gcc -mabi=32 -mabi=n32' produces an internal error in ld. Thus we do -# not supply target's CFLAGS in multilib builds - and after compiling pass-1 gcc, -# attempt to determine which CFLAGS need to be filtered out. -# -# 2. If "demultilibing" is in effect, create top-level directories for any -# multilibs not in lib/ as symlinks to lib. -cc_gcc_multilib_housekeeping() { - local cc host - local ml_arch ml_abi ml_cpu ml_tune ml_fpu ml_float ml_endian ml_mode ml_unknown ml - local new_cflags - - for arg in "$@"; do - eval "${arg// /\\ }" - done - - if [ \( "${CT_CANADIAN}" = "y" -o "${CT_CROSS_NATIVE}" = "y" \) -a "${host}" = "${CT_HOST}" ]; then - CT_DoLog EXTRA "Canadian Cross/Cross-native unable to confirm multilibs configuration "\ - "directly; will use build-compiler for housekeeping." - # Since we cannot run the desired compiler, substitute build-CC with the assumption - # that the host-CC is configured in the same way. - cc="${CT_BUILDTOOLS_PREFIX_DIR}/bin/${CT_TARGET}-${CT_CC}" - fi - - CT_IterateMultilibs evaluate_multilib_cflags evaluate_cflags - - # Filtering out some of the options provided in CT-NG config. Then *prepend* - # them to CT_TARGET_CFLAGS, like scripts/crosstool-NG.sh does. Zero out - # the stashed MULTILIB flags so that we don't process them again in the passes - # that follow. - CT_DoLog DEBUG "Configured target CFLAGS: '${CT_ARCH_TARGET_CFLAGS_MULTILIB}'" - ml_unknown= # Pass through anything we don't know about - for f in ${CT_ARCH_TARGET_CFLAGS_MULTILIB}; do - eval ml=\$ml_`cc_gcc_classify_opt ${f}` - if [ "${ml}" != "seen" ]; then - new_cflags="${new_cflags} ${f}" - fi - done - CT_DoLog DEBUG "Filtered target CFLAGS: '${new_cflags}'" - CT_EnvModify CT_TARGET_CFLAGS "${new_cflags} ${CT_TARGET_CFLAGS}" - CT_EnvModify CT_ARCH_TARGET_CFLAGS_MULTILIB "" - - # Currently, the only LDFLAGS are endianness-related - CT_DoLog DEBUG "Configured target LDFLAGS: '${CT_ARCH_TARGET_LDFLAGS_MULTILIB}'" - if [ "${ml_endian}" != "seen" ]; then - CT_EnvModify CT_TARGET_LDFLAGS "${CT_ARCH_TARGET_LDFLAGS_MULTILIB} ${CT_TARGET_LDFLAGS}" - CT_EnvModify CT_ARCH_TARGET_LDFLAGS_MULTILIB "" - fi - CT_DoLog DEBUG "Filtered target LDFLAGS: '${CT_ARCH_TARGET_LDFLAGS_MULTILIB}'" -} - -#------------------------------------------------------------------------------ -# Core gcc pass 1 -do_gcc_core_pass_1() { - local -a core_opts - - if [ "${CT_CC_CORE_PASS_1_NEEDED}" != "y" ]; then - return 0 - fi - - core_opts+=( "mode=static" ) - core_opts+=( "host=${CT_BUILD}" ) - core_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" ) - core_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" ) - core_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" ) - core_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" ) - core_opts+=( "lang_list=c" ) - core_opts+=( "build_step=core1" ) - - CT_DoStep INFO "Installing pass-1 core C gcc compiler" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-core-pass-1" - - do_gcc_core_backend "${core_opts[@]}" - - CT_Popd - CT_EndStep -} - -# Core gcc pass 2 -do_gcc_core_pass_2() { - local -a core_opts - - if [ "${CT_CC_CORE_PASS_2_NEEDED}" != "y" ]; then - return 0 - fi - - # Common options: - core_opts+=( "host=${CT_BUILD}" ) - core_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" ) - core_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" ) - core_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" ) - core_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" ) - core_opts+=( "lang_list=c" ) - core_opts+=( "build_step=core2" ) - - # Different conditions are at stake here: - # - In case the threading model is NPTL, we need a shared-capable core - # gcc; in all other cases, we need a static-only core gcc. - # - In case the threading model is NPTL or win32, or gcc is 4.3 or - # later, we need to build libgcc - case "${CT_THREADS}" in - nptl) - core_opts+=( "mode=shared" ) - core_opts+=( "build_libgcc=yes" ) - ;; - win32) - core_opts+=( "mode=static" ) - core_opts+=( "build_libgcc=yes" ) - ;; - *) - core_opts+=( "mode=static" ) - core_opts+=( "build_libgcc=yes" ) - ;; - esac - - CT_DoStep INFO "Installing pass-2 core C gcc compiler" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-core-pass-2" - - do_gcc_core_backend "${core_opts[@]}" - - CT_Popd - CT_EndStep -} - -#------------------------------------------------------------------------------ -# Build core gcc -# This function is used to build the core C compiler. -# Usage: do_gcc_core_backend param=value [...] -# Parameter : Definition : Type : Default -# mode : build a 'static', 'shared' or 'baremetal' : string : (none) -# host : the machine the core will run on : tuple : (none) -# prefix : dir prefix to install into : dir : (none) -# complibs : dir where complibs are installed : dir : (none) -# lang_list : the list of languages to build : string : (empty) -# build_libgcc : build libgcc or not : bool : no -# build_libstdcxx : build libstdc++ or not : bool : no -# build_libgfortran : build libgfortran or not : bool : no -# build_staticlinked : build statically linked or not : bool : no -# build_manuals : whether to build manuals or not : bool : no -# cflags : cflags to use : string : (empty) -# ldflags : ldflags to use : string : (empty) -# build_step : build step 'core1', 'core2', 'gcc_build' -# or 'gcc_host' : string : (none) -# Usage: do_gcc_core_backend mode=[static|shared|baremetal] build_libgcc=[yes|no] build_staticlinked=[yes|no] -do_gcc_core_backend() { - local mode - local build_libgcc=no - local build_libstdcxx=no - local build_libgfortran=no - local build_staticlinked=no - local build_manuals=no - local host - local prefix - local complibs - local lang_list - local cflags - local cflags_for_build - local ldflags - local build_step - local log_txt - local tmp - local -a host_libstdcxx_flags - local -a extra_config - local -a core_LDFLAGS - local -a core_targets - local -a core_targets_all - local -a core_targets_install - local -a extra_user_config - local arg - - for arg in "$@"; do - eval "${arg// /\\ }" - done - - # This function gets called in case of a bare metal compiler for the final gcc, too. - case "${build_step}" in - core1|core2) - CT_DoLog EXTRA "Configuring core C gcc compiler" - log_txt="gcc" - extra_user_config=( "${CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY[@]}" ) - ;; - gcc_build|gcc_host) - CT_DoLog EXTRA "Configuring final gcc compiler" - extra_user_config=( "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" ) - log_txt="final gcc compiler" - # to inhibit the libiberty and libgcc tricks later on - build_libgcc=no - ;; - *) - CT_Abort "Internal Error: 'build_step' must be one of: 'core1', 'core2', 'gcc_build' or 'gcc_host', not '${build_step:-(empty)}'" - ;; - esac - - case "${mode}" in - static) - extra_config+=("--with-newlib") - extra_config+=("--enable-threads=no") - extra_config+=("--disable-shared") - ;; - shared) - extra_config+=("--enable-shared") - ;; - baremetal) - extra_config+=("--with-newlib") - extra_config+=("--enable-threads=no") - extra_config+=("--disable-shared") - ;; - *) - CT_Abort "Internal Error: 'mode' must be one of: 'static', 'shared' or 'baremetal', not '${mode:-(empty)}'" - ;; - esac - - # This is only needed when building libstdc++ in a canadian environment with - # this function being used for final step (i.e., when building for bare metal). - if [ "${build_step}" = "gcc_build" ]; then - CT_DoLog DEBUG "Copying headers to install area of core C compiler" - CT_DoExecLog ALL cp -a "${CT_HEADERS_DIR}" "${prefix}/${CT_TARGET}/include" - fi - - for tmp in ARCH ABI CPU TUNE FPU FLOAT; do - eval tmp="\${CT_ARCH_WITH_${tmp}}" - if [ -n "${tmp}" ]; then - extra_config+=("${tmp}") - fi - done - - extra_config+=("--with-pkgversion=${CT_PKGVERSION}") - [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") - - if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then - extra_config+=("--enable-__cxa_atexit") - else - extra_config+=("--disable-__cxa_atexit") - fi - - if [ -n "${CT_CC_GCC_ENABLE_CXX_FLAGS}" \ - -a "${mode}" = "baremetal" ]; then - extra_config+=("--enable-cxx-flags=${CT_CC_GCC_ENABLE_CXX_FLAGS}") - fi - - extra_config+=(--disable-libgomp) - extra_config+=(--disable-libmudflap) - extra_config+=(--disable-libmpx) - - if [ "${CT_CC_GCC_LIBSSP}" = "y" ]; then - extra_config+=(--enable-libssp) - else - extra_config+=(--disable-libssp) - fi - if [ "${CT_CC_GCC_LIBQUADMATH}" = "y" ]; then - extra_config+=(--enable-libquadmath) - extra_config+=(--enable-libquadmath-support) - else - extra_config+=(--disable-libquadmath) - extra_config+=(--disable-libquadmath-support) - fi - - core_LDFLAGS+=("${ldflags}") - - # *** WARNING ! *** - # Keep this full if-else-if-elif-fi-fi block in sync - # with the same block in do_gcc_backend, below. - if [ "${build_staticlinked}" = "yes" ]; then - core_LDFLAGS+=("-static") - host_libstdcxx_flags+=("-static-libgcc") - host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++") - host_libstdcxx_flags+=("-lm") - # Companion libraries are build static (eg !shared), so - # the libstdc++ is not pulled automatically, although it - # is needed. Shoe-horn it in our LDFLAGS - # Ditto libm on some Fedora boxen - core_LDFLAGS+=("-lstdc++") - core_LDFLAGS+=("-lm") - else - if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" ]; then - # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2 - # build script - # INFO: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++, - # see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html - host_libstdcxx_flags+=("-static-libgcc") - host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++,-Bdynamic") - host_libstdcxx_flags+=("-lm") - fi - # When companion libraries are build static (eg !shared), - # the libstdc++ is not pulled automatically, although it - # is needed. Shoe-horn it in our LDFLAGS - # Ditto libm on some Fedora boxen - core_LDFLAGS+=("-lstdc++") - core_LDFLAGS+=("-lm") - fi - - extra_config+=("--with-gmp=${complibs}") - extra_config+=("--with-mpfr=${complibs}") - extra_config+=("--with-mpc=${complibs}") - if [ "${CT_CC_GCC_USE_GRAPHITE}" = "y" ]; then - if [ "${CT_ISL}" = "y" ]; then - extra_config+=("--with-isl=${complibs}") - fi - if [ "${CT_CLOOG}" = "y" ]; then - extra_config+=("--with-cloog=${complibs}") - fi - else - extra_config+=("--with-isl=no") - extra_config+=("--with-cloog=no") - fi - if [ "${CT_CC_GCC_USE_LTO}" = "y" ]; then - extra_config+=("--enable-lto") - else - extra_config+=("--disable-lto") - fi - - if [ ${#host_libstdcxx_flags[@]} -ne 0 ]; then - extra_config+=("--with-host-libstdcxx=${host_libstdcxx_flags[*]}") - fi - - if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ]; then - extra_config+=("--enable-target-optspace") - fi - if [ "${CT_CC_GCC_DISABLE_PCH}" = "y" ]; then - extra_config+=("--disable-libstdcxx-pch") - fi - - case "${CT_CC_GCC_LDBL_128}" in - y) extra_config+=("--with-long-double-128");; - m) ;; - "") extra_config+=("--without-long-double-128");; - esac - - if [ "${CT_CC_GCC_BUILD_ID}" = "y" ]; then - extra_config+=( --enable-linker-build-id ) - fi - - case "${CT_CC_GCC_LNK_HASH_STYLE}" in - "") ;; - *) extra_config+=( "--with-linker-hash-style=${CT_CC_GCC_LNK_HASH_STYLE}" );; - esac - - case "${CT_CC_GCC_DEC_FLOATS}" in - "") ;; - *) extra_config+=( "--enable-decimal-float=${CT_CC_GCC_DEC_FLOATS}" );; - esac - - case "${CT_ARCH}" in - mips) - case "${CT_CC_GCC_mips_llsc}" in - y) extra_config+=( --with-llsc );; - m) ;; - *) extra_config+=( --without-llsc );; - esac - case "${CT_CC_GCC_mips_synci}" in - y) extra_config+=( --with-synci );; - m) ;; - *) extra_config+=( --without-synci );; - esac - if [ "${CT_CC_GCC_mips_plt}" ]; then - extra_config+=( --with-mips-plt ) - fi - ;; # ARCH is mips - esac - - if [ "${CT_TOOLCHAIN_ENABLE_NLS}" = "y" ]; then - extra_config+=("--with-libintl-prefix=${complibs}") - else - extra_config+=("--disable-nls") - fi - - if [ "${CT_CC_GCC_SYSTEM_ZLIB}" = "y" ]; then - extra_config+=("--with-system-zlib") - fi - - case "${CT_CC_GCC_CONFIG_TLS}" in - y) extra_config+=("--enable-tls");; - m) ;; - "") extra_config+=("--disable-tls");; - esac - - # Some versions of gcc have a defective --enable-multilib. - # Since that's the default, only pass --disable-multilib. For multilib, - # also enable multiarch. Without explicit --enable-multiarch, pass-1 - # compiler is configured as multilib/no-multiarch and pass-2/final - # are multilib/multiarch (because gcc autodetects multiarch based on - # multiple instances of crt*.o in the install directory - which do - # not exist in pass-1). - if [ "${CT_MULTILIB}" != "y" ]; then - extra_config+=("--disable-multilib") - else - extra_config+=("--enable-multiarch") - if [ -n "${CT_CC_GCC_MULTILIB_LIST}" ]; then - extra_config+=("--with-multilib-list=${CT_CC_GCC_MULTILIB_LIST}") - fi - fi - - CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'" - - # We may need to modify host/build CFLAGS separately below - cflags_for_build="${CT_CFLAGS_FOR_BUILD}" - - # Clang's default bracket-depth is 256, and building GCC - # requires somewhere between 257 and 512. - if [ "${host}" = "${CT_BUILD}" ]; then - if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then - cflags="$cflags "-fbracket-depth=512 - cflags_for_build="$cflags_for_build "-fbracket-depth=512 - fi - else - # FIXME we currently don't support clang as host compiler, only as build - if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then - cflags_for_build="$cflags_for_build "-fbracket-depth=512 - fi - fi - - # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532) - CT_DoExecLog CFG \ - CC_FOR_BUILD="${CT_BUILD}-gcc" \ - CFLAGS="${cflags}" \ - CFLAGS_FOR_BUILD="${cflags_for_build}" \ - CXXFLAGS="${cflags}" \ - CXXFLAGS_FOR_BUILD="${cflags_for_build}" \ - LDFLAGS="${core_LDFLAGS[*]}" \ - CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \ - CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \ - LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \ - ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/configure" \ - --build=${CT_BUILD} \ - --host=${host} \ - --target=${CT_TARGET} \ - --prefix="${prefix}" \ - --with-local-prefix="${CT_SYSROOT_DIR}" \ - ${CC_CORE_SYSROOT_ARG} \ - "${extra_config[@]}" \ - --enable-languages="${lang_list}" \ - "${extra_user_config[@]}" - - if [ "${build_libgcc}" = "yes" ]; then - # HACK: we need to override SHLIB_LC from gcc/config/t-slibgcc-elf-ver or - # gcc/config/t-libunwind so -lc is removed from the link for - # libgcc_s.so, as we do not have a target -lc yet. - # This is not as ugly as it appears to be ;-) All symbols get resolved - # during the glibc build, and we provide a proper libgcc_s.so for the - # cross toolchain during the final gcc build. - # - # As we cannot modify the source tree, nor override SHLIB_LC itself - # during configure or make, we have to edit the resultant - # gcc/libgcc.mk itself to remove -lc from the link. - # This causes us to have to jump through some hoops... - # - # To produce libgcc.mk to edit we firstly require libiberty.a, - # so we configure then build it. - # Next we have to configure gcc, create libgcc.mk then edit it... - # So much easier if we just edit the source tree, but hey... - if [ ! -f "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" ]; then - CT_DoExecLog CFG make ${JOBSFLAGS} configure-libiberty - CT_DoExecLog ALL make ${JOBSFLAGS} -C libiberty libiberty.a - CT_DoExecLog CFG make ${JOBSFLAGS} configure-gcc configure-libcpp - CT_DoExecLog ALL make ${JOBSFLAGS} all-libcpp - else - CT_DoExecLog CFG make ${JOBSFLAGS} configure-gcc configure-libcpp configure-build-libiberty - CT_DoExecLog ALL make ${JOBSFLAGS} all-libcpp all-build-libiberty - fi - # HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here. - if [ -d "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/libdecnumber" ]; then - CT_DoExecLog CFG make ${JOBSFLAGS} configure-libdecnumber - CT_DoExecLog ALL make ${JOBSFLAGS} -C libdecnumber libdecnumber.a - fi - # HACK: gcc-4.8 uses libbacktrace to make libgcc.mvars, so make it here. - if [ -d "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/libbacktrace" ]; then - CT_DoExecLog CFG make ${JOBSFLAGS} configure-libbacktrace - CT_DoExecLog ALL make ${JOBSFLAGS} -C libbacktrace - fi - - libgcc_rule="libgcc.mvars" - core_targets=( gcc target-libgcc ) - - # On bare metal and canadian build the host-compiler is used when - # actually the build-system compiler is required. Choose the correct - # compilers for canadian build and use the defaults on other - # configurations. - if [ "${CT_BARE_METAL},${CT_CANADIAN}" = "y,y" ]; then - repair_cc="CC_FOR_BUILD=${CT_BUILD}-gcc \ - CXX_FOR_BUILD=${CT_BUILD}-g++ \ - GCC_FOR_TARGET=${CT_TARGET}-${CT_CC}" - else - repair_cc="" - fi - - CT_DoExecLog ALL make ${JOBSFLAGS} -C gcc ${libgcc_rule} \ - ${repair_cc} - sed -r -i -e 's@-lc@@g' gcc/${libgcc_rule} - else # build_libgcc - core_targets=( gcc ) - fi # ! build libgcc - if [ "${build_libstdcxx}" = "yes" \ - -a "${CT_CC_LANG_CXX}" = "y" \ - ]; then - core_targets+=( target-libstdc++-v3 ) - fi - - if [ "${build_libgfortran}" = "yes" \ - -a "${CT_CC_LANG_FORTRAN}" = "y" \ - ]; then - core_targets+=( target-libgfortran ) - fi - - core_targets_all="${core_targets[@]/#/all-}" - core_targets_install="${core_targets[@]/#/install-}" - - case "${build_step}" in - gcc_build|gcc_host) - core_targets_all=all - core_targets_install=install - ;; - esac - - CT_DoLog EXTRA "Building ${log_txt}" - CT_DoExecLog ALL make ${JOBSFLAGS} ${core_targets_all} - - # Do not pass ${JOBSFLAGS} here: recent GCC builds have been failing - # in parallel 'make install' at random locations: libitm, libcilk, - # always for the files that are installed more than once to the same - # location (such as libitm.info). - # The symptom is that the install command fails with "File exists" - # error; running the same command manually succeeds. It looks like - # attempts to remove the destination and re-create it, but another - # install gets in the way. - CT_DoLog EXTRA "Installing ${log_txt}" - CT_DoExecLog ALL make ${core_targets_install} - - # Remove the libtool "pseudo-libraries": having them in the installed - # tree makes the libtoolized utilities that are built next assume - # that, for example, libsupc++ is an "accessory library", and not include - # -lsupc++ to the link flags. That breaks ltrace, for example. - CT_DoLog EXTRA "Housekeeping for core gcc compiler" - CT_Pushd "${prefix}" - find . -type f -name "*.la" -exec rm {} \; |CT_DoLog ALL - CT_Popd - - if [ "${build_manuals}" = "yes" ]; then - CT_DoLog EXTRA "Building the GCC manuals" - CT_DoExecLog ALL make pdf html - CT_DoLog EXTRA "Installing the GCC manuals" - CT_DoExecLog ALL make install-{pdf,html}-gcc - fi - - # Create a symlink ${CT_TARGET}-cc to ${CT_TARGET}-${CT_CC} to always be able - # to call the C compiler with the same, somewhat canonical name. - # check whether compiler has an extension - file="$( ls -1 "${prefix}/bin/${CT_TARGET}-${CT_CC}."* 2>/dev/null || true )" - [ -z "${file}" ] || ext=".${file##*.}" - if [ -f "${prefix}/bin/${CT_TARGET}-${CT_CC}${ext}" ]; then - CT_DoExecLog ALL ln -sfv "${CT_TARGET}-${CT_CC}${ext}" "${prefix}/bin/${CT_TARGET}-cc${ext}" - fi - - cc_gcc_multilib_housekeeping cc="${prefix}/bin/${CT_TARGET}-${CT_CC}" \ - host="${host}" -} - -#------------------------------------------------------------------------------ -# Build complete gcc to run on build -do_gcc_for_build() { - local -a build_final_opts - local build_final_backend - - # If native or simple cross toolchain is being built, then build==host; - # nothing to do. - case "${CT_TOOLCHAIN_TYPE}" in - native|cross) return 0;; - esac - - build_final_opts+=( "host=${CT_BUILD}" ) - build_final_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" ) - build_final_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" ) - build_final_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" ) - build_final_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" ) - build_final_opts+=( "lang_list=$( cc_gcc_lang_list )" ) - build_final_opts+=( "build_step=gcc_build" ) - if [ "${CT_BARE_METAL}" = "y" ]; then - # In the tests I've done, bare-metal was not impacted by the - # lack of such a compiler, but better safe than sorry... - build_final_opts+=( "mode=baremetal" ) - build_final_opts+=( "build_libgcc=yes" ) - build_final_opts+=( "build_libstdcxx=yes" ) - build_final_opts+=( "build_libgfortran=yes" ) - if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then - build_final_opts+=( "build_staticlinked=yes" ) - fi - build_final_backend=do_gcc_core_backend - else - build_final_backend=do_gcc_backend - fi - - CT_DoStep INFO "Installing final gcc compiler for build" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-final-build-${CT_BUILD}" - - "${build_final_backend}" "${build_final_opts[@]}" - - CT_Popd - CT_EndStep -} - -gcc_movelibs() { - local multi_flags multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_index multi_count - local gcc_dir dst_dir - local rel - - for arg in "$@"; do - eval "${arg// /\\ }" - done - - # Move only files, directories are for other multilibs. We're looking inside - # GCC's directory structure, thus use unmangled multi_os_dir that GCC reports. - gcc_dir="${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_os_dir_gcc}" - if [ ! -d "${gcc_dir}" ]; then - # GCC didn't install anything outside of sysroot - return - fi - # Depending on the selected libc, we may or may not have the ${multi_os_dir_gcc} - # created by libc installation. If we do, use it. If we don't, use ${multi_os_dir} - # to avoid creating an otherwise empty directory. - dst_dir="${multi_root}/lib/${multi_os_dir_gcc}" - if [ ! -d "${dst_dir}" ]; then - dst_dir="${multi_root}/lib/${multi_os_dir}" - fi - CT_SanitizeVarDir dst_dir gcc_dir - rel=$( echo "${gcc_dir#${CT_PREFIX_DIR}/}" | sed 's#[^/]\{1,\}#..#g' ) - - ls "${gcc_dir}" | while read f; do - case "${f}" in - *.ld) - # Linker scripts remain in GCC's directory; elf2flt insists on - # finding them there. - continue - ;; - esac - if [ -f "${gcc_dir}/${f}" ]; then - CT_DoExecLog ALL mkdir -p "${dst_dir}" - CT_DoExecLog ALL mv "${gcc_dir}/${f}" "${dst_dir}/${f}" - CT_DoExecLog ALL ln -sf "${rel}/${dst_dir#${CT_PREFIX_DIR}/}/${f}" "${gcc_dir}/${f}" - fi - done -} - -#------------------------------------------------------------------------------ -# Build final gcc to run on host -do_gcc_for_host() { - local -a final_opts - local final_backend - - final_opts+=( "host=${CT_HOST}" ) - final_opts+=( "prefix=${CT_PREFIX_DIR}" ) - final_opts+=( "complibs=${CT_HOST_COMPLIBS_DIR}" ) - final_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" ) - final_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" ) - final_opts+=( "lang_list=$( cc_gcc_lang_list )" ) - final_opts+=( "build_step=gcc_host" ) - if [ "${CT_BUILD_MANUALS}" = "y" ]; then - final_opts+=( "build_manuals=yes" ) - fi - if [ "${CT_BARE_METAL}" = "y" ]; then - final_opts+=( "mode=baremetal" ) - final_opts+=( "build_libgcc=yes" ) - final_opts+=( "build_libstdcxx=yes" ) - final_opts+=( "build_libgfortran=yes" ) - if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then - final_opts+=( "build_staticlinked=yes" ) - fi - final_backend=do_gcc_core_backend - else - final_backend=do_gcc_backend - fi - - CT_DoStep INFO "Installing final gcc compiler" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-final" - "${final_backend}" "${final_opts[@]}" - CT_Popd - - # GCC installs stuff (including libgcc) into its own /lib dir, - # outside of sysroot, breaking linking with -static-libgcc. - # Fix up by moving the libraries into the sysroot. - if [ "${CT_USE_SYSROOT}" = "y" ]; then - CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-final-movelibs" - CT_IterateMultilibs gcc_movelibs movelibs - CT_Popd - fi - - CT_EndStep -} - -#------------------------------------------------------------------------------ -# Build the final gcc -# Usage: do_gcc_backend param=value [...] -# Parameter : Definition : Type : Default -# host : the host we run onto : tuple : (none) -# prefix : the runtime prefix : dir : (none) -# complibs : the companion libraries prefix : dir : (none) -# cflags : cflags to use : string : (empty) -# ldflags : ldflags to use : string : (empty) -# lang_list : the list of languages to build : string : (empty) -# build_manuals : whether to build manuals or not : bool : no -do_gcc_backend() { - local host - local prefix - local complibs - local lang_list - local cflags - local cflags_for_build - local ldflags - local build_manuals - local -a host_libstdcxx_flags - local -a extra_config - local -a final_LDFLAGS - local tmp - local arg - - for arg in "$@"; do - eval "${arg// /\\ }" - done - - CT_DoLog EXTRA "Configuring final gcc compiler" - - # Enable selected languages - extra_config+=("--enable-languages=${lang_list}") - - for tmp in ARCH ABI CPU TUNE FPU FLOAT; do - eval tmp="\${CT_ARCH_WITH_${tmp}}" - if [ -n "${tmp}" ]; then - extra_config+=("${tmp}") - fi - done - - [ "${CT_SHARED_LIBS}" = "y" ] || extra_config+=("--disable-shared") - extra_config+=("--with-pkgversion=${CT_PKGVERSION}") - [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") - - case "${CT_CC_GCC_SJLJ_EXCEPTIONS}" in - y) extra_config+=("--enable-sjlj-exceptions");; - m) ;; - "") extra_config+=("--disable-sjlj-exceptions");; - esac - if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then - extra_config+=("--enable-__cxa_atexit") - else - extra_config+=("--disable-__cxa_atexit") - fi - - if [ -n "${CT_CC_GCC_ENABLE_CXX_FLAGS}" ]; then - extra_config+=("--enable-cxx-flags=${CT_CC_GCC_ENABLE_CXX_FLAGS}") - fi - - if [ "${CT_THREADS}" = "none" ]; then - extra_config+=(--disable-libatomic) - fi - if [ "${CT_CC_GCC_LIBMUDFLAP}" = "y" ]; then - extra_config+=(--enable-libmudflap) - else - extra_config+=(--disable-libmudflap) - fi - if [ "${CT_CC_GCC_LIBGOMP}" = "y" ]; then - extra_config+=(--enable-libgomp) - else - extra_config+=(--disable-libgomp) - fi - if [ "${CT_CC_GCC_LIBSSP}" = "y" ]; then - extra_config+=(--enable-libssp) - else - extra_config+=(--disable-libssp) - fi - if [ "${CT_CC_GCC_LIBQUADMATH}" = "y" ]; then - extra_config+=(--enable-libquadmath) - extra_config+=(--enable-libquadmath-support) - else - extra_config+=(--disable-libquadmath) - extra_config+=(--disable-libquadmath-support) - fi - - if [ "${CT_CC_GCC_LIBSANITIZER}" = "y" ]; then - extra_config+=(--enable-libsanitizer) - else - extra_config+=(--disable-libsanitizer) - fi - - if [ "${CT_CC_GCC_HAS_LIBMPX}" = "y" ]; then - if [ "${CT_CC_GCC_LIBMPX}" = "y" ]; then - extra_config+=(--enable-libmpx) - else - extra_config+=(--disable-libmpx) - fi - fi - - final_LDFLAGS+=("${ldflags}") - - # *** WARNING ! *** - # Keep this full if-else-if-elif-fi-fi block in sync - # with the same block in do_gcc_core_backend, above. - if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then - final_LDFLAGS+=("-static") - host_libstdcxx_flags+=("-static-libgcc") - host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++") - host_libstdcxx_flags+=("-lm") - # Companion libraries are build static (eg !shared), so - # the libstdc++ is not pulled automatically, although it - # is needed. Shoe-horn it in our LDFLAGS - # Ditto libm on some Fedora boxen - final_LDFLAGS+=("-lstdc++") - final_LDFLAGS+=("-lm") - else - if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" ]; then - # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2 - # build script - # INFO: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++, - # see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html - host_libstdcxx_flags+=("-static-libgcc") - host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++,-Bdynamic") - host_libstdcxx_flags+=("-lm") - fi - # When companion libraries are build static (eg !shared), - # the libstdc++ is not pulled automatically, although it - # is needed. Shoe-horn it in our LDFLAGS - # Ditto libm on some Fedora boxen - final_LDFLAGS+=("-lstdc++") - final_LDFLAGS+=("-lm") - fi - - extra_config+=("--with-gmp=${complibs}") - extra_config+=("--with-mpfr=${complibs}") - extra_config+=("--with-mpc=${complibs}") - if [ "${CT_CC_GCC_USE_GRAPHITE}" = "y" ]; then - if [ "${CT_ISL}" = "y" ]; then - extra_config+=("--with-isl=${complibs}") - fi - if [ "${CT_CLOOG}" = "y" ]; then - extra_config+=("--with-cloog=${complibs}") - fi - else - extra_config+=("--with-isl=no") - extra_config+=("--with-cloog=no") - fi - if [ "${CT_CC_GCC_USE_LTO}" = "y" ]; then - extra_config+=("--enable-lto") - else - extra_config+=("--disable-lto") - fi - - if [ ${#host_libstdcxx_flags[@]} -ne 0 ]; then - extra_config+=("--with-host-libstdcxx=${host_libstdcxx_flags[*]}") - fi - - if [ "${CT_THREADS}" = "none" ]; then - extra_config+=("--disable-threads") - else - if [ "${CT_THREADS}" = "win32" ]; then - extra_config+=("--enable-threads=win32") - extra_config+=("--disable-win32-registry") - else - extra_config+=("--enable-threads=posix") - fi - fi - - if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ]; then - extra_config+=("--enable-target-optspace") - fi - if [ "${CT_CC_GCC_DISABLE_PCH}" = "y" ]; then - extra_config+=("--disable-libstdcxx-pch") - fi - - case "${CT_CC_GCC_LDBL_128}" in - y) extra_config+=("--with-long-double-128");; - m) ;; - "") extra_config+=("--without-long-double-128");; - esac - - if [ "${CT_CC_GCC_BUILD_ID}" = "y" ]; then - extra_config+=( --enable-linker-build-id ) - fi - - case "${CT_CC_GCC_LNK_HASH_STYLE}" in - "") ;; - *) extra_config+=( "--with-linker-hash-style=${CT_CC_GCC_LNK_HASH_STYLE}" );; - esac - - case "${CT_CC_GCC_DEC_FLOATS}" in - "") ;; - *) extra_config+=( "--enable-decimal-float=${CT_CC_GCC_DEC_FLOATS}" );; - esac - - if [ "${CT_CC_GCC_ENABLE_PLUGINS}" = "y" ]; then - extra_config+=( --enable-plugin ) - else - extra_config+=( --disable-plugin ) - fi - if [ "${CT_CC_GCC_GOLD}" = "y" ]; then - extra_config+=( --enable-gold ) - fi - - case "${CT_ARCH}" in - mips) - case "${CT_CC_GCC_mips_llsc}" in - y) extra_config+=( --with-llsc );; - m) ;; - *) extra_config+=( --without-llsc );; - esac - case "${CT_CC_GCC_mips_synci}" in - y) extra_config+=( --with-synci );; - m) ;; - *) extra_config+=( --without-synci );; - esac - if [ "${CT_CC_GCC_mips_plt}" ]; then - extra_config+=( --with-mips-plt ) - fi - ;; # ARCH is mips - esac - - if [ "${CT_TOOLCHAIN_ENABLE_NLS}" = "y" ]; then - extra_config+=("--with-libintl-prefix=${complibs}") - else - extra_config+=("--disable-nls") - fi - - if [ "${CT_CC_GCC_SYSTEM_ZLIB}" = "y" ]; then - extra_config+=("--with-system-zlib") - fi - - case "${CT_CC_GCC_CONFIG_TLS}" in - y) extra_config+=("--enable-tls");; - m) ;; - "") extra_config+=("--disable-tls");; - esac - - # Some versions of gcc have a defective --enable-multilib. - # Since that's the default, only pass --disable-multilib. - if [ "${CT_MULTILIB}" != "y" ]; then - extra_config+=("--disable-multilib") - else - extra_config+=("--enable-multiarch") - if [ -n "${CT_CC_GCC_MULTILIB_LIST}" ]; then - extra_config+=("--with-multilib-list=${CT_CC_GCC_MULTILIB_LIST}") - fi - fi - - CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'" - - # We may need to modify host/build CFLAGS separately below - cflags_for_build="${cflags}" - - # Clang's default bracket-depth is 256, and building GCC - # requires somewhere between 257 and 512. - if [ "${host}" = "${CT_BUILD}" ]; then - if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then - cflags="$cflags "-fbracket-depth=512 - cflags_for_build="$cflags_for_build "-fbracket-depth=512 - fi - else - # FIXME we currently don't support clang as host compiler, only as build - if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then - cflags_for_build="$cflags_for_build "-fbracket-depth=512 - fi - fi - - CT_DoExecLog CFG \ - CC_FOR_BUILD="${CT_BUILD}-gcc" \ - CFLAGS="${cflags}" \ - CFLAGS_FOR_BUILD="${cflags_for_build}" \ - CXXFLAGS="${cflags}" \ - CXXFLAGS_FOR_BUILD="${cflags_for_build}" \ - LDFLAGS="${final_LDFLAGS[*]}" \ - CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \ - CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \ - LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \ - ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/configure" \ - --build=${CT_BUILD} \ - --host=${host} \ - --target=${CT_TARGET} \ - --prefix="${prefix}" \ - ${CC_SYSROOT_ARG} \ - "${extra_config[@]}" \ - --with-local-prefix="${CT_SYSROOT_DIR}" \ - --enable-long-long \ - "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" - - if [ "${CT_CANADIAN}" = "y" ]; then - CT_DoLog EXTRA "Building libiberty" - CT_DoExecLog ALL make ${JOBSFLAGS} all-build-libiberty - fi - - CT_DoLog EXTRA "Building final gcc compiler" - CT_DoExecLog ALL make ${JOBSFLAGS} all - - # See the note on issues with parallel 'make install' in GCC above. - CT_DoLog EXTRA "Installing final gcc compiler" - if [ "${CT_STRIP_TARGET_TOOLCHAIN_EXECUTABLES}" = "y" ]; then - CT_DoExecLog ALL make install-strip - else - CT_DoExecLog ALL make install - fi - - # Remove the libtool "pseudo-libraries": having them in the installed - # tree makes the libtoolized utilities that are built next assume - # that, for example, libsupc++ is an "accessory library", and not include - # -lsupc++ to the link flags. That breaks ltrace, for example. - CT_DoLog EXTRA "Housekeeping for final gcc compiler" - CT_Pushd "${prefix}" - find . -type f -name "*.la" -exec rm {} \; |CT_DoLog ALL - CT_Popd - - if [ "${build_manuals}" = "yes" ]; then - CT_DoLog EXTRA "Building the GCC manuals" - CT_DoExecLog ALL make pdf html - CT_DoLog EXTRA "Installing the GCC manuals" - CT_DoExecLog ALL make install-{pdf,html}-gcc - fi - - # Create a symlink ${CT_TARGET}-cc to ${CT_TARGET}-${CT_CC} to always be able - # to call the C compiler with the same, somewhat canonical name. - # check whether compiler has an extension - file="$( ls -1 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${CT_CC}."* 2>/dev/null || true )" - [ -z "${file}" ] || ext=".${file##*.}" - if [ -f "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${CT_CC}${ext}" ]; then - CT_DoExecLog ALL ln -sfv "${CT_TARGET}-${CT_CC}${ext}" "${prefix}/bin/${CT_TARGET}-cc${ext}" - fi - - cc_gcc_multilib_housekeeping cc="${prefix}/bin/${CT_TARGET}-${CT_CC}" \ - host="${host}" -} diff --git a/scripts/build/cc/gcc.sh b/scripts/build/cc/gcc.sh new file mode 100644 index 00000000..449aafb6 --- /dev/null +++ b/scripts/build/cc/gcc.sh @@ -0,0 +1,1156 @@ +# This file adds the function to build the gcc C compiler +# Copyright 2007 Yann E. MORIN +# Licensed under the GPL v2. See COPYING in the root of this package + +# Download gcc +do_gcc_get() { + local linaro_version="" + local linaro_series="" + + CT_Fetch GCC + + # Starting with GCC 4.3, ecj is used for Java, and will only be + # built if the configure script finds ecj.jar at the top of the + # GCC source tree, which will not be there unless we get it and + # put it there ourselves + if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" ]; then + CT_GetFile ecj-latest .jar http://mirrors.kernel.org/sourceware/java/ \ + ftp://gcc.gnu.org/pub/java \ + ftp://sourceware.org/pub/java + fi +} + +# Extract gcc +do_gcc_extract() { + # TBD handle xtensa overlays + CT_ExtractPatch GCC + + # Copy ecj-latest.jar to ecj.jar at the top of the GCC source tree + if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" -a ! -f "${CT_SRC_DIR}/gcc/ecj.jar" ]; then + CT_DoExecLog ALL cp -v "${CT_TARBALLS_DIR}/ecj-latest.jar" "${CT_SRC_DIR}/gcc/ecj.jar" + fi +} + +#------------------------------------------------------------------------------ +# This function builds up the set of languages to enable +# No argument expected, returns the comma-separated language list on stdout +cc_gcc_lang_list() { + local lang_list + + lang_list="c" + [ "${CT_CC_LANG_CXX}" = "y" ] && lang_list+=",c++" + [ "${CT_CC_LANG_FORTRAN}" = "y" ] && lang_list+=",fortran" + [ "${CT_CC_LANG_ADA}" = "y" ] && lang_list+=",ada" + [ "${CT_CC_LANG_JAVA}" = "y" ] && lang_list+=",java" + [ "${CT_CC_LANG_OBJC}" = "y" ] && lang_list+=",objc" + [ "${CT_CC_LANG_OBJCXX}" = "y" ] && lang_list+=",obj-c++" + [ "${CT_CC_LANG_GOLANG}" = "y" ] && lang_list+=",go" + lang_list+="${CT_CC_LANG_OTHERS:+,${CT_CC_LANG_OTHERS}}" + + printf "%s" "${lang_list}" +} + +#------------------------------------------------------------------------------ +# Report the type of a GCC option +cc_gcc_classify_opt() { + # Options present in multiple architectures + case "${1}" in + -march=*) echo "arch"; return;; + -mabi=*) echo "abi"; return;; + -mcpu=*|-mmcu=*) echo "cpu"; return;; + -mtune=*) echo "tune"; return;; + -mfpu=*) echo "fpu"; return;; + -mhard-float|-msoft-float|-mno-soft-float|-mno-float|-mfloat-abi=*|\ + -mfpu|-mno-fpu) echo "float"; return;; + -EB|-EL|-mbig-endian|-mlittle-endian|-mbig|-mlittle|-meb|-mel|-mb|-ml) echo "endian"; return;; + -mthumb|-marm) echo "mode"; return;; + esac + + # Arch-specific options and aliases + case "${CT_ARCH}" in + m68k) + case "${1}" in + -m68881) echo "float"; return;; + -m5[234]*|-mcfv4e) echo "cpu"; return;; + -m68*|-mc68*) echo "arch"; return;; + esac + ;; + mips) + case "${1}" in + -mips[1234]|-mips32|-mips32r*|-mips64|-mips64r*) echo "cpu"; return;; + esac + ;; + sh) + case "${1}" in + -m[12345]*) echo "cpu"; return;; + esac + esac + + # All tried and failed + echo "unknown" +} + +evaluate_multilib_cflags() +{ + local multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_flags multi_index multi_count + local mdir mdir_os dirtop + local f + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + mdir="lib/${multi_dir}" + mdir_os="lib/${multi_os_dir_gcc}" + CT_SanitizeVarDir mdir mdir_os + CT_DoLog EXTRA " '${multi_flags}' --> ${mdir} (gcc) ${mdir_os} (os)" + for f in ${multi_flags}; do + eval ml_`cc_gcc_classify_opt ${f}`=seen + done + if [ "${CT_DEMULTILIB}" = "y" -a "${CT_USE_SYSROOT}" = "y" ]; then + case "${mdir_os}" in + lib/*) + ;; + *) + dirtop="${mdir_os%%/*}" + if [ ! -e "${multi_root}/${mdir_os}" ]; then + CT_DoExecLog ALL ln -sfv lib "${multi_root}/${mdir_os}" + fi + if [ ! -e "${multi_root}/usr/${mdir_os}" ]; then + CT_DoExecLog ALL ln -sfv lib "${multi_root}/usr/${mdir_os}" + fi + ;; + esac + fi +} + +#------------------------------------------------------------------------------ +# This function lists the multilibs configured in the compiler (even if multilib +# is disabled - so that it lists the default GCC/OS directory, which may differ +# from the default 'lib'). It then performs a few multilib checks/quirks: +# +# 1. On MIPS target, gcc (or rather, ld, which it invokes under the hood) chokes +# if supplied with two -mabi=* options. I.e., 'gcc -mabi=n32' and 'gcc -mabi=32' both +# work, but 'gcc -mabi=32 -mabi=n32' produces an internal error in ld. Thus we do +# not supply target's CFLAGS in multilib builds - and after compiling pass-1 gcc, +# attempt to determine which CFLAGS need to be filtered out. +# +# 2. If "demultilibing" is in effect, create top-level directories for any +# multilibs not in lib/ as symlinks to lib. +cc_gcc_multilib_housekeeping() { + local cc host + local ml_arch ml_abi ml_cpu ml_tune ml_fpu ml_float ml_endian ml_mode ml_unknown ml + local new_cflags + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + if [ \( "${CT_CANADIAN}" = "y" -o "${CT_CROSS_NATIVE}" = "y" \) -a "${host}" = "${CT_HOST}" ]; then + CT_DoLog EXTRA "Canadian Cross/Cross-native unable to confirm multilibs configuration "\ + "directly; will use build-compiler for housekeeping." + # Since we cannot run the desired compiler, substitute build-CC with the assumption + # that the host-CC is configured in the same way. + cc="${CT_BUILDTOOLS_PREFIX_DIR}/bin/${CT_TARGET}-${CT_CC}" + fi + + CT_IterateMultilibs evaluate_multilib_cflags evaluate_cflags + + # Filtering out some of the options provided in CT-NG config. Then *prepend* + # them to CT_TARGET_CFLAGS, like scripts/crosstool-NG.sh does. Zero out + # the stashed MULTILIB flags so that we don't process them again in the passes + # that follow. + CT_DoLog DEBUG "Configured target CFLAGS: '${CT_ARCH_TARGET_CFLAGS_MULTILIB}'" + ml_unknown= # Pass through anything we don't know about + for f in ${CT_ARCH_TARGET_CFLAGS_MULTILIB}; do + eval ml=\$ml_`cc_gcc_classify_opt ${f}` + if [ "${ml}" != "seen" ]; then + new_cflags="${new_cflags} ${f}" + fi + done + CT_DoLog DEBUG "Filtered target CFLAGS: '${new_cflags}'" + CT_EnvModify CT_TARGET_CFLAGS "${new_cflags} ${CT_TARGET_CFLAGS}" + CT_EnvModify CT_ARCH_TARGET_CFLAGS_MULTILIB "" + + # Currently, the only LDFLAGS are endianness-related + CT_DoLog DEBUG "Configured target LDFLAGS: '${CT_ARCH_TARGET_LDFLAGS_MULTILIB}'" + if [ "${ml_endian}" != "seen" ]; then + CT_EnvModify CT_TARGET_LDFLAGS "${CT_ARCH_TARGET_LDFLAGS_MULTILIB} ${CT_TARGET_LDFLAGS}" + CT_EnvModify CT_ARCH_TARGET_LDFLAGS_MULTILIB "" + fi + CT_DoLog DEBUG "Filtered target LDFLAGS: '${CT_ARCH_TARGET_LDFLAGS_MULTILIB}'" +} + +#------------------------------------------------------------------------------ +# Core gcc pass 1 +do_gcc_core_pass_1() { + local -a core_opts + + if [ "${CT_CC_CORE_PASS_1_NEEDED}" != "y" ]; then + return 0 + fi + + core_opts+=( "mode=static" ) + core_opts+=( "host=${CT_BUILD}" ) + core_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" ) + core_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" ) + core_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" ) + core_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" ) + core_opts+=( "lang_list=c" ) + core_opts+=( "build_step=core1" ) + + CT_DoStep INFO "Installing pass-1 core C gcc compiler" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-core-pass-1" + + do_gcc_core_backend "${core_opts[@]}" + + CT_Popd + CT_EndStep +} + +# Core gcc pass 2 +do_gcc_core_pass_2() { + local -a core_opts + + if [ "${CT_CC_CORE_PASS_2_NEEDED}" != "y" ]; then + return 0 + fi + + # Common options: + core_opts+=( "host=${CT_BUILD}" ) + core_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" ) + core_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" ) + core_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" ) + core_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" ) + core_opts+=( "lang_list=c" ) + core_opts+=( "build_step=core2" ) + + # Different conditions are at stake here: + # - In case the threading model is NPTL, we need a shared-capable core + # gcc; in all other cases, we need a static-only core gcc. + # - In case the threading model is NPTL or win32, or gcc is 4.3 or + # later, we need to build libgcc + case "${CT_THREADS}" in + nptl) + core_opts+=( "mode=shared" ) + core_opts+=( "build_libgcc=yes" ) + ;; + win32) + core_opts+=( "mode=static" ) + core_opts+=( "build_libgcc=yes" ) + ;; + *) + core_opts+=( "mode=static" ) + core_opts+=( "build_libgcc=yes" ) + ;; + esac + + CT_DoStep INFO "Installing pass-2 core C gcc compiler" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-core-pass-2" + + do_gcc_core_backend "${core_opts[@]}" + + CT_Popd + CT_EndStep +} + +#------------------------------------------------------------------------------ +# Build core gcc +# This function is used to build the core C compiler. +# Usage: do_gcc_core_backend param=value [...] +# Parameter : Definition : Type : Default +# mode : build a 'static', 'shared' or 'baremetal' : string : (none) +# host : the machine the core will run on : tuple : (none) +# prefix : dir prefix to install into : dir : (none) +# complibs : dir where complibs are installed : dir : (none) +# lang_list : the list of languages to build : string : (empty) +# build_libgcc : build libgcc or not : bool : no +# build_libstdcxx : build libstdc++ or not : bool : no +# build_libgfortran : build libgfortran or not : bool : no +# build_staticlinked : build statically linked or not : bool : no +# build_manuals : whether to build manuals or not : bool : no +# cflags : cflags to use : string : (empty) +# ldflags : ldflags to use : string : (empty) +# build_step : build step 'core1', 'core2', 'gcc_build' +# or 'gcc_host' : string : (none) +# Usage: do_gcc_core_backend mode=[static|shared|baremetal] build_libgcc=[yes|no] build_staticlinked=[yes|no] +do_gcc_core_backend() { + local mode + local build_libgcc=no + local build_libstdcxx=no + local build_libgfortran=no + local build_staticlinked=no + local build_manuals=no + local host + local prefix + local complibs + local lang_list + local cflags + local cflags_for_build + local ldflags + local build_step + local log_txt + local tmp + local -a host_libstdcxx_flags + local -a extra_config + local -a core_LDFLAGS + local -a core_targets + local -a core_targets_all + local -a core_targets_install + local -a extra_user_config + local arg + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + # This function gets called in case of a bare metal compiler for the final gcc, too. + case "${build_step}" in + core1|core2) + CT_DoLog EXTRA "Configuring core C gcc compiler" + log_txt="gcc" + extra_user_config=( "${CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY[@]}" ) + ;; + gcc_build|gcc_host) + CT_DoLog EXTRA "Configuring final gcc compiler" + extra_user_config=( "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" ) + log_txt="final gcc compiler" + # to inhibit the libiberty and libgcc tricks later on + build_libgcc=no + ;; + *) + CT_Abort "Internal Error: 'build_step' must be one of: 'core1', 'core2', 'gcc_build' or 'gcc_host', not '${build_step:-(empty)}'" + ;; + esac + + case "${mode}" in + static) + extra_config+=("--with-newlib") + extra_config+=("--enable-threads=no") + extra_config+=("--disable-shared") + ;; + shared) + extra_config+=("--enable-shared") + ;; + baremetal) + extra_config+=("--with-newlib") + extra_config+=("--enable-threads=no") + extra_config+=("--disable-shared") + ;; + *) + CT_Abort "Internal Error: 'mode' must be one of: 'static', 'shared' or 'baremetal', not '${mode:-(empty)}'" + ;; + esac + + # This is only needed when building libstdc++ in a canadian environment with + # this function being used for final step (i.e., when building for bare metal). + if [ "${build_step}" = "gcc_build" ]; then + CT_DoLog DEBUG "Copying headers to install area of core C compiler" + CT_DoExecLog ALL cp -a "${CT_HEADERS_DIR}" "${prefix}/${CT_TARGET}/include" + fi + + for tmp in ARCH ABI CPU TUNE FPU FLOAT; do + eval tmp="\${CT_ARCH_WITH_${tmp}}" + if [ -n "${tmp}" ]; then + extra_config+=("${tmp}") + fi + done + + extra_config+=("--with-pkgversion=${CT_PKGVERSION}") + [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") + + if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then + extra_config+=("--enable-__cxa_atexit") + else + extra_config+=("--disable-__cxa_atexit") + fi + + if [ -n "${CT_CC_GCC_ENABLE_CXX_FLAGS}" \ + -a "${mode}" = "baremetal" ]; then + extra_config+=("--enable-cxx-flags=${CT_CC_GCC_ENABLE_CXX_FLAGS}") + fi + + extra_config+=(--disable-libgomp) + extra_config+=(--disable-libmudflap) + extra_config+=(--disable-libmpx) + + if [ "${CT_CC_GCC_LIBSSP}" = "y" ]; then + extra_config+=(--enable-libssp) + else + extra_config+=(--disable-libssp) + fi + if [ "${CT_CC_GCC_LIBQUADMATH}" = "y" ]; then + extra_config+=(--enable-libquadmath) + extra_config+=(--enable-libquadmath-support) + else + extra_config+=(--disable-libquadmath) + extra_config+=(--disable-libquadmath-support) + fi + + core_LDFLAGS+=("${ldflags}") + + # *** WARNING ! *** + # Keep this full if-else-if-elif-fi-fi block in sync + # with the same block in do_gcc_backend, below. + if [ "${build_staticlinked}" = "yes" ]; then + core_LDFLAGS+=("-static") + host_libstdcxx_flags+=("-static-libgcc") + host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++") + host_libstdcxx_flags+=("-lm") + # Companion libraries are build static (eg !shared), so + # the libstdc++ is not pulled automatically, although it + # is needed. Shoe-horn it in our LDFLAGS + # Ditto libm on some Fedora boxen + core_LDFLAGS+=("-lstdc++") + core_LDFLAGS+=("-lm") + else + if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" ]; then + # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2 + # build script + # INFO: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++, + # see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html + host_libstdcxx_flags+=("-static-libgcc") + host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++,-Bdynamic") + host_libstdcxx_flags+=("-lm") + fi + # When companion libraries are build static (eg !shared), + # the libstdc++ is not pulled automatically, although it + # is needed. Shoe-horn it in our LDFLAGS + # Ditto libm on some Fedora boxen + core_LDFLAGS+=("-lstdc++") + core_LDFLAGS+=("-lm") + fi + + extra_config+=("--with-gmp=${complibs}") + extra_config+=("--with-mpfr=${complibs}") + extra_config+=("--with-mpc=${complibs}") + if [ "${CT_CC_GCC_USE_GRAPHITE}" = "y" ]; then + if [ "${CT_ISL}" = "y" ]; then + extra_config+=("--with-isl=${complibs}") + fi + if [ "${CT_CLOOG}" = "y" ]; then + extra_config+=("--with-cloog=${complibs}") + fi + else + extra_config+=("--with-isl=no") + extra_config+=("--with-cloog=no") + fi + if [ "${CT_CC_GCC_USE_LTO}" = "y" ]; then + extra_config+=("--enable-lto") + else + extra_config+=("--disable-lto") + fi + + if [ ${#host_libstdcxx_flags[@]} -ne 0 ]; then + extra_config+=("--with-host-libstdcxx=${host_libstdcxx_flags[*]}") + fi + + if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ]; then + extra_config+=("--enable-target-optspace") + fi + if [ "${CT_CC_GCC_DISABLE_PCH}" = "y" ]; then + extra_config+=("--disable-libstdcxx-pch") + fi + + case "${CT_CC_GCC_LDBL_128}" in + y) extra_config+=("--with-long-double-128");; + m) ;; + "") extra_config+=("--without-long-double-128");; + esac + + if [ "${CT_CC_GCC_BUILD_ID}" = "y" ]; then + extra_config+=( --enable-linker-build-id ) + fi + + case "${CT_CC_GCC_LNK_HASH_STYLE}" in + "") ;; + *) extra_config+=( "--with-linker-hash-style=${CT_CC_GCC_LNK_HASH_STYLE}" );; + esac + + case "${CT_CC_GCC_DEC_FLOATS}" in + "") ;; + *) extra_config+=( "--enable-decimal-float=${CT_CC_GCC_DEC_FLOATS}" );; + esac + + case "${CT_ARCH}" in + mips) + case "${CT_CC_GCC_mips_llsc}" in + y) extra_config+=( --with-llsc );; + m) ;; + *) extra_config+=( --without-llsc );; + esac + case "${CT_CC_GCC_mips_synci}" in + y) extra_config+=( --with-synci );; + m) ;; + *) extra_config+=( --without-synci );; + esac + if [ "${CT_CC_GCC_mips_plt}" ]; then + extra_config+=( --with-mips-plt ) + fi + ;; # ARCH is mips + esac + + if [ "${CT_TOOLCHAIN_ENABLE_NLS}" = "y" ]; then + extra_config+=("--with-libintl-prefix=${complibs}") + else + extra_config+=("--disable-nls") + fi + + if [ "${CT_CC_GCC_SYSTEM_ZLIB}" = "y" ]; then + extra_config+=("--with-system-zlib") + fi + + case "${CT_CC_GCC_CONFIG_TLS}" in + y) extra_config+=("--enable-tls");; + m) ;; + "") extra_config+=("--disable-tls");; + esac + + # Some versions of gcc have a defective --enable-multilib. + # Since that's the default, only pass --disable-multilib. For multilib, + # also enable multiarch. Without explicit --enable-multiarch, pass-1 + # compiler is configured as multilib/no-multiarch and pass-2/final + # are multilib/multiarch (because gcc autodetects multiarch based on + # multiple instances of crt*.o in the install directory - which do + # not exist in pass-1). + if [ "${CT_MULTILIB}" != "y" ]; then + extra_config+=("--disable-multilib") + else + extra_config+=("--enable-multiarch") + if [ -n "${CT_CC_GCC_MULTILIB_LIST}" ]; then + extra_config+=("--with-multilib-list=${CT_CC_GCC_MULTILIB_LIST}") + fi + fi + + CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'" + + # We may need to modify host/build CFLAGS separately below + cflags_for_build="${CT_CFLAGS_FOR_BUILD}" + + # Clang's default bracket-depth is 256, and building GCC + # requires somewhere between 257 and 512. + if [ "${host}" = "${CT_BUILD}" ]; then + if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then + cflags="$cflags "-fbracket-depth=512 + cflags_for_build="$cflags_for_build "-fbracket-depth=512 + fi + else + # FIXME we currently don't support clang as host compiler, only as build + if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then + cflags_for_build="$cflags_for_build "-fbracket-depth=512 + fi + fi + + # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532) + CT_DoExecLog CFG \ + CC_FOR_BUILD="${CT_BUILD}-gcc" \ + CFLAGS="${cflags}" \ + CFLAGS_FOR_BUILD="${cflags_for_build}" \ + CXXFLAGS="${cflags}" \ + CXXFLAGS_FOR_BUILD="${cflags_for_build}" \ + LDFLAGS="${core_LDFLAGS[*]}" \ + CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \ + CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \ + LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/gcc/configure" \ + --build=${CT_BUILD} \ + --host=${host} \ + --target=${CT_TARGET} \ + --prefix="${prefix}" \ + --with-local-prefix="${CT_SYSROOT_DIR}" \ + ${CC_CORE_SYSROOT_ARG} \ + "${extra_config[@]}" \ + --enable-languages="${lang_list}" \ + "${extra_user_config[@]}" + + if [ "${build_libgcc}" = "yes" ]; then + # HACK: we need to override SHLIB_LC from gcc/config/t-slibgcc-elf-ver or + # gcc/config/t-libunwind so -lc is removed from the link for + # libgcc_s.so, as we do not have a target -lc yet. + # This is not as ugly as it appears to be ;-) All symbols get resolved + # during the glibc build, and we provide a proper libgcc_s.so for the + # cross toolchain during the final gcc build. + # + # As we cannot modify the source tree, nor override SHLIB_LC itself + # during configure or make, we have to edit the resultant + # gcc/libgcc.mk itself to remove -lc from the link. + # This causes us to have to jump through some hoops... + # + # To produce libgcc.mk to edit we firstly require libiberty.a, + # so we configure then build it. + # Next we have to configure gcc, create libgcc.mk then edit it... + # So much easier if we just edit the source tree, but hey... + if [ ! -f "${CT_SRC_DIR}/gcc/gcc/BASE-VER" ]; then + CT_DoExecLog CFG make ${JOBSFLAGS} configure-libiberty + CT_DoExecLog ALL make ${JOBSFLAGS} -C libiberty libiberty.a + CT_DoExecLog CFG make ${JOBSFLAGS} configure-gcc configure-libcpp + CT_DoExecLog ALL make ${JOBSFLAGS} all-libcpp + else + CT_DoExecLog CFG make ${JOBSFLAGS} configure-gcc configure-libcpp configure-build-libiberty + CT_DoExecLog ALL make ${JOBSFLAGS} all-libcpp all-build-libiberty + fi + # HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here. + if [ -d "${CT_SRC_DIR}/gcc/libdecnumber" ]; then + CT_DoExecLog CFG make ${JOBSFLAGS} configure-libdecnumber + CT_DoExecLog ALL make ${JOBSFLAGS} -C libdecnumber libdecnumber.a + fi + # HACK: gcc-4.8 uses libbacktrace to make libgcc.mvars, so make it here. + if [ -d "${CT_SRC_DIR}/gcc/libbacktrace" ]; then + CT_DoExecLog CFG make ${JOBSFLAGS} configure-libbacktrace + CT_DoExecLog ALL make ${JOBSFLAGS} -C libbacktrace + fi + + libgcc_rule="libgcc.mvars" + core_targets=( gcc target-libgcc ) + + # On bare metal and canadian build the host-compiler is used when + # actually the build-system compiler is required. Choose the correct + # compilers for canadian build and use the defaults on other + # configurations. + if [ "${CT_BARE_METAL},${CT_CANADIAN}" = "y,y" ]; then + repair_cc="CC_FOR_BUILD=${CT_BUILD}-gcc \ + CXX_FOR_BUILD=${CT_BUILD}-g++ \ + GCC_FOR_TARGET=${CT_TARGET}-${CT_CC}" + else + repair_cc="" + fi + + CT_DoExecLog ALL make ${JOBSFLAGS} -C gcc ${libgcc_rule} \ + ${repair_cc} + sed -r -i -e 's@-lc@@g' gcc/${libgcc_rule} + else # build_libgcc + core_targets=( gcc ) + fi # ! build libgcc + if [ "${build_libstdcxx}" = "yes" \ + -a "${CT_CC_LANG_CXX}" = "y" \ + ]; then + core_targets+=( target-libstdc++-v3 ) + fi + + if [ "${build_libgfortran}" = "yes" \ + -a "${CT_CC_LANG_FORTRAN}" = "y" \ + ]; then + core_targets+=( target-libgfortran ) + fi + + core_targets_all="${core_targets[@]/#/all-}" + core_targets_install="${core_targets[@]/#/install-}" + + case "${build_step}" in + gcc_build|gcc_host) + core_targets_all=all + core_targets_install=install + ;; + esac + + CT_DoLog EXTRA "Building ${log_txt}" + CT_DoExecLog ALL make ${JOBSFLAGS} ${core_targets_all} + + # Do not pass ${JOBSFLAGS} here: recent GCC builds have been failing + # in parallel 'make install' at random locations: libitm, libcilk, + # always for the files that are installed more than once to the same + # location (such as libitm.info). + # The symptom is that the install command fails with "File exists" + # error; running the same command manually succeeds. It looks like + # attempts to remove the destination and re-create it, but another + # install gets in the way. + CT_DoLog EXTRA "Installing ${log_txt}" + CT_DoExecLog ALL make ${core_targets_install} + + # Remove the libtool "pseudo-libraries": having them in the installed + # tree makes the libtoolized utilities that are built next assume + # that, for example, libsupc++ is an "accessory library", and not include + # -lsupc++ to the link flags. That breaks ltrace, for example. + CT_DoLog EXTRA "Housekeeping for core gcc compiler" + CT_Pushd "${prefix}" + find . -type f -name "*.la" -exec rm {} \; |CT_DoLog ALL + CT_Popd + + if [ "${build_manuals}" = "yes" ]; then + CT_DoLog EXTRA "Building the GCC manuals" + CT_DoExecLog ALL make pdf html + CT_DoLog EXTRA "Installing the GCC manuals" + CT_DoExecLog ALL make install-{pdf,html}-gcc + fi + + # Create a symlink ${CT_TARGET}-cc to ${CT_TARGET}-${CT_CC} to always be able + # to call the C compiler with the same, somewhat canonical name. + # check whether compiler has an extension + file="$( ls -1 "${prefix}/bin/${CT_TARGET}-${CT_CC}."* 2>/dev/null || true )" + [ -z "${file}" ] || ext=".${file##*.}" + if [ -f "${prefix}/bin/${CT_TARGET}-${CT_CC}${ext}" ]; then + CT_DoExecLog ALL ln -sfv "${CT_TARGET}-${CT_CC}${ext}" "${prefix}/bin/${CT_TARGET}-cc${ext}" + fi + + cc_gcc_multilib_housekeeping cc="${prefix}/bin/${CT_TARGET}-${CT_CC}" \ + host="${host}" +} + +#------------------------------------------------------------------------------ +# Build complete gcc to run on build +do_gcc_for_build() { + local -a build_final_opts + local build_final_backend + + # If native or simple cross toolchain is being built, then build==host; + # nothing to do. + case "${CT_TOOLCHAIN_TYPE}" in + native|cross) return 0;; + esac + + build_final_opts+=( "host=${CT_BUILD}" ) + build_final_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" ) + build_final_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" ) + build_final_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" ) + build_final_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" ) + build_final_opts+=( "lang_list=$( cc_gcc_lang_list )" ) + build_final_opts+=( "build_step=gcc_build" ) + if [ "${CT_BARE_METAL}" = "y" ]; then + # In the tests I've done, bare-metal was not impacted by the + # lack of such a compiler, but better safe than sorry... + build_final_opts+=( "mode=baremetal" ) + build_final_opts+=( "build_libgcc=yes" ) + build_final_opts+=( "build_libstdcxx=yes" ) + build_final_opts+=( "build_libgfortran=yes" ) + if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then + build_final_opts+=( "build_staticlinked=yes" ) + fi + build_final_backend=do_gcc_core_backend + else + build_final_backend=do_gcc_backend + fi + + CT_DoStep INFO "Installing final gcc compiler for build" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-final-build-${CT_BUILD}" + + "${build_final_backend}" "${build_final_opts[@]}" + + CT_Popd + CT_EndStep +} + +gcc_movelibs() { + local multi_flags multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_index multi_count + local gcc_dir dst_dir + local rel + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + # Move only files, directories are for other multilibs. We're looking inside + # GCC's directory structure, thus use unmangled multi_os_dir that GCC reports. + gcc_dir="${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_os_dir_gcc}" + if [ ! -d "${gcc_dir}" ]; then + # GCC didn't install anything outside of sysroot + return + fi + # Depending on the selected libc, we may or may not have the ${multi_os_dir_gcc} + # created by libc installation. If we do, use it. If we don't, use ${multi_os_dir} + # to avoid creating an otherwise empty directory. + dst_dir="${multi_root}/lib/${multi_os_dir_gcc}" + if [ ! -d "${dst_dir}" ]; then + dst_dir="${multi_root}/lib/${multi_os_dir}" + fi + CT_SanitizeVarDir dst_dir gcc_dir + rel=$( echo "${gcc_dir#${CT_PREFIX_DIR}/}" | sed 's#[^/]\{1,\}#..#g' ) + + ls "${gcc_dir}" | while read f; do + case "${f}" in + *.ld) + # Linker scripts remain in GCC's directory; elf2flt insists on + # finding them there. + continue + ;; + esac + if [ -f "${gcc_dir}/${f}" ]; then + CT_DoExecLog ALL mkdir -p "${dst_dir}" + CT_DoExecLog ALL mv "${gcc_dir}/${f}" "${dst_dir}/${f}" + CT_DoExecLog ALL ln -sf "${rel}/${dst_dir#${CT_PREFIX_DIR}/}/${f}" "${gcc_dir}/${f}" + fi + done +} + +#------------------------------------------------------------------------------ +# Build final gcc to run on host +do_gcc_for_host() { + local -a final_opts + local final_backend + + final_opts+=( "host=${CT_HOST}" ) + final_opts+=( "prefix=${CT_PREFIX_DIR}" ) + final_opts+=( "complibs=${CT_HOST_COMPLIBS_DIR}" ) + final_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" ) + final_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" ) + final_opts+=( "lang_list=$( cc_gcc_lang_list )" ) + final_opts+=( "build_step=gcc_host" ) + if [ "${CT_BUILD_MANUALS}" = "y" ]; then + final_opts+=( "build_manuals=yes" ) + fi + if [ "${CT_BARE_METAL}" = "y" ]; then + final_opts+=( "mode=baremetal" ) + final_opts+=( "build_libgcc=yes" ) + final_opts+=( "build_libstdcxx=yes" ) + final_opts+=( "build_libgfortran=yes" ) + if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then + final_opts+=( "build_staticlinked=yes" ) + fi + final_backend=do_gcc_core_backend + else + final_backend=do_gcc_backend + fi + + CT_DoStep INFO "Installing final gcc compiler" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-final" + "${final_backend}" "${final_opts[@]}" + CT_Popd + + # GCC installs stuff (including libgcc) into its own /lib dir, + # outside of sysroot, breaking linking with -static-libgcc. + # Fix up by moving the libraries into the sysroot. + if [ "${CT_USE_SYSROOT}" = "y" ]; then + CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-final-movelibs" + CT_IterateMultilibs gcc_movelibs movelibs + CT_Popd + fi + + CT_EndStep +} + +#------------------------------------------------------------------------------ +# Build the final gcc +# Usage: do_gcc_backend param=value [...] +# Parameter : Definition : Type : Default +# host : the host we run onto : tuple : (none) +# prefix : the runtime prefix : dir : (none) +# complibs : the companion libraries prefix : dir : (none) +# cflags : cflags to use : string : (empty) +# ldflags : ldflags to use : string : (empty) +# lang_list : the list of languages to build : string : (empty) +# build_manuals : whether to build manuals or not : bool : no +do_gcc_backend() { + local host + local prefix + local complibs + local lang_list + local cflags + local cflags_for_build + local ldflags + local build_manuals + local -a host_libstdcxx_flags + local -a extra_config + local -a final_LDFLAGS + local tmp + local arg + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + CT_DoLog EXTRA "Configuring final gcc compiler" + + # Enable selected languages + extra_config+=("--enable-languages=${lang_list}") + + for tmp in ARCH ABI CPU TUNE FPU FLOAT; do + eval tmp="\${CT_ARCH_WITH_${tmp}}" + if [ -n "${tmp}" ]; then + extra_config+=("${tmp}") + fi + done + + [ "${CT_SHARED_LIBS}" = "y" ] || extra_config+=("--disable-shared") + extra_config+=("--with-pkgversion=${CT_PKGVERSION}") + [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") + + case "${CT_CC_GCC_SJLJ_EXCEPTIONS}" in + y) extra_config+=("--enable-sjlj-exceptions");; + m) ;; + "") extra_config+=("--disable-sjlj-exceptions");; + esac + if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then + extra_config+=("--enable-__cxa_atexit") + else + extra_config+=("--disable-__cxa_atexit") + fi + + if [ -n "${CT_CC_GCC_ENABLE_CXX_FLAGS}" ]; then + extra_config+=("--enable-cxx-flags=${CT_CC_GCC_ENABLE_CXX_FLAGS}") + fi + + if [ "${CT_THREADS}" = "none" ]; then + extra_config+=(--disable-libatomic) + fi + if [ "${CT_CC_GCC_LIBMUDFLAP}" = "y" ]; then + extra_config+=(--enable-libmudflap) + else + extra_config+=(--disable-libmudflap) + fi + if [ "${CT_CC_GCC_LIBGOMP}" = "y" ]; then + extra_config+=(--enable-libgomp) + else + extra_config+=(--disable-libgomp) + fi + if [ "${CT_CC_GCC_LIBSSP}" = "y" ]; then + extra_config+=(--enable-libssp) + else + extra_config+=(--disable-libssp) + fi + if [ "${CT_CC_GCC_LIBQUADMATH}" = "y" ]; then + extra_config+=(--enable-libquadmath) + extra_config+=(--enable-libquadmath-support) + else + extra_config+=(--disable-libquadmath) + extra_config+=(--disable-libquadmath-support) + fi + + if [ "${CT_CC_GCC_LIBSANITIZER}" = "y" ]; then + extra_config+=(--enable-libsanitizer) + else + extra_config+=(--disable-libsanitizer) + fi + + if [ "${CT_CC_GCC_HAS_LIBMPX}" = "y" ]; then + if [ "${CT_CC_GCC_LIBMPX}" = "y" ]; then + extra_config+=(--enable-libmpx) + else + extra_config+=(--disable-libmpx) + fi + fi + + final_LDFLAGS+=("${ldflags}") + + # *** WARNING ! *** + # Keep this full if-else-if-elif-fi-fi block in sync + # with the same block in do_gcc_core_backend, above. + if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then + final_LDFLAGS+=("-static") + host_libstdcxx_flags+=("-static-libgcc") + host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++") + host_libstdcxx_flags+=("-lm") + # Companion libraries are build static (eg !shared), so + # the libstdc++ is not pulled automatically, although it + # is needed. Shoe-horn it in our LDFLAGS + # Ditto libm on some Fedora boxen + final_LDFLAGS+=("-lstdc++") + final_LDFLAGS+=("-lm") + else + if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" ]; then + # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2 + # build script + # INFO: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++, + # see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html + host_libstdcxx_flags+=("-static-libgcc") + host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++,-Bdynamic") + host_libstdcxx_flags+=("-lm") + fi + # When companion libraries are build static (eg !shared), + # the libstdc++ is not pulled automatically, although it + # is needed. Shoe-horn it in our LDFLAGS + # Ditto libm on some Fedora boxen + final_LDFLAGS+=("-lstdc++") + final_LDFLAGS+=("-lm") + fi + + extra_config+=("--with-gmp=${complibs}") + extra_config+=("--with-mpfr=${complibs}") + extra_config+=("--with-mpc=${complibs}") + if [ "${CT_CC_GCC_USE_GRAPHITE}" = "y" ]; then + if [ "${CT_ISL}" = "y" ]; then + extra_config+=("--with-isl=${complibs}") + fi + if [ "${CT_CLOOG}" = "y" ]; then + extra_config+=("--with-cloog=${complibs}") + fi + else + extra_config+=("--with-isl=no") + extra_config+=("--with-cloog=no") + fi + if [ "${CT_CC_GCC_USE_LTO}" = "y" ]; then + extra_config+=("--enable-lto") + else + extra_config+=("--disable-lto") + fi + + if [ ${#host_libstdcxx_flags[@]} -ne 0 ]; then + extra_config+=("--with-host-libstdcxx=${host_libstdcxx_flags[*]}") + fi + + if [ "${CT_THREADS}" = "none" ]; then + extra_config+=("--disable-threads") + else + if [ "${CT_THREADS}" = "win32" ]; then + extra_config+=("--enable-threads=win32") + extra_config+=("--disable-win32-registry") + else + extra_config+=("--enable-threads=posix") + fi + fi + + if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ]; then + extra_config+=("--enable-target-optspace") + fi + if [ "${CT_CC_GCC_DISABLE_PCH}" = "y" ]; then + extra_config+=("--disable-libstdcxx-pch") + fi + + case "${CT_CC_GCC_LDBL_128}" in + y) extra_config+=("--with-long-double-128");; + m) ;; + "") extra_config+=("--without-long-double-128");; + esac + + if [ "${CT_CC_GCC_BUILD_ID}" = "y" ]; then + extra_config+=( --enable-linker-build-id ) + fi + + case "${CT_CC_GCC_LNK_HASH_STYLE}" in + "") ;; + *) extra_config+=( "--with-linker-hash-style=${CT_CC_GCC_LNK_HASH_STYLE}" );; + esac + + case "${CT_CC_GCC_DEC_FLOATS}" in + "") ;; + *) extra_config+=( "--enable-decimal-float=${CT_CC_GCC_DEC_FLOATS}" );; + esac + + if [ "${CT_CC_GCC_ENABLE_PLUGINS}" = "y" ]; then + extra_config+=( --enable-plugin ) + else + extra_config+=( --disable-plugin ) + fi + if [ "${CT_CC_GCC_GOLD}" = "y" ]; then + extra_config+=( --enable-gold ) + fi + + case "${CT_ARCH}" in + mips) + case "${CT_CC_GCC_mips_llsc}" in + y) extra_config+=( --with-llsc );; + m) ;; + *) extra_config+=( --without-llsc );; + esac + case "${CT_CC_GCC_mips_synci}" in + y) extra_config+=( --with-synci );; + m) ;; + *) extra_config+=( --without-synci );; + esac + if [ "${CT_CC_GCC_mips_plt}" ]; then + extra_config+=( --with-mips-plt ) + fi + ;; # ARCH is mips + esac + + if [ "${CT_TOOLCHAIN_ENABLE_NLS}" = "y" ]; then + extra_config+=("--with-libintl-prefix=${complibs}") + else + extra_config+=("--disable-nls") + fi + + if [ "${CT_CC_GCC_SYSTEM_ZLIB}" = "y" ]; then + extra_config+=("--with-system-zlib") + fi + + case "${CT_CC_GCC_CONFIG_TLS}" in + y) extra_config+=("--enable-tls");; + m) ;; + "") extra_config+=("--disable-tls");; + esac + + # Some versions of gcc have a defective --enable-multilib. + # Since that's the default, only pass --disable-multilib. + if [ "${CT_MULTILIB}" != "y" ]; then + extra_config+=("--disable-multilib") + else + extra_config+=("--enable-multiarch") + if [ -n "${CT_CC_GCC_MULTILIB_LIST}" ]; then + extra_config+=("--with-multilib-list=${CT_CC_GCC_MULTILIB_LIST}") + fi + fi + + CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'" + + # We may need to modify host/build CFLAGS separately below + cflags_for_build="${cflags}" + + # Clang's default bracket-depth is 256, and building GCC + # requires somewhere between 257 and 512. + if [ "${host}" = "${CT_BUILD}" ]; then + if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then + cflags="$cflags "-fbracket-depth=512 + cflags_for_build="$cflags_for_build "-fbracket-depth=512 + fi + else + # FIXME we currently don't support clang as host compiler, only as build + if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then + cflags_for_build="$cflags_for_build "-fbracket-depth=512 + fi + fi + + CT_DoExecLog CFG \ + CC_FOR_BUILD="${CT_BUILD}-gcc" \ + CFLAGS="${cflags}" \ + CFLAGS_FOR_BUILD="${cflags_for_build}" \ + CXXFLAGS="${cflags}" \ + CXXFLAGS_FOR_BUILD="${cflags_for_build}" \ + LDFLAGS="${final_LDFLAGS[*]}" \ + CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \ + CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \ + LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/gcc/configure" \ + --build=${CT_BUILD} \ + --host=${host} \ + --target=${CT_TARGET} \ + --prefix="${prefix}" \ + ${CC_SYSROOT_ARG} \ + "${extra_config[@]}" \ + --with-local-prefix="${CT_SYSROOT_DIR}" \ + --enable-long-long \ + "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" + + if [ "${CT_CANADIAN}" = "y" ]; then + CT_DoLog EXTRA "Building libiberty" + CT_DoExecLog ALL make ${JOBSFLAGS} all-build-libiberty + fi + + CT_DoLog EXTRA "Building final gcc compiler" + CT_DoExecLog ALL make ${JOBSFLAGS} all + + # See the note on issues with parallel 'make install' in GCC above. + CT_DoLog EXTRA "Installing final gcc compiler" + if [ "${CT_STRIP_TARGET_TOOLCHAIN_EXECUTABLES}" = "y" ]; then + CT_DoExecLog ALL make install-strip + else + CT_DoExecLog ALL make install + fi + + # Remove the libtool "pseudo-libraries": having them in the installed + # tree makes the libtoolized utilities that are built next assume + # that, for example, libsupc++ is an "accessory library", and not include + # -lsupc++ to the link flags. That breaks ltrace, for example. + CT_DoLog EXTRA "Housekeeping for final gcc compiler" + CT_Pushd "${prefix}" + find . -type f -name "*.la" -exec rm {} \; |CT_DoLog ALL + CT_Popd + + if [ "${build_manuals}" = "yes" ]; then + CT_DoLog EXTRA "Building the GCC manuals" + CT_DoExecLog ALL make pdf html + CT_DoLog EXTRA "Installing the GCC manuals" + CT_DoExecLog ALL make install-{pdf,html}-gcc + fi + + # Create a symlink ${CT_TARGET}-cc to ${CT_TARGET}-${CT_CC} to always be able + # to call the C compiler with the same, somewhat canonical name. + # check whether compiler has an extension + file="$( ls -1 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${CT_CC}."* 2>/dev/null || true )" + [ -z "${file}" ] || ext=".${file##*.}" + if [ -f "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${CT_CC}${ext}" ]; then + CT_DoExecLog ALL ln -sfv "${CT_TARGET}-${CT_CC}${ext}" "${prefix}/bin/${CT_TARGET}-cc${ext}" + fi + + cc_gcc_multilib_housekeeping cc="${prefix}/bin/${CT_TARGET}-${CT_CC}" \ + host="${host}" +} -- cgit v1.2.3 From 993b4acec54f02f3391fce6b56e0366304b79f01 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sun, 25 Jun 2017 22:54:29 -0700 Subject: Building packages using the new framework (fails at building GMP off the VCS because it needs to run bootstrap scripts) Signed-off-by: Alexey Neyman --- config/arch/xtensa.in | 1 + config/arch/xtensa.in.2 | 23 +- config/global/extract.in | 27 +- config/target.in | 26 ++ scripts/build/arch/xtensa.sh | 61 --- scripts/build/cc/gcc.sh | 1 + scripts/build/kernel/linux.sh | 30 +- scripts/build/libc/glibc.sh | 4 +- scripts/crosstool-NG.sh.in | 3 +- scripts/functions | 887 +++++++++++++++++++----------------------- 10 files changed, 446 insertions(+), 617 deletions(-) (limited to 'scripts/build/cc') diff --git a/config/arch/xtensa.in b/config/arch/xtensa.in index 3ffa4e80..c247f62a 100644 --- a/config/arch/xtensa.in +++ b/config/arch/xtensa.in @@ -5,6 +5,7 @@ ## select ARCH_DEFAULT_LE ## select ARCH_SUPPORTS_BOTH_MMU ## select ARCH_DEFAULT_HAS_MMU +## select USE_OVERLAY ## ## help The xtensa architecture ## help diff --git a/config/arch/xtensa.in.2 b/config/arch/xtensa.in.2 index 25ece701..5ae14d2c 100644 --- a/config/arch/xtensa.in.2 +++ b/config/arch/xtensa.in.2 @@ -4,30 +4,9 @@ choice config XTENSA_CUSTOM bool "Custom Xtensa processor configuration" + select TARGET_USE_OVERLAY config ARCH_xtensa_fsf bool "fsf - Default configuration" endchoice - -config ARCH_XTENSA_CUSTOM_NAME - string "Custom Xtensa processor configuration name" - depends on XTENSA_CUSTOM - default "" - help - Enter the name of the custom processor configuration. - Overlay file for that configuration must be called - 'xtensa_.tar'. - - Leave blank to use the default 'xtensa-overlay.tar'. - For more information about this option, please also consult - section 'Using crosstool-NG to build Xtensa toolchains' in the - docs/C - Misc. tutorials.txt - -config ARCH_XTENSA_CUSTOM_OVERLAY_LOCATION - string "Full path to custom Xtensa processor configurations" - depends on XTENSA_CUSTOM - default "" - help - Enter the path to the directory for the custom processor - configuration file. diff --git a/config/global/extract.in b/config/global/extract.in index b7547757..582e69c2 100644 --- a/config/global/extract.in +++ b/config/global/extract.in @@ -73,24 +73,6 @@ config PATCH_LOCAL_BUNDLED Apply your local patches, then apply the patches bundled with crosstool-NG. -config PATCH_BUNDLED_FALLBACK_LOCAL - bool - prompt "Bundled only, local if no bundled" - select PATCH_USE_LOCAL - select PATCH_SINGLE - help - Apply the patches bundled with crosstool-NG; - if there's no bundled patches, apply your local patches. - -config PATCH_LOCAL_FALLBACK_BUNDLED - bool - prompt "Local only, bundled if no local" - select PATCH_USE_LOCAL - select PATCH_SINGLE - help - Only apply your local patches; - if there's no local patches, apply patches bundled with crosstool-NG. - config PATCH_NONE bool prompt "None" @@ -110,19 +92,16 @@ config PATCH_ORDER string default "bundled" if PATCH_BUNDLED default "local" if PATCH_LOCAL - default "bundled,local" if PATCH_BUNDLED_LOCAL || PATCH_BUNDLED_FALLBACK_LOCAL - default "local,bundled" if PATCH_LOCAL_BUNDLED || PATCH_LOCAL_FALLBACK_BUNDLED + default "bundled,local" if PATCH_BUNDLED_LOCAL + default "local,bundled" if PATCH_LOCAL_BUNDLED default "none" if PATCH_NONE -config PATCH_SINGLE - bool - config PATCH_USE_LOCAL bool config LOCAL_PATCH_DIR string - prompt "| Local patch directory" + prompt "Local patch directory" default "" depends on PATCH_USE_LOCAL help diff --git a/config/target.in b/config/target.in index 3d86b557..1011ac92 100644 --- a/config/target.in +++ b/config/target.in @@ -404,4 +404,30 @@ config ARCH_FLOAT source "config/gen/arch.in.2" +config TARGET_USE_OVERLAY + bool + +if TARGET_USE_OVERLAY + +config OVERLAY_NAME + string "Custom processor configuration name" + help + Enter the name of the custom processor configuration. + Overlay file for that configuration must be called + '_.tar' (optionally, with .gz/.bz2/.lzma/.xz + extension). + + Leave blank to use the default '-overlay.tar'. + For more information about this option, please also consult the + section 'Using crosstool-NG to build Xtensa toolchains' in the + in http://crosstool-ng.github.io/docs/caveats-features/ + +config OVERLAY_LOCATION + string "Full path to custom configuration (overlay)" + help + Enter the path to the directory for the custom processor + configuration file. + +endif + endmenu diff --git a/scripts/build/arch/xtensa.sh b/scripts/build/arch/xtensa.sh index bf94ddfa..744bbb2d 100644 --- a/scripts/build/arch/xtensa.sh +++ b/scripts/build/arch/xtensa.sh @@ -12,67 +12,6 @@ CT_DoArchTupleValues() { esac } -# This function updates the specified component (binutils, gcc, gdb, etc.) -# with the processor specific configuration. -CT_ConfigureXtensa() { - local component="${1}" - local version="${2}" - local custom_overlay="xtensa_${CT_ARCH_XTENSA_CUSTOM_NAME}.tar" - local custom_location="${CT_ARCH_XTENSA_CUSTOM_OVERLAY_LOCATION}" - - if [ -z "${CT_ARCH_XTENSA_CUSTOM_NAME}" ]; then - custom_overlay="xtensa-overlay.tar" - fi - - CT_TestAndAbort "${custom_overlay}: CT_ARCH_XTENSA_CUSTOM_OVERLAY_LOCATION must be set." -z "${custom_location}" - - local full_file="${custom_location}/${custom_overlay}" - local basename="${component}-${version}" - local ext - - ext=${full_file/*./.} - - if [ -z "${ext}" ] ; then - CT_DoLog WARN "'${full_file}' not found" - return 1 - fi - - if [ -e "${CT_SRC_DIR}/.${basename}.configuring" ]; then - CT_DoLog ERROR "The '${basename}' source were partially configured." - CT_DoLog ERROR "Please remove first:" - CT_DoLog ERROR " - the source dir for '${basename}', in '${CT_SRC_DIR}'" - CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${basename}.extracted'" - CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${basename}.patch'" - CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${basename}.configuring'" - CT_Abort - fi - - CT_DoLog EXTRA "Using '${custom_overlay}' from ${custom_location}" - CT_DoExecLog DEBUG ln -sf "${custom_location}/${custom_overlay}" \ - "${CT_TARBALLS_DIR}/${custom_overlay}" - - CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.${basename}.configuring" - - CT_Pushd "${CT_SRC_DIR}/${basename}" - - tar_opts=( "--strip-components=1" ) - tar_opts+=( "-xv" ) - - case "${ext}" in - .tar) CT_DoExecLog FILE tar "${tar_opts[@]}" -f "${full_file}" "${component}";; - .gz|.tgz) gzip -dc "${full_file}" | CT_DoExecLog FILE tar "${tar_opts[@]}" -f - "${component}";; - .bz2) bzip2 -dc "${full_file}" | CT_DoExecLog FILE tar "${tar_opts[@]}" -f - "${component}";; - *) CT_DoLog WARN "Don't know how to handle '${basename}${ext}': unknown extension" - return 1 - ;; - esac - - CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.${basename}.configured" - CT_DoExecLog DEBUG rm -f "${CT_SRC_DIR}/.${basename}.configuring" - - CT_Popd -} - CT_DoArchUClibcConfig() { local cfg="${1}" diff --git a/scripts/build/cc/gcc.sh b/scripts/build/cc/gcc.sh index 449aafb6..e836c826 100644 --- a/scripts/build/cc/gcc.sh +++ b/scripts/build/cc/gcc.sh @@ -14,6 +14,7 @@ do_gcc_get() { # GCC source tree, which will not be there unless we get it and # put it there ourselves if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" ]; then + # TBD check return code CT_GetFile ecj-latest .jar http://mirrors.kernel.org/sourceware/java/ \ ftp://gcc.gnu.org/pub/java \ ftp://sourceware.org/pub/java diff --git a/scripts/build/kernel/linux.sh b/scripts/build/kernel/linux.sh index 0f04d64e..5ab49182 100644 --- a/scripts/build/kernel/linux.sh +++ b/scripts/build/kernel/linux.sh @@ -22,21 +22,23 @@ do_kernel_get() { CT_Fetch LINUX } -# Extract kernel -do_kernel_extract() { - CT_ExtractPatch LINUX - - # Disable building relocs application - it needs - # on the host, which may not be present on Cygwin or MacOS; it - # needs , which again is not present on MacOS; and most - # important, we don't need it to install the headers. - # This is not done as a patch, since it varies from Linux version - # to version - patching each particular Linux version would be - # too cumbersome. - # TBD should happen before marking the sources as "patched"? - CT_Pushd "${CT_SRC_DIR}/linux" +# Disable building relocs application - it needs +# on the host, which may not be present on Cygwin or MacOS; it +# needs , which again is not present on MacOS; and most +# important, we don't need it to install the headers. +# This is not done as a patch, since it varies from Linux version +# to version - patching each particular Linux version would be +# too cumbersome. +linux_disable_build_relocs() +{ sed -i -r 's/(\$\(MAKE\) .* relocs)$/:/' arch/*/Makefile - CT_Popd +} + +# Extract kernel +do_kernel_extract() +{ + # TBD verify linux_disable_build_relocs is run + CT_ExtractPatch LINUX linux_disable_build_relocs } # Install kernel headers using headers_install from kernel sources. diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index 5862759a..eae64bc4 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -17,9 +17,9 @@ do_libc_get() { do_libc_extract() { local addon - CT_ExtrachPatch GLIBC + CT_ExtractPatch GLIBC if [ "${CT_GLIBC_USE_PORTS_EXTERNAL}" = "y" ]; then - CT_Fetch GLIBC_PORTS + CT_ExtractPatch GLIBC_PORTS fi # TBD make patches for addons (ports? anything else?) uniformly using short names # TBD make the configure timestamp fix in all patched packages (e.g. part of CT_ExtractPatch) diff --git a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in index 78b3d0fb..d40faba9 100644 --- a/scripts/crosstool-NG.sh.in +++ b/scripts/crosstool-NG.sh.in @@ -166,7 +166,8 @@ CT_PKGVERSION="crosstool-NG ${CT_VERSION}${CT_TOOLCHAIN_PKGVERSION:+ - ${CT_TOOL # Compute the working directories names CT_TARBALLS_DIR="${CT_WORK_DIR}/tarballs" -CT_SRC_DIR="${CT_WORK_DIR}/src" +CT_COMMON_SRC_DIR="${CT_WORK_DIR}/src" +CT_SRC_DIR="${CT_BUILD_DIR}/src" CT_BUILDTOOLS_PREFIX_DIR="${CT_BUILD_TOP_DIR}/buildtools" CT_STATE_DIR="${CT_WORK_DIR}/${CT_TARGET}/state" # Note about HOST_COMPLIBS_DIR: it's always gonna be in the buildtools dir, or a diff --git a/scripts/functions b/scripts/functions index af1b1082..091b2029 100644 --- a/scripts/functions +++ b/scripts/functions @@ -624,7 +624,8 @@ CT_SetLibPath() { # Build up the list of allowed tarball extensions # Add them in the prefered order; most preferred comes first -CT_DoListTarballExt() { +CT_DoListTarballExt() +{ printf ".tar.xz\n" printf ".tar.lzma\n" printf ".tar.bz2\n" @@ -637,7 +638,8 @@ CT_DoListTarballExt() { # Usage: CT_GetFileExtension [extension] # If found, echoes the extension to stdout, and return 0 # If not found, echoes nothing on stdout, and return !0. -CT_GetFileExtension() { +CT_GetFileExtension() +{ local ext local file="$1" shift @@ -646,7 +648,7 @@ CT_GetFileExtension() { # we need to also check for an empty extension for those very # peculiar components that don't have one (such as sstrip from # buildroot). - for ext in ${first_ext} $(CT_DoListTarballExt) /.git ''; do + for ext in ${first_ext} $(CT_DoListTarballExt); do if [ -e "${CT_TARBALLS_DIR}/${file}${ext}" -o -L "${CT_TARBALLS_DIR}/${file}${ext}" ]; then echo "${ext}" exit 0 @@ -656,6 +658,20 @@ CT_GetFileExtension() { exit 1 } +# Get file's basename by stripping supported archive extensions +CT_GetFileBasename() +{ + local bn="${1}" + local ext + + for ext in $(CT_DoListTarballExt); do + if [ "${bn%.${ext}}" != "${bn}" ]; then + echo "${bn%.${ext}}" + exit 0 + fi + done +} + # Try to retrieve the specified URL (HTTP or FTP) # Usage: CT_DoGetFile # This functions always returns true (0), as it can be legitimate not @@ -733,61 +749,6 @@ CT_GetLocal() { return 1 } -# This function gets the custom source from either a tarball or directory -# Usage: CT_GetCustom -CT_GetCustom() { - local component_name="$1" - local component_version="$2" - local component_location="$3" - - # Some local variables we use to help us figure out what to do - local component_location_type="dir" # str: 'file' or 'dir' - local component_location_filename="" # filename... if it's a file - - CT_TestAndAbort \ - "${component_name}: Custom location setting is empty" \ - -z "${component_location}" - - CT_TestAndAbort \ - "${component_name}: Custom version setting is empty" \ - -z "${component_version}" - - if [ -f "${component_location}" ]; then - component_location_type="file" - component_location_filename="$(basename ${component_location})" - elif [ -d "${component_location}" ]; then - # Yes, it's the default, but it rules out the else case in the `if'. - component_location_type="dir" - # as -d and -f say: it's a and is readable! - else - CT_Abort "${component_name}: Unable to read ${component_location}, make sure the setting is correct and double check the permissions!" - fi - - if [ "${component_location_type}" = "file" ]; then - CT_DoLog EXTRA "Got '${component_location}' from custom location" - # We need to know the custom tarball extension, - # so we can create a properly-named symlink, which - # we use later on in 'extract' - case "${component_location}" in - *.tar.xz|*.tar.bz2|*.tar.lzma|*.tar.gz|*.tgz|*.tar|*.zip) ;; - *) CT_Abort "Unknown extension for custom tarball '${component_location}'" ;; - esac - [ ! -L "${CT_TARBALLS_DIR}/${component_location_filename}" ] && \ - CT_DoExecLog DEBUG ln -sf "${component_location}" \ - "${CT_TARBALLS_DIR}/${component_location_filename}" - elif [ "${component_location_type}" = "dir" ]; then - CT_DoLog EXTRA "Got '${component_location}' from custom location" - [ ! -d "${CT_SRC_DIR}/${component_name}-${component_version}" ] && \ - CT_DoExecLog DEBUG ln -sf "${component_location}" \ - "${CT_SRC_DIR}/${component_name}-${component_version}" - - # Don't try to extract from source directory, it's extracted! - touch "${CT_SRC_DIR}/.${component_name}-${component_version}.extracted" - fi - # Don't patch a custom source, it's custom! - touch "${CT_SRC_DIR}/.${component_name}-${component_version}.patched" -} - # This function saves the specified to local storage if possible, # and if so, symlinks it for later usage # Usage: CT_SaveLocal @@ -864,425 +825,11 @@ CT_GetFile() { done done - # Just return error, someone may want to catch and handle the error - # (eg. glibc add-ons can be missing). + # Just return error: CT_DoFetch will check it and will handle it appropriately. return 1 } -# Checkout from CVS, and build the associated tarball -# The tarball will be called ${basename}.tar.bz2 -# Prerequisite: either the server does not require password, -# or the user must already be logged in. -# 'tag' is the tag to retrieve. Must be specified, but can be empty. -# are passed as a single argument, space-separated. -# Usage: CT_GetCVS -CT_GetCVS() { - local basename="${1}" - local uri="${2%% *}" - local module="${2##* }" - local tag="${3}" - local date="${4}" - local tmp_dir version - - # If date is not give, use current. Otherwise, check if format is correct. - # We don't support fancy CVS specifications like "1 day ago", as we'll need - # to convert them to some stable representation like 20170617231304. - if [ -z "${date}" ]; then - date=`LANG=C TZ=UTC date '+%Y/%m/%d %H:%M:%S'` - else - case "${date}" in - [12][0-9][0-9][0-9]/[01][0-9]/[0-3][0-9]\ [0-2][0-9]:[0-5][0-9]:[0-5][0-9]) - ;; - *) - CT_Abort "${basename}: invalid date format ${date}" - ;; - esac - fi - version="${tag:-trunk}-${date//[^0-9]/}" - - # First try locally, then the mirror - if CT_GetFile "${basename}-${version}" .tar.bz2; then - # Got it! Return early! :-) - return 0 - fi - - CT_DoLog EXTRA "Retrieving '${basename}-${version}' (cvs)" - if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then - CT_DoLog WARN "Downloads forbidden, not trying cvs retrieval" - return 1 - fi - - CT_MktempDir tmp_dir - CT_Pushd "${tmp_dir}" - - CT_DoExecLog ALL cvs -z 9 -d "${uri}" co -P ${tag:+-r ${tag}} -D "${date} UTC" "${module}" - CT_DoExecLog ALL mv "${module}" "${basename}-${version}" - CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${basename}-${version}.tar.bz2" \ - "${basename}-${version}" - CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}-${version}.tar.bz2" - - CT_Popd - CT_DoExecLog ALL rm -rf "${tmp_dir}" -} - -# Check out from SVN, and build the associated tarball -# The tarball will be called ${basename}.tar.bz2 -# Prerequisite: either the server does not require password, -# or the user must already be logged in. -# 'rev' is the revision to retrieve -# Usage: CT_GetSVN [rev] -CT_GetSVN() { - local basename="${1}" - local uri="${2}" - local branch="${3:-/trunk}" - local rev="${4}" - local version - - # If revision is not given, find the most recent - if [ -z "${rev}" ]; then - # '--show-item revision' only exists in SVN 1.9+ - rev=`svn info "${uri}" | sed -n 's/^Revision: //p'` - fi - - # Construct version from branch/revision - version="${branch//\//_}" - version="${version#_}" - version="${version%_}" - version="${version}-${rev}" - - # First try locally, then the mirror - if CT_GetFile "${basename}-${version}" .tar.bz2; then - # Got it! Return early! :-) - return 0 - fi - - if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then - CT_DoLog WARN "Downloads forbidden, not trying svn retrieval" - return 1 - fi - - CT_DoLog EXTRA "Retrieving '${basename}-${version}' (svn)" - CT_MktempDir tmp_dir - CT_Pushd "${tmp_dir}" - - if ! CT_DoExecLog ALL svn export ${rev:+-r ${rev}} "${uri}${branch}" \ - "${basename}-${version}"; then - CT_DoLog WARN "Could not retrieve '${basename}-${version}'" - return 1 - fi - CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${basename}-${version}.tar.bz2" \ - "${basename}-${version}" - CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}-${version}.tar.bz2" - - CT_Popd - CT_DoExecLog ALL rm -rf "${tmp_dir}" -} - -# Check out from Mercurial (Hg) -# Usage: CT_GetHg -CT_GetHg() -{ - local basename="${1}" - local uri="${2}" - local branch="${3}" - local cset="${4}" - - if [ -n "${branch}" -a -n "${cset}" ]; then - CT_Abort "${basename}: cannot specify both branch and changeset for Mercurial" - fi - - # Mercurial cannot query remote branches except the default, so we'll have - # to clone if cset is not known and a branch is given. - if [ -z "${branch}" ]; then - # Mercurial does not allow querying bran - cset=`hg identify "${uri}"` - else - CT_DoLog WARN "${basename}: Mercurial cannot query non-default branch, will clone" - fi - if [ -n "${cset}" ]; then - if CT_GetFile "${basename}-${cset}" .tar.bz2; then - # Got it - return 0 - fi - fi - - if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then - CT_DoLog WARN "Downloads forbidden, not trying hg retrieval" - return 1 - fi - - CT_MktempDir tmp_dir - CT_Pushd "${tmp_dir}" - CT_DoExecLog ALL hg clone "${uri}" "${basename}" - CT_Pushd "${basename}" - if [ -n "${branch}" ]; then - CT_DoExecLog ALL hg update "${branch}" - fi - if [ -z "${cset}" ]; then - cset=`hg identify -i` - else - CT_DoExecLog ALL hg update "${cset}" - fi - CT_DoLog EXTRA "Retrieving '${basename}-${cset}' (hg)" - CT_DoExecLog ALL rm -rf .hg - CT_Popd - CT_DoExecLog ALL mv "${basename}" "${basename}-${cset}" - CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${basename}-${cset}.tar.bz2" \ - "${basename}-${cset}" - CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}-${cset}.tar.bz2" - - CT_Popd - CT_DoExecLog ALL rm -rf "${tmp_dir}" -} - -# Clone a git tree -# Prerequisites: either the server does not require password, -# or the user has already taken any action to authenticate to the server. -# In this case, 'git ls-remote' is used to get the sha1 and can also -# be used to get a list valid refs (e.g. HEAD, refs/heads/master, refs/tags/v3.3.0) -# Usage: CT_GetGit -CT_GetGit() { - local basename="${1}" - local url="${2}" - local ref="${3}" - local cset="${4}" - - if [ -n "${ref}" -a -n "${cset}" ]; then - CT_Abort "${basename}: cannot specify both branch and changeset for Git" - fi - - ref="${ref:-master}" - if [ -z "${cset}" ]; then - local matches=$(git ls-remote --exit-code "${url}" --refs "${ref}" || echo "not found") - - # Cannot test $?, setting a trap on ERR prevents bash from returning the - # status code. - if [ "${matches}" = "not found" ]; then - CT_Abort "Failed to find git ref ${ref} at ${url}" - fi - if [ $(echo "${matches}" | wc -l) -gt 1 ]; then - CT_DoLog WARN "Ambiguous ref ${ref} at ${url}, using first" - fi - cset=$(echo "$matches" | head -n1 | cut -c1-8) - CT_DoLog DEBUG "ref ${ref} at ${url} has cset of ${cset}" - else - CT_DoLog DEBUG "cset ${cset}" - fi - - local dir="${CT_TARBALLS_DIR}/${basename}-${cset}.git" - local file="${basename}-${cset}.tar.gz" - local dest="${CT_TARBALLS_DIR}/${file}" - local tmp="${CT_TARBALLS_DIR}/${file}.tmp-dl" - - if CT_GetFile "${basename}-${cset}" .tar.gz; then - return 0 - fi - - if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then - CT_DoLog WARN "Downloads forbidden, not trying git retrieval" - return 1 - fi - - CT_DoLog EXTRA "Retrieving '${basename}-${cset}' (git)" - - # Remove potential left-over from a previous run - CT_DoExecLog ALL rm -rf "${tmp}.tar.gz" "${tmp}.tar" "${tmp}" "${dir}" - - if CT_DoExecLog ALL git clone "${url}" "${dir}"; then - # Yep, cloned OK - CT_Pushd "${dir}" - CT_DoExecLog ALL git archive --format=tar \ - --prefix="${basename}-${cset}/" \ - -o "${tmp}.tar" \ - "${cset}" - CT_DoExecLog ALL gzip -9 "${tmp}.tar" - CT_DoExecLog ALL mv -f "${tmp}.tar.gz" "${dest}" - CT_SaveLocal "${dest}" - CT_DoExecLog ALL rm -rf "${tmp}.tar.gz" "${tmp}.tar" "${tmp}" "${dir}" - CT_Popd - return 0 - else - # Woops... - CT_DoExecLog ALL rm -rf "${dir}" - CT_DoLog DEBUG "Could not clone '${basename}'" - return 1 - fi -} - -# Extract a tarball -# Some tarballs need to be extracted in specific places. Eg.: glibc addons -# must be extracted in the glibc directory; uCLibc locales must be extracted -# in the extra/locale sub-directory of uClibc. This is taken into account -# by the caller, that did a 'cd' into the correct path before calling us -# and sets nochdir to 'nochdir'. -# Note also that this function handles the git trees! -# Usage: CT_Extract [nochdir] [options] -# where 'options' are dependent on the source (eg. git branch/tag...) -CT_Extract() { - local nochdir="$1" - local basename - local ext - local -a tar_opts - - if [ "${nochdir}" = "nochdir" ]; then - shift - nochdir="$(pwd)" - else - nochdir="${CT_SRC_DIR}" - fi - - basename="$1" - shift - - # Check if already extracted - if [ -e "${CT_SRC_DIR}/.${basename}.extracted" ]; then - CT_DoLog DEBUG "Already extracted '${basename}'" - return 0 - fi - - if ! ext="$(CT_GetFileExtension "${basename}")"; then - CT_DoLog WARN "'${basename}' not found in '${CT_TARBALLS_DIR}'" - return 1 - fi - local full_file="${CT_TARBALLS_DIR}/${basename}${ext}" - - # Check if previously partially extracted - if [ -e "${CT_SRC_DIR}/.${basename}.extracting" ]; then - CT_DoLog ERROR "The '${basename}' sources were partially extracted." - CT_DoLog ERROR "Please remove first:" - CT_DoLog ERROR " - the source dir for '${basename}', in '${CT_SRC_DIR}'" - CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${basename}.extracting'" - CT_Abort "I'll stop now to avoid any carnage..." - fi - CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.${basename}.extracting" - - CT_Pushd "${nochdir}" - - CT_DoLog EXTRA "Extracting '${basename}'" - CT_DoExecLog FILE mkdir -p "${basename}" - tar_opts=( "--strip-components=1" ) - tar_opts+=( "-C" "${basename}" ) - tar_opts+=( "-xv" ) - - case "${ext}" in - .tar.xz) xz -fdc "${full_file}" | CT_DoExecLog FILE tar "${tar_opts[@]}" -f -;; - .tar.lzma) xz -fdc "${full_file}" | CT_DoExecLog FILE tar "${tar_opts[@]}" -f -;; - .tar.bz2) bzip2 -dc "${full_file}" | CT_DoExecLog FILE tar "${tar_opts[@]}" -f -;; - .tar.gz|.tgz) gzip -dc "${full_file}" | CT_DoExecLog FILE tar "${tar_opts[@]}" -f -;; - .tar) CT_DoExecLog FILE tar "${tar_opts[@]}" -f "${full_file}";; - .zip) CT_DoExecLog FILE unzip "${@}" "${full_file}";; - *) CT_DoLog WARN "Don't know how to handle '${basename}${ext}': unknown extension" - return 1 - ;; - esac - - # Don't mark as being extracted for git - case "${ext}" in - /.git) ;; - *) CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.${basename}.extracted";; - esac - CT_DoExecLog DEBUG rm -f "${CT_SRC_DIR}/.${basename}.extracting" - - CT_Popd -} - -# Patches the specified component -# See CT_Extract, above, for explanations on 'nochdir' -# Usage: CT_Patch [nochdir] -# If the package directory is *not* packagename-packageversion, then -# the caller must cd into the proper directory first, and call us -# with nochdir -CT_Patch() { - local nochdir="$1" - local pkgname - local version - local pkgdir - local base_file - local ver_file - local d - local -a patch_dirs - local bundled_patch_dir - local local_patch_dir - local bundled_exp_patch_dir - local local_exp_patch_dir - - if [ "${nochdir}" = "nochdir" ]; then - shift - pkgname="$1" - version="$2" - pkgdir="${pkgname}-${version}" - nochdir="$(pwd)" - else - pkgname="$1" - version="$2" - pkgdir="${pkgname}-${version}" - nochdir="${CT_SRC_DIR}/${pkgdir}" - fi - - # Check if already patched - if [ -e "${CT_SRC_DIR}/.${pkgdir}.patched" ]; then - CT_DoLog DEBUG "Already patched '${pkgdir}'" - return 0 - fi - - # Check if already partially patched - if [ -e "${CT_SRC_DIR}/.${pkgdir}.patching" ]; then - CT_DoLog ERROR "The '${pkgdir}' sources were partially patched." - CT_DoLog ERROR "Please remove first:" - CT_DoLog ERROR " - the source dir for '${pkgdir}', in '${CT_SRC_DIR}'" - CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${pkgdir}.extracted'" - CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${pkgdir}.patching'" - CT_Abort "I'll stop now to avoid any carnage..." - fi - touch "${CT_SRC_DIR}/.${pkgdir}.patching" - - CT_Pushd "${nochdir}" - - CT_DoLog EXTRA "Patching '${pkgdir}'" - - bundled_patch_dir="${CT_LIB_DIR}/packages/${pkgname}/${version}" - local_patch_dir="${CT_LOCAL_PATCH_DIR}/${pkgname}/${version}" - - case "${CT_PATCH_ORDER}" in - bundled) patch_dirs=("${bundled_patch_dir}");; - local) patch_dirs=("${local_patch_dir}");; - bundled,local) patch_dirs=("${bundled_patch_dir}" "${local_patch_dir}");; - local,bundled) patch_dirs=("${local_patch_dir}" "${bundled_patch_dir}");; - none) patch_dirs=;; - esac - - for d in "${patch_dirs[@]}"; do - CT_DoLog DEBUG "Looking for patches in '${d}'..." - if [ -n "${d}" -a -d "${d}" ]; then - for p in "${d}"/*.patch; do - if [ -f "${p}" ]; then - CT_DoExecLog ALL ${patch} --no-backup-if-mismatch -g0 -F1 -p1 -f -i "${p}" - fi - done - if [ "${CT_PATCH_SINGLE}" = "y" ]; then - break - fi - fi - done - - if [ "${CT_OVERRIDE_CONFIG_GUESS_SUB}" = "y" ]; then - CT_DoLog ALL "Overiding config.guess and config.sub" - for cfg in config_guess config_sub; do - eval ${cfg}="${CT_LIB_DIR}/scripts/${cfg/_/.}" - [ -e "${CT_TOP_DIR}/scripts/${cfg/_/.}" ] && eval ${cfg}="${CT_TOP_DIR}/scripts/${cfg/_/.}" - # Can't use CT_DoExecLog because of the '{} \;' to be passed un-mangled to find - find . -type f -name "${cfg/_/.}" \ - -exec chmod -v u+w {} \; \ - -exec cp -v "${!cfg}" {} \; |CT_DoLog ALL - done - fi - - CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.${pkgdir}.patched" - CT_DoExecLog DEBUG rm -f "${CT_SRC_DIR}/.${pkgdir}.patching" - - CT_Popd -} - +# TBD these should not be needed if config.sub/guess is a package # Two wrappers to call config.(guess|sub) either from CT_TOP_DIR or CT_LIB_DIR. # Those from CT_TOP_DIR, if they exist, will be be more recent than those from CT_LIB_DIR. CT_DoConfigGuess() { @@ -1935,6 +1482,7 @@ CT_Mirrors() echo "https://releases.linaro.org/archive/${yymm}/components/toolchain/${project}-linaro" ;; kernel.org) + # TBD move to linux.sh? if [ "${project}" != "linux" ]; then CT_Abort "Unsupported project" fi @@ -1966,6 +1514,145 @@ CT_Mirrors() esac } +# Get most recent version for CVS check-out. +# CVS does not have a repository-wide identifier for a commit, so we must +# use date. Variables are set by CT_PackageRun +CT_GetVersion_cvs() +{ + # If date is not given, use current. Otherwise, check if format is correct. + # We don't support fancy CVS specifications like "1 day ago", as we'll need + # to convert them to some stable representation like 20170617231304. + if [ -z "${devel_revision}" ]; then + devel_revision=`LANG=C TZ=UTC date '+%Y/%m/%d %H:%M:%S'` + else + case "${devel_revision}" in + [12][0-9][0-9][0-9]/[01][0-9]/[0-3][0-9]\ [0-2][0-9]:[0-5][0-9]:[0-5][0-9]) + ;; + *) + CT_Abort "${pkg_name}: invalid date format ${devel_revision}" + ;; + esac + fi + basename="${pkg_name}-${devel_branch:-trunk}-${devel_revision//[^0-9]/}" +} + +# Check out sources from CVS. Variables are set by CT_PackageRun. +CT_Download_cvs() +{ + local pserver="${devel_url%% *}" + local module="${devel_url##* }" + + # CVS has no name for "main" branch, so use -r only if non-default + # TBD try -'d ${basename}', with/without -N + CT_DoExecLog ALL cvs -z 9 -d "${pserver}" co -P ${devel_branch:+-r ${devel_branch}} \ + -D "${devel_revision} UTC" "${module}" + CT_DoExecLog ALL mv "${module}" "${basename}" +} + +# Find the most recent version from Subversion. +CT_GetVersion_svn() +{ + local version + + devel_branch="${devel_branch:-/trunk}" + + # If revision is not given, find the most recent + if [ -z "${devel_revision}" ]; then + devel_revision=`svn info "${devel_url}${devel_branch}" | sed -n 's/^Last Changed Rev: //p'` + fi + + # Construct version from branch/revision + version="${devel_branch//\//_}" + version="${version#_}" + version="${version%_}" + version="${version}-${devel_revision}" + basename="${pkg_name}-${version}" +} + +# Retrieve sources from Subversion. +CT_Download_svn() +{ + CT_DoExecLog ALL svn export -r "${devel_revision}" "${devel_url}${devel_branch}" "${basename}" +} + +# Find the most recent version from Mercurial. +CT_GetVersion_hg() +{ + if [ -n "${devel_branch}" -a -n "${devel_revision}" ]; then + CT_Abort "${pkg_name}: cannot specify both branch and changeset for Mercurial" + fi + + # Mercurial cannot query remote branches except the default, so we'll have + # to clone if cset is not known and a branch is given. + if [ -z "${devel_revision}" ]; then + if [ -z "${devel_branch}" ]; then + # Mercurial does not allow querying branches + devel_revision=`hg identify "${devel_url}"` + else + CT_DoLog WARN "${pkg_name}: Mercurial cannot query non-default branch, will clone" + devel_revision="TBD" + fi + fi + basename="${pkg_name}-${devel_revision}" +} + +# Retrieve sources from Mercurial. +CT_Download_hg() +{ + CT_DoExecLog ALL hg clone "${devel_url}" "${pkg_name}" + CT_Pushd "${pkg_name}" + if [ -n "${devel_branch}" ]; then + CT_DoExecLog ALL hg update "${devel_branch}" + fi + if [ "${devel_revision}" = "TBD" ]; then + # Report what we found out (as common message lacks the revision) + devel_revision=`hg identify -i` + basename="${pkg_name}-${devel_revision}" + CT_DoLog EXTRA "Retrieved revision ${devel_revision}" + else + CT_DoExecLog ALL hg update "${devel_revision}" + fi + CT_DoExecLog ALL rm -rf .hg + CT_Popd + CT_DoExecLog ALL mv "${pkg_name}" "${basename}" +} + +# Get the most recent version from Git. +CT_GetVersion_git() +{ + if [ -n "${devel_branch}" -a -n "${devel_revision}" ]; then + CT_Abort "${pkg_name}: cannot specify both branch and changeset for Git" + fi + + devel_branch="${devel_branch:-master}" + if [ -z "${devel_revision}" ]; then + local matches=`git ls-remote --exit-code "${devel_url}" --refs "${devel_branch}" \ + || echo "not found"` + + # Cannot test $?, setting a trap on ERR prevents bash from returning the + # status code. + if [ "${matches}" = "not found" ]; then + CT_Abort "Failed to find git ref ${devel_branch} at ${devel_url}" + fi + if [ `echo "${matches}" | wc -l` -gt 1 ]; then + CT_DoLog WARN "Ambiguous ref ${devel_branch} at ${devel_url}, using first" + fi + devel_revision=`echo "$matches" | head -n1 | cut -c1-8` + CT_DoLog DEBUG "ref ${devel_branch} at ${devel_url} has cset of ${devel_revision}" + fi + basename="${pkg_name}-${devel_revision}" +} + +# Retrieve sources from Git. +CT_Download_git() +{ + CT_DoExecLog ALL git clone "${devel_url}" "${basename}" + CT_Pushd "${basename}" + CT_DoExecLog ALL git checkout "${devel_revision}" -- + CT_DoExecLog ALL rm -rf .git + CT_Popd +} + # Helper: run another action after setting local variables CT_PackageRun() { @@ -1977,40 +1664,82 @@ CT_PackageRun() shift 2 # Variables that are per-project - for v in USE DIR_NAME; do - eval "local CT_${v}=\${CT_${sym}_${v}}" + for v in use dir_name; do + eval "local ${v}=\${CT_${sym}_${v^^}}" done - # If CT_USE is not set, we only have one fork to handle - CT_USE="${CT_USE:-${sym}}" + # If $use is not set, we only have one fork to handle + use="${use:-${sym}}" # Variables that are per-fork - for v in PKG_NAME VERSION SRC_RELEASE MIRRORS SRC_DEVEL SRC_CUSTOM \ - DEVEL_VCS DEVEL_URL DEVEL_BRANCH DEVEL_REVISION CUSTOM_LOCATION; do - eval "local CT_${v}=\${CT_${CT_USE}_${v}}" + for v in basename pkg_name version src_release mirrors src_devel src_custom \ + devel_vcs devel_url devel_branch devel_revision custom_location; do + eval "local ${v}=\${CT_${use}_${v^^}}" done ${run} "$@" + + # Save certain variables that may be modified by the callback. + # Fetching the sources is run in the main process, so no need to + # use CT_EnvModify. + for v in devel_branch devel_revision basename; do + eval "CT_${use}_${v^^}=\${${v}}" + done } # Closure for fetching the sources CT_DoFetch() { - if [ "${CT_SRC_RELEASE}" = "y" ]; then - CT_GetFile "${CT_PKG_NAME}-${CT_VERSION}" ${CT_MIRRORS} - elif [ "${CT_SRC_DEVEL}" = "y" ]; then - local -A fetchfn=( [git]=CT_GetGit [svn]=CT_GetSVN [hg]=CT_GetHg [cvs]=CT_GetCVS ) + local tmp_dir - if [ -z "${CT_DEVEL_REVISION}" -a "${CT_FORBID_DOWNLOAD}" = "y" ]; then - CT_Abort "${CT_PKG_NAME}: cannot find most recent revisions with downloads prohibited" + if [ "${src_release}" = "y" ]; then + basename="${pkg_name}-${version}" + if ! CT_GetFile "${basename}" ${CT_MIRRORS}; then + CT_Abort "${pkg_name}: download failed" fi - if [ -n "${fetchfn[${CT_DEVEL_VCS}]}" ]; then - ${fetchfn[${CT_DEVEL_VCS}]} "${CT_PKG_NAME}" "${CT_DEVEL_URL}" \ - "${CT_DEVEL_BRANCH}" "${CT_DEVEL_REVISION}" - else - CT_Abort "${CT_PKG_NAME}: Unsupported VCS: ${CT_DEVEL_VCS}" + + elif [ "${src_devel}" = "y" ]; then + + if [ -z "${devel_revision}" -a "${CT_FORBID_DOWNLOAD}" = "y" ]; then + CT_Abort "${pkg_name}: cannot find most recent revisions with downloads prohibited" + fi + + # Each VCS backend must provide two methods: + # - CT_GetVersion_xxx that sets the base name for the package (package name + # and some unique identifier for the version) + # - CT_Download_xxx that retrieves the sources into the directory named as + # ${basename} + # Both these methods can also modify devel_branch/devel_revision. Typically, + # this would override empty (default) values with "default branch name" and + # "most current revision", respectively. + + CT_GetVersion_${devel_vcs} + if [ -z "${basename}" ]; then + CT_Abort "${pkg_name}: ${devel_vcs} did not set base name" + fi + + # Try getting the tarball with empty list of URLs: it will only + # attempt getting it from local storage or from the mirror if configured. + # TBD extra "Retrieving" message from CT_GetFile + if CT_GetFile "${basename}" .tar.bz2; then + return 0 + fi + + CT_DoLog EXTRA "Retrieving '${basename}' (${devel_vcs} ${devel_url} ${devel_branch} ${devel_revision})" + if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then + CT_DoLog WARN "Downloads forbidden, not trying ${devel_vcs} retrieval" + return 1 fi - elif [ "${CT_SRC_CUSTOM}" = "y" ]; then + + CT_MktempDir tmp_dir + CT_Pushd "${tmp_dir}" + CT_Download_${devel_vcs} + CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${basename}.tar.bz2" "${basename}" + CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}.tar.bz2" + CT_Popd + CT_DoExecLog ALL rm -rf "${tmp_dir}" + + elif [ "${src_custom}" = "y" ]; then # Will be handled during extraction/patching :; else @@ -2024,3 +1753,175 @@ CT_Fetch() { CT_PackageRun "${1}" CT_DoFetch } + +# Unpack an archive. +CT_Extract() +{ + local file="${1}" + local dir="${2}" + local components="${3}" + + CT_DoExecLog ALL mkdir -p "${dir}" + case "${file}" in + *.tar.xz) + xz -fdc "${file}" | CT_DoExecLog FILE tar x -f - -C "${dir}" ${components} + ;; + *.tar.lzma) + xz -fdc "${file}" | CT_DoExecLog FILE tar x -f - -C "${dir}" ${components} + ;; + *.tar.bz2) + bzip2 -dc "${file}" | CT_DoExecLog FILE tar x -f - -C "${dir}" ${components} + ;; + *.tar.gz|*.tgz) + gzip -dc "${file}" | CT_DoExecLog FILE tar x -f - -C "${dir}" ${components} + ;; + *.tar) + CT_DoExecLog FILE tar x -f "${file}" -C "${dir}" ${components} + ;; + *.zip) + CT_Pushd "${dir}" + CT_DoExecLog FILE unzip "${file}" ${components} + CT_Popd + ;; + *) + CT_Abort "Don't know how to handle ${file}: unknown extension" + ;; + esac +} + +# Closure for unpacking/patching the sources. There are two source directories: +# - CT_COMMON_SRC_DIR stores common sources, such as released tarballs (including +# bundled or local patches, if necessary) or checked out working copies. +# Custom sources cannot be placed here, as they may have similarly named +# packages coming from different origins. +# - CT_SRC_DIR stores per-configuration sources. These are either symlinks back +# to CT_ORIG_SRC_DIR sources, or a copy from the custom source, or a copy +# from CT_ORIG_SRC_DIR + target-specific overrides. +CT_DoExtractPatch() +{ + local patchfunc="${1}" + local ext + local -a patch_dirs + local bundled_patch_dir + local local_patch_dir + + CT_DoLog EXTRA "Extracting ${basename}" + if [ "${src_custom}" != "y" ]; then + # Non-custom: extract to shared location + # If the previous extraction/patching was aborted, clean up. + if [ -r "${CT_COMMON_SRC_DIR}/.${basename}.extracting" -o \ + -r "${CT_COMMON_SRC_DIR}/.${basename}.patching" ]; then + CT_DoLog WARN "Sources for ${basename} were partially extracted/patched, cleaning up" + CT_DoExecLog ALL rm -rf "${CT_COMMON_SRC_DIR}/${basename}" + CT_DoExecLog ALL rm -f "${CT_COMMON_SRC_DIR}/.${basename}".* + fi + + if [ -f "${CT_COMMON_SRC_DIR}/.${basename}.extracted" ]; then + CT_DoLog DEBUG "Already extracted ${basename}" + else + CT_DoExecLog ALL touch "${CT_COMMON_SRC_DIR}/.${basename}.extracting" + # TBD save/discover the extension while fetching + ext=`CT_GetFileExtension "${basename}"` + CT_Extract "${CT_TARBALLS_DIR}/${basename}${ext}" "${CT_COMMON_SRC_DIR}" + CT_DoExecLog ALL touch "${CT_COMMON_SRC_DIR}/.${basename}.extracted" + CT_DoExecLog ALL rm -f "${CT_COMMON_SRC_DIR}/.${basename}.extracting" + fi + fi + + # Patch the released tarballs + if [ "${src_release}" = "y" ]; then + if [ -f "${CT_COMMON_SRC_DIR}/.${basename}.patched" ]; then + CT_DoLog DEBUG "Already patched ${basename}" + else + CT_DoLog EXTRA "Patching ${basename}" + CT_DoExecLog ALL touch "${CT_COMMON_SRC_DIR}/.${basename}.patching" + + bundled_patch_dir="${CT_LIB_DIR}/packages/${pkg_name}/${version}" + local_patch_dir="${CT_LOCAL_PATCH_DIR}/${pkg_name}/${version}" + + case "${CT_PATCH_ORDER}" in + bundled) patch_dirs=("${bundled_patch_dir}");; + local) patch_dirs=("${local_patch_dir}");; + bundled,local) patch_dirs=("${bundled_patch_dir}" "${local_patch_dir}");; + local,bundled) patch_dirs=("${local_patch_dir}" "${bundled_patch_dir}");; + none) patch_dirs=;; + esac + + CT_Pushd "${CT_COMMON_SRC_DIR}/${basename}" + for d in "${patch_dirs[@]}"; do + CT_DoLog DEBUG "Looking for patches in '${d}'..." + if [ -n "${d}" -a -d "${d}" ]; then + for p in "${d}"/*.patch; do + if [ -f "${p}" ]; then + CT_DoExecLog ALL ${patch} --no-backup-if-mismatch -g0 -F1 -p1 -f -i "${p}" + fi + done + fi + done + + if [ "${CT_OVERRIDE_CONFIG_GUESS_SUB}" = "y" ]; then + CT_DoLog ALL "Overiding config.guess and config.sub" + for cfg in config.guess config.sub; do + # Can't use CT_DoExecLog because of the '{} \;' to be passed un-mangled to find + find . -type f -name "${cfg}" \ + -exec chmod -v u+w {} \; \ + -exec cp -v "${CT_TOP_DIR}/scripts/${cfg}" {} \; |CT_DoLog ALL + done + fi + + if [ -n "${patchfunc}" ]; then + ${patchfunc} + fi + + CT_Popd + + CT_DoExecLog ALL touch "${CT_COMMON_SRC_DIR}/.${basename}.patched" + CT_DoExecLog ALL rm -f "${CT_COMMON_SRC_DIR}/.${basename}.patching" + fi + else + CT_DoLog WARN "${pkg_name}: not using a released version, no patches applied" + fi + + # Symlink/copy/overlay into per-target source directory + if [ "${src_custom}" = "y" ]; then + # Custom sources: unpack or copy into per-target directory + if [ "${CT_TARGET_USE_OVERLAY}" ]; then + CT_DoLog WARN "${pkg_name}: using custom location, no overlays applied" + fi + if [ -d "${custom_location}" ]; then + CT_DoExecLog ALL cp -av "${custom_location}" "${CT_SRC_DIR}/${pkg_name}" + elif [ -f "${custom_location}" ]; then + # Assume "foo.tar.gz" (or likes) contain the "foo" directory + local bn + + CT_Extract "${custom_location}" "${CT_SRC_DIR}" + bn=`CT_GetFileBasename "${custom_location##*/}"` + CT_TestOrAbort "Unknown file extension: ${custom_location}" -n "${bn}" + CT_DoExecLog ALL mv -v "${CT_SRC_DIR}/${bn%${ext}}" "${CT_SRC_DIR}/${pkg_name}" + else + CT_Abort "Neither file nor directory: ${custom_location}" + fi + elif [ "${CT_TARGET_USE_OVERLAY}" = "y" ]; then + # Possibly has overlays; copy from common source and apply overlays if any + local overlay + + CT_DoExecLog ALL cp -av "${CT_COMMON_SRC_DIR}/${basename}" "${CT_SRC_DIR}/${pkg_name}" + overlay="${CT_OVERLAY_LOCATION}/${CT_ARCH}-${CT_OVERLAY_NAME:-overlay}" + ext=`CT_GetFileExtension "${overlay}"` + CT_Extract "${overlay}${ext}" "${CT_SRC_DIR}" "${pkg_name}" + else + # Common source, just symlink + CT_DoExecLog ALL ln -s "${CT_COMMON_SRC_DIR}/${basename}" "${CT_SRC_DIR}/${pkg_name}" + fi +} + +# Extract/copy the sources to the shared source directory, then either symlink +# or copy the sources into a private source directory and apply target-specific +# changes (such as xtensa overrides). +CT_ExtractPatch() +{ + local pkg="${1}" + + shift + CT_PackageRun "${pkg}" CT_DoExtractPatch "$@" +} -- cgit v1.2.3 From c9b31439db79b325a96b39c3a19a6b9aed347979 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Thu, 6 Jul 2017 23:10:40 -0700 Subject: Some locations were missed while renaming kconfig symbols ... because there the symbols were constructer part by part. Also, remove cc.sh and source $(CT_CC).sh directly - we only build a single compiler at a time. Signed-off-by: Alexey Neyman --- scripts/build/cc.sh | 58 ---------------------------------------- scripts/build/cc/gcc.sh | 13 +++++---- scripts/build/companion_tools.sh | 2 +- scripts/build/debug.sh | 2 +- scripts/build/test_suite.sh | 3 +-- scripts/functions | 2 +- 6 files changed, 10 insertions(+), 70 deletions(-) delete mode 100644 scripts/build/cc.sh (limited to 'scripts/build/cc') diff --git a/scripts/build/cc.sh b/scripts/build/cc.sh deleted file mode 100644 index 0db6b9ce..00000000 --- a/scripts/build/cc.sh +++ /dev/null @@ -1,58 +0,0 @@ -# Wrapper to build the companion tools facilities - -# List all companion tools facilities, and parse their scripts -CT_CC_FACILITY_LIST= -for f in "${CT_LIB_DIR}/scripts/build/cc/"*.sh; do - _f="$(basename "${f}" .sh)" - _f="${_f#???-}" - __f="CT_CC_${_f}" - if [ "${!__f}" = "y" ]; then - CT_DoLog DEBUG "Enabling cc '${_f}'" - . "${f}" - CT_CC_FACILITY_LIST="${CT_CC_FACILITY_LIST} ${_f}" - else - CT_DoLog DEBUG "Disabling cc '${_f}'" - fi -done - -# Download the cc facilities -do_cc_get() { - for f in ${CT_CC_FACILITY_LIST}; do - do_${f}_get - done -} - -# Extract and patch the cc facilities -do_cc_extract() { - for f in ${CT_CC_FACILITY_LIST}; do - do_${f}_extract - done -} - -# Core pass 1 the cc facilities -do_cc_core_pass_1() { - for f in ${CT_CC_FACILITY_LIST}; do - do_${f}_core_pass_1 - done -} - -# Core pass 2 the cc facilities -do_cc_core_pass_2() { - for f in ${CT_CC_FACILITY_LIST}; do - do_${f}_core_pass_2 - done -} - -# Build for build the cc facilities -do_cc_for_build() { - for f in ${CT_CC_FACILITY_LIST}; do - do_${f}_for_build - done -} - -# Build for host the cc facilities -do_cc_for_host() { - for f in ${CT_CC_FACILITY_LIST}; do - do_${f}_for_host - done -} diff --git a/scripts/build/cc/gcc.sh b/scripts/build/cc/gcc.sh index e836c826..2f0d3f79 100644 --- a/scripts/build/cc/gcc.sh +++ b/scripts/build/cc/gcc.sh @@ -3,7 +3,7 @@ # Licensed under the GPL v2. See COPYING in the root of this package # Download gcc -do_gcc_get() { +do_cc_get() { local linaro_version="" local linaro_series="" @@ -22,8 +22,7 @@ do_gcc_get() { } # Extract gcc -do_gcc_extract() { - # TBD handle xtensa overlays +do_cc_extract() { CT_ExtractPatch GCC # Copy ecj-latest.jar to ecj.jar at the top of the GCC source tree @@ -184,7 +183,7 @@ cc_gcc_multilib_housekeeping() { #------------------------------------------------------------------------------ # Core gcc pass 1 -do_gcc_core_pass_1() { +do_cc_core_pass_1() { local -a core_opts if [ "${CT_CC_CORE_PASS_1_NEEDED}" != "y" ]; then @@ -210,7 +209,7 @@ do_gcc_core_pass_1() { } # Core gcc pass 2 -do_gcc_core_pass_2() { +do_cc_core_pass_2() { local -a core_opts if [ "${CT_CC_CORE_PASS_2_NEEDED}" != "y" ]; then @@ -690,7 +689,7 @@ do_gcc_core_backend() { #------------------------------------------------------------------------------ # Build complete gcc to run on build -do_gcc_for_build() { +do_cc_for_build() { local -a build_final_opts local build_final_backend @@ -775,7 +774,7 @@ gcc_movelibs() { #------------------------------------------------------------------------------ # Build final gcc to run on host -do_gcc_for_host() { +do_cc_for_host() { local -a final_opts local final_backend diff --git a/scripts/build/companion_tools.sh b/scripts/build/companion_tools.sh index b190ed7d..7776f64a 100644 --- a/scripts/build/companion_tools.sh +++ b/scripts/build/companion_tools.sh @@ -5,7 +5,7 @@ CT_COMP_TOOLS_FACILITY_LIST= for f in "${CT_LIB_DIR}/scripts/build/companion_tools/"*.sh; do _f="$(basename "${f}" .sh)" _f="${_f#???-}" - __f="CT_COMP_TOOLS_${_f}" + __f="CT_COMP_TOOLS_${_f^^}" if [ "${!__f}" = "y" ]; then CT_DoLog DEBUG "Enabling companion tool '${_f}'" . "${f}" diff --git a/scripts/build/debug.sh b/scripts/build/debug.sh index f07b295c..f8178ddf 100644 --- a/scripts/build/debug.sh +++ b/scripts/build/debug.sh @@ -5,7 +5,7 @@ CT_DEBUG_FACILITY_LIST= for f in "${CT_LIB_DIR}/scripts/build/debug/"*.sh; do _f="$(basename "${f}" .sh)" _f="${_f#???-}" - __f="CT_DEBUG_${_f}" + __f="CT_DEBUG_${_f^^}" if [ "${!__f}" = "y" ]; then CT_DoLog DEBUG "Enabling debug '${_f}'" . "${f}" diff --git a/scripts/build/test_suite.sh b/scripts/build/test_suite.sh index 8fabf42f..e963a994 100644 --- a/scripts/build/test_suite.sh +++ b/scripts/build/test_suite.sh @@ -7,8 +7,7 @@ CT_TEST_SUITE_FACILITY_LIST= for f in "${CT_LIB_DIR}/scripts/build/test_suite/"*.sh; do _f="$(basename "${f}" .sh)" - __f="CT_TEST_SUITE_${_f}" - __f=`echo ${__f} | tr "[:lower:]" "[:upper:]"` + __f="CT_TEST_SUITE_${_f^^}" if [ "${!__f}" = "y" ]; then CT_DoLog DEBUG "Enabling test suite '${_f}'" . "${f}" diff --git a/scripts/functions b/scripts/functions index 7ec6e83d..1a8db3b0 100644 --- a/scripts/functions +++ b/scripts/functions @@ -23,7 +23,7 @@ CT_LoadConfig() { . "${CT_LIB_DIR}/scripts/build/companion_libs.sh" . "${CT_LIB_DIR}/scripts/build/binutils/${CT_BINUTILS}.sh" . "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh" - . "${CT_LIB_DIR}/scripts/build/cc.sh" + . "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh" . "${CT_LIB_DIR}/scripts/build/debug.sh" . "${CT_LIB_DIR}/scripts/build/test_suite.sh" -- cgit v1.2.3 From fd522eed500576a6e62431724314858e120679c6 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sun, 9 Jul 2017 23:08:12 -0700 Subject: Resolve a few more TBDs Signed-off-by: Alexey Neyman --- bootstrap | 2 -- packages/binutils/package.desc | 2 +- packages/gcc/package.desc | 2 +- packages/gdb/package.desc | 2 +- packages/glibc-ports/package.desc | 2 +- packages/glibc/package.desc | 2 +- scripts/build/cc/gcc.sh | 9 +++++---- scripts/build/debug/200-duma.sh | 1 - scripts/functions | 7 +++---- 9 files changed, 13 insertions(+), 16 deletions(-) (limited to 'scripts/build/cc') diff --git a/bootstrap b/bootstrap index e32feaa1..f5784cd5 100755 --- a/bootstrap +++ b/bootstrap @@ -605,8 +605,6 @@ enter_choice() local choice="${1}" local l - # TBD generate sourcing of versions/$component.in automatically - and add a comment - # TBD that versions must be generated first? [what to do with glibc/glibc-ports] info[choice]="${choice}" info[kcfg_choice]=`kconfigize "${choice}"` diff --git a/packages/binutils/package.desc b/packages/binutils/package.desc index ae3d2f15..4591f7c7 100644 --- a/packages/binutils/package.desc +++ b/packages/binutils/package.desc @@ -1,4 +1,4 @@ repository='git git://sourceware.org/git/binutils-gdb.git' -mirrors='$(CT_Mirrors GNU binutils) $(CT_Mirrors sourceware)' +mirrors='$(CT_Mirrors GNU binutils) $(CT_Mirrors sourceware/releases)' origin='GNU' milestones='2.23' diff --git a/packages/gcc/package.desc b/packages/gcc/package.desc index c38ead7e..dc49186e 100644 --- a/packages/gcc/package.desc +++ b/packages/gcc/package.desc @@ -1,4 +1,4 @@ repository='svn svn://gcc.gnu.org/svn/gcc' -mirrors='$(CT_Mirrors GNU gcc/gcc-${CT_GCC_VERSION}) $(CT_Mirrors sourceware gcc gcc-${CT_GCC_VERSION})' +mirrors='$(CT_Mirrors GNU gcc/gcc-${CT_GCC_VERSION}) $(CT_Mirrors sourceware gcc/releases/gcc-${CT_GCC_VERSION})' origin='GNU' milestones='4.8 4.9 4.9.2 5 6 7' diff --git a/packages/gdb/package.desc b/packages/gdb/package.desc index c23c701e..e6120f24 100644 --- a/packages/gdb/package.desc +++ b/packages/gdb/package.desc @@ -1,4 +1,4 @@ origin='GNU' repository='git git://sourceware.org/git/binutils-gdb.git' -mirrors='$(CT_Mirrors GNU gdb) $(CT_Mirrors sourceware gdb)' +mirrors='$(CT_Mirrors GNU gdb) $(CT_Mirrors sourceware gdb/releases)' milestones='7.0 7.2 8.0' diff --git a/packages/glibc-ports/package.desc b/packages/glibc-ports/package.desc index 5df2f20c..4f7e7ac0 100644 --- a/packages/glibc-ports/package.desc +++ b/packages/glibc-ports/package.desc @@ -2,7 +2,7 @@ # the ports were an external add-on, it used a separate repository # and separate tarballs. repository='git git://sourceware.org/git/glibc-ports.git' -mirrors='$(CT_Mirrors GNU glibc) $(CT_Mirrors sourceware glibc)' +mirrors='$(CT_Mirrors GNU glibc) $(CT_Mirrors sourceware glibc/releases)' # Version of this package must be the same as the glibc's versionlocked='glibc' diff --git a/packages/glibc/package.desc b/packages/glibc/package.desc index f6cc8e24..13e2233c 100644 --- a/packages/glibc/package.desc +++ b/packages/glibc/package.desc @@ -1,4 +1,4 @@ origin='GNU' repository='git git://sourceware.org/git/glibc.git' -mirrors='$(CT_Mirrors GNU glibc) $(CT_Mirrors sourceware glibc)' +mirrors='$(CT_Mirrors GNU glibc) $(CT_Mirrors sourceware glibc/releases)' milestones='2.17 2.20 2.23' diff --git a/scripts/build/cc/gcc.sh b/scripts/build/cc/gcc.sh index 2f0d3f79..6019b35a 100644 --- a/scripts/build/cc/gcc.sh +++ b/scripts/build/cc/gcc.sh @@ -14,10 +14,11 @@ do_cc_get() { # GCC source tree, which will not be there unless we get it and # put it there ourselves if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" ]; then - # TBD check return code - CT_GetFile ecj-latest .jar http://mirrors.kernel.org/sourceware/java/ \ - ftp://gcc.gnu.org/pub/java \ - ftp://sourceware.org/pub/java + if ! CT_GetFile ecj-latest .jar $(CT_Mirrors sourceware java); then + # Should be a package, too - but with Java retirement in GCC, + # it may not make sense. + CT_Abort "Failed to download ecj-latest.jar" + fi fi } diff --git a/scripts/build/debug/200-duma.sh b/scripts/build/debug/200-duma.sh index afaeb027..bd350304 100644 --- a/scripts/build/debug/200-duma.sh +++ b/scripts/build/debug/200-duma.sh @@ -1,7 +1,6 @@ # Build script for D.U.M.A. do_debug_duma_get() { - # TBD need cleanup after sourceforge.net download? CT_Fetch DUMA } diff --git a/scripts/functions b/scripts/functions index a7dd5412..79b7321b 100644 --- a/scripts/functions +++ b/scripts/functions @@ -1460,10 +1460,9 @@ CT_Mirrors() echo "ftp://ftp.gnu.org/gnu/${project}" ;; sourceware) - local subdir="${3:+/${3}}" - echo "ftp://sourceware.org/pub/${project}/releases${subdir}" - echo "http://mirrors.kernel.org/sourceware/${project}/releases${subdir}" - echo "http://gcc.gnu.org/pub/${project}/releases${subdir}" + echo "ftp://sourceware.org/pub/${project}" + echo "http://mirrors.kernel.org/sourceware/${project}" + echo "http://gcc.gnu.org/pub/${project}" ;; Linaro) eval "local version=\"\${${3}}\"" -- cgit v1.2.3