1 # This file adds functions to build glibc
2 # Copyright 2007 Yann E. MORIN
3 # Licensed under the GPL v2. See COPYING in the root of this package
11 addons_list=($(do_libc_add_ons_list " "))
13 if [ "${CT_LIBC_GLIBC_TARBALL}" = "y" ]; then
14 # Use release tarballs
15 CT_GetFile "glibc-${CT_LIBC_VERSION}" \
16 {ftp,http}://ftp.gnu.org/gnu/glibc \
17 ftp://gcc.gnu.org/pub/glibc/releases \
18 ftp://gcc.gnu.org/pub/glibc/snapshots
21 for addon in "${addons_list[@]}"; do
22 # NPTL addon is not to be downloaded, in any case
23 [ "${addon}" = "nptl" ] && continue || true
24 CT_GetFile "glibc-${addon}-${CT_LIBC_VERSION}" \
25 {ftp,http}://ftp.gnu.org/gnu/glibc \
26 ftp://gcc.gnu.org/pub/glibc/releases \
27 ftp://gcc.gnu.org/pub/glibc/snapshots
29 elif [ "${CT_LIBC_GLIBC_CVS}" = "y" ]; then
31 version="${CT_LIBC_VERSION//./_}"
32 date="${CT_LIBC_GLIBC_CVS_date}"
34 CT_GetCVS "glibc-cvs-${CT_LIBC_VERSION}" \
35 ":pserver:anoncvs@sources.redhat.com:/cvs/glibc" \
37 "glibc-${version}-branch${date:+:}${date}" \
38 "glibc-cvs-${CT_LIBC_VERSION}"
41 for addon in "${addons_list[@]}"; do
42 # NPTL addon is not to be downloaded, in any case
43 [ "${addon}" = "nptl" ] && continue || true
44 CT_GetCVS "glibc-${addon}-cvs-${CT_LIBC_VERSION}" \
45 ":pserver:anoncvs@sources.redhat.com:/cvs/glibc" \
47 "glibc-${version}-branch${date:+:}${date}" \
48 "glibc-${addon}-cvs-${CT_LIBC_VERSION}"
60 addons_list=($(do_libc_add_ons_list " "))
62 [ "${CT_LIBC_GLIBC_CVS}" = "y" ] && cvs="cvs-"
64 CT_Extract "glibc-${cvs}${CT_LIBC_VERSION}"
66 CT_Pushd "${CT_SRC_DIR}/glibc-${cvs}${CT_LIBC_VERSION}"
67 CT_Patch "glibc-${CT_LIBC_VERSION}" nochdir
70 for addon in "${addons_list[@]}"; do
71 # NPTL addon is not to be extracted, in any case
72 [ "${addon}" = "nptl" ] && continue || true
73 CT_Extract "glibc-${addon}-${cvs}${CT_LIBC_VERSION}" nochdir
75 # Some addons have the 'long' name, while others have the
76 # 'short' name, but patches are non-uniformly built with
77 # either the 'long' or 'short' name, whatever the addons name
78 # so we have to make symlinks from the existing to the missing
79 # Fortunately for us, [ -d foo ], when foo is a symlink to a
80 # directory, returns true!
81 [ -d "${addon}" ] || CT_DoExecLog ALL ln -s "glibc-${addon}-${cvs}${CT_LIBC_VERSION}" "${addon}"
82 [ -d "glibc-${addon}-${cvs}${CT_LIBC_VERSION}" ] || CT_DoExecLog ALL ln -s "${addon}" "glibc-${addon}-${cvs}${CT_LIBC_VERSION}"
83 CT_Patch "glibc-${addon}-${CT_LIBC_VERSION}" nochdir
86 # The configure files may be older than the configure.in files
87 # if using a snapshot (or even some tarballs). Fake them being
90 find . -type f -name configure -exec touch {} \; 2>&1 |CT_DoLog ALL
97 # There is nothing to do for glibc check config
98 do_libc_check_config() {
102 # This function installs the glibc headers needed to build the core compiler
105 local -a extra_config
108 CT_DoStep INFO "Installing C library headers"
110 [ "${CT_LIBC_GLIBC_CVS}" = "y" ] && cvs="cvs-"
112 mkdir -p "${CT_BUILD_DIR}/build-libc-headers"
113 cd "${CT_BUILD_DIR}/build-libc-headers"
115 CT_DoLog EXTRA "Configuring C library"
117 # The x86 arch needs special care... Bizarelly enough... :-(
118 case "${CT_KERNEL_ARCH}:${CT_ARCH_BITNESS}" in
119 x86:32) arch4hdrs="i386";;
120 x86:64) arch4hdrs="x86_64";;
121 *) arch4hdrs="${CT_KERNEL_ARCH}";;
124 # The following three things have to be done to build glibc-2.3.x, but they don't hurt older versions.
125 # 1. override CC to keep glibc's configure from using $TARGET-gcc.
126 # 2. disable linuxthreads, which needs a real cross-compiler to generate tcb-offsets.h properly
127 # 3. build with gcc 3.2 or later
128 # Compare these options with the ones used when building glibc for real below - they're different.
129 # As of glibc-2.3.2, to get this step to work for hppa-linux, you need --enable-hacker-mode
130 # so when configure checks to make sure gcc has access to the assembler you just built...
131 # Alternately, we could put ${PREFIX}/${TARGET}/bin on the path.
132 # Set --build so maybe we don't have to specify "cross-compiling=yes" below (haven't tried yet)
134 # "*** WARNING: Are you sure you do not want to use the `linuxthreads'"
136 # is ok here, since all we want are the basic headers at this point.
137 # Override libc_cv_ppc_machine so glibc-cvs doesn't complain
138 # 'a version of binutils that supports .machine "altivec" is needed'.
140 # We need to remove any threading addon when installing headers
141 addons_list="$(do_libc_add_ons_list " " \
142 |sed -r -e 's/\<(nptl|linuxthreads)\>/ /g;' \
143 -e 's/ +/,/g; s/^,+//; s/,+$//;' \
146 extra_config+=("--enable-add-ons=${addons_list}")
148 extra_config+=("${addons_config}")
149 extra_config+=("$(do_libc_min_kernel_config)")
151 # Pre-seed the configparms file with values from the config option
152 printf "${CT_LIBC_GLIBC_CONFIGPARMS}\n" > configparms
154 cross_cc=$(CT_Which "${CT_TARGET}-gcc")
155 CT_DoLog DEBUG "Using gcc for target: '${cross_cc}'"
156 CT_DoLog DEBUG "Extra config passed : '${extra_config[*]}'"
158 libc_cv_ppc_machine=yes \
159 libc_cv_mlong_double_128=yes \
160 libc_cv_mlong_double_128ibm=yes \
163 "${CT_SRC_DIR}/glibc-${cvs}${CT_LIBC_VERSION}/configure" \
164 --build="${CT_BUILD}" \
165 --host="${CT_TARGET}" \
167 --with-headers="${CT_HEADERS_DIR}" \
169 --disable-sanity-checks \
170 --enable-hacker-mode \
171 "${extra_config[@]}" \
174 CT_DoLog EXTRA "Installing C library headers"
176 if grep -q GLIBC_2.3 "${CT_SRC_DIR}/glibc-${cvs}${CT_LIBC_VERSION}/ChangeLog"; then
177 # glibc-2.3.x passes cross options to $(CC) when generating errlist-compat.c,
178 # which fails without a real cross-compiler.
179 # Fortunately, we don't need errlist-compat.c, since we just need .h
180 # files, so work around this by creating a fake errlist-compat.c and
181 # satisfying its dependencies.
182 # Another workaround might be to tell configure to not use any cross
184 # The real fix would be to get install-headers to not generate
186 # Note: BOOTSTRAP_GCC is used by:
187 # patches/glibc-2.3.5/glibc-mips-bootstrap-gcc-header-install.patch
189 libc_cv_ppc_machine=yes \
191 make CFLAGS="-O2 -DBOOTSTRAP_GCC" \
192 OBJDUMP_FOR_HOST="${CT_TARGET}-objdump" \
193 PARALLELMFLAGS="${PARALLELMFLAGS}" \
194 sysdeps/gnu/errlist.c
195 mkdir -p stdio-common
197 # sleep for 2 seconds for benefit of filesystems with lousy time
198 # resolution, like FAT, so make knows for sure errlist-compat.c doesn't
201 CT_DoExecLog ALL touch stdio-common/errlist-compat.c
203 # Note: BOOTSTRAP_GCC (see above)
204 libc_cv_ppc_machine=yes \
206 make cross-compiling=yes \
207 install_root=${CT_SYSROOT_DIR} \
208 CFLAGS="-O2 -DBOOTSTRAP_GCC" \
209 ${LIBC_SYSROOT_ARG} \
210 OBJDUMP_FOR_HOST="${CT_TARGET}-objdump" \
211 PARALLELMFLAGS="${PARALLELMFLAGS}" \
214 # Two headers -- stubs.h and features.h -- aren't installed by install-headers,
215 # so do them by hand. We can tolerate an empty stubs.h for the moment.
216 # See e.g. http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html
217 mkdir -p "${CT_HEADERS_DIR}/gnu"
218 CT_DoExecLog ALL touch "${CT_HEADERS_DIR}/gnu/stubs.h"
219 CT_DoExecLog ALL cp -v "${CT_SRC_DIR}/glibc-${cvs}${CT_LIBC_VERSION}/include/features.h" \
220 "${CT_HEADERS_DIR}/features.h"
222 # Building the bootstrap gcc requires either setting inhibit_libc, or
223 # having a copy of stdio_lim.h... see
224 # http://sources.redhat.com/ml/libc-alpha/2003-11/msg00045.html
225 CT_DoExecLog ALL cp -v bits/stdio_lim.h "${CT_HEADERS_DIR}/bits/stdio_lim.h"
227 # Following error building gcc-4.0.0's gcj:
228 # error: bits/syscall.h: No such file or directory
229 # solved by following copy; see http://sourceware.org/ml/crossgcc/2005-05/msg00168.html
230 # but it breaks arm, see http://sourceware.org/ml/crossgcc/2006-01/msg00091.html
231 [ "${CT_ARCH}" != "arm" ] && CT_DoExecLog ALL cp -v misc/syscall-list.h "${CT_HEADERS_DIR}/bits/syscall.h" || true
233 # Those headers are to be manually copied so gcc can build properly
234 pthread_h="${CT_SRC_DIR}/glibc-${cvs}${CT_LIBC_VERSION}/${CT_THREADS}/sysdeps/pthread/pthread.h"
236 case "${CT_THREADS}" in
238 # NOTE: for some archs, the pathes are different, but they are not
239 # supported by crosstool-NG right now. See original crosstool when they are.
240 pthread_h="${CT_SRC_DIR}/glibc-${cvs}${CT_LIBC_VERSION}/${CT_THREADS}/sysdeps/pthread/pthread.h"
241 pthreadtypes_h="${CT_SRC_DIR}/glibc-${cvs}${CT_LIBC_VERSION}/nptl/sysdeps/unix/sysv/linux/${arch4hdrs}/bits/pthreadtypes.h"
242 if [ ! -f "${pthreadtypes_h}" ]; then
243 pthreadtypes_h="${CT_SRC_DIR}/glibc-${cvs}${CT_LIBC_VERSION}/ports/sysdeps/unix/sysv/linux/${arch4hdrs}/nptl/bits/pthreadtypes.h"
247 pthreadtypes_h="${CT_SRC_DIR}/glibc-${cvs}${CT_LIBC_VERSION}/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h"
254 if [ -n "${pthread_h}" ]; then
255 CT_DoExecLog ALL cp -v "${pthread_h}" "${CT_HEADERS_DIR}/pthread.h"
257 if [ -n "${pthreadtypes_h}" ]; then
258 CT_DoExecLog ALL cp -v "${pthreadtypes_h}" "${CT_HEADERS_DIR}/bits/pthreadtypes.h"
264 # Build and install start files
265 do_libc_start_files() {
267 local -a extra_config
269 # Needed only in the NPTL case. Otherwise, return.
270 [ "${CT_THREADS}" = "nptl" ] || return 0
272 CT_DoStep INFO "Installing C library start files"
274 [ "${CT_LIBC_GLIBC_CVS}" = "y" ] && cvs="cvs-"
276 mkdir -p "${CT_BUILD_DIR}/build-libc-startfiles"
277 cd "${CT_BUILD_DIR}/build-libc-startfiles"
279 CT_DoLog EXTRA "Configuring C library"
281 # Add some default glibc config options if not given by user.
282 case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
284 *) extra_config+=("--with-tls")
286 case "${CT_SHARED_LIBS}" in
287 y) extra_config+=("--enable-shared");;
288 *) extra_config+=("--disable-shared");;
290 case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
291 y,) extra_config+=("--with-fp");;
292 ,y) extra_config+=("--without-fp");;
294 # Obviously, we want threads, as we come here only for NPTL
295 extra_config+=("--with-__thread")
297 addons_config="--enable-add-ons=$(do_libc_add_ons_list ,)"
298 extra_config+=("${addons_config}")
300 extra_config+=("$(do_libc_min_kernel_config)")
302 # Add some default CC args
303 glibc_version_major=$(echo ${CT_LIBC_VERSION} |sed -r -e 's/^([[:digit:]]+).*/\1/')
304 glibc_version_minor=$(echo ${CT_LIBC_VERSION} |sed -r -e 's/^[[:digit:]]+[\.-_]([[:digit:]]+).*/\1/')
305 if [ ${glibc_version_major} -eq 2 -a ${glibc_version_minor} -ge 6 \
306 -o ${glibc_version_major} -gt 2 ]; then
307 # Don't use -pipe: configure chokes on it for glibc >= 2.6.
308 CT_Test 'Removing "-pipe" for use with glibc>=2.6' "${CT_USE_PIPES}" = "y"
309 extra_cc_args="${CT_CFLAGS_FOR_HOST/-pipe}"
311 extra_cc_args="${CT_CFLAGS_FOR_HOST}"
313 extra_cc_args="${extra_cc_args} ${CT_ARCH_ENDIAN_OPT}"
315 cross_cc=$(CT_Which "${CT_TARGET}-gcc")
316 CT_DoLog DEBUG "Using gcc for target : '${cross_cc}'"
317 CT_DoLog DEBUG "Configuring with addons : '$(do_libc_add_ons_list ,)'"
318 CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'"
319 CT_DoLog DEBUG "Extra CC args passed : '${extra_cc_args}'"
321 # Pre-seed the configparms file with values from the config option
322 printf "${CT_LIBC_GLIBC_CONFIGPARMS}\n" > configparms
324 echo "libc_cv_forced_unwind=yes" > config.cache
325 echo "libc_cv_c_cleanup=yes" >> config.cache
327 # Please see the comment for the configure step in do_libc().
329 BUILD_CC="${CT_BUILD}-gcc" \
330 CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O2" \
331 CC="${cross_cc} ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \
333 RANLIB=${CT_TARGET}-ranlib \
335 "${CT_SRC_DIR}/glibc-${cvs}${CT_LIBC_VERSION}/configure" \
337 --build="${CT_BUILD}" \
338 --host=${CT_TARGET} \
343 --with-headers="${CT_HEADERS_DIR}" \
344 --cache-file=config.cache \
345 "${extra_config[@]}" \
346 ${CT_LIBC_GLIBC_EXTRA_CONFIG}
348 #TODO: should check whether slibdir has been set in configparms to */lib64
349 # and copy the startfiles into the appropriate libdir.
350 CT_DoLog EXTRA "Building C library start files"
351 CT_DoExecLog ALL make OBJDUMP_FOR_HOST="${CT_TARGET}-objdump" \
352 PARALLELMFLAGS="${PARALLELMFLAGS}" \
355 CT_DoLog EXTRA "Installing C library start files"
356 if [ "${CT_USE_SYSROOT}" = "y" ]; then
357 CT_DoExecLog ALL cp -fpv csu/crt[1in].o "${CT_SYSROOT_DIR}/usr/lib/"
359 CT_DoExecLog ALL cp -fpv csu/crt[1in].o "${CT_SYSROOT_DIR}/lib/"
365 # This function builds and install the full glibc
368 local -a extra_config
370 CT_DoStep INFO "Installing C library"
372 [ "${CT_LIBC_GLIBC_CVS}" = "y" ] && cvs="cvs-"
374 mkdir -p "${CT_BUILD_DIR}/build-libc"
375 cd "${CT_BUILD_DIR}/build-libc"
377 CT_DoLog EXTRA "Configuring C library"
379 # Add some default glibc config options if not given by user.
380 # We don't need to be conditional on wether the user did set different
381 # values, as they CT_LIBC_GLIBC_EXTRA_CONFIG is passed after extra_config
383 case "${CT_THREADS}" in
384 nptl) extra_config+=("--with-__thread" "--with-tls");;
385 linuxthreads) extra_config+=("--with-__thread" "--without-tls" "--without-nptl");;
386 none) extra_config+=("--without-__thread" "--without-nptl")
387 case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
389 *) extra_config+=("--without-tls");;
394 case "${CT_SHARED_LIBS}" in
395 y) extra_config+=("--enable-shared");;
396 *) extra_config+=("--disable-shared");;
399 case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
400 y,) extra_config+=("--with-fp");;
401 ,y) extra_config+=("--without-fp");;
404 case "$(do_libc_add_ons_list ,)" in
406 *) extra_config+=("--enable-add-ons=$(do_libc_add_ons_list ,)");;
409 extra_config+=("$(do_libc_min_kernel_config)")
411 # Add some default CC args
412 glibc_version_major=$(echo ${CT_LIBC_VERSION} |sed -r -e 's/^([[:digit:]]+).*/\1/')
413 glibc_version_minor=$(echo ${CT_LIBC_VERSION} |sed -r -e 's/^[[:digit:]]+[\.-_]([[:digit:]]+).*/\1/')
414 if [ ${glibc_version_major} -eq 2 -a ${glibc_version_minor} -ge 6 \
415 -o ${glibc_version_major} -gt 2 ]; then
416 # Don't use -pipe: configure chokes on it for glibc >= 2.6.
417 CT_Test 'Removing "-pipe" for use with glibc>=2.6' "${CT_USE_PIPES}" = "y"
418 extra_cc_args="${CT_CFLAGS_FOR_HOST/-pipe}"
420 extra_cc_args="${CT_CFLAGS_FOR_HOST}"
422 extra_cc_args="${extra_cc_args} ${CT_ARCH_ENDIAN_OPT}"
424 cross_cc=$(CT_Which "${CT_TARGET}-gcc")
425 CT_DoLog DEBUG "Using gcc for target : '${cross_cc}'"
426 CT_DoLog DEBUG "Configuring with addons : '$(do_libc_add_ons_list ,)'"
427 CT_DoLog DEBUG "Extra config args passed: '${extra_config}'"
428 CT_DoLog DEBUG "Extra CC args passed : '${extra_cc_args}'"
430 # Pre-seed the configparms file with values from the config option
431 printf "${CT_LIBC_GLIBC_CONFIGPARMS}\n" > configparms
433 # For glibc 2.3.4 and later we need to set some autoconf cache
434 # variables, because nptl/sysdeps/pthread/configure.in does not
435 # work when cross-compiling.
436 if [ "${CT_THREADS}" = "nptl" ]; then
437 echo libc_cv_forced_unwind=yes
438 echo libc_cv_c_cleanup=yes
441 # Configure with --prefix the way we want it on the target...
442 # There are a whole lot of settings here. You'll probably want
443 # to read up on what they all mean, and customize a bit, possibly by setting GLIBC_EXTRA_CONFIG
444 # Compare these options with the ones used when installing the glibc headers above - they're different.
445 # Adding "--without-gd" option to avoid error "memusagestat.c:36:16: gd.h: No such file or directory"
446 # See also http://sources.redhat.com/ml/libc-alpha/2000-07/msg00024.html.
447 # Set BUILD_CC, or you won't be able to build datafiles
448 # Set --build, else glibc-2.3.2 will think you're not cross-compiling, and try to run the test programs
450 # OK. I'm fed up with those folks telling me what I should do.
451 # I don't configure nptl? Well, maybe that's purposedly because
452 # I don't want nptl! --disable-sanity-checks will shut up those
453 # silly messages. GNU folks again, he?
455 BUILD_CC="${CT_BUILD}-gcc" \
456 CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O2" \
457 CC="${CT_TARGET}-gcc ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \
459 RANLIB=${CT_TARGET}-ranlib \
461 "${CT_SRC_DIR}/glibc-${cvs}${CT_LIBC_VERSION}/configure" \
463 --build=${CT_BUILD} \
464 --host=${CT_TARGET} \
469 --disable-sanity-checks \
470 --cache-file=config.cache \
471 --with-headers="${CT_HEADERS_DIR}" \
472 "${extra_config[@]}" \
473 ${CT_LIBC_GLIBC_EXTRA_CONFIG}
475 if grep -l '^install-lib-all:' "${CT_SRC_DIR}/glibc-${cvs}${CT_LIBC_VERSION}/Makerules" > /dev/null; then
477 # If the install-lib-all target (which is added by our make-install-lib-all.patch)
478 # is present, it means we're building glibc-2.3.3 or later, and we can't
479 # build programs yet, as they require libeh, which won't be installed
480 # until full build of gcc
481 # YEM-FIXME: This comment is misleading: latest glibc-s do not have the
482 # make-install-lib-all.patch applied, so do not pass through this
483 # part of the if statement; nonetheless, they do build, and
484 # the result is useable (maybe the dual-pass core gcc is
485 # responsible for this).
486 GLIBC_INITIAL_BUILD_RULE=lib
487 GLIBC_INITIAL_INSTALL_RULE="install-lib-all install-headers"
488 GLIBC_INSTALL_APPS_LATER=yes
491 # We can build and install everything with the bootstrap compiler.
492 # YEM-FIXME: See the above FIXME as well.
493 GLIBC_INITIAL_BUILD_RULE=all
494 GLIBC_INITIAL_INSTALL_RULE=install
495 GLIBC_INSTALL_APPS_LATER=no
498 # glibc initial build hacks
499 # http://sourceware.org/ml/crossgcc/2008-10/msg00068.html
500 case "${CT_ARCH},${CT_ARCH_CPU}" in
502 CT_DoLog DEBUG "Activating support for memset on broken ppc-8xx (CPU15 erratum)"
503 GLIBC_INITIAL_BUILD_ASFLAGS="-DBROKEN_PPC_8xx_CPU15";;
506 # If this fails with an error like this:
507 # ... linux/autoconf.h: No such file or directory
508 # then you need to set the KERNELCONFIG variable to point to a .config file for this arch.
509 # The following architectures are known to need kernel .config: alpha, arm, ia64, s390, sh, sparc
510 # Note: LD and RANLIB needed by glibc-2.1.3's c_stub directory, at least on macosx
511 CT_DoLog EXTRA "Building C library"
512 CT_DoExecLog ALL make LD=${CT_TARGET}-ld \
513 RANLIB=${CT_TARGET}-ranlib \
514 OBJDUMP_FOR_HOST="${CT_TARGET}-objdump" \
515 ASFLAGS="${GLIBC_INITIAL_BUILD_ASFLAGS}" \
516 PARALLELMFLAGS="${PARALLELMFLAGS}" \
517 ${GLIBC_INITIAL_BUILD_RULE}
519 CT_DoLog EXTRA "Installing C library"
520 CT_DoExecLog ALL make install_root="${CT_SYSROOT_DIR}" \
521 ${LIBC_SYSROOT_ARG} \
522 OBJDUMP_FOR_HOST="${CT_TARGET}-objdump" \
523 PARALLELMFLAGS="${PARALLELMFLAGS}" \
524 ${GLIBC_INITIAL_INSTALL_RULE}
526 # This doesn't seem to work when building a crosscompiler,
527 # as it tries to execute localedef using the just-built ld.so!?
528 #CT_DoLog EXTRA "Installing locales"
529 #make localedata/install-locales install_root=${SYSROOT} 2>&1 |CT_DoLog ALL
531 # Fix problems in linker scripts.
533 # Remove lines containing BUG per http://sources.redhat.com/ml/bug-glibc/2003-05/msg00055.html,
534 # needed to fix gcc-3.2.3/glibc-2.3.2 targeting arm
535 # No need to look into the lib64/ dirs here and there, they point to the
536 # corresponding lib/ directories.
538 # To make "strip *.so.*" not fail (ptxdist does this), rename to .so_orig rather than .so.orig
539 CT_DoLog EXTRA "Fixing C library linker scripts"
540 for file in libc.so libpthread.so libgcc_s.so; do
541 for dir in lib usr/lib; do
542 if [ -f "${CT_SYSROOT_DIR}/${dir}/${file}" -a ! -L ${CT_SYSROOT_DIR}/$lib/$file ]; then
543 CT_DoExecLog ALL cp -v "${CT_SYSROOT_DIR}/${dir}/${file}" "${CT_SYSROOT_DIR}/${dir}/${file}_orig"
544 CT_DoLog DEBUG "Fixing '${CT_SYS_ROOT_DIR}/${dir}/${file}'"
545 CT_DoExecLog ALL sed -i -r -e '/BUG in libc.scripts.output-format.sed/d' "${CT_SYSROOT_DIR}/${dir}/${file}"
553 # This function finishes the glibc install
555 # Finally, build and install glibc programs, now that libeh (if any) is installed
556 # Don't do this unless needed, 'cause it causes glibc-2.{1.3,2.2} to fail here with
557 # .../gcc-3.4.1-glibc-2.1.3/build-glibc/libc.so.6: undefined reference to `__deregister_frame_info'
558 # .../gcc-3.4.1-glibc-2.1.3/build-glibc/libc.so.6: undefined reference to `__register_frame_info'
559 [ "${GLIBC_INSTALL_APPS_LATER}" = "yes" ] || return 0
561 CT_DoStep INFO "Finishing C library"
563 cd "${CT_BUILD_DIR}/build-libc"
565 CT_DoLog EXTRA "Re-building C library"
566 CT_DoExecLog ALL make LD=${CT_TARGET}-ld \
567 RANLIB=${CT_TARGET}-ranlib \
568 OBJDUMP_FOR_HOST="${CT_TARGET}-objdump" \
569 ASFLAGS="${GLIBC_INITIAL_BUILD_ASFLAGS}" \
570 PARALLELMFLAGS="${PARALLELMFLAGS}"
572 CT_DoLog EXTRA "Installing missing C library components"
573 # note: should do full install and then fix linker scripts, but this is faster
574 for t in bin rootsbin sbin data others; do
575 CT_DoExecLog ALL make install_root="${CT_SYSROOT_DIR}" \
576 ${LIBC_SYSROOT_ARG} \
577 OBJDUMP_FOR_HOST="${CT_TARGET}-objdump" \
578 PARALLELMFLAGS="${PARALLELMFLAGS}" \
585 # Build up the addons list, separated with $1
586 do_libc_add_ons_list() {
588 local addons_list=$(echo "${CT_LIBC_ADDONS_LIST}" |sed -r -e "s/[ ,]/${sep}/g;")
589 case "${CT_THREADS}" in
591 *) addons_list="${addons_list}${sep}${CT_THREADS}";;
593 [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && addons_list="${addons_list}${sep}ports"
594 # Remove duplicate, leading and trailing separators
595 echo "${addons_list}" |sed -r -e "s/${sep}+/${sep}/g; s/^${sep}//; s/${sep}\$//;"
598 # Builds up the minimum supported Linux kernel version
599 do_libc_min_kernel_config() {
600 local min_kernel_config=
601 case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
603 *) if [ "${CT_LIBC_GLIBC_KERNEL_VERSION_AS_HEADERS}" = "y" ]; then
604 # We can't rely on the kernel version from the configuration,
605 # because it might not be available if the user uses pre-installed
606 # headers. On the other hand, both method will have the kernel
607 # version installed in "usr/include/linux/version.h" in the sys-root.
608 # Parse that instead of having two code-paths.
609 version_code_file="${CT_SYSROOT_DIR}/usr/include/linux/version.h"
610 CT_TestOrAbort "Linux version is unavailable in installed headers files" -f "${version_code_file}" -a -r "${version_code_file}"
611 version_code=$(grep -E LINUX_VERSION_CODE "${version_code_file}" |cut -d ' ' -f 3)
612 version=$(((version_code>>16)&0xFF))
613 patchlevel=$(((version_code>>8)&0xFF))
614 sublevel=$((version_code&0xFF))
615 min_kernel_config="--enable-kernel=${version}.${patchlevel}.${sublevel}"
616 elif [ "${CT_LIBC_GLIBC_KERNEL_VERSION_CHOSEN}" = "y" ]; then
617 # Trim the fourth part of the linux version, keeping only the first three numbers
618 min_kernel_config="--enable-kernel=$(echo ${CT_LIBC_GLIBC_MIN_KERNEL_VERSION} |sed -r -e 's/^([^.]+\.[^.]+\.[^.]+)(|\.[^.]+)$/\1/;')"
622 echo "${min_kernel_config}"