summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/build/binutils.sh14
-rw-r--r--scripts/build/cc_core_gcc.sh138
-rw-r--r--scripts/build/debug/dmalloc.sh2
-rw-r--r--scripts/build/libc_glibc.sh217
-rw-r--r--scripts/build/libc_uClibc.sh5
-rw-r--r--scripts/build/libfloat.sh6
-rwxr-xr-xscripts/crosstool.sh33
-rw-r--r--scripts/functions57
8 files changed, 391 insertions, 81 deletions
diff --git a/scripts/build/binutils.sh b/scripts/build/binutils.sh
index 3dec3ca..7615963 100644
--- a/scripts/build/binutils.sh
+++ b/scripts/build/binutils.sh
@@ -39,14 +39,18 @@ do_binutils() {
CT_DoLog EXTRA "Installing binutils"
make install 2>&1 |CT_DoLog ALL
- # Make those new tools available to the core C compiler to come:
+ # Make those new tools available to the core C compilers to come:
# Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as
# well. Create that (libfloat is one such sucker).
- mkdir -p "${CT_CC_CORE_PREFIX_DIR}/${CT_TARGET}/bin"
- mkdir -p "${CT_CC_CORE_PREFIX_DIR}/bin"
+ mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/bin"
+ mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/bin"
+ mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/bin"
+ mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/bin"
for t in ar as ld strip; do
- ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
- ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
+ ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
+ ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_STATIC_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
+ ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/bin/${t}"
+ ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" "${CT_CC_CORE_SHARED_PREFIX_DIR}/bin/${CT_TARGET}-${t}"
done |CT_DoLog ALL
CT_EndStep
diff --git a/scripts/build/cc_core_gcc.sh b/scripts/build/cc_core_gcc.sh
index af6b744..20f1240 100644
--- a/scripts/build/cc_core_gcc.sh
+++ b/scripts/build/cc_core_gcc.sh
@@ -21,27 +21,47 @@ do_cc_core_extract() {
CT_ExtractAndPatch "${CT_CC_CORE_FILE}"
}
-# Build core gcc
-do_cc_core() {
- mkdir -p "${CT_BUILD_DIR}/build-cc-core"
- cd "${CT_BUILD_DIR}/build-cc-core"
+# Core gcc pass 1
+do_cc_core_pass_1() {
+ # In case we're NPTL, build the static core gcc;
+ # in any other case, do nothing.
+ case "${CT_THREADS}" in
+ nptl) do_cc_core_static;;
+ *) ;;
+ esac
+}
+
+# Core gcc pass 2
+do_cc_core_pass_2() {
+ # In case we're NPTL, build the shared core gcc,
+ # in any other case, build the static core gcc.
+ case "${CT_THREADS}" in
+ nptl) do_cc_core_shared;;
+ *) do_cc_core_static;;
+ esac
+}
+
+# Build static core gcc
+do_cc_core_static() {
+ mkdir -p "${CT_BUILD_DIR}/build-cc-core-static"
+ cd "${CT_BUILD_DIR}/build-cc-core-static"
- CT_DoStep INFO "Installing core C compiler"
+ CT_DoStep INFO "Installing static core C compiler"
CT_DoLog EXTRA "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
- mkdir -p "${CT_CC_CORE_PREFIX_DIR}/${CT_TARGET}/include"
- cp -r "${CT_HEADERS_DIR}"/* "${CT_CC_CORE_PREFIX_DIR}/${CT_TARGET}/include" 2>&1 |CT_DoLog DEBUG
+ mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/include"
+ cp -r "${CT_HEADERS_DIR}"/* "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/include" 2>&1 |CT_DoLog DEBUG
- CT_DoLog EXTRA "Configuring core C compiler"
+ CT_DoLog EXTRA "Configuring static core C compiler"
extra_config=""
[ "${CT_ARCH_FLOAT_SW}" = "y" ] && extra_config="${extra_config} --with-float=soft"
[ -n "${CT_ARCH_ABI}" ] && extra_config="${extra_config} --with-abi=${CT_ARCH_ABI}"
+ [ -n "${CT_ARCH_ARCH}" ] && extra_config="${extra_config} --with-arch=${CT_ARCH_ARCH}"
[ -n "${CT_ARCH_CPU}" ] && extra_config="${extra_config} --with-cpu=${CT_ARCH_CPU}"
[ -n "${CT_ARCH_TUNE}" ] && extra_config="${extra_config} --with-tune=${CT_ARCH_TUNE}"
- [ -n "${CT_ARCH_ARCH}" ] && extra_config="${extra_config} --with-arch=${CT_ARCH_ARCH}"
[ -n "${CT_ARCH_FPU}" ] && extra_config="${extra_config} --with-fpu=${CT_ARCH_FPU}"
- [ "${CT_CC_CXA_ATEXIT}" == "y" ] && extra_config="${extra_config} --enable-__cxa_atexit"
+ [ "${CT_CC_CXA_ATEXIT}" = "y" ] && extra_config="${extra_config} --enable-__cxa_atexit"
CT_DoLog DEBUG "Extra config passed: \"${extra_config}\""
@@ -49,9 +69,9 @@ do_cc_core() {
CFLAGS="${CT_CFLAGS_FOR_HOST}" \
"${CT_SRC_DIR}/${CT_CC_CORE_FILE}/configure" \
${CT_CANADIAN_OPT} \
- --target=${CT_TARGET} \
--host=${CT_HOST} \
- --prefix="${CT_CC_CORE_PREFIX_DIR}" \
+ --target=${CT_TARGET} \
+ --prefix="${CT_CC_CORE_STATIC_PREFIX_DIR}" \
--with-local-prefix="${CT_SYSROOT_DIR}" \
--disable-multilib \
--with-newlib \
@@ -69,12 +89,102 @@ do_cc_core() {
make ${PARALLELMFLAGS} all-build-libiberty 2>&1 |CT_DoLog ALL
fi
- CT_DoLog EXTRA "Building core C compiler"
+ CT_DoLog EXTRA "Building static core C compiler"
make ${PARALLELMFLAGS} all-gcc 2>&1 |CT_DoLog ALL
- CT_DoLog EXTRA "Installing core C compiler"
+ CT_DoLog EXTRA "Installing static core C compiler"
make install-gcc 2>&1 |CT_DoLog ALL
CT_EndStep
}
+# Build shared core gcc
+do_cc_core_shared() {
+ mkdir -p "${CT_BUILD_DIR}/build-cc-core-shared"
+ cd "${CT_BUILD_DIR}/build-cc-core-shared"
+
+ CT_DoStep INFO "Installing shared core C compiler"
+
+ CT_DoLog EXTRA "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
+ mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/include"
+ cp -r "${CT_HEADERS_DIR}"/* "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/include" 2>&1 |CT_DoLog DEBUG
+
+ CT_DoLog EXTRA "Configuring shared core C compiler"
+
+ extra_config=""
+ [ "${CT_ARCH_FLOAT_SW}" = "y" ] && extra_config="${extra_config} --with-float=soft"
+ [ -n "${CT_ARCH_ABI}" ] && extra_config="${extra_config} --with-abi=${CT_ARCH_ABI}"
+ [ -n "${CT_ARCH_ARCH}" ] && extra_config="${extra_config} --with-arch=${CT_ARCH_ARCH}"
+ [ -n "${CT_ARCH_CPU}" ] && extra_config="${extra_config} --with-cpu=${CT_ARCH_CPU}"
+ [ -n "${CT_ARCH_TUNE}" ] && extra_config="${extra_config} --with-tune=${CT_ARCH_TUNE}"
+ [ -n "${CT_ARCH_FPU}" ] && extra_config="${extra_config} --with-fpu=${CT_ARCH_FPU}"
+ [ "${CT_CC_CXA_ATEXIT}" = "y" ] && extra_config="${extra_config} --enable-__cxa_atexit"
+
+ CT_DoLog DEBUG "Extra config passed: \"${extra_config}\""
+
+ CFLAGS="${CT_CFLAGS_FOR_HOST}" \
+ "${CT_SRC_DIR}/${CT_CC_CORE_FILE}/configure" \
+ ${CT_CANADIAN_OPT} \
+ --target=${CT_TARGET} \
+ --host=${CT_HOST} \
+ --prefix="${CT_CC_CORE_SHARED_PREFIX_DIR}" \
+ --with-local-prefix="${CT_SYSROOT_DIR}" \
+ --disable-multilib \
+ ${CC_CORE_SYSROOT_ARG} \
+ ${extra_config} \
+ --disable-nls \
+ --enable-symvers=gnu \
+ --enable-languages=c \
+ --enable-shared \
+ ${CT_CC_CORE_EXTRA_CONFIG} 2>&1 |CT_DoLog ALL
+
+ # 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}/${CT_CC_CORE_FILE}/gcc/BASE-VER" ]; then
+ make configure-libiberty
+ make -C libiberty libiberty.a
+ make configure-gcc
+ make configure-libcpp
+ make all-libcpp
+ else
+ make configure-gcc
+ make configure-libcpp
+ make configure-build-libiberty
+ make all-libcpp
+ make all-build-libiberty
+ fi 2>&1 |CT_DoLog ALL
+ # HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here.
+ if [ -d "${CT_SRC_DIR}/${CT_CC_CORE_FILE}/libdecnumber" ]; then
+ make configure-libdecnumber
+ make -C libdecnumber libdecnumber.a
+ fi 2>&1 |CT_DoLog ALL
+ make -C gcc libgcc.mk 2>&1 |CT_DoLog ALL
+ sed -r -i -e 's@-lc@@g' gcc/libgcc.mk
+
+ if [ "${CT_CANADIAN}" = "y" ]; then
+ CT_DoLog EXTRA "Building libiberty"
+ make ${PARALLELMFLAGS} all-build-libiberty 2>&1 |CT_DoLog ALL
+ fi
+
+ CT_DoLog EXTRA "Building shared core C compiler"
+ make ${PARALLELMFLAGS} all-gcc 2>&1 |CT_DoLog ALL
+
+ CT_DoLog EXTRA "Installing shared core C compiler"
+ make install-gcc 2>&1 |CT_DoLog ALL
+
+ CT_EndStep
+}
diff --git a/scripts/build/debug/dmalloc.sh b/scripts/build/debug/dmalloc.sh
index e9bc0da..075035c 100644
--- a/scripts/build/debug/dmalloc.sh
+++ b/scripts/build/debug/dmalloc.sh
@@ -22,7 +22,7 @@ do_debug_dmalloc_build() {
y) extra_config="${extra_config} --enable-cxx";;
*) extra_config="${extra_config} --disable-cxx";;
esac
- case "${CT_LIBC_THREADS_NONE}" in
+ case "${CT_THREADS_NONE}" in
y) extra_config="${extra_config} --disable-threads";;
*) extra_config="${extra_config} --enable-threads";;
esac
diff --git a/scripts/build/libc_glibc.sh b/scripts/build/libc_glibc.sh
index 41be59a..36f1ba2 100644
--- a/scripts/build/libc_glibc.sh
+++ b/scripts/build/libc_glibc.sh
@@ -11,10 +11,13 @@ do_libc_get() {
# C library addons
addons_list=`echo "${CT_LIBC_ADDONS_LIST}" |sed -r -e 's/,/ /g; s/ $//g;'`
+ case "${CT_THREADS}" in
+ linuxthreads) addons_list="${addons_list} linuxthreads";;
+ esac
+ [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && addons_list="${addons_list} ports"
for addon in ${addons_list}; do
CT_GetFile "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" ftp://ftp.gnu.org/gnu/glibc
done
- [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && CT_GetFile "${CT_LIBC}-ports-${CT_LIBC_VERSION}" ftp://ftp.gnu.org/gnu/glibc
return 0
}
@@ -25,10 +28,13 @@ do_libc_extract() {
# C library addons
addons_list=`echo "${CT_LIBC_ADDONS_LIST}" |sed -r -e 's/,/ /g; s/ $//g;'`
+ case "${CT_THREADS}" in
+ linuxthreads) addons_list="${addons_list} linuxthreads";;
+ esac
+ [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && addons_list="${addons_list} ports"
for addon in ${addons_list}; do
CT_ExtractAndPatch "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}"
done
- [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && CT_ExtractAndPatch "${CT_LIBC}-ports-${CT_LIBC_VERSION}"
return 0
}
@@ -68,21 +74,27 @@ do_libc_headers() {
# 'a version of binutils that supports .machine "altivec" is needed'.
# We also need to use the ports addon if specified
- addons=
- [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && addons="${CT_LIBC}-ports-${CT_LIBC_VERSION}"
+ addons_list=
+ case "${CT_LIBC_ADDONS},${CT_LIBC_GLIBC_USE_PORTS}" in
+ y,y) addons_list="${CT_LIBC_ADDONS_LIST},ports";;
+ y,) addons_list="${CT_LIBC_ADDONS_LIST}";;
+ ,y) addons_list="ports";;
+ *) addons_list="";;
+ esac
+ addons_config="--enable-add-ons=`echo ${addons_list} |sed -r -e 's/,+/,/g; s/^,+//; s/,+$//;'`"
libc_cv_ppc_machine=yes \
CC=${CT_CC_NATIVE} \
"${CT_SRC_DIR}/${CT_LIBC_FILE}/configure" \
- --build="${CT_BUILD}" \
+ --build="${CT_UNIQ_BUILD}" \
--host="${CT_TARGET}" \
--prefix=/usr \
--with-headers="${CT_HEADERS_DIR}" \
--without-cvs \
--disable-sanity-checks \
--enable-hacker-mode \
- --enable-add-ons="${addons}" \
- --without-nptl 2>&1 |CT_DoLog ALL
+ --without-nptl \
+ ${addons_config} 2>&1 |CT_DoLog ALL
CT_DoLog EXTRA "Installing C library headers"
@@ -133,15 +145,40 @@ do_libc_headers() {
# but it breaks arm, see http://sourceware.org/ml/crossgcc/2006-01/msg00091.html
[ "${CT_ARCH}" != "arm" ] && cp misc/syscall-list.h "${CT_HEADERS_DIR}/bits/syscall.h" || true
+ # Those headers are to be manually copied so gcc can build properly
+ pthread_h=
+ pthreadtypes_h=
+ case "${CT_THREADS}" in
+ nptl)
+ # NOTE: for some archs, the pathes are different, but they are not
+ # supported by ct-ng right now. See original crosstool when they are.
+ pthread_h="${CT_SRC_DIR}/${CT_LIBC_FILE}/${CT_THREADS}/sysdeps/pthread/pthread.h"
+ pthreadtypes_h="${CT_SRC_DIR}/${CT_LIBC_FILE}/nptl/sysdeps/unix/sysv/linux/${CT_KERNEL_ARCH}/bits/pthreadtypes.h"
+ ;;
+ linuxthreads)
+ pthread_h="${CT_SRC_DIR}/${CT_LIBC_FILE}/${CT_THREADS}/sysdeps/pthread/pthread.h"
+ pthreadtypes_h="${CT_SRC_DIR}/${CT_LIBC_FILE}/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h"
+ ;;
+ esac
+ if [ -n "${pthread_h}" ]; then
+ cp -v "${pthread_h}" "${CT_HEADERS_DIR}/pthread.h" 2>&1 |CT_DoLog ALL
+ fi
+ if [ -n "${pthreadtypes_h}" ]; then
+ cp -v "${pthreadtypes_h}" "${CT_HEADERS_DIR}/bits/pthreadtypes.h" 2>&1 |CT_DoLog ALL
+ fi
+
CT_EndStep
}
-# This function builds and install the full glibc
-do_libc() {
- CT_DoStep INFO "Installing C library"
+# Build and install start files
+do_libc_start_files() {
+ # Needed only in the NPTL case. Otherwise, return.
+ [ "${CT_THREADS}" = "nptl" ] || return 0
- mkdir -p "${CT_BUILD_DIR}/build-libc"
- cd "${CT_BUILD_DIR}/build-libc"
+ CT_DoStep INFO "Installing C library start files"
+
+ mkdir -p "${CT_BUILD_DIR}/build-libc-startfiles"
+ cd "${CT_BUILD_DIR}/build-libc-startfiles"
CT_DoLog EXTRA "Configuring C library"
@@ -153,31 +190,32 @@ do_libc() {
esac
case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
*-tls*) ;;
- *) extra_config="${extra_config} --without-tls"
- esac
- case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
- *-__thread*) ;;
- *) extra_config="${extra_config} --without-__thread"
+ *) extra_config="${extra_config} --with-tls"
esac
case "${CT_SHARED_LIBS}" in
y) extra_config="${extra_config} --enable-shared";;
*) extra_config="${extra_config} --disable-shared";;
esac
case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
- *--with-fp*) ;;
- *--without-fp*) ;;
- *) case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
+ *--with-fp*) ;;
+ *--without-fp*) ;;
+ *) case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
y,) extra_config="${extra_config} --with-fp";;
,y) extra_config="${extra_config} --without-fp";;
esac;;
esac
+ # Obviously, we want threads, as we come here only for NPTL
+ extra_config="${extra_config} --with-__thread"
+ addons_list=
case "${CT_LIBC_ADDONS},${CT_LIBC_GLIBC_USE_PORTS}" in
- y,y) addons_config="--enable-add-ons=${CT_LIBC_ADDONS_LIST},${CT_LIBC}-ports-${CT_LIBC_VERSION}";;
- y,) addons_config="--enable-add-ons=${CT_LIBC_ADDONS_LIST}";;
- ,y) addons_config="--enable-add-ons=${CT_LIBC}-ports-${CT_LIBC_VERSION}";;
- *) addons_config="";;
+ y,y) addons_list="nptl,${CT_LIBC_ADDONS_LIST},ports";;
+ y,) addons_list="nptl,${CT_LIBC_ADDONS_LIST}";;
+ ,y) addons_list="nptl,ports";;
+ *) addons_list="nptl";;
esac
+ addons_config="--enable-add-ons=`echo ${addons_list} |sed -r -e 's/,+/,/g; s/^,+//; s/,+$//;'`"
+ extra_config="${extra_config} ${addons_config}"
# Add some default CC args
extra_cc_args="${CT_CFLAGS_FOR_HOST}"
@@ -190,7 +228,114 @@ do_libc() {
esac;;
esac
- CT_DoLog DEBUG "Configuring with addons : \"${addons_config}\""
+ CT_DoLog DEBUG "Configuring with addons : \"${addons_list}\""
+ CT_DoLog DEBUG "Extra config args passed: \"${extra_config}\""
+ CT_DoLog DEBUG "Extra CC args passed: \"${extra_cc_args}\""
+
+ # sh3 and sh4 really need to set configparms as of gcc-3.4/glibc-2.3.2
+ # note: this is awkward, doesn't work well if you need more than one line in configparms
+ echo ${CT_LIBC_GLIBC_CONFIGPARMS} > configparms
+
+ echo "libc_cv_forced_unwind=yes" > config.cache
+ echo "libc_cv_c_cleanup=yes" >> config.cache
+
+ # Please see the comment for the configure step in do_libc().
+
+ BUILD_CC=${CT_CC_NATIVE} \
+ CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O" \
+ CC="${CT_TARGET}-gcc ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \
+ AR=${CT_TARGET}-ar \
+ RANLIB=${CT_TARGET}-ranlib \
+ "${CT_SRC_DIR}/${CT_LIBC_FILE}/configure" \
+ --prefix=/usr \
+ --build="${CT_UNIQ_BUILD}" \
+ --host=${CT_TARGET} \
+ --without-cvs \
+ --disable-profile \
+ --disable-debug \
+ --without-gd \
+ --with-headers="${CT_HEADERS_DIR}" \
+ --cache-file=config.cache \
+ ${extra_config} \
+ ${CT_LIBC_GLIBC_EXTRA_CONFIG} 2>&1 |CT_DoLog ALL
+
+
+ #TODO: should check whether slibdir has been set in configparms to */lib64
+ # and copy the startfiles into the appropriate libdir.
+ make csu/subdir_lib 2>&1 |CT_DoLog ALL
+
+ if [ "${CT_USE_SYSROOT}" = "y" ]; then
+ cp -fp csu/crt[1in].o "${CT_SYSROOT_DIR}/usr/lib/"
+ else
+ cp -fp csu/crt[1in].o "${CT_SYSROOT_DIR}/lib/"
+ fi
+
+ CT_EndStep
+}
+
+# This function builds and install the full glibc
+do_libc() {
+ 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"
+
+ # Add some default glibc config options if not given by user.
+ # We don't need to be conditional on wether the user did set different
+ # values, as they CT_LIBC_GLIBC_EXTRA_CONFIG is passed after extra_config
+
+ extra_config="--enable-kernel=`echo ${CT_KERNEL_VERSION} |sed -r -e 's/^([^.]+\.[^.]+\.[^.]+)(|\.[^.]+)$/\1/;'`"
+
+ case "${CT_THREADS}" in
+ nptl) extra_config="${extra_config} --with-__thread --with-tls";;
+ linuxthreads) extra_config="${extra_config} --with-__thread --without-tls --without-nptl";;
+ none) extra_config="${extra_config} --without-__thread --without-nptl"
+ case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
+ *-tls*) ;;
+ *) extra_config="${extra_config} --without-tls";;
+ esac
+ ;;
+ esac
+
+ case "${CT_SHARED_LIBS}" in
+ y) extra_config="${extra_config} --enable-shared";;
+ *) extra_config="${extra_config} --disable-shared";;
+ esac
+
+ case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
+ y,) extra_config="${extra_config} --with-fp";;
+ ,y) extra_config="${extra_config} --without-fp";;
+ esac
+
+ addons_list=
+ case "${CT_LIBC_ADDONS},${CT_LIBC_GLIBC_USE_PORTS}" in
+ y,y) addons_list="${CT_LIBC_ADDONS_LIST},ports";;
+ y,) addons_list="${CT_LIBC_ADDONS_LIST}";;
+ ,y) addons_list="ports";;
+ *) addons_list="";;
+ esac
+ case "${CT_THREADS}" in
+ none) ;;
+ *) addons_list="${addons_list},${CT_THREADS}";;
+ esac
+ case "${addons_list}" in
+ "") ;;
+ *) addons_config="--enable-add-ons=`echo ${addons_list} |sed -r -e 's/,+/,/g; s/^,+//g; s/,+$//;'`";;
+ esac
+ extra_config="${extra_config} ${addons_config}"
+
+ # Add some default CC args
+ if [ "${CT_USE_PIPES}" = "y" ]; then
+ extra_cc_args="-pipe"
+ fi
+ case "${CT_ARCH_BE},${CT_ARCH_LE}" in
+ y,) extra_cc_args="${extra_cc_args} -mbig-endian";;
+ ,y) extra_cc_args="${extra_cc_args} -mlittle-endian";;
+ esac
+
+ CT_DoLog DEBUG "Configuring with addons : \"${addons_list}\""
CT_DoLog DEBUG "Extra config args passed: \"${extra_config}\""
CT_DoLog DEBUG "Extra CC args passed: \"${extra_cc_args}\""
@@ -201,11 +346,10 @@ do_libc() {
# For glibc 2.3.4 and later we need to set some autoconf cache
# variables, because nptl/sysdeps/pthread/configure.in does not
# work when cross-compiling.
- if test -d ${GLIBC_DIR}/nptl; then
- libc_cv_forced_unwind=yes
- libc_cv_c_cleanup=yes
- export libc_cv_forced_unwind libc_cv_c_cleanup
- fi
+ if [ "${CT_THREADS}" = "nptl" ]; then
+ echo libc_cv_forced_unwind=yes
+ echo libc_cv_c_cleanup=yes
+ fi >config.cache
# Configure with --prefix the way we want it on the target...
# There are a whole lot of settings here. You'll probably want
@@ -216,19 +360,26 @@ do_libc() {
# Set BUILD_CC, or you won't be able to build datafiles
# Set --build, else glibc-2.3.2 will think you're not cross-compiling, and try to run the test programs
+ # OK. I'm fed up with those folks telling me what I should do.
+ # I don't configure nptl? Well, maybe that's purposedly because
+ # I don't want nptl! --disable-sanity-checks will shut up those
+ # silly messages. GNU folks again, he?
+
BUILD_CC=${CT_CC_NATIVE} \
CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O" \
- CC="${CT_TARGET}-gcc ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \
+ CC="${CT_TARGET}-gcc ${extra_cc_args} ${CT_LIBC_EXTRA_CC_ARGS}" \
AR=${CT_TARGET}-ar \
RANLIB=${CT_TARGET}-ranlib \
"${CT_SRC_DIR}/${CT_LIBC_FILE}/configure" \
--prefix=/usr \
- --build=${CT_BUILD} --host=${CT_TARGET} \
+ --build=${CT_UNIQ_BUILD} \
+ --host=${CT_TARGET} \
--without-cvs \
- --without-nptl \
--disable-profile \
--disable-debug \
--without-gd \
+ --disable-sanity-checks \
+ --cache-file=config.cache \
--with-headers="${CT_HEADERS_DIR}" \
${addons_config} \
${extra_config} \
diff --git a/scripts/build/libc_uClibc.sh b/scripts/build/libc_uClibc.sh
index a8fb9be..632db69 100644
--- a/scripts/build/libc_uClibc.sh
+++ b/scripts/build/libc_uClibc.sh
@@ -79,6 +79,11 @@ do_libc_headers() {
CT_EndStep
}
+# Build and install start files
+do_libc_start_files() {
+ :
+}
+
# This function build and install the full uClibc
do_libc() {
CT_DoStep INFO "Installing C library"
diff --git a/scripts/build/libfloat.sh b/scripts/build/libfloat.sh
index b557404..147d046 100644
--- a/scripts/build/libfloat.sh
+++ b/scripts/build/libfloat.sh
@@ -40,11 +40,11 @@ do_libfloat() {
make clean 2>&1 |CT_DoLog ALL
CT_DoLog EXTRA "Building library"
- make CROSS_COMPILE="${CT_CC_CORE_PREFIX_DIR}/bin/${CT_TARGET}-" 2>&1 |CT_DoLog ALL
+ make CROSS_COMPILE="${CT_CC_CORE_SHARED_PREFIX_DIR}/bin/${CT_TARGET}-" 2>&1 |CT_DoLog ALL
CT_DoLog EXTRA "Installing library"
- make CROSS_COMPILE="${CT_CC_CORE_PREFIX_DIR}/bin/${CT_TARGET}-" \
- DESTDIR="${CT_SYSROOT_DIR}" install 2>&1 |CT_DoLog ALL
+ make CROSS_COMPILE="${CT_CC_CORE_SHARED_PREFIX_DIR}/bin/${CT_TARGET}-" \
+ DESTDIR="${CT_SYSROOT_DIR}" install 2>&1 |CT_DoLog ALL
CT_Popd
diff --git a/scripts/crosstool.sh b/scripts/crosstool.sh
index 8c78e57..80f938f 100755
--- a/scripts/crosstool.sh
+++ b/scripts/crosstool.sh
@@ -31,7 +31,7 @@ CT_STAR_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S`
# - first of all, save stdout so we can see the live logs: fd #6
exec 6>&1
# - then point stdout to the log file (temporary for now)
-tmp_log_file="${CT_TOP_DIR}/$$.log"
+tmp_log_file="${CT_TOP_DIR}/log.$$"
exec >>"${tmp_log_file}"
# Are we configured? We'll need that later...
@@ -118,7 +118,8 @@ CT_DEBUG_INSTALL_DIR="${CT_INSTALL_DIR}/${CT_TARGET}/debug-root"
# Note: we'll always install the core compiler in its own directory, so as to
# not mix the two builds: core and final. Anyway, its generic, wether we use
# a different compiler as core, or not.
-CT_CC_CORE_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core"
+CT_CC_CORE_STATIC_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core-static"
+CT_CC_CORE_SHARED_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core-shared"
CT_STATE_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/state"
# Make all path absolute, it so much easier!
@@ -201,11 +202,12 @@ mkdir -p "${CT_BUILD_DIR}"
mkdir -p "${CT_INSTALL_DIR}"
mkdir -p "${CT_PREFIX_DIR}"
mkdir -p "${CT_DEBUG_INSTALL_DIR}"
-mkdir -p "${CT_CC_CORE_PREFIX_DIR}"
+mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}"
+mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}"
mkdir -p "${CT_STATE_DIR}"
# Kludge: CT_INSTALL_DIR and CT_PREFIX_DIR might have grown read-only if
-# the previous build was successfull. To ba able to move the logfile there,
+# the previous build was successfull. To be able to move the logfile there,
# switch them back to read/write
chmod -R u+w "${CT_INSTALL_DIR}" "${CT_PREFIX_DIR}"
@@ -269,16 +271,22 @@ if [ -z "${CT_RESTART}" ]; then
mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
# Canadian-cross are really picky on the way they are built. Tweak the values.
+ CT_UNIQ_BUILD=`echo "${CT_BUILD}" |sed -r -e 's/-/-build_/'`
if [ "${CT_CANADIAN}" = "y" ]; then
# Arrange so that gcc never, ever think that build system == host system
- CT_CANADIAN_OPT="--build=`echo \"${CT_BUILD}\" |sed -r -e 's/-/-build_/'`"
+ CT_CANADIAN_OPT="--build=${CT_UNIQ_BUILD}"
# We shall have a compiler for this target!
# Do test here...
else
CT_HOST="${CT_BUILD}"
CT_CANADIAN_OPT="--build=${CT_BUILD}"
# Add the target toolchain in the path so that we can build the C library
- export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_PREFIX_DIR}/bin:${PATH}"
+ # Carefully add paths in the order we want them:
+ # - first try in ${CT_PREFIX_DIR}/bin
+ # - then try in ${CT_CC_CORE_SHARED_PREFIX_DIR}/bin
+ # - then try in ${CT_CC_CORE_STATIC_PREFIX_DIR}/bin
+ # - fall back to searching user's PATH
+ export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_SHARED_PREFIX_DIR}/bin:${CT_CC_CORE_STATIC_PREFIX_DIR}/bin:${PATH}"
fi
# Modify GCC_HOST to never be equal to $BUILD or $TARGET
@@ -294,7 +302,7 @@ if [ -z "${CT_RESTART}" ]; then
# (Copied almost as-is from original crosstool):
case "${CT_KERNEL},${CT_CANADIAN}" in
cygwin,y) ;;
- *) CT_HOST="`echo \"${CT_HOST}\" |sed -r -e 's/-/-host_/;'`";;
+ *,y) CT_HOST="`echo \"${CT_HOST}\" |sed -r -e 's/-/-host_/;'`";;
esac
# Ah! Recent versions of binutils need some of the build and/or host system
@@ -304,10 +312,9 @@ if [ -z "${CT_RESTART}" ]; then
mkdir -p "${CT_PREFIX_DIR}/bin"
for tool in ar as dlltool gcc g++ gnatbind gnatmake ld nm ranlib strip windres objcopy objdump; do
if [ -n "`which ${tool}`" ]; then
- ln -sv "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_BUILD}-${tool}"
- case "${CT_TOOLCHAIN_TYPE}" in
- cross|native) ln -sv "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_HOST}-${tool}";;
- esac
+ ln -sfv "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_BUILD}-${tool}"
+ ln -sfv "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_UNIQ_BUILD}-${tool}"
+ ln -sfv "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_HOST}-${tool}"
fi |CT_DoLog DEBUG
done
@@ -392,8 +399,10 @@ if [ "${CT_ONLY_DOWNLOAD}" != "y" -a "${CT_ONLY_EXTRACT}" != "y" ]; then
kernel_check_config \
kernel_headers \
binutils \
+ cc_core_pass_1 \
libc_headers \
- cc_core \
+ libc_start_files \
+ cc_core_pass_2 \
libfloat \
libc \
cc \
diff --git a/scripts/functions b/scripts/functions
index dcf4160..ce4c001 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -2,6 +2,7 @@
# Copyright 2007 Yann E. MORIN
# Licensed under the GPL v2. See COPYING in the root of this package
+# Prepare the fault handler
CT_OnError() {
ret=$?
CT_DoLog ERROR "Build failed in step \"${CT_STEP_MESSAGE[${CT_STEP_COUNT}]}\""
@@ -17,11 +18,23 @@ CT_OnError() {
CT_DoEnd ERROR
exit $ret
}
+
+# Install the fault handler
trap CT_OnError ERR
+# Inherit the fault handler in subshells and functions
set -E
+
+# Make pipes fail on the _first_ failed command
+# Not supported on bash < 3.x, but we need it, so drop the obsoleting bash-2.x
set -o pipefail
+# Don't hash commands' locations, and search every time it is requested.
+# This is slow, but needed because of the static/shared core gcc which shall
+# always match to shared if it exists, and only fallback to static if the
+# shared is not found
+set +o hashall
+
# The different log levels:
CT_LOG_LEVEL_ERROR=0
CT_LOG_LEVEL_WARN=1
@@ -392,8 +405,16 @@ CT_ExtractAndPatch() {
# a libc addon, or a plain package. Apply patches now.
CT_DoLog EXTRA "Patching \"${file}\""
- # If libc addon, we're already in the correct place.
- [ -z "${libc_addon}" ] && cd "${file}"
+ if [ "${libc_addon}" = "y" ]; then
+ # Some addons tarball directly contian the correct addon directory,
+ # while others have the addon directory named ofter the tarball.
+ # Fix that bu always using the short name (eg: linuxthreads, ports, etc...)
+ addon_short_name=`echo "${file}" |sed -r -e 's/^[^-]+-//; s/-[^-]+$//;'`
+ [ -d "${addon_short_name}" ] || ln -s "${file}" "${addon_short_name}"
+ # If libc addon, we're already in the correct place
+ else
+ cd "${file}"
+ fi
[ "${CUSTOM_PATCH_ONLY}" = "y" ] || official_patch_dir="${CT_TOP_DIR}/patches/${base_file}/${ver_file}"
[ "${CT_CUSTOM_PATCH}" = "y" ] && custom_patch_dir="${CT_CUSTOM_PATCH_DIR}/${base_file}/${ver_file}"
@@ -493,14 +514,19 @@ CT_DoSaveState() {
$0 == "}" { _p = 1; }
' |egrep -v '^[^ ]+ \(\)' >"${state_dir}/env.sh"
- CT_DoLog DEBUG " Saving CT_CC_CORE_PREFIX_DIR=\"${CT_CC_CORE_PREFIX_DIR}\""
- CT_Pushd "${CT_CC_CORE_PREFIX_DIR}"
- tar ${tar_opt} "${state_dir}/cc_core_prefix_dir${tar_ext}" .
+ CT_DoLog DEBUG " Saving CT_CC_CORE_STATIC_PREFIX_DIR=\"${CT_CC_CORE_STATIC_PREFIX_DIR}\""
+ CT_Pushd "${CT_CC_CORE_STATIC_PREFIX_DIR}"
+ tar ${tar_opt} "${state_dir}/cc_core_static_prefix_dir${tar_ext}" .
+ CT_Popd
+
+ CT_DoLog DEBUG " Saving CT_CC_CORE_SHARED_PREFIX_DIR=\"${CT_CC_CORE_SHARED_PREFIX_DIR}\""
+ CT_Pushd "${CT_CC_CORE_SHARED_PREFIX_DIR}"
+ tar ${tar_opt} "${state_dir}/cc_core_shared_prefix_dir${tar_ext}" .
CT_Popd
CT_DoLog DEBUG " Saving CT_PREFIX_DIR=\"${CT_PREFIX_DIR}\""
CT_Pushd "${CT_PREFIX_DIR}"
- tar ${tar_opt} "${state_dir}/prefix_dir${tar_ext}" .
+ tar ${tar_opt} "${state_dir}/prefix_dir${tar_ext}" --exclude '*.log' .
CT_Popd
if [ "${CT_LOG_TO_FILE}" = "y" ]; then
@@ -514,7 +540,7 @@ CT_DoSaveState() {
fi
}
-# This functions restores a previously saved state
+# This function restores a previously saved state
# Usage: CT_DoLoadState <state_name>
CT_DoLoadState(){
local state_name="$1"
@@ -534,18 +560,23 @@ CT_DoLoadState(){
esac
CT_DoLog DEBUG " Removing previous build directories"
- chmod -R u+rwX "${CT_PREFIX_DIR}" "${CT_CC_CORE_PREFIX_DIR}"
- rm -rf "${CT_PREFIX_DIR}" "${CT_CC_CORE_PREFIX_DIR}"
- mkdir -p "${CT_PREFIX_DIR}" "${CT_CC_CORE_PREFIX_DIR}"
+ chmod -R u+rwX "${CT_PREFIX_DIR}" "${CT_CC_CORE_SHARED_PREFIX_DIR}" "${CT_CC_CORE_STATIC_PREFIX_DIR}"
+ rm -rf "${CT_PREFIX_DIR}" "${CT_CC_CORE_SHARED_PREFIX_DIR}" "${CT_CC_CORE_STATIC_PREFIX_DIR}"
+ mkdir -p "${CT_PREFIX_DIR}" "${CT_CC_CORE_SHARED_PREFIX_DIR}" "${CT_CC_CORE_STATIC_PREFIX_DIR}"
CT_DoLog DEBUG " Restoring CT_PREFIX_DIR=\"${CT_PREFIX_DIR}\""
CT_Pushd "${CT_PREFIX_DIR}"
tar ${tar_opt} "${state_dir}/prefix_dir${tar_ext}"
CT_Popd
- CT_DoLog DEBUG " Restoring CT_CC_CORE_PREFIX_DIR=\"${CT_CC_CORE_PREFIX_DIR}\""
- CT_Pushd "${CT_CC_CORE_PREFIX_DIR}"
- tar ${tar_opt} "${state_dir}/cc_core_prefix_dir${tar_ext}"
+ CT_DoLog DEBUG " Restoring CT_CC_CORE_SHARED_PREFIX_DIR=\"${CT_CC_CORE_SHARED_PREFIX_DIR}\""
+ CT_Pushd "${CT_CC_CORE_SHARED_PREFIX_DIR}"
+ tar ${tar_opt} "${state_dir}/cc_core_shared_prefix_dir${tar_ext}"
+ CT_Popd
+
+ CT_DoLog DEBUG " Restoring CT_CC_CORE_STATIC_PREFIX_DIR=\"${CT_CC_CORE_STATIC_PREFIX_DIR}\""
+ CT_Pushd "${CT_CC_CORE_STATIC_PREFIX_DIR}"
+ tar ${tar_opt} "${state_dir}/cc_core_static_prefix_dir${tar_ext}"
CT_Popd
# Restore the environment, discarding any error message