# HG changeset patch # User pablaasmo # Date 1343974985 -7200 # Branch crosstool-ng-atmel # Node ID 83eb78ed9d01dc2322f5b6f20730a91850e123f6 # Parent 9bf1030384c048073fd8dbb330ec1135e30451d0 gcc.sh: changed handling of CANADIAN build so that correct compiler is used when building compiler for build. .sh: added functions do_libc_for_build and dor_libc_for_host so that building newlib works in CANADIAN builds. steps.mk: removed step libc, and replaced with libc_for_build and libc_for host diff -r 9bf1030384c0 -r 83eb78ed9d01 scripts/build/cc/gcc.sh --- a/scripts/build/cc/gcc.sh Thu Aug 02 14:36:01 2012 +0200 +++ b/scripts/build/cc/gcc.sh Fri Aug 03 08:23:05 2012 +0200 @@ -420,8 +420,13 @@ # 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 \ + # If we are building the core C compiler it should be on native platform + if [ "${host}" = "${CT_BUILD}" ]; then + repair_cc="CC_FOR_BUILD=${CT_BUILD}-gcc" + else + repair_cc="CC_FOR_BUILD=${CT_BUILD}-gcc \ GCC_FOR_TARGET=${CT_TARGET}-gcc" + fi else repair_cc="" fi @@ -459,8 +464,15 @@ CT_DoExecLog ALL ln -sfv "${CT_TARGET}-gcc${ext}" "${prefix}/bin/${CT_TARGET}-cc${ext}" if [ "${CT_MULTILIB}" = "y" ]; then - multilibs=( $( "${prefix}/bin/${CT_TARGET}-gcc" -print-multi-lib \ - |tail -n +2 ) ) + if [ "${CT_CANADIAN}" = "y" ] && [ "${host}" != "${CT_BUILD}" ]; then + # If we do CANADIAN build and are building the host C compiler + # we should use build platforms executables + multilibs=( $( "${CT_BUILDTOOLS_PREFIX_DIR}/bin/${CT_TARGET}-gcc" -print-multi-lib \ + |tail -n +2 ) ) + else + multilibs=( $( "${prefix}/bin/${CT_TARGET}-gcc" -print-multi-lib \ + |tail -n +2 ) ) + fi if [ ${#multilibs[@]} -ne 0 ]; then CT_DoLog EXTRA "gcc configured with these multilibs (besides the default):" for i in "${multilibs[@]}"; do @@ -540,6 +552,14 @@ final_backend=do_cc_backend fi + # We can not use system zlib from build on host when + # doing a CANADIAN build unless we also build it first + # for the host. + if [ "${CT_CANADIAN}" = "y" ]; then + CT_DoStep INFO "Unsetting CT_CC_GCC_SYSTEM_ZLIB" + unset CT_CC_GCC_SYSTEM_ZLIB + fi + CT_DoStep INFO "Installing final compiler" CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-final" diff -r 9bf1030384c0 -r 83eb78ed9d01 scripts/build/libc/glibc-eglibc.sh-common --- a/scripts/build/libc/glibc-eglibc.sh-common Thu Aug 02 14:36:01 2012 +0200 +++ b/scripts/build/libc/glibc-eglibc.sh-common Fri Aug 03 08:23:05 2012 +0200 @@ -60,6 +60,20 @@ do_libc_backend libc_mode=startfiles } +# Builds a libc for the build platform +do_libc_for_build { + # Not really necessary here but for compatibility + # with the api of other c-lib scripts + : +} + +# Builds a libc for the host platform +do_libc_for_host { + # Not really necessary here but for compatibility + # with the api of other c-lib scripts + do_libc +} + # This function builds and install the full C library do_libc() { do_libc_backend libc_mode=final diff -r 9bf1030384c0 -r 83eb78ed9d01 scripts/build/libc/mingw.sh --- a/scripts/build/libc/mingw.sh Thu Aug 02 14:36:01 2012 +0200 +++ b/scripts/build/libc/mingw.sh Fri Aug 03 08:23:05 2012 +0200 @@ -53,6 +53,20 @@ CT_EndStep } +# Builds a libc for the build platform +do_libc_for_build { + # Not really necessary here but for compatibility + # with the api of other c-lib scripts + : +} + +# Builds a libc for the host platform +do_libc_for_host { + # Not really necessary here but for compatibility + # with the api of other c-lib scripts + do_libc +} + do_libc() { CT_DoStep INFO "Building MinGW files" diff -r 9bf1030384c0 -r 83eb78ed9d01 scripts/build/libc/newlib.sh --- a/scripts/build/libc/newlib.sh Thu Aug 02 14:36:01 2012 +0200 +++ b/scripts/build/libc/newlib.sh Fri Aug 03 08:23:05 2012 +0200 @@ -52,14 +52,57 @@ : } +do_libc_for_build() { + local -a build_final_opts + local build_final_backend + + # In case we're canadian or cross-native, it seems that a + # real, complete compiler is needed?!? WTF? Sigh... + # Otherwise, there is 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}" ) + + CT_DoStep INFO "Installing C library for build" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-build" + + do_libc "${build_final_opts[@]}" + + CT_Popd + CT_EndStep +} + +do_libc_for_host() { + local -a build_final_opts + local build_final_backend + + final_opts+=( "host=${CT_HOST}" ) + final_opts+=( "prefix=${CT_PREFIX_DIR}" ) + + CT_DoStep INFO "Installing C library for host" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-final" + + do_libc "${final_opts[@]}" + + CT_Popd + CT_EndStep +} + do_libc() { local -a newlib_opts + local host + local prefix + local arg + + for arg in "$@"; do + eval "${arg// /\\ }" + done CT_DoStep INFO "Installing C library" - mkdir -p "${CT_BUILD_DIR}/build-libc" - cd "${CT_BUILD_DIR}/build-libc" - CT_DoLog EXTRA "Configuring C library" if [ "${CT_LIBC_NEWLIB_IO_C99FMT}" = "y" ]; then @@ -102,9 +145,9 @@ AR=${CT_TARGET}-ar \ RANLIB=${CT_TARGET}-ranlib \ "${CT_SRC_DIR}/newlib-$(libc_newlib_version)/configure" \ - --host=${CT_BUILD} \ + --host=${host} \ --target=${CT_TARGET} \ - --prefix=${CT_PREFIX_DIR} \ + --prefix=${prefix} \ "${newlib_opts[@]}" \ "${CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY[@]}" diff -r 9bf1030384c0 -r 83eb78ed9d01 scripts/build/libc/none.sh --- a/scripts/build/libc/none.sh Thu Aug 02 14:36:01 2012 +0200 +++ b/scripts/build/libc/none.sh Fri Aug 03 08:23:05 2012 +0200 @@ -18,6 +18,14 @@ : } +do_libc_for_build() { + : +} + +do_libc_for_host() { + : +} + do_libc() { : } diff -r 9bf1030384c0 -r 83eb78ed9d01 scripts/build/libc/uClibc.sh --- a/scripts/build/libc/uClibc.sh Thu Aug 02 14:36:01 2012 +0200 +++ b/scripts/build/libc/uClibc.sh Fri Aug 03 08:23:05 2012 +0200 @@ -154,6 +154,20 @@ CT_EndStep } +# Builds a libc for the build platform +do_libc_for_build { + # Not really necessary here but for compatibility + # with the api of other c-lib scripts + : +} + +# Builds a libc for the host platform +do_libc_for_host { + # Not really necessary here but for compatibility + # with the api of other c-lib scripts + do_libc +} + # This function build and install the full uClibc do_libc() { CT_DoStep INFO "Installing C library" diff -r 9bf1030384c0 -r 83eb78ed9d01 steps.mk --- a/steps.mk Thu Aug 02 14:36:01 2012 +0200 +++ b/steps.mk Fri Aug 03 08:23:05 2012 +0200 @@ -40,8 +40,9 @@ kernel_headers \ libc_start_files \ cc_core_pass_2 \ - libc \ + libc_for_build \ cc_for_build \ + libc_for_host \ cc_for_host \ libc_finish \ libelf_for_target \