libc/glibc: use the common start_files procedure
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Jan 22 22:37:25 2011 +0100 (2011-01-22)
changeset 22720ff5b3570cd6
parent 2271 42ebee266fe5
child 2273 c6d2311442ad
libc/glibc: use the common start_files procedure

Use the common procedure, shared between glibc and eglibc. This requires
that glibc-specific bits be included in the shared procedure.

But still build the full libc with the glibc-specific procedure. This will
be commonalised in a future commit.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
scripts/build/libc/glibc-eglibc.sh-common
scripts/build/libc/glibc.sh
     1.1 --- a/scripts/build/libc/glibc-eglibc.sh-common	Mon Jan 17 23:04:57 2011 +0100
     1.2 +++ b/scripts/build/libc/glibc-eglibc.sh-common	Sat Jan 22 22:37:25 2011 +0100
     1.3 @@ -60,6 +60,28 @@
     1.4           install_root=${CT_SYSROOT_DIR} \
     1.5           install-bootstrap-headers=yes
     1.6  
     1.7 +    # For glibc, a few headers need to be manually installed
     1.8 +    if [ "${CT_LIBC}" = "glibc" ]; then
     1.9 +        # Two headers -- stubs.h and features.h -- aren't installed by install-headers,
    1.10 +        # so do them by hand.  We can tolerate an empty stubs.h for the moment.
    1.11 +        # See e.g. http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html
    1.12 +        mkdir -p "${CT_HEADERS_DIR}/gnu"
    1.13 +        CT_DoExecLog ALL touch "${CT_HEADERS_DIR}/gnu/stubs.h"
    1.14 +        CT_DoExecLog ALL cp -v "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/include/features.h"  \
    1.15 +                               "${CT_HEADERS_DIR}/features.h"
    1.16 +
    1.17 +        # Building the bootstrap gcc requires either setting inhibit_libc, or
    1.18 +        # having a copy of stdio_lim.h... see
    1.19 +        # http://sources.redhat.com/ml/libc-alpha/2003-11/msg00045.html
    1.20 +        CT_DoExecLog ALL cp -v bits/stdio_lim.h "${CT_HEADERS_DIR}/bits/stdio_lim.h"
    1.21 +
    1.22 +        # Following error building gcc-4.0.0's gcj:
    1.23 +        #  error: bits/syscall.h: No such file or directory
    1.24 +        # solved by following copy; see http://sourceware.org/ml/crossgcc/2005-05/msg00168.html
    1.25 +        # but it breaks arm, see http://sourceware.org/ml/crossgcc/2006-01/msg00091.html
    1.26 +        [ "${CT_ARCH}" != "arm" ] && CT_DoExecLog ALL cp -v misc/syscall-list.h "${CT_HEADERS_DIR}/bits/syscall.h" || true
    1.27 +    fi
    1.28 +
    1.29      CT_DoLog EXTRA "Installing C library start files"
    1.30  
    1.31      # there are a few object files needed to link shared libraries,
     2.1 --- a/scripts/build/libc/glibc.sh	Mon Jan 17 23:04:57 2011 +0100
     2.2 +++ b/scripts/build/libc/glibc.sh	Sat Jan 22 22:37:25 2011 +0100
     2.3 @@ -2,6 +2,11 @@
     2.4  # Copyright 2007 Yann E. MORIN
     2.5  # Licensed under the GPL v2. See COPYING in the root of this package
     2.6  
     2.7 +# Add the definitions common to glibc and eglibc
     2.8 +#   do_libc_headers
     2.9 +#   do_libc_start_files
    2.10 +. "${CT_LIB_DIR}/scripts/build/libc/glibc-eglibc.sh-common"
    2.11 +
    2.12  # Download glibc
    2.13  do_libc_get() {
    2.14      local date
    2.15 @@ -73,239 +78,6 @@
    2.16      :
    2.17  }
    2.18  
    2.19 -# This function installs the glibc headers needed to build the core compiler
    2.20 -do_libc_headers() {
    2.21 -    local -a extra_config
    2.22 -    local arch4hdrs
    2.23 -
    2.24 -    CT_DoStep INFO "Installing C library headers"
    2.25 -
    2.26 -    mkdir -p "${CT_BUILD_DIR}/build-libc-headers"
    2.27 -    cd "${CT_BUILD_DIR}/build-libc-headers"
    2.28 -
    2.29 -    CT_DoLog EXTRA "Configuring C library"
    2.30 -
    2.31 -    # The x86 arch needs special care... Bizarelly enough... :-(
    2.32 -    case "${CT_ARCH}:${CT_ARCH_BITNESS}" in
    2.33 -        x86:32) arch4hdrs="i386";;
    2.34 -        x86:64) arch4hdrs="x86_64";;
    2.35 -        *)      arch4hdrs="${CT_ARCH}";;
    2.36 -    esac
    2.37 -
    2.38 -    # The following three things have to be done to build glibc-2.3.x, but they don't hurt older versions.
    2.39 -    # 1. override CC to keep glibc's configure from using $TARGET-gcc. 
    2.40 -    # 2. disable linuxthreads, which needs a real cross-compiler to generate tcb-offsets.h properly
    2.41 -    # 3. build with gcc 3.2 or later
    2.42 -    # Compare these options with the ones used when building glibc for real below - they're different.
    2.43 -    # As of glibc-2.3.2, to get this step to work for hppa-linux, you need --enable-hacker-mode
    2.44 -    # so when configure checks to make sure gcc has access to the assembler you just built...
    2.45 -    # Alternately, we could put ${PREFIX}/${TARGET}/bin on the path.
    2.46 -    # Set --build so maybe we don't have to specify "cross-compiling=yes" below (haven't tried yet)
    2.47 -    # Note: the warning
    2.48 -    # "*** WARNING: Are you sure you do not want to use the `linuxthreads'"
    2.49 -    # *** add-on?"
    2.50 -    # is ok here, since all we want are the basic headers at this point.
    2.51 -    # Override libc_cv_ppc_machine so glibc-cvs doesn't complain
    2.52 -    # 'a version of binutils that supports .machine "altivec" is needed'.
    2.53 -
    2.54 -    # We need to remove any threading addon when installing headers
    2.55 -    addons_list="$(do_libc_add_ons_list " "                     \
    2.56 -                   |sed -r -e 's/\<(nptl|linuxthreads)\>/ /g;'  \
    2.57 -                           -e 's/ +/,/g; s/^,+//; s/,+$//;'     \
    2.58 -                  )"
    2.59 -
    2.60 -    extra_config+=("--enable-add-ons=${addons_list}")
    2.61 -
    2.62 -    extra_config+=("${addons_config}")
    2.63 -    extra_config+=("$(do_libc_min_kernel_config)")
    2.64 -
    2.65 -    # Pre-seed the configparms file with values from the config option
    2.66 -    printf "${CT_LIBC_GLIBC_CONFIGPARMS}\n" > configparms
    2.67 -
    2.68 -    cross_cc=$(CT_Which "${CT_TARGET}-gcc")
    2.69 -    CT_DoLog DEBUG "Using gcc for target: '${cross_cc}'"
    2.70 -    CT_DoLog DEBUG "Extra config passed : '${extra_config[*]}'"
    2.71 -
    2.72 -    libc_cv_ppc_machine=yes                                     \
    2.73 -    libc_cv_mlong_double_128=yes                                \
    2.74 -    libc_cv_mlong_double_128ibm=yes                             \
    2.75 -    CC=${cross_cc}                                              \
    2.76 -    CT_DoExecLog CFG                                            \
    2.77 -    "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/configure"          \
    2.78 -        --build="${CT_BUILD}"                                   \
    2.79 -        --host="${CT_TARGET}"                                   \
    2.80 -        --prefix=/usr                                           \
    2.81 -        --with-headers="${CT_HEADERS_DIR}"                      \
    2.82 -        --without-cvs                                           \
    2.83 -        --disable-sanity-checks                                 \
    2.84 -        --enable-hacker-mode                                    \
    2.85 -        "${extra_config[@]}"                                    \
    2.86 -        --without-nptl
    2.87 -
    2.88 -    CT_DoLog EXTRA "Installing C library headers"
    2.89 -
    2.90 -    # Note: BOOTSTRAP_GCC (see above)
    2.91 -    libc_cv_ppc_machine=yes                         \
    2.92 -    CT_DoExecLog ALL                                \
    2.93 -    make cross-compiling=yes                        \
    2.94 -         install_root=${CT_SYSROOT_DIR}             \
    2.95 -         CFLAGS="-O2 -DBOOTSTRAP_GCC"               \
    2.96 -         ${LIBC_SYSROOT_ARG}                        \
    2.97 -         OBJDUMP_FOR_HOST="${CT_TARGET}-objdump"    \
    2.98 -         PARALLELMFLAGS="${PARALLELMFLAGS}"         \
    2.99 -         install-headers
   2.100 -
   2.101 -    # Two headers -- stubs.h and features.h -- aren't installed by install-headers,
   2.102 -    # so do them by hand.  We can tolerate an empty stubs.h for the moment.
   2.103 -    # See e.g. http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html
   2.104 -    mkdir -p "${CT_HEADERS_DIR}/gnu"
   2.105 -    CT_DoExecLog ALL touch "${CT_HEADERS_DIR}/gnu/stubs.h"
   2.106 -    CT_DoExecLog ALL cp -v "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/include/features.h"  \
   2.107 -                           "${CT_HEADERS_DIR}/features.h"
   2.108 -
   2.109 -    # Building the bootstrap gcc requires either setting inhibit_libc, or
   2.110 -    # having a copy of stdio_lim.h... see
   2.111 -    # http://sources.redhat.com/ml/libc-alpha/2003-11/msg00045.html
   2.112 -    CT_DoExecLog ALL cp -v bits/stdio_lim.h "${CT_HEADERS_DIR}/bits/stdio_lim.h"
   2.113 -
   2.114 -    # Following error building gcc-4.0.0's gcj:
   2.115 -    #  error: bits/syscall.h: No such file or directory
   2.116 -    # solved by following copy; see http://sourceware.org/ml/crossgcc/2005-05/msg00168.html
   2.117 -    # but it breaks arm, see http://sourceware.org/ml/crossgcc/2006-01/msg00091.html
   2.118 -    [ "${CT_ARCH}" != "arm" ] && CT_DoExecLog ALL cp -v misc/syscall-list.h "${CT_HEADERS_DIR}/bits/syscall.h" || true
   2.119 -
   2.120 -    # Those headers are to be manually copied so gcc can build properly
   2.121 -    pthread_h="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/${CT_THREADS}/sysdeps/pthread/pthread.h"
   2.122 -    pthreadtypes_h=
   2.123 -    case "${CT_THREADS}" in
   2.124 -        nptl)
   2.125 -            # NOTE: for some archs, the pathes are different, but they are not
   2.126 -            # supported by crosstool-NG right now. See original crosstool when they are.
   2.127 -            pthread_h="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/${CT_THREADS}/sysdeps/pthread/pthread.h"
   2.128 -            pthreadtypes_h="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/nptl/sysdeps/unix/sysv/linux/${arch4hdrs}/bits/pthreadtypes.h"
   2.129 -            if [ ! -f "${pthreadtypes_h}" ]; then
   2.130 -                pthreadtypes_h="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/ports/sysdeps/unix/sysv/linux/${arch4hdrs}/nptl/bits/pthreadtypes.h"
   2.131 -            fi
   2.132 -            ;;
   2.133 -        linuxthreads)
   2.134 -            pthreadtypes_h="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h"
   2.135 -            ;;
   2.136 -        *)
   2.137 -            pthread_h=
   2.138 -            pthreadtypes_h=
   2.139 -            ;;
   2.140 -    esac
   2.141 -    if [ -n "${pthread_h}" ]; then
   2.142 -        CT_DoExecLog ALL cp -v "${pthread_h}" "${CT_HEADERS_DIR}/pthread.h"
   2.143 -    fi
   2.144 -    if [ -n "${pthreadtypes_h}" ]; then
   2.145 -        CT_DoExecLog ALL cp -v "${pthreadtypes_h}" "${CT_HEADERS_DIR}/bits/pthreadtypes.h"
   2.146 -    fi
   2.147 -
   2.148 -    CT_EndStep
   2.149 -}
   2.150 -
   2.151 -# Build and install start files
   2.152 -do_libc_start_files() {
   2.153 -    local -a extra_config
   2.154 -
   2.155 -    # Needed only in the NPTL case. Otherwise, return.
   2.156 -    [ "${CT_THREADS}" = "nptl" ] || return 0
   2.157 -
   2.158 -    CT_DoStep INFO "Installing C library start files"
   2.159 -
   2.160 -    mkdir -p "${CT_BUILD_DIR}/build-libc-startfiles"
   2.161 -    cd "${CT_BUILD_DIR}/build-libc-startfiles"
   2.162 -
   2.163 -    CT_DoLog EXTRA "Configuring C library"
   2.164 -
   2.165 -    # Add some default glibc config options if not given by user.
   2.166 -    case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
   2.167 -        *-tls*) ;;
   2.168 -        *) extra_config+=("--with-tls")
   2.169 -    esac
   2.170 -    case "${CT_SHARED_LIBS}" in
   2.171 -        y) extra_config+=("--enable-shared");;
   2.172 -        *) extra_config+=("--disable-shared");;
   2.173 -    esac
   2.174 -    case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
   2.175 -        y,) extra_config+=("--with-fp");;
   2.176 -        ,y) extra_config+=("--without-fp");;
   2.177 -    esac
   2.178 -    # Obviously, we want threads, as we come here only for NPTL
   2.179 -    extra_config+=("--with-__thread")
   2.180 -
   2.181 -    addons_config="--enable-add-ons=$(do_libc_add_ons_list ,)"
   2.182 -    extra_config+=("${addons_config}")
   2.183 -
   2.184 -    extra_config+=("$(do_libc_min_kernel_config)")
   2.185 -
   2.186 -    # Add some default CC args
   2.187 -    glibc_version="$( grep -E '\<VERSION\>' "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/version.h"  \
   2.188 -                      |cut -d '"' -f 2
   2.189 -                    )"
   2.190 -    glibc_version_major=$(echo ${glibc_version} |sed -r -e 's/^([[:digit:]]+).*/\1/')
   2.191 -    glibc_version_minor=$(echo ${glibc_version} |sed -r -e 's/^[[:digit:]]+[\.-_]([[:digit:]]+).*/\1/')
   2.192 -    if [    ${glibc_version_major} -eq 2 -a ${glibc_version_minor} -ge 6    \
   2.193 -         -o ${glibc_version_major} -gt 2                                    ]; then
   2.194 -        # Don't use -pipe: configure chokes on it for glibc >= 2.6.
   2.195 -        CT_Test 'Removing "-pipe" for use with glibc>=2.6' "${CT_USE_PIPES}" = "y"
   2.196 -        extra_cc_args="${CT_CFLAGS_FOR_HOST/-pipe}"
   2.197 -    else
   2.198 -        extra_cc_args="${CT_CFLAGS_FOR_HOST}"
   2.199 -    fi
   2.200 -    extra_cc_args="${extra_cc_args} ${CT_ARCH_ENDIAN_OPT}"
   2.201 -
   2.202 -    cross_cc=$(CT_Which "${CT_TARGET}-gcc")
   2.203 -    CT_DoLog DEBUG "Using gcc for target    : '${cross_cc}'"
   2.204 -    CT_DoLog DEBUG "Configuring with addons : '$(do_libc_add_ons_list ,)'"
   2.205 -    CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'"
   2.206 -    CT_DoLog DEBUG "Extra CC args passed    : '${extra_cc_args}'"
   2.207 -
   2.208 -    # Pre-seed the configparms file with values from the config option
   2.209 -    printf "${CT_LIBC_GLIBC_CONFIGPARMS}\n" > configparms
   2.210 -
   2.211 -    echo "libc_cv_forced_unwind=yes" > config.cache
   2.212 -    echo "libc_cv_c_cleanup=yes" >> config.cache
   2.213 -
   2.214 -    # Please see the comment for the configure step in do_libc().
   2.215 -
   2.216 -    BUILD_CC="${CT_BUILD}-gcc"                                      \
   2.217 -    CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O2"  \
   2.218 -    CC="${cross_cc} ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}"      \
   2.219 -    AR=${CT_TARGET}-ar                                              \
   2.220 -    RANLIB=${CT_TARGET}-ranlib                                      \
   2.221 -    CT_DoExecLog CFG                                                \
   2.222 -    "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/configure"              \
   2.223 -        --prefix=/usr                                               \
   2.224 -        --build="${CT_BUILD}"                                       \
   2.225 -        --host=${CT_TARGET}                                         \
   2.226 -        --without-cvs                                               \
   2.227 -        --disable-profile                                           \
   2.228 -        --disable-debug                                             \
   2.229 -        --without-gd                                                \
   2.230 -        --with-headers="${CT_HEADERS_DIR}"                          \
   2.231 -        --cache-file=config.cache                                   \
   2.232 -        "${extra_config[@]}"                                        \
   2.233 -        ${CT_LIBC_GLIBC_EXTRA_CONFIG}
   2.234 -
   2.235 -    #TODO: should check whether slibdir has been set in configparms to */lib64
   2.236 -    #      and copy the startfiles into the appropriate libdir.
   2.237 -    CT_DoLog EXTRA "Building C library start files"
   2.238 -    CT_DoExecLog ALL make OBJDUMP_FOR_HOST="${CT_TARGET}-objdump"   \
   2.239 -                          PARALLELMFLAGS="${PARALLELMFLAGS}"        \
   2.240 -                          csu/subdir_lib
   2.241 -
   2.242 -    CT_DoLog EXTRA "Installing C library start files"
   2.243 -    if [ "${CT_USE_SYSROOT}" = "y" ]; then
   2.244 -        CT_DoExecLog ALL cp -fpv csu/crt[1in].o "${CT_SYSROOT_DIR}/usr/lib/"
   2.245 -    else
   2.246 -        CT_DoExecLog ALL cp -fpv csu/crt[1in].o "${CT_SYSROOT_DIR}/lib/"
   2.247 -    fi
   2.248 -
   2.249 -    CT_EndStep
   2.250 -}
   2.251 -
   2.252  # This function builds and install the full glibc
   2.253  do_libc() {
   2.254      local -a extra_config
   2.255 @@ -492,11 +264,6 @@
   2.256      CT_EndStep
   2.257  }
   2.258  
   2.259 -# This function finishes the glibc install
   2.260 -do_libc_finish() {
   2.261 -    :
   2.262 -}
   2.263 -
   2.264  # Build up the addons list, separated with $1
   2.265  do_libc_add_ons_list() {
   2.266      local sep="$1"