Cross Toolchain on Gentoo Prefix

Introduction

  1. Gentoo Prefix is ideal as a secondary package management system.
  2. With Gentoo portage, a tool called crossdev is available. Crossdev is actually a shell script to prepare portage for building cross compilation toolchain.

Tutorial: Starting from gcc-4.1

We are going to build a toolchain for powerpc-unknown-linux-gnu.

  1. Make a new category called cross-powerpc-unknown-linux-gnu in PORTDIR_OVERLAY.
  2. Create a soft link of binutils, gcc, linux-headers and glibc from Gentoo portage tree to inside cross-powerpc-unknown-linux-gnu.
  3. glibc is not in Gentoo Prefix portage tree. Copy it from gentoo x86 with ecopy and also manually copy files/ebilts from gentoo-x86. Then make glibc Prefix compatable by replacing ${D} with ${ED} in files/ebilts/src_install.eblit.
  4. Add cross-powerpc-unknown-linux-gnu in ${EROOT}/etc/portage/categories.
  5. emerge cross-powerpc-unknown-linux-gnu/linux-headers.
  6. emerge cross-powerpc-unknown-linux-gnu/gcc-4.1with only "nocxx" USE.
  7. emerge cross-powerpc-unknown-linux-gnu/glibcwith no USE set. (optional, USE=crosscompile_opts_headers-only)
  8. emerge cross-powerpc-unknown-linux-gnu/gcc with the latest version.
  9. emerge cross-powerpc-unknown-linux-gnu/glibc, again.

Tutorial: Starting from gcc-4.7

We are going to build a toolchain for armv7a-hardfloat-linux-gnueabi.

  1. Make a new category called cross-armv7a-hardfloat-linux-gnueabi in PORTDIR_OVERLAY.
  2. Create a soft link of binutils, gcc, linux-headers and glibc from Gentoo portage tree to inside cross-armv7a-hardfloat-linux-gnueabi.
  3. glibc is not in Gentoo Prefix portage tree. Copy it from gentoo x86 with ecopy and also manually copy files/ebilts from gentoo-x86. Then make glibc Prefix compatable by replacing ${D} with ${ED} in files/ebilts/src_install.eblit.
  4. Add armv7a-hardfloat-linux-gnueabi in ${EPREFIX}/etc/portage/categories.
  5. emerge cross-armv7a-hardfloat-linux-gnueabi/linux-headers.
  6. env USE=crosscompile_opts_headers-only emerge cross-armv7a-hardfloat-linux-gnueabi/glibc
  7. put cross-armv7a-hardfloat-linux-gnueabi/gcc -boundschecking -d -gtk -gcj -libffi -mudflap -objc -objc++ -objc-gc into ${EPREFIX}/etc/portage/package.use
  8. env USE="-* nocxx" emerge cross-armv7a-hardfloat-linux-gnueabi/gcc. It will pull in binutils.
  9. emerge cross-armv7a-hardfloat-linux-gnueabi/glibc, again.
  10. emerge cross-armv7a-hardfloat-linux-gnueabi/gcc, again.

Last modified: Thu Mar 14 08:04:18 JST 2013