diff options
Diffstat (limited to 'scripts/build/cc')
-rw-r--r-- | scripts/build/cc/gcc.sh (renamed from scripts/build/cc/100-gcc.sh) | 96 |
1 files changed, 47 insertions, 49 deletions
diff --git a/scripts/build/cc/100-gcc.sh b/scripts/build/cc/gcc.sh index 2ca8e6f3..54303410 100644 --- a/scripts/build/cc/100-gcc.sh +++ b/scripts/build/cc/gcc.sh @@ -3,53 +3,32 @@ # 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="" - 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 + 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/ \ - http://crosstool-ng.org/pub/java \ - ftp://gcc.gnu.org/pub/java \ - ftp://sourceware.org/pub/java + if ! CT_GetFile ecj 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 } # Extract gcc -do_gcc_extract() { - CT_Extract "gcc-${CT_CC_GCC_VERSION}" - CT_Patch "gcc" "${CT_CC_GCC_VERSION}" +do_cc_extract() { + 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-${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}" + 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 } @@ -205,7 +184,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 @@ -231,7 +210,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 @@ -254,7 +233,11 @@ do_gcc_core_pass_2() { # later, we need to build libgcc case "${CT_THREADS}" in nptl) - core_opts+=( "mode=shared" ) + if [ "${CT_SHARED_LIBS}" = "y" ]; then + core_opts+=( "mode=shared" ) + else + core_opts+=( "mode=static" ) + fi core_opts+=( "build_libgcc=yes" ) ;; win32) @@ -371,14 +354,14 @@ do_gcc_core_backend() { CT_DoExecLog ALL cp -a "${CT_HEADERS_DIR}" "${prefix}/${CT_TARGET}/include" fi - for tmp in ARCH ABI CPU TUNE FPU FLOAT; do + for tmp in ARCH ABI CPU TUNE FPU FLOAT ENDIAN; do eval tmp="\${CT_ARCH_WITH_${tmp}}" if [ -n "${tmp}" ]; then extra_config+=("${tmp}") fi done - extra_config+=("--with-pkgversion=${CT_PKGVERSION}") + [ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}") [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then @@ -474,6 +457,18 @@ do_gcc_core_backend() { extra_config+=("--disable-libstdcxx-pch") fi + if [ "${CT_LIBC_GLIBC}" = "y" ]; then + # Report GLIBC's version to GCC, it affects the defaults on other options. + # Pass-2 should be able to get it from the headers, but for some options + # (such as --with-long-double-128) we need to get it right even in pass-1. + # GCC expects just two numbers separated by a dot. + local glibc_version + + CT_GetPkgVersion GLIBC glibc_version + glibc_version=`echo "${glibc_version}" | sed 's/\([1-9][0-9]*\.[1-9][0-9]*\).*/\1/'` + extra_config+=("--with-glibc-version=${glibc_version}") + fi + case "${CT_CC_GCC_LDBL_128}" in y) extra_config+=("--with-long-double-128");; m) ;; @@ -575,13 +570,13 @@ do_gcc_core_backend() { CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \ LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/configure" \ + "${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} \ + ${CT_CC_CORE_SYSROOT_ARG} \ "${extra_config[@]}" \ --enable-languages="${lang_list}" \ "${extra_user_config[@]}" @@ -603,7 +598,7 @@ do_gcc_core_backend() { # 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 + 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 @@ -613,12 +608,12 @@ do_gcc_core_backend() { 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 + 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-${CT_CC_GCC_VERSION}/libbacktrace" ]; then + if [ -d "${CT_SRC_DIR}/gcc/libbacktrace" ]; then CT_DoExecLog CFG make ${JOBSFLAGS} configure-libbacktrace CT_DoExecLog ALL make ${JOBSFLAGS} -C libbacktrace fi @@ -711,7 +706,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 @@ -796,7 +791,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 @@ -882,10 +877,13 @@ do_gcc_backend() { fi done - [ "${CT_SHARED_LIBS}" = "y" ] || extra_config+=("--disable-shared") - extra_config+=("--with-pkgversion=${CT_PKGVERSION}") + [ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}") [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") + if [ "${CT_SHARED_LIBS}" != "y" ]; then + extra_config+=("--disable-shared") + fi + case "${CT_CC_GCC_SJLJ_EXCEPTIONS}" in y) extra_config+=("--enable-sjlj-exceptions");; m) ;; @@ -1121,12 +1119,12 @@ do_gcc_backend() { CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \ LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/configure" \ + "${CT_SRC_DIR}/gcc/configure" \ --build=${CT_BUILD} \ --host=${host} \ --target=${CT_TARGET} \ --prefix="${prefix}" \ - ${CC_SYSROOT_ARG} \ + ${CT_CC_SYSROOT_ARG} \ "${extra_config[@]}" \ --with-local-prefix="${CT_SYSROOT_DIR}" \ --enable-long-long \ |