This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] libc/prebuilt-glibc: add support for a pre-built GLIBC


# HG changeset patch
# User Michael Hope <michael.hope@linaro.org>
# Date 1321238468 -46800
# Branch prebuilt-sysroot
# Node ID ebfc38601b7351231f742d5dbc4db71c878a3a5d
# Parent  20bc56e72ca1559279b3c9c9b191d41061757653
libc/prebuilt-glibc: add support for a pre-built GLIBC

Used to build a cross compiler against an existing sysroot such as
Debian or Ubuntu.  Adds Ubuntu Maverick (the last before Ubuntu added
multiarch) as an example.  Can be extended to support Debian 6 and
Fedora but left as an exercise to the reader :)

Warts:
 * Still builds the intermediate stage compilers even though they're
   not needed
 * Still pulls in the linux headers even though they're incompletely
   overwritten
 * Includes arch -> Debian arch conversion for ARM only.  Others
   should be added as they're tested

Signed-off-by: Michael Hope <michael.hope@linaro.org>

diff -r 20bc56e72ca1 -r ebfc38601b73 config/libc/prebuilt-glibc.in
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config/libc/prebuilt-glibc.in	Mon Nov 14 15:41:08 2011 +1300
@@ -0,0 +1,29 @@
+# Prebuilt GLIBC options
+
+## depends on ! MINGW32 && ! BARE_METAL && ARCH_USE_MMU
+##
+## select LIBC_SUPPORT_NPTL
+##
+## help Use a pre-built GLIBC or EGLIBC instead of building from
+## help source.  Used when building a cross compiler for a existing
+## help target such as a particular Debian or Ubuntu release.
+##
+
+choice
+    bool
+    prompt "Distribution version"
+# Don't remove next line
+# CT_INSERT_VERSION_BELOW
+
+config LIBC_PREBUILTGLIBC_UBUNTU_10_10
+    bool
+    prompt "Ubuntu 10.10 (Maverick)"
+    depends on EXPERIMENTAL
+
+endchoice
+
+config LIBC_VERSION
+    string
+# Don't remove next line
+# CT_INSERT_VERSION_STRING_BELOW
+    default "ubuntu_10_10" if LIBC_PREBUILTGLIBC_UBUNTU_10_10
diff -r 20bc56e72ca1 -r ebfc38601b73 scripts/build/libc/prebuilt-glibc.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/build/libc/prebuilt-glibc.sh	Mon Nov 14 15:41:08 2011 +1300
@@ -0,0 +1,110 @@
+# This file adds functions to fetch and use a prebuilt GLIBC such as
+# Debian or Ubuntu.
+# Copyright 2011  Linaro Limited
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+# Convert a crosstool-NG architecture into the Debian form
+do_libc_to_debian_arch() {
+    local arch
+    local endian="${CT_ARCH_BE},${CT_ARCH_LE}"
+    local abi="${CT_ARCH_FLOAT_SW},${CT_ARCH_FLOAT_HW}"
+
+    case "${CT_ARCH},${endian},${abi}" in
+	arm,,y,y,)  arch=armel;;
+	arm,y,,y,)  arch=armeb;;
+	arm,,y,,y)  arch=armhf;;
+	*)          CT_Abort "Unhandled architecture \"${CT_ARCH}\"";;
+    esac
+
+    echo "${arch}"
+}
+
+# Generate the list of files to fetch for the particular distro and
+# arch
+do_libc_file_list() {
+    local arch
+    local libc
+    local linux
+    local files
+
+    case "${CT_LIBC_VERSION}" in
+	ubuntu_10_10)
+	    arch=$( do_libc_to_debian_arch )
+	    libc="2.12.1-0ubuntu6"
+	    linux="2.6.35-1022.33"
+	    files="libc6_${libc}_${arch}"
+	    files="${files} libc6-dev_${libc}_${arch}"
+	    files="${files} linux-libc-dev_${linux}_${arch}"
+	    ;;
+	*)  CT_Abort "Unhandled libc version ${CT_LIBC_VERSION}"
+    esac
+
+    echo "${files}"
+}
+
+do_libc_get() {
+    local pool
+    local ext
+
+    # Where to pull packages from
+    case "${CT_LIBC_VERSION}" in
+	ubuntu_*)
+	    pool="http://ports.ubuntu.com/pool";
+	    ext=".deb"
+	    ;;
+    esac
+
+    files=$( do_libc_file_list )
+
+    for file in ${files}; do
+	CT_DoLog DEBUG "Fetching ${file}"
+	CT_GetFile "${file}" "${ext}" \
+	    "${pool}/main/{e/eglibc,l/linux}"
+    done
+
+    return 0
+}
+
+do_libc_extract() {
+    for file in $( do_libc_file_list ); do
+	CT_Extract "${file}"
+    done
+}
+
+do_libc_check_config() {
+    :
+}
+
+do_libc_start_files() {
+    # do_kernel_headers has already run
+    CT_DoLog EXTRA "Installing the pre-built libc"
+
+    for file in $( do_libc_file_list ); do
+	CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/${file}"/* "${CT_SYSROOT_DIR}"
+    done
+
+    # Some packages include absolute links in sysroot/usr/lib.
+    # Convert to relative links instead
+    for lib in "${CT_SYSROOT_DIR}/usr/lib"/*; do \
+	if [ -L "${lib}" ] && (readlink "${lib}" | grep -q ^/); then
+	    target=$( readlink "${lib}" )
+	    base=$( basename "${target}" )
+	    rm "${lib}"
+
+	    CT_DoLog DEBUG "Fixing up the absolute link to ${target}"
+
+	    case $( dirname "${target}" ) in
+		/lib)  CT_DoExecLog ALL ln -s "../../lib/${base}" "${lib}";;
+		*)     CT_Abort "Unhandled absolute path ${target}";;
+	    esac
+	fi
+    done
+}
+
+do_libc() {
+    :
+}
+
+do_libc_finish() {
+    :
+}

--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]