From 129bf2fa66e33b248f5560af96fe2485643f42b1 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Sat, 22 Jan 2011 22:35:58 +0100 Subject: libc/glibc: add glibc specifics to the shared code, and use it Final step at sharing code between glibc and eglibc. Fall, wall of shame, fall!... :-) Signed-off-by: "Yann E. MORIN" diff --git a/scripts/build/libc/glibc-eglibc.sh-common b/scripts/build/libc/glibc-eglibc.sh-common index 50cd450..4c60b4b 100644 --- a/scripts/build/libc/glibc-eglibc.sh-common +++ b/scripts/build/libc/glibc-eglibc.sh-common @@ -107,6 +107,7 @@ do_libc_start_files() { # This function builds and install the full C library do_libc() { local src_dir="${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}" + local extra_cc_args local -a extra_config local -a extra_make_args @@ -128,6 +129,12 @@ do_libc() { OPTIMIZE=-O2 fi ;; + glibc) + # glibc can't be built without -O2 (reference needed!) + OPTIMIZE=-O2 + # Also, if those two are missing, iconv build breaks + extra_config+=( --disable-debug --disable-sanity-checks ) + ;; esac # Add some default glibc config options if not given by user. @@ -172,6 +179,9 @@ do_libc() { extra_cc_args="${extra_cc_args} ${CT_ARCH_ENDIAN_OPT}" + # 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}'" @@ -192,6 +202,14 @@ do_libc() { # or even after they get installed... eglibc is such a sucker... echo "ac_cv_path_BASH_SHELL=/bin/bash" >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 + # to read up on what they all mean, and customize a bit, possibly by setting GLIBC_EXTRA_CONFIG + # Compare these options with the ones used when installing the glibc headers above - they're different. + # Adding "--without-gd" option to avoid error "memusagestat.c:36:16: gd.h: No such file or directory" + # See also http://sources.redhat.com/ml/libc-alpha/2000-07/msg00024.html. + # Set BUILD_CC, or we won't be able to build datafiles + BUILD_CC="${CT_BUILD}-gcc" \ CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} ${OPTIMIZE}" \ CC="${CT_TARGET}-gcc ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \ @@ -200,36 +218,35 @@ do_libc() { CT_DoExecLog CFG \ "${src_dir}/configure" \ --prefix=/usr \ - --with-headers="${CT_HEADERS_DIR}" \ --build=${CT_BUILD} \ --host=${CT_TARGET} \ + --without-cvs \ --disable-profile \ --without-gd \ - --without-cvs \ --cache-file=config.cache \ + --with-headers="${CT_HEADERS_DIR}" \ "${extra_config[@]}" \ ${CT_LIBC_GLIBC_EXTRA_CONFIG} - CT_DoLog EXTRA "Building C library" - - # eglibc build hacks - case "${CT_LIBC}" in - eglibc) - case "${CT_ARCH},${CT_ARCH_CPU}" in - powerpc,8??) - # http://sourceware.org/ml/crossgcc/2008-10/msg00068.html - CT_DoLog DEBUG "Activating support for memset on broken ppc-8xx (CPU15 erratum)" - extra_make_args+=( ASFLAGS="-DBROKEN_PPC_8xx_CPU15" ) - ;; - esac + # build hacks + case "${CT_ARCH},${CT_ARCH_CPU}" in + powerpc,8??) + # http://sourceware.org/ml/crossgcc/2008-10/msg00068.html + CT_DoLog DEBUG "Activating support for memset on broken ppc-8xx (CPU15 erratum)" + extra_make_args+=( ASFLAGS="-DBROKEN_PPC_8xx_CPU15" ) ;; esac - CT_DoExecLog ALL make -j${CT_PARALLEL_JOBS} "${extra_make_args[@]}" + CT_DoLog EXTRA "Building C library" + CT_DoExecLog ALL make -j${CT_PARALLEL_JOBS} \ + "${extra_make_args[@]}" \ + all CT_DoLog EXTRA "Installing C library" - - CT_DoExecLog ALL make install "${extra_make_args[@]}" install_root="${CT_SYSROOT_DIR}" + CT_DoExecLog ALL make -j${CT_PARALLEL_JOBS} \ + "${extra_make_args[@]}" \ + install_root="${CT_SYSROOT_DIR}" \ + install CT_EndStep } @@ -280,8 +297,8 @@ do_libc_min_kernel_config() { min_kernel_config="${version}.${patchlevel}.${sublevel}" elif [ "${CT_LIBC_GLIBC_KERNEL_VERSION_CHOSEN}" = "y" ]; then # Trim the fourth part of the linux version, keeping only the first three numbers - min_kernel_config="$( echo "${CT_LIBC_GLIBC_MIN_KERNEL_VERSION}" \ - |sed -r -e 's/^([^.]+\.[^.]+\.[^.]+)(|\.[^.]+)$/\1/;')" \ + min_kernel_config="$( echo "${CT_LIBC_GLIBC_MIN_KERNEL_VERSION}" \ + |sed -r -e 's/^([^.]+\.[^.]+\.[^.]+)(|\.[^.]+)$/\1/;' \ )" fi echo "--enable-kernel=${min_kernel_config}" diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index 4c20553..fad673c 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -77,187 +77,3 @@ do_libc_extract() { do_libc_check_config() { : } - -# This function builds and install the full glibc -do_libc() { - local -a extra_config - - 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 - - case "${CT_THREADS}" in - nptl) extra_config+=("--with-__thread" "--with-tls");; - linuxthreads) extra_config+=("--with-__thread" "--without-tls" "--without-nptl");; - none) extra_config+=("--without-__thread" "--without-nptl") - case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in - *-tls*) ;; - *) extra_config+=("--without-tls");; - esac - ;; - 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 - - if [ "${CT_LIBC_DISABLE_VERSIONING}" = "y" ]; then - extra_config+=("--disable-versioning") - fi - - if [ "${CT_LIBC_OLDEST_ABI}" != "" ]; then - extra_config+=("--enable-oldest-abi=${CT_LIBC_OLDEST_ABI}") - fi - - case "$(do_libc_add_ons_list ,)" in - "") ;; - *) extra_config+=("--enable-add-ons=$(do_libc_add_ons_list ,)");; - esac - - extra_config+=("$(do_libc_min_kernel_config)") - - # Add some default CC args - glibc_version="$( grep -E '\' "${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 - - # 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 [ "${CT_THREADS}" = "nptl" ]; then - echo libc_cv_forced_unwind=yes - echo libc_cv_c_cleanup=yes - fi >config.cache - - # ./configure is mislead by our tools override wrapper for bash - # so just tell it where the real bash is _on_the_target_! - # Notes: - # - ${ac_cv_path_BASH_SHELL} is only used to set BASH_SHELL - # - ${BASH_SHELL} is only used to set BASH - # - ${BASH} is only used to set the shebang - # in two scripts to run on the target - # So we can safely bypass bash detection at compile time. - # Should this change in a future glibc release, we'd better - # directly mangle the generated scripts _after_ they get built, - # or even after they get installed... glibc is such a sucker... - echo "ac_cv_path_BASH_SHELL=/bin/bash" >>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 - # to read up on what they all mean, and customize a bit, possibly by setting GLIBC_EXTRA_CONFIG - # Compare these options with the ones used when installing the glibc headers above - they're different. - # Adding "--without-gd" option to avoid error "memusagestat.c:36:16: gd.h: No such file or directory" - # See also http://sources.redhat.com/ml/libc-alpha/2000-07/msg00024.html. - # 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_BUILD}-gcc" \ - CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O2" \ - CC="${CT_TARGET}-gcc ${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 \ - --disable-sanity-checks \ - --cache-file=config.cache \ - --with-headers="${CT_HEADERS_DIR}" \ - "${extra_config[@]}" \ - ${CT_LIBC_GLIBC_EXTRA_CONFIG} - - # glibc initial build hacks - # http://sourceware.org/ml/crossgcc/2008-10/msg00068.html - case "${CT_ARCH},${CT_ARCH_CPU}" in - powerpc,8??) - CT_DoLog DEBUG "Activating support for memset on broken ppc-8xx (CPU15 erratum)" - GLIBC_INITIAL_BUILD_ASFLAGS="-DBROKEN_PPC_8xx_CPU15";; - esac - - # If this fails with an error like this: - # ... linux/autoconf.h: No such file or directory - # then you need to set the KERNELCONFIG variable to point to a .config file for this arch. - # The following architectures are known to need kernel .config: alpha, arm, ia64, s390, sh, sparc - # Note: LD and RANLIB needed by glibc-2.1.3's c_stub directory, at least on macosx - CT_DoLog EXTRA "Building C library" - CT_DoExecLog ALL make LD=${CT_TARGET}-ld \ - RANLIB=${CT_TARGET}-ranlib \ - OBJDUMP_FOR_HOST="${CT_TARGET}-objdump" \ - ASFLAGS="${GLIBC_INITIAL_BUILD_ASFLAGS}" \ - all - - CT_DoLog EXTRA "Installing C library" - CT_DoExecLog ALL make install_root="${CT_SYSROOT_DIR}" \ - ${LIBC_SYSROOT_ARG} \ - OBJDUMP_FOR_HOST="${CT_TARGET}-objdump" \ - install - - # This doesn't seem to work when building a crosscompiler, - # as it tries to execute localedef using the just-built ld.so!? - #CT_DoLog EXTRA "Installing locales" - #make localedata/install-locales install_root=${SYSROOT} 2>&1 |CT_DoLog ALL - - # Fix problems in linker scripts. - # - # Remove lines containing BUG per http://sources.redhat.com/ml/bug-glibc/2003-05/msg00055.html, - # needed to fix gcc-3.2.3/glibc-2.3.2 targeting arm - # No need to look into the lib64/ dirs here and there, they point to the - # corresponding lib/ directories. - # - # To make "strip *.so.*" not fail (ptxdist does this), rename to .so_orig rather than .so.orig - CT_DoLog EXTRA "Fixing C library linker scripts" - for file in libc.so libpthread.so libgcc_s.so; do - for dir in lib usr/lib; do - if [ -f "${CT_SYSROOT_DIR}/${dir}/${file}" -a ! -L ${CT_SYSROOT_DIR}/$lib/$file ]; then - CT_DoExecLog ALL cp -v "${CT_SYSROOT_DIR}/${dir}/${file}" "${CT_SYSROOT_DIR}/${dir}/${file}_orig" - CT_DoLog DEBUG "Fixing '${CT_SYS_ROOT_DIR}/${dir}/${file}'" - CT_DoExecLog ALL sed -i -r -e '/BUG in libc.scripts.output-format.sed/d' "${CT_SYSROOT_DIR}/${dir}/${file}" - fi - done - done - - CT_EndStep -} -- cgit v0.10.2-6-g49f6