This wikipage is work in progress (broken formatting, and out of date)
STEP 0 preparation
1 sudo debootstrap sid sid-chroot
2 sudo pbuilder login --no-targz --buildplace sid-chroot
3 sed -i ’s/^deb http/deb [arch=amd64] http/‘ /etc/apt/sources.list
4 echo “deb-src http://ftp.us.debian.org/debian sid main” >> /etc/apt/sources.list
5 dpkg --add-architecture mips64el
6 apt-get update
7 apt-get install binutils-mips64el-linux-gnuabi64 devscripts rdfind symlinks
STEP 1 build gcc stage1
apt-get build-dep gcc-4.9 apt-get purge libx32* libc6-i386 libc6-x32 # they conflicts with mips64el multilib packages
downgrade all packages from gcc-4.9 to 4.9.2-3 i.e. before with_deps_on_target_arch_pkgs was removed: download them from snapshot.debian.org
dget http://snapshot.debian.org/archive/debian/20141126T040641Z/pool/main/g/gcc-4.9/gcc-4.9_4.9.2-3.dsc cd gcc-4.9-4.9.2
enable with_deps_on_target_arch_pkgs in debian/rules.defs
Patch some files
in debian/rules.defs,
Enable gccbase for stage1 and cross,
change
to:
with_gccbase := yes
In debian/rules.conf,
Enable gccbase for stage1,
After
add
Then run command
with_deps_on_target_arch_pkgs=yes DH_VERBOSE=1 WITH_SYSROOT=/ BACKPORT=false PKG_IGNORE_CURRENTLY_BUILDING=1 DEB_BUILD_OPTIONS=nostrip DEB_STAGE=stage1 dpkg-buildpackage --target-arch=mips64el -b -uc -us -d
We can get these deb files:
cpp-4.9-mips64el-linux-gnuabi64_4.9.2-3_amd64.deb gcc-4.9-multilib-mips64el-linux-gnuabi64_4.9.2-3_amd64.deb libgcc-4.9-dev_4.9.2-3_mips64el.deb gcc-4.9-mips64el-linux-gnuabi64_4.9.2-3_amd64.deb lib32gcc-4.9-dev_4.9.2-3_mips64el.deb libn32gcc-4.9-dev_4.9.2-3_mips64el.deb gcc-4.9-base_4.9.2-3_mips64el.deb
rm ../gcc-4.9-multilib*.deb dpkg -i ../*.deb
STEP 2 build linux-libc-dev
apt-get source linux; cd linux-* make -f debian/rules.gen binary-libc-dev_mips64el dpkg -i ../linux-libc-dev*.deb
STEP 3 glibc stage1
apt-get source glibc; cd glibc-*
change debian/sysdeps/linux.mk
from
ifndef LINUX_SOURCE ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) LINUX_HEADERS := /usr/include else LINUX_HEADERS := /usr/$(DEB_HOST_GNU_TYPE)/include endif LINUX_ARCH_HEADERS := /usr/include/$(DEB_HOST_MULTIARCH) else LINUX_HEADERS := $(LINUX_SOURCE)/include endif
to:
ifndef LINUX_SOURCE LINUX_HEADERS := /usr/include LINUX_ARCH_HEADERS := /usr/include/$(DEB_HOST_MULTIARCH) else LINUX_HEADERS := $(LINUX_SOURCE)/include endif
Then run
FIXME: libc6-dev depends on libc6, while for stage1, we have no libc6,
- how to fix it?
- libc6-dev-mips32 has /usr/include/fpu_control.h also, we need move fpu_control.h to
/usr/include/<triple> for stage1 in debian/rules.d/build.mk
- we have /usr/include/gnu/stubs-o32_hard.h, while no
- /usr/include/gnu/stubs-n32_hard.h maybe a problem of glibc,
- and stubs-n64_hard.h also not in it.
STEP 4 gcc stage2
with_deps_on_target_arch_pkgs=yes DH_VERBOSE=1 WITH_SYSROOT=/ BACKPORT=false PKG_IGNORE_CURRENTLY_BUILDING=1 DEB_BUILD_OPTIONS=nostrip DEB_STAGE=stage2 dpkg-buildpackage --target-arch=mips64el -b -uc -us -d
on the same source with stage1 gcc.