public inbox for crossgcc@sourceware.org
 help / color / mirror / Atom feed
From: Michael Hope <michael.hope@linaro.org>
To: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Cc: crossgcc@sourceware.org
Subject: [PATCH] libc/prebuilt-glibc: add support for a pre-built GLIBC
Date: Mon, 14 Nov 2011 02:43:00 -0000	[thread overview]
Message-ID: <ebfc38601b7351231f74.1321238611@crucis> (raw)

# 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

             reply	other threads:[~2011-11-14  2:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-14  2:43 Michael Hope [this message]
2011-11-14 22:52 ` Yann E. MORIN
2011-11-15  1:45   ` Michael Hope

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ebfc38601b7351231f74.1321238611@crucis \
    --to=michael.hope@linaro.org \
    --cc=crossgcc@sourceware.org \
    --cc=yann.morin.1998@anciens.enib.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).