There's still a lot of stuff left to get cleaned up and submitted, though.
Cheers,
Kyle Moffett
My name is Kyle Moffett and I am a Linux Geek. I specialize in Perl, Shell, and C, especially things like kernels and low-level software. This blog is where I put my headaches so that I can make them go away.
Woohoo!
I am finally on Google+ after months of waiting; here is my Profile (which is also conveniently linked from the Blogger sidebar).
Cheers,
Kyle Moffett
We're actively working on making Profiles (and Google+) available for Google Apps - it should be available in the coming months – John Costigan @ Jun 28, 2011Here's hoping that it will be sometime soon!
powerpc-linux-gnuspe-gcc-4.6Unfortunately, by default autoconf won't actually find those, and the "gcc-defaults" package does not have a cross-compiler mode (although it can be cross-"compiled", as we will need to do later). So symlink the relevant binaries to versions without the "-4.6" at the end:
powerpc-linux-gnuspe-g++-4.6
$ cd /usr/bin
$ for i in powerpc-linux-gnuspe-*-4.6; do sudo ln -s "$i" "${i%-4.6}"; done
$ sudo apt-get install grep-dctrl
$ grep-available -Xn -s Package -FEssential 'yes' >new-pkgs.txt
$ echo 'build-essential' >>new-pkgs.txt
$ : >all-pkgs.txt
$ while [ -s new-pkgs.txt ]; do \
cat new-pkgs.txt >>all-pkgs.txt; \
for i in $(cat new-pkgs.txt); do \
grep-available -PXn -s Depends,PreDepends "$i"; \
done | sed -e 's/([^)]\+)//g' -e 's/, /\n/g' \
-e 's/ *|[^\n]*//g' | grep . | sort | uniq >dep-pkgs.txt; \
cat dep-pkgs.txt all-pkgs.txt all-pkgs.txt \
| sort | uniq -u >new-pkgs.txt; \
done
$ for i in $(cat all-pkgs.txt); do \
grep-available -PXn -sSource:Package "$i"; \
done | sed -e 's/ (.*//' | sort | uniq >all-srcs.txt
base-files base-passwd bash binutils build-essential bzip2 coreutils dash db debconf debianutils diffutils dpkg e2fsprogs eglibc findutils gcc-4.6 gcc-defaults gdbm gmp grep gzip hostname insserv libselinux libsepol libtimedate-perl linux-2.6 lsb make-dfsg mpclib mpfr4 ncurses patch perl sed sensible-utils shadow sysvinit tar tzdata util-linux xz-utils zlibNot too unreasonable, right? What you will rapidly realize is that build-dependencies are the key, and we have not actually tried to list those out yet. The biggest problem tends to be docs-generation tools (EG: LaTeX, Doxygen, etc) which are entirely unnecessary for bootstrap purposes but have lots of dependencies of their own (EG: xorg, qt4, etc).
$ mkdir gzip && cd gzip && apt-get source gzip=1.4-1First you should check the "Build-Depends" field in the "debian/control" file, to make sure you have all of the necessary dependencies. Note that some dependencies (automake, autoconf, texinfo, etc) should be satisfied by your build-system architecture (EG: amd64), while others (libc6, etc) should be satisfied by "-cross" packages for your target architecture.
$ grep Build-Depends: gzip-1.4/debian/rulesOk, everything looks good there. Now check the "debian/rules" file to check for the following few issues:
Build-Depends: debhelper (>= 5), texinfo, autoconf, automake, autotools-dev
$ ( cd gzip-1.4 && dpkg-buildpackage -a"${MYARCH}" -us -uc -B ) 2>&1 | tee build-gzip.logEven if the build finishes successfully, you should use "lintian" and "dpkg-deb -c" to verify that the package files look correct. If you have any errors or unexpected package contents then you have some serious work to do to figure out why and fix the package. In the "gzip" case I identified a minor bug (Debian bug #644785) in the packaging which resulted in one particular setting coming from the build-system instead of from the host.
$ sudo apt-get build-dep dpkg=1.16.1Going back to the EGLIBC commands I listed previously for step 6, here is an updated version:
$ sudo apt-get source dpkg=1.16.1
$ curl -o 'Dpkg-Shlibs.pm-multiarch-search-paths.patch' \
'http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=595144;msg=37;att=1'
$ patch -d dpkg-1.16.1 -p1 <Dpkg-Shlibs.pm-multiarch-search-paths.patch
$ ( cd dpkg-1.16.1 && dpkg-buildpackage -b -us -uc ) 2>&1 | tee dpkg.log
$ sudo dpkg -i libdpkg-perl_1.16.1_all.deb
$ sudo apt-get build-dep eglibc=2.13-21Once the build finishes, it will have produced a bunch of deb files, but you only actually need the libc6 and libc6-dev packages. As before, we will eventually be able to install foreign architecture packages but for now we have to forcibly dpkg-cross them (with a few ignored dependencies).
$ apt-get source eglibc=2.13-21
$ curl -o 'eglibc-2.13-cross-stage1-support.patch' \
'http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=644546;msg=5;att=1'
$ curl -o 'eglibc-fix-ssp-detection.patch' \
'http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=644662;msg=5;att=1'
$ curl -o 'eglibc-disable-cross-locales-all.patch' \
'http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=644771;msg=5;att=1'
$ patch -d eglibc-2.13 -p1 <eglibc-2.13-cross-stage1-support.patch
$ patch -d eglibc-2.13 -p1 <eglibc-fix-ssp-detection.patch
$ patch -d eglibc-2.13 -p1 <eglibc-disable-cross-locales-all.patch... MAKE ANY OTHER CHANGES TO EGLIBC HERE ...
$ ( cd eglibc-2.13 && DEB_GCC_VERSION=-4.6 \
dpkg-buildpackage -a"${MYARCH}" -B -us -uc ) 2>&1 \
| tee eglibc-stage2.log
$ sudo dpkg-cross -M -a "${MYARCH}" -X libc-bin -X libc-dev-bin -i \After this completes we have a fully usable C library for our target architecture, and it's time for the final GCC cross-compiler build with all features enabled.
"libc6_2.13-21_${MYARCH}.deb"
"libc6-dev_2.13-21_${MYARCH}.deb"
$ sudo apt-get build-dep gcc-4.6=4.6.1-13The final GCC build leaves about 23 packages lying around in the directory, and you should probably install all of them.
$ apt-get source gcc-4.6=4.6.1-13
... MAKE ANY CHANGES TO GCC HERE ...
$ ( cd gcc-4.6-4.6.1 && DEB_GCC_TARGET="${MYARCH}" DEB_STAGE=stage2 \
dpkg-buildpackage -b -us -uc ) 2>&1 | tee gcc-4.6-stage2.log
$ sudo dpkg -i $(dcmd --deb gcc-4.6_4.6.1-13_*.changes)
/usr/share/dpkg/archtableSo let's set these shell variables:
/usr/share/dpkg/cputable
/usr/share/dpkg/triplettable
$ unset MYARCH MYTRIPLET TARGETNOTE: You will see a warning that your GNU system type does not match your GCC system type. This is OK, and part of cross-compiling.
$ MYARCH=powerpcspe
$ MYTRIPLET="$(dpkg-architecture -a"$MYARCH" -qDEB_HOST_GNU_TYPE)"
$ sudo apt-get build-dep binutils=2.21.90.20111004-1Step 2 - Commands to download and modify Linux Kernel headers:
$ apt-get source binutils=2.21.90.20111004-1
... MAKE ANY CHANGES TO BINUTILS HERE ...
$ ( cd binutils-2.21.90.20111004 && TARGET="${MYTRIPLET}" \
dpkg-buildpackage -b -us -uc ) 2>&1 | tee binutils-build.log
$ sudo dpkg -i "binutils-${MYTRIPLET}_2.21.90.20111004-1_amd64.deb"
$ sudo apt-get build-dep linux-2.6=3.0.0-3Step 2.1 - You will need to edit the "debian/rules
$ apt-get source linux-2.6=3.0.0-3
$ pushd linux-2.6-3.0.0
$ vim debian/config/defines ## Add "${MYARCH}" to list
$ cp -a debian/config/{powerpc,"${MYARCH}"}
$ vim debian/config/"${MYARCH}"/* ## Make it work
... MAKE ANY OTHER CHANGES TO THE LINUX KERNEL HERE ...
## THE NEXT COMMAND FAILS WITH A WARNING MESSAGE, THAT IS OK!!!
$ dpkg-buildpackage -a"${MYARCH}" -b -us -uc -T"debian/control-real"
Step 2.2 - Commands to actually build Linux Kernel headers:
.PHONY: FORCE
binary-%: FORCE
dh_testdir
$(MAKE) -f debian/rules.gen binary-$*_$(DEB_HOST_ARCH)
$ dpkg-buildpackage -a"${MYARCH}" -b -us -uc -TsourceFIXME: Right now 2011/10/05 dpkg in testing/unstable does not support installing packages from foreign architectures, so we have to run the following command to forcibly convert the linux-libc-dev package with dpkg-cross. Eventually "foreign-architecture ${MYARCH}" in your /etc/dpkg/dpkg.cfg file will be enough to make "dpkg -i" just work.
$ dpkg-buildpackage -a"${MYARCH}" -b -us -uc -Tbinary-libc-dev \
--as-root -rfakeroot
$ popd
$ sudo dpkg-cross -M -a "${MYARCH}" -i \Alternate Step 2.3 (UNTESTED) - Eventually (with full multiarch dpkg, already in some Ubuntu) you will just use this command:
"linux-libc-dev_3.0.0-3_${MYARCH}.deb"
$ sudo dpkg -i "linux-libc-dev_3.0.0-3_${MYARCH}.deb"FIXME: The GCC stage1 build has a bug right now (Debian Bug #644439) which causes the gcc-4.6-powerpc-linux-gnuspe package to falsely depend on a libgcc-powerpcspe-cross package which is not part of a stage1 build.
$ sudo apt-get build-dep gcc-4.6=4.6.1-13FIXME: The EGLIBC debian package does not actually have a way to build this as a part of a minimal package file (see Debian Bug #644546), so we need to apply this patch that lets us build stage1 packages.
$ apt-get source gcc-4.6=4.6.1-13
$ curl -o 'gcc-4.6-cross-stage1-dep-fix-v2.patch' \
'http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=644439;msg=30;att=1'
$ patch -d gcc-4.6-4.6.1 -p1 <gcc-4.6-cross-stage1-dep-fix-v3.patch
... MAKE ANY OTHER CHANGES TO GCC HERE ...
$ ( cd gcc-4.6-4.6.1 && DEB_GCC_TARGET="${MYARCH}" DEB_STAGE=stage1 \
dpkg-buildpackage -b -us -uc ) 2>&1 | tee gcc-4.6-stage1.log
$ sudo dpkg -i "cpp-4.6-${MYTRIPLET}_4.6.1-13_amd64.deb"
$ sudo dpkg -i "gcc-4.6-${MYTRIPLET}_4.6.1-13_amd64.deb"
$ sudo apt-get build-dep eglibc=2.13-21FIXME: Right now 2011/10/05 dpkg in testing/unstable does not support installing packages from foreign architectures, so we have to run the following command to forcibly convert the libc6-dev package with dpkg-cross. Eventually "foreign-architecture ${MYARCH}" in your /etc/dpkg/dpkg.cfg file will be enough to make "dpkg -i" just work.
$ apt-get source eglibc=2.13-21
$ curl -o 'eglibc-2.13-cross-stage1-support.patch' \
'http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=644546;msg=5;att=1'
$ patch -d eglibc-2.13 -p1 <eglibc-2.13-cross-stage1-support.patch
... MAKE ANY OTHER CHANGES TO GLIBC HERE ...
$ ( cd eglibc-2.13 && DEB_GCC_VERSION=-4.6 DEB_STAGE=stage1 \
dpkg-buildpackage -a"${MYARCH}" -b -us -uc ) 2>&1 \
| tee eglibc-stage1.log
$ sudo dpkg-cross -M -a "${MYARCH}" -X libc6 -X libc-dev-bin \Alternate Step 4.1 (UNTESTED, BROKEN) - Eventually (with full multiarch dpkg, and the dependencies fixed) you will just use this command:
-i "libc6-dev_2.13-21_${MYARCH}.deb"
$ sudo dpkg -i "libc6-dev_2.13-21_${MYARCH}.deb"Step 5 - Commands to build and install a stage2 GCC:
$ sudo apt-get build-dep gcc-4.6=4.6.1-13
$ apt-get source gcc-4.6=4.6.1-13
... MAKE ANY CHANGES TO GCC HERE ...
$ ( cd gcc-4.6-4.6.1 && DEB_GCC_TARGET="${MYARCH}" DEB_STAGE=stage2 \
dpkg-buildpackage -b -us -uc ) 2>&1 | tee gcc-4.6-stage2.log
$ sudo dpkg -i "gcc-4.6-${MYTRIPLET}-base_4.6.1-13_amd64.deb"
$ sudo dpkg -i "libgcc1-${MYARCH}-cross_4.6.1-13_all.deb"
$ sudo dpkg -i "libgcc1-dbg-${MYARCH}-cross_4.6.1-13_all.deb"
$ sudo dpkg -i "gcc-4.6-${MYTRIPLET}_4.6.1-13_amd64.deb"
$ sudo dpkg -i "cpp-4.6-${MYTRIPLET}_4.6.1-13_amd64.deb"
$ sudo apt-get build-dep eglibc=2.13-21
$ apt-get source eglibc=2.13-21
$ curl -o 'eglibc-2.13-cross-stage1-support.patch' \
'http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=644546;msg=5;att=1'
$ patch -d eglibc-2.13 -p1 <eglibc-2.13-cross-stage1-support.patch
... MAKE ANY OTHER CHANGES TO GLIBC HERE ...
$ ( cd eglibc-2.13 && DEB_GCC_VERSION=-4.6 \
dpkg-buildpackage -a"${MYARCH}" -b -us -uc ) 2>&1 \
| tee eglibc-final.log