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>
This commit is contained in:
Yann E. MORIN" 2011-01-22 22:37:25 +01:00
parent b43ff236bb
commit b560936e09
2 changed files with 27 additions and 238 deletions

View File

@ -60,6 +60,28 @@ do_libc_start_files() {
install_root=${CT_SYSROOT_DIR} \
install-bootstrap-headers=yes
# For glibc, a few headers need to be manually installed
if [ "${CT_LIBC}" = "glibc" ]; then
# Two headers -- stubs.h and features.h -- aren't installed by install-headers,
# so do them by hand. We can tolerate an empty stubs.h for the moment.
# See e.g. http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html
mkdir -p "${CT_HEADERS_DIR}/gnu"
CT_DoExecLog ALL touch "${CT_HEADERS_DIR}/gnu/stubs.h"
CT_DoExecLog ALL cp -v "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/include/features.h" \
"${CT_HEADERS_DIR}/features.h"
# Building the bootstrap gcc requires either setting inhibit_libc, or
# having a copy of stdio_lim.h... see
# http://sources.redhat.com/ml/libc-alpha/2003-11/msg00045.html
CT_DoExecLog ALL cp -v bits/stdio_lim.h "${CT_HEADERS_DIR}/bits/stdio_lim.h"
# Following error building gcc-4.0.0's gcj:
# error: bits/syscall.h: No such file or directory
# solved by following copy; see http://sourceware.org/ml/crossgcc/2005-05/msg00168.html
# but it breaks arm, see http://sourceware.org/ml/crossgcc/2006-01/msg00091.html
[ "${CT_ARCH}" != "arm" ] && CT_DoExecLog ALL cp -v misc/syscall-list.h "${CT_HEADERS_DIR}/bits/syscall.h" || true
fi
CT_DoLog EXTRA "Installing C library start files"
# there are a few object files needed to link shared libraries,

View File

@ -2,6 +2,11 @@
# Copyright 2007 Yann E. MORIN
# Licensed under the GPL v2. See COPYING in the root of this package
# Add the definitions common to glibc and eglibc
# do_libc_headers
# do_libc_start_files
. "${CT_LIB_DIR}/scripts/build/libc/glibc-eglibc.sh-common"
# Download glibc
do_libc_get() {
local date
@ -73,239 +78,6 @@ do_libc_check_config() {
:
}
# This function installs the glibc headers needed to build the core compiler
do_libc_headers() {
local -a extra_config
local arch4hdrs
CT_DoStep INFO "Installing C library headers"
mkdir -p "${CT_BUILD_DIR}/build-libc-headers"
cd "${CT_BUILD_DIR}/build-libc-headers"
CT_DoLog EXTRA "Configuring C library"
# The x86 arch needs special care... Bizarelly enough... :-(
case "${CT_ARCH}:${CT_ARCH_BITNESS}" in
x86:32) arch4hdrs="i386";;
x86:64) arch4hdrs="x86_64";;
*) arch4hdrs="${CT_ARCH}";;
esac
# The following three things have to be done to build glibc-2.3.x, but they don't hurt older versions.
# 1. override CC to keep glibc's configure from using $TARGET-gcc.
# 2. disable linuxthreads, which needs a real cross-compiler to generate tcb-offsets.h properly
# 3. build with gcc 3.2 or later
# Compare these options with the ones used when building glibc for real below - they're different.
# As of glibc-2.3.2, to get this step to work for hppa-linux, you need --enable-hacker-mode
# so when configure checks to make sure gcc has access to the assembler you just built...
# Alternately, we could put ${PREFIX}/${TARGET}/bin on the path.
# Set --build so maybe we don't have to specify "cross-compiling=yes" below (haven't tried yet)
# Note: the warning
# "*** WARNING: Are you sure you do not want to use the `linuxthreads'"
# *** add-on?"
# is ok here, since all we want are the basic headers at this point.
# Override libc_cv_ppc_machine so glibc-cvs doesn't complain
# 'a version of binutils that supports .machine "altivec" is needed'.
# We need to remove any threading addon when installing headers
addons_list="$(do_libc_add_ons_list " " \
|sed -r -e 's/\<(nptl|linuxthreads)\>/ /g;' \
-e 's/ +/,/g; s/^,+//; s/,+$//;' \
)"
extra_config+=("--enable-add-ons=${addons_list}")
extra_config+=("${addons_config}")
extra_config+=("$(do_libc_min_kernel_config)")
# Pre-seed the configparms file with values from the config option
printf "${CT_LIBC_GLIBC_CONFIGPARMS}\n" > configparms
cross_cc=$(CT_Which "${CT_TARGET}-gcc")
CT_DoLog DEBUG "Using gcc for target: '${cross_cc}'"
CT_DoLog DEBUG "Extra config passed : '${extra_config[*]}'"
libc_cv_ppc_machine=yes \
libc_cv_mlong_double_128=yes \
libc_cv_mlong_double_128ibm=yes \
CC=${cross_cc} \
CT_DoExecLog CFG \
"${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/configure" \
--build="${CT_BUILD}" \
--host="${CT_TARGET}" \
--prefix=/usr \
--with-headers="${CT_HEADERS_DIR}" \
--without-cvs \
--disable-sanity-checks \
--enable-hacker-mode \
"${extra_config[@]}" \
--without-nptl
CT_DoLog EXTRA "Installing C library headers"
# Note: BOOTSTRAP_GCC (see above)
libc_cv_ppc_machine=yes \
CT_DoExecLog ALL \
make cross-compiling=yes \
install_root=${CT_SYSROOT_DIR} \
CFLAGS="-O2 -DBOOTSTRAP_GCC" \
${LIBC_SYSROOT_ARG} \
OBJDUMP_FOR_HOST="${CT_TARGET}-objdump" \
PARALLELMFLAGS="${PARALLELMFLAGS}" \
install-headers
# Two headers -- stubs.h and features.h -- aren't installed by install-headers,
# so do them by hand. We can tolerate an empty stubs.h for the moment.
# See e.g. http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html
mkdir -p "${CT_HEADERS_DIR}/gnu"
CT_DoExecLog ALL touch "${CT_HEADERS_DIR}/gnu/stubs.h"
CT_DoExecLog ALL cp -v "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/include/features.h" \
"${CT_HEADERS_DIR}/features.h"
# Building the bootstrap gcc requires either setting inhibit_libc, or
# having a copy of stdio_lim.h... see
# http://sources.redhat.com/ml/libc-alpha/2003-11/msg00045.html
CT_DoExecLog ALL cp -v bits/stdio_lim.h "${CT_HEADERS_DIR}/bits/stdio_lim.h"
# Following error building gcc-4.0.0's gcj:
# error: bits/syscall.h: No such file or directory
# solved by following copy; see http://sourceware.org/ml/crossgcc/2005-05/msg00168.html
# but it breaks arm, see http://sourceware.org/ml/crossgcc/2006-01/msg00091.html
[ "${CT_ARCH}" != "arm" ] && CT_DoExecLog ALL cp -v 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="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/${CT_THREADS}/sysdeps/pthread/pthread.h"
pthreadtypes_h=
case "${CT_THREADS}" in
nptl)
# NOTE: for some archs, the pathes are different, but they are not
# supported by crosstool-NG right now. See original crosstool when they are.
pthread_h="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/${CT_THREADS}/sysdeps/pthread/pthread.h"
pthreadtypes_h="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/nptl/sysdeps/unix/sysv/linux/${arch4hdrs}/bits/pthreadtypes.h"
if [ ! -f "${pthreadtypes_h}" ]; then
pthreadtypes_h="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/ports/sysdeps/unix/sysv/linux/${arch4hdrs}/nptl/bits/pthreadtypes.h"
fi
;;
linuxthreads)
pthreadtypes_h="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h"
;;
*)
pthread_h=
pthreadtypes_h=
;;
esac
if [ -n "${pthread_h}" ]; then
CT_DoExecLog ALL cp -v "${pthread_h}" "${CT_HEADERS_DIR}/pthread.h"
fi
if [ -n "${pthreadtypes_h}" ]; then
CT_DoExecLog ALL cp -v "${pthreadtypes_h}" "${CT_HEADERS_DIR}/bits/pthreadtypes.h"
fi
CT_EndStep
}
# Build and install start files
do_libc_start_files() {
local -a extra_config
# Needed only in the NPTL case. Otherwise, return.
[ "${CT_THREADS}" = "nptl" ] || return 0
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"
# Add some default glibc config options if not given by user.
case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
*-tls*) ;;
*) extra_config+=("--with-tls")
esac
case "${CT_SHARED_LIBS}" in
y) extra_config+=("--enable-shared");;
*) extra_config+=("--disable-shared");;
esac
case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
y,) extra_config+=("--with-fp");;
,y) extra_config+=("--without-fp");;
esac
# Obviously, we want threads, as we come here only for NPTL
extra_config+=("--with-__thread")
addons_config="--enable-add-ons=$(do_libc_add_ons_list ,)"
extra_config+=("${addons_config}")
extra_config+=("$(do_libc_min_kernel_config)")
# Add some default CC args
glibc_version="$( grep -E '\<VERSION\>' "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/version.h" \
|cut -d '"' -f 2
)"
glibc_version_major=$(echo ${glibc_version} |sed -r -e 's/^([[:digit:]]+).*/\1/')
glibc_version_minor=$(echo ${glibc_version} |sed -r -e 's/^[[:digit:]]+[\.-_]([[:digit:]]+).*/\1/')
if [ ${glibc_version_major} -eq 2 -a ${glibc_version_minor} -ge 6 \
-o ${glibc_version_major} -gt 2 ]; then
# Don't use -pipe: configure chokes on it for glibc >= 2.6.
CT_Test 'Removing "-pipe" for use with glibc>=2.6' "${CT_USE_PIPES}" = "y"
extra_cc_args="${CT_CFLAGS_FOR_HOST/-pipe}"
else
extra_cc_args="${CT_CFLAGS_FOR_HOST}"
fi
extra_cc_args="${extra_cc_args} ${CT_ARCH_ENDIAN_OPT}"
cross_cc=$(CT_Which "${CT_TARGET}-gcc")
CT_DoLog DEBUG "Using gcc for target : '${cross_cc}'"
CT_DoLog DEBUG "Configuring with addons : '$(do_libc_add_ons_list ,)'"
CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'"
CT_DoLog DEBUG "Extra CC args passed : '${extra_cc_args}'"
# Pre-seed the configparms file with values from the config option
printf "${CT_LIBC_GLIBC_CONFIGPARMS}\n" > 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_BUILD}-gcc" \
CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O2" \
CC="${cross_cc} ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \
AR=${CT_TARGET}-ar \
RANLIB=${CT_TARGET}-ranlib \
CT_DoExecLog CFG \
"${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/configure" \
--prefix=/usr \
--build="${CT_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}
#TODO: should check whether slibdir has been set in configparms to */lib64
# and copy the startfiles into the appropriate libdir.
CT_DoLog EXTRA "Building C library start files"
CT_DoExecLog ALL make OBJDUMP_FOR_HOST="${CT_TARGET}-objdump" \
PARALLELMFLAGS="${PARALLELMFLAGS}" \
csu/subdir_lib
CT_DoLog EXTRA "Installing C library start files"
if [ "${CT_USE_SYSROOT}" = "y" ]; then
CT_DoExecLog ALL cp -fpv csu/crt[1in].o "${CT_SYSROOT_DIR}/usr/lib/"
else
CT_DoExecLog ALL cp -fpv csu/crt[1in].o "${CT_SYSROOT_DIR}/lib/"
fi
CT_EndStep
}
# This function builds and install the full glibc
do_libc() {
local -a extra_config
@ -492,11 +264,6 @@ do_libc() {
CT_EndStep
}
# This function finishes the glibc install
do_libc_finish() {
:
}
# Build up the addons list, separated with $1
do_libc_add_ons_list() {
local sep="$1"