1.1 --- a/scripts/build/libc/glibc.sh Mon Jan 03 23:40:22 2011 +0100
1.2 +++ b/scripts/build/libc/glibc.sh Sat Jan 22 22:37:25 2011 +0100
1.3 @@ -2,6 +2,11 @@
1.4 # Copyright 2007 Yann E. MORIN
1.5 # Licensed under the GPL v2. See COPYING in the root of this package
1.6
1.7 +# Add the definitions common to glibc and eglibc
1.8 +# do_libc_headers
1.9 +# do_libc_start_files
1.10 +. "${CT_LIB_DIR}/scripts/build/libc/glibc-eglibc.sh-common"
1.11 +
1.12 # Download glibc
1.13 do_libc_get() {
1.14 local date
1.15 @@ -73,239 +78,6 @@
1.16 :
1.17 }
1.18
1.19 -# This function installs the glibc headers needed to build the core compiler
1.20 -do_libc_headers() {
1.21 - local -a extra_config
1.22 - local arch4hdrs
1.23 -
1.24 - CT_DoStep INFO "Installing C library headers"
1.25 -
1.26 - mkdir -p "${CT_BUILD_DIR}/build-libc-headers"
1.27 - cd "${CT_BUILD_DIR}/build-libc-headers"
1.28 -
1.29 - CT_DoLog EXTRA "Configuring C library"
1.30 -
1.31 - # The x86 arch needs special care... Bizarelly enough... :-(
1.32 - case "${CT_ARCH}:${CT_ARCH_BITNESS}" in
1.33 - x86:32) arch4hdrs="i386";;
1.34 - x86:64) arch4hdrs="x86_64";;
1.35 - *) arch4hdrs="${CT_ARCH}";;
1.36 - esac
1.37 -
1.38 - # The following three things have to be done to build glibc-2.3.x, but they don't hurt older versions.
1.39 - # 1. override CC to keep glibc's configure from using $TARGET-gcc.
1.40 - # 2. disable linuxthreads, which needs a real cross-compiler to generate tcb-offsets.h properly
1.41 - # 3. build with gcc 3.2 or later
1.42 - # Compare these options with the ones used when building glibc for real below - they're different.
1.43 - # As of glibc-2.3.2, to get this step to work for hppa-linux, you need --enable-hacker-mode
1.44 - # so when configure checks to make sure gcc has access to the assembler you just built...
1.45 - # Alternately, we could put ${PREFIX}/${TARGET}/bin on the path.
1.46 - # Set --build so maybe we don't have to specify "cross-compiling=yes" below (haven't tried yet)
1.47 - # Note: the warning
1.48 - # "*** WARNING: Are you sure you do not want to use the `linuxthreads'"
1.49 - # *** add-on?"
1.50 - # is ok here, since all we want are the basic headers at this point.
1.51 - # Override libc_cv_ppc_machine so glibc-cvs doesn't complain
1.52 - # 'a version of binutils that supports .machine "altivec" is needed'.
1.53 -
1.54 - # We need to remove any threading addon when installing headers
1.55 - addons_list="$(do_libc_add_ons_list " " \
1.56 - |sed -r -e 's/\<(nptl|linuxthreads)\>/ /g;' \
1.57 - -e 's/ +/,/g; s/^,+//; s/,+$//;' \
1.58 - )"
1.59 -
1.60 - extra_config+=("--enable-add-ons=${addons_list}")
1.61 -
1.62 - extra_config+=("${addons_config}")
1.63 - extra_config+=("$(do_libc_min_kernel_config)")
1.64 -
1.65 - # Pre-seed the configparms file with values from the config option
1.66 - printf "${CT_LIBC_GLIBC_CONFIGPARMS}\n" > configparms
1.67 -
1.68 - cross_cc=$(CT_Which "${CT_TARGET}-gcc")
1.69 - CT_DoLog DEBUG "Using gcc for target: '${cross_cc}'"
1.70 - CT_DoLog DEBUG "Extra config passed : '${extra_config[*]}'"
1.71 -
1.72 - libc_cv_ppc_machine=yes \
1.73 - libc_cv_mlong_double_128=yes \
1.74 - libc_cv_mlong_double_128ibm=yes \
1.75 - CC=${cross_cc} \
1.76 - CT_DoExecLog CFG \
1.77 - "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/configure" \
1.78 - --build="${CT_BUILD}" \
1.79 - --host="${CT_TARGET}" \
1.80 - --prefix=/usr \
1.81 - --with-headers="${CT_HEADERS_DIR}" \
1.82 - --without-cvs \
1.83 - --disable-sanity-checks \
1.84 - --enable-hacker-mode \
1.85 - "${extra_config[@]}" \
1.86 - --without-nptl
1.87 -
1.88 - CT_DoLog EXTRA "Installing C library headers"
1.89 -
1.90 - # Note: BOOTSTRAP_GCC (see above)
1.91 - libc_cv_ppc_machine=yes \
1.92 - CT_DoExecLog ALL \
1.93 - make cross-compiling=yes \
1.94 - install_root=${CT_SYSROOT_DIR} \
1.95 - CFLAGS="-O2 -DBOOTSTRAP_GCC" \
1.96 - ${LIBC_SYSROOT_ARG} \
1.97 - OBJDUMP_FOR_HOST="${CT_TARGET}-objdump" \
1.98 - PARALLELMFLAGS="${PARALLELMFLAGS}" \
1.99 - install-headers
1.100 -
1.101 - # Two headers -- stubs.h and features.h -- aren't installed by install-headers,
1.102 - # so do them by hand. We can tolerate an empty stubs.h for the moment.
1.103 - # See e.g. http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html
1.104 - mkdir -p "${CT_HEADERS_DIR}/gnu"
1.105 - CT_DoExecLog ALL touch "${CT_HEADERS_DIR}/gnu/stubs.h"
1.106 - CT_DoExecLog ALL cp -v "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/include/features.h" \
1.107 - "${CT_HEADERS_DIR}/features.h"
1.108 -
1.109 - # Building the bootstrap gcc requires either setting inhibit_libc, or
1.110 - # having a copy of stdio_lim.h... see
1.111 - # http://sources.redhat.com/ml/libc-alpha/2003-11/msg00045.html
1.112 - CT_DoExecLog ALL cp -v bits/stdio_lim.h "${CT_HEADERS_DIR}/bits/stdio_lim.h"
1.113 -
1.114 - # Following error building gcc-4.0.0's gcj:
1.115 - # error: bits/syscall.h: No such file or directory
1.116 - # solved by following copy; see http://sourceware.org/ml/crossgcc/2005-05/msg00168.html
1.117 - # but it breaks arm, see http://sourceware.org/ml/crossgcc/2006-01/msg00091.html
1.118 - [ "${CT_ARCH}" != "arm" ] && CT_DoExecLog ALL cp -v misc/syscall-list.h "${CT_HEADERS_DIR}/bits/syscall.h" || true
1.119 -
1.120 - # Those headers are to be manually copied so gcc can build properly
1.121 - pthread_h="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/${CT_THREADS}/sysdeps/pthread/pthread.h"
1.122 - pthreadtypes_h=
1.123 - case "${CT_THREADS}" in
1.124 - nptl)
1.125 - # NOTE: for some archs, the pathes are different, but they are not
1.126 - # supported by crosstool-NG right now. See original crosstool when they are.
1.127 - pthread_h="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/${CT_THREADS}/sysdeps/pthread/pthread.h"
1.128 - pthreadtypes_h="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/nptl/sysdeps/unix/sysv/linux/${arch4hdrs}/bits/pthreadtypes.h"
1.129 - if [ ! -f "${pthreadtypes_h}" ]; then
1.130 - pthreadtypes_h="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/ports/sysdeps/unix/sysv/linux/${arch4hdrs}/nptl/bits/pthreadtypes.h"
1.131 - fi
1.132 - ;;
1.133 - linuxthreads)
1.134 - pthreadtypes_h="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h"
1.135 - ;;
1.136 - *)
1.137 - pthread_h=
1.138 - pthreadtypes_h=
1.139 - ;;
1.140 - esac
1.141 - if [ -n "${pthread_h}" ]; then
1.142 - CT_DoExecLog ALL cp -v "${pthread_h}" "${CT_HEADERS_DIR}/pthread.h"
1.143 - fi
1.144 - if [ -n "${pthreadtypes_h}" ]; then
1.145 - CT_DoExecLog ALL cp -v "${pthreadtypes_h}" "${CT_HEADERS_DIR}/bits/pthreadtypes.h"
1.146 - fi
1.147 -
1.148 - CT_EndStep
1.149 -}
1.150 -
1.151 -# Build and install start files
1.152 -do_libc_start_files() {
1.153 - local -a extra_config
1.154 -
1.155 - # Needed only in the NPTL case. Otherwise, return.
1.156 - [ "${CT_THREADS}" = "nptl" ] || return 0
1.157 -
1.158 - CT_DoStep INFO "Installing C library start files"
1.159 -
1.160 - mkdir -p "${CT_BUILD_DIR}/build-libc-startfiles"
1.161 - cd "${CT_BUILD_DIR}/build-libc-startfiles"
1.162 -
1.163 - CT_DoLog EXTRA "Configuring C library"
1.164 -
1.165 - # Add some default glibc config options if not given by user.
1.166 - case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
1.167 - *-tls*) ;;
1.168 - *) extra_config+=("--with-tls")
1.169 - esac
1.170 - case "${CT_SHARED_LIBS}" in
1.171 - y) extra_config+=("--enable-shared");;
1.172 - *) extra_config+=("--disable-shared");;
1.173 - esac
1.174 - case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
1.175 - y,) extra_config+=("--with-fp");;
1.176 - ,y) extra_config+=("--without-fp");;
1.177 - esac
1.178 - # Obviously, we want threads, as we come here only for NPTL
1.179 - extra_config+=("--with-__thread")
1.180 -
1.181 - addons_config="--enable-add-ons=$(do_libc_add_ons_list ,)"
1.182 - extra_config+=("${addons_config}")
1.183 -
1.184 - extra_config+=("$(do_libc_min_kernel_config)")
1.185 -
1.186 - # Add some default CC args
1.187 - glibc_version="$( grep -E '\<VERSION\>' "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/version.h" \
1.188 - |cut -d '"' -f 2
1.189 - )"
1.190 - glibc_version_major=$(echo ${glibc_version} |sed -r -e 's/^([[:digit:]]+).*/\1/')
1.191 - glibc_version_minor=$(echo ${glibc_version} |sed -r -e 's/^[[:digit:]]+[\.-_]([[:digit:]]+).*/\1/')
1.192 - if [ ${glibc_version_major} -eq 2 -a ${glibc_version_minor} -ge 6 \
1.193 - -o ${glibc_version_major} -gt 2 ]; then
1.194 - # Don't use -pipe: configure chokes on it for glibc >= 2.6.
1.195 - CT_Test 'Removing "-pipe" for use with glibc>=2.6' "${CT_USE_PIPES}" = "y"
1.196 - extra_cc_args="${CT_CFLAGS_FOR_HOST/-pipe}"
1.197 - else
1.198 - extra_cc_args="${CT_CFLAGS_FOR_HOST}"
1.199 - fi
1.200 - extra_cc_args="${extra_cc_args} ${CT_ARCH_ENDIAN_OPT}"
1.201 -
1.202 - cross_cc=$(CT_Which "${CT_TARGET}-gcc")
1.203 - CT_DoLog DEBUG "Using gcc for target : '${cross_cc}'"
1.204 - CT_DoLog DEBUG "Configuring with addons : '$(do_libc_add_ons_list ,)'"
1.205 - CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'"
1.206 - CT_DoLog DEBUG "Extra CC args passed : '${extra_cc_args}'"
1.207 -
1.208 - # Pre-seed the configparms file with values from the config option
1.209 - printf "${CT_LIBC_GLIBC_CONFIGPARMS}\n" > configparms
1.210 -
1.211 - echo "libc_cv_forced_unwind=yes" > config.cache
1.212 - echo "libc_cv_c_cleanup=yes" >> config.cache
1.213 -
1.214 - # Please see the comment for the configure step in do_libc().
1.215 -
1.216 - BUILD_CC="${CT_BUILD}-gcc" \
1.217 - CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O2" \
1.218 - CC="${cross_cc} ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \
1.219 - AR=${CT_TARGET}-ar \
1.220 - RANLIB=${CT_TARGET}-ranlib \
1.221 - CT_DoExecLog CFG \
1.222 - "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/configure" \
1.223 - --prefix=/usr \
1.224 - --build="${CT_BUILD}" \
1.225 - --host=${CT_TARGET} \
1.226 - --without-cvs \
1.227 - --disable-profile \
1.228 - --disable-debug \
1.229 - --without-gd \
1.230 - --with-headers="${CT_HEADERS_DIR}" \
1.231 - --cache-file=config.cache \
1.232 - "${extra_config[@]}" \
1.233 - ${CT_LIBC_GLIBC_EXTRA_CONFIG}
1.234 -
1.235 - #TODO: should check whether slibdir has been set in configparms to */lib64
1.236 - # and copy the startfiles into the appropriate libdir.
1.237 - CT_DoLog EXTRA "Building C library start files"
1.238 - CT_DoExecLog ALL make OBJDUMP_FOR_HOST="${CT_TARGET}-objdump" \
1.239 - PARALLELMFLAGS="${PARALLELMFLAGS}" \
1.240 - csu/subdir_lib
1.241 -
1.242 - CT_DoLog EXTRA "Installing C library start files"
1.243 - if [ "${CT_USE_SYSROOT}" = "y" ]; then
1.244 - CT_DoExecLog ALL cp -fpv csu/crt[1in].o "${CT_SYSROOT_DIR}/usr/lib/"
1.245 - else
1.246 - CT_DoExecLog ALL cp -fpv csu/crt[1in].o "${CT_SYSROOT_DIR}/lib/"
1.247 - fi
1.248 -
1.249 - CT_EndStep
1.250 -}
1.251 -
1.252 # This function builds and install the full glibc
1.253 do_libc() {
1.254 local -a extra_config
1.255 @@ -492,11 +264,6 @@
1.256 CT_EndStep
1.257 }
1.258
1.259 -# This function finishes the glibc install
1.260 -do_libc_finish() {
1.261 - :
1.262 -}
1.263 -
1.264 # Build up the addons list, separated with $1
1.265 do_libc_add_ons_list() {
1.266 local sep="$1"