From Gentoo Wiki
Jump to:navigation Jump to:search


Nope, its all fucked, I give up, you can't step-ladder stages, they're fucked.

Long Form

Build QEmu to support this mess

You'll need:

  • "static-user" is important, because you need to copy the binary into your chroot later, and expect it to work.
  • "-tci" is important, as for whatever reason, everything even slightly complicated (perl, python, all of portage) segfault in its code.


Set up the kernel to dispatch m68k binaries to qemu user

This mostly involves:

  • Having a kernel with binfmt_misc support
  • making sure the /proc fs for binfmt_misc is mounted
  • making sure the right glue entries are present

Some of which can be mostly done with:

/etc/init.d/binfmt start
/etc/init.d/qemu-binfmt start


Build your chroot

  • wget a stage image: [1]
  • untar it somewhere ( $CHROOT )
  • cp /usr/bin/qemu-m68k $CHROOT/usr/bin/

Drop into Chroot

And that should mostly be enough to get chrooting to work:

chroot ${CHROOT} /bin/bash
# uname -a
Linux katipo2 5.7.14-gentoo #61 SMP PREEMPT Thu Aug 13 17:39:19 NZST 2020 m68k GNU/Linux

Now, obviously this is not adequate for real work, you'll probably need some bind-mounts or whatever, the standard fare for doing chroots, covered by most install guides, if you want "/proc" to exist, for instance.

But its enough to prove you can start doing m68k-ish stuff.


Getting things up-to-date is hell, because the stage is dated 2013, and well, that means its portage is pre-EAPI(whatever), and you can't even install the latest portage with it.

I suggest cracking open sync/gentoo.git and rewinding to 3474fda92548e6c24979ba08ffd77e8106a9d591 (October 2016)

Make sure to eselect profile and pick a valid one, or bootstrap can't work.

This seems to be old enough that portage-2013 finds a legal depgraph, and the tarballs aren't all gone poof into the dark bits.




Often, you'll get situations where distfiles exist, ... but simply cant be fetched, due to SSL legacy issues.

Connecting to|2a04:4e42:37::223|:443... connected.
OpenSSL: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
Unable to establish SSL connection.

Fortunately, you can still fetch these manually in the host with a more recent wget or whatever, and dodge that bullet.

mmap stack: Cannot allocate memory

Yeah, don't set MAKEOPTS with a -j value >1 . It doesn't play nice with the whole "you can only use 4G Virtual Address space on 32bit" and "make calls vfork" and "vfork has to be done in qemu, duplicating the address space somewhere at some point while also trying to share it", and things like util-linux will poo the sheets trying to call "as" with a bunch of things, and you will be sad.

In fact, you should explicitly set MAKEOPTS=-j1, as somewhere after upgrading something, something will "autodetect" a default and you'll find MAKEOPTS="-j4" kicks in your build environment.

If avoiding MAKEOPTS is not sufficient, also set QEMU_STACK_SIZE=256M and cross your appendages. Worked for me!?

More out of memory errors 8 hours into a gcc compile

You're kinda screwed here, haven't worked out how to avoid this, other than crossing your fingers and start over with emerge.

It might help to quit the chroot, reap all qemu- process manually, then re-enter the chroot.

But ...

Alternatively, try USE="-fortran -openmp" for gcc, which will mean portage won't try to reinstall it at all after getting past bootstrap, as bootstrap seems to toggle that.

udev: hidden symbol `__stop_BUS_ERROR_MAP' isn't defined

Its fucked and I can't unfuck it.

I gave up and just started --exclude sys-fs/udev --exclude sys-fs/static-dev

You need both exclusions as static-dev is the fallback for when you don't have udev, but like, I'm bind-mounting udev, so ....

Fallback to busybox mdev? Idk.

Bash segfault *** Error in `/bin/bash': free(): invalid pointer: 0x3ff97000 ***


For some weird reason, bash using '[' instead of '[[' makes it panic. God only wut.

I hand edited /etc/profile and replaced '[ ]' with '[[ ]]' and the panics go away. WHY.

Known good-ish states

October 2016


Most of the distfiles are retrievable automatically, but some I had to ask for help for copies (++NeddySeagoon) and dig up some sources from google (++vapier, ++ whoevers responsible for )

This is suitable for a full run :)

  • make sure to use gcc-config to select a valid profile when done ( m68k-unknown-linux-gnu-5.4.0 )
  • make sure to use `eselect python` to set valid python's
eselect python set --cpython python3.4
eselect python set --python2 python2.7
eselect python set --python3 python3.4

Then feel free to

emerge -C sysvinit udev-init-scripts

You don't need them under chroot anyway, so its cool.

And I recommend:

emerge -uvat --fetchonly @system

First, because you're gonna want to know what you're missing.

Also, to save yourself a waste of time:

emerge -va1 atari-fdisk # make sure its up-to-date
# fix stupid file collision with util-linux 
rm /sbin/atari-fdisk 
rm /usr/share/man/man8/fdisk.8.bz2
mv /sbin/fdisk /sbin/atari-fdisk
# unfuck the CONTENTS so it doesn't fuck util-linux later
nano /var/db/pkg/sys-fs/atari-fdisk-
# Tweak this shit
obj /sbin/fdisk f9d6c2490d71d9e200d8e5d03204b7fe 1601972877
sym /sbin/atari-fdisk -> fdisk 1601972868
sym /usr/share/man/man8/fdisk.8.bz2 -> atari-fdisk.8.bz2 1601972882
# To This shit
obj /sbin/atari-fdisk f9d6c2490d71d9e200d8e5d03204b7fe 1601972877
# make sure you remove both "sym" lines


emerge -uvat --keep-going @system

First deploy a few hacks for keywords and USE flags

mkdir -p /etc/portage/package.accept_keywords/
mkdir -p /etc/portage/package.use
mkdir -p /etc/portage/package.mask
echo '=dev-util/gperf-3.0.4 **' > /etc/portage/package.accept_keywords/autounmask-2016
echo '=dev-util/pkgconfig-0.29.1 internal-glib' >> /etc/portage/package.use/autounmask-2016
echo "=sys-devel/gcc-5.4.0 -fortran -openmp" > /etc/portage/package.use/hacks-2016
echo '=sys-apps/busybox-1.24.2 mdev' >> /etc/portage/package.use/hacks-2016
echo "<=sys-fs/udev-230-r1" > /etc/portage/package.mask/bad-2016
echo "<=sys-fs/static-dev-0.1" >> /etc/portage/package.mask/bad-2016

Make sure you didn't miss any distfiles

emerge -uvatDN --with-bdeps=y --fetchonly @world

And when that all checks out

emerge -uvatDN --with-bdeps=y @world

When all is done, congrats!, you just leaped forward 3 years and have a semi-recentish openssl. total: 43:15:52 for 144 merges, 12 unmerges

Yikes, and that's not including the 5 failed gcc's and udev's I had to go through.

depclean / cleanup
emerge --depclean -va --with-bdeps=y

Yes, removing udev is fine here. We're still chroot, yain't gonna need it.

dispatch-conf # (or etc-update)

You also probably want to ensure your portage is setup now as per recent portages with "repos.conf"

Here's what I'm using, I'm not ready to actually tell portage it can sync stuff itself.

#  cat /etc/portage/repos.conf/gentoo.conf 
main-repo = gentoo

location = /var/cache/portage

Do yourself a favour though:

nano -w /etc/python-exec/python-exec.conf
# remove lines about python3.2

I don't know why these are here and its just annoying.

October 2018


These following instructions assume you got October 2018 working first.


Employ this fix: Glibc_2.26_porting_notes/nsswitch.conf_in_glibc-2.26

emerge -C sandbox
echo "=app-crypt/pinentry-1.1.0-r2 **" > /etc/portage/package.accept_keywords/autounmask-2018
echo "=dev-libs/libksba-1.3.5-r1 **" >> /etc/portage/package.accept_keywords/autounmask-2018
echo "=dev-libs/libassuan-2.5.1 **" >> /etc/portage/package.accept_keywords/autounmask-2018
echo "=dev-python/bz2file-0.98 **" >> /etc/portage/package.accept_keywords/autounmask-2018
emerge -uvat --keep-going @system

Somewhere in the middle of this it will fuck up (probably) in automake, like:

panic: corrupt saved stack index -1414812757, <> line 1214.
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
./bootstrap: line 106:  8435 Segmentation fault      $PERL -w bin/gen-perl-protos $p.tmp > $p.tmp2
 * ERROR: sys-devel/automake-1.15.1-r2::gentoo failed (prepare phase):
 *   (no error message)
 * Call stack:
 *, line 115:  Called src_prepare
 *   environment, line 2159:  Called die
 * The specific snippet of code:
 *       ./bootstrap || die;

Just ignore it, and re-run the emerge -uvat @system and it mysteriously stops being a target, and lets hope we can fix that shit later.

You'll also see similar segfaults in grep, but whatever, doesn't stop the compile.

checking for perl5.005 or newer... ./configure: line 25790: 20612 Segmentation fault      ( $perl -e 'require 5.005; use File::Compare' ) > /dev/null 2>&1
configure: WARNING:
WARNING: You don't seem to have perl5.005 or newer installed, or you lack
         a usable version of the Perl File::Compare module.  As a result,
         you may be unable to run a few tests or to regenerate certain
         files if you modify the sources from which they are derived.

And somewhere in binutils

panic: corrupt saved stack index -2147059664.
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
/bin/sh: line 1:   991 Segmentation fault      perl /var/tmp/portage/sys-devel/binutils-2.31.1-r1/work/binutils-2.31.1/ld/../etc/ -I /var/tmp/portage/sys-devel/binutils-2.31.1-r1/work/binutils-2.31.1/ld -I /var/tmp/portage/sys-devel/binutils-2.31.1-r1/work/binutils-2.31.1/ld/../bfd/doc -I ../bfd/doc -I /var/tmp/portage/sys-devel/binutils-2.31.1-r1/work/binutils-2.31.1/ld/../libiberty -Dman < /var/tmp/portage/sys-devel/binutils-2.31.1-r1/work/binutils-2.31.1/ld/ld.texi > ld.pod
make[4]: [Makefile:3495: ld.1] Error 139 (ignored)
(pod2man --center="GNU Development Tools" --release="binutils-2.31.1" --section=1 ld.pod | \
	sed -e '/^.if n .na/d' > ld.1.T$$ && \
	mv -f ld.1.T$$ ld.1) || \
	(rm -f ld.1.T$$ && exit 1)
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
rm -f ld.pod

Yikes 😬 I'm gonna hope reinstalling perl somewhere later unfucks this.

Anywho, I eventually get this far before I'm blocked by coreutils

[ebuild     U  ] sys-fs/e2fsprogs-1.44.4::gentoo [1.43.3::gentoo] USE="nls -fuse -static-libs" 0 KiB
[ebuild     U  ] sys-apps/diffutils-3.6-r1::gentoo [3.5::gentoo] USE="nls -static" 0 KiB
[ebuild     U  ] sys-apps/net-tools-1.60_p20180626073013::gentoo [1.60_p20160215155418::gentoo] USE="arp hostname ipv6 nls -nis -plipconfig (-selinux) -slattach -static" 0 KiB
[ebuild  NS    ] sys-devel/gcc-8.2.0-r3:8.2.0::gentoo [5.4.0:5.4.0::gentoo] USE="cxx fortran nls nptl openmp pch (pie) ssp (-altivec) -debug -doc (-fixed-point) -go (-graphite) (-hardened) (-jit) (-libssp) (-mpx) (-multilib) -objc -objc++ -objc-gc -pgo -regression-test (-sanitize) -systemtap -vanilla (-vtv)" 0 KiB
[ebuild     U  ] sys-apps/iproute2-4.18.0::gentoo [4.7.0::gentoo] USE="berkdb iptables ipv6 -atm -elf% -minimal (-selinux)" 0 KiB
[ebuild     U  ] net-misc/wget-1.19.5::gentoo [1.18::gentoo] USE="ipv6 nls pcre ssl zlib -debug -gnutls -idn -libressl -ntlm -static {-test} -uuid" 0 KiB
[ebuild     U  ] sys-apps/coreutils-8.30::gentoo [8.25::gentoo] USE="acl nls split-usr%* xattr -caps -gmp -hostname -kill -multicall (-selinux) -static {-test%} -vanilla" 0 KiB

Sooo lets fix this fucking perl problem eh

# Look ma, no hands! The brave mans perl upgrade
emerge -C perl-core/File-Temp
emerge -C virtual/perl-*
# yolo
FEATURES="test" emerge -uva1 dev-lang/perl
!!! Problem with sandbox binary. Disabling...

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild     U  ] dev-lang/perl-5.26.2:0/5.26::gentoo [5.24.0-r1:0/5.24::gentoo] USE="berkdb gdbm -debug -doc -ithreads" 11,770 KiB
[ebuild  N     ] virtual/perl-Test-Harness-3.380.0::gentoo  0 KiB
[ebuild  N     ] virtual/perl-Data-Dumper-2.167.0::gentoo  0 KiB
[ebuild  N     ] perl-core/File-Temp-0.230.400-r1::gentoo  59 KiB
[ebuild  N     ] virtual/perl-File-Temp-0.230.400-r5::gentoo  0

Yeah. K.


LD_LIBRARY_PATH=/var/tmp/portage/dev-lang/perl-5.26.2/work/perl-5.26.2 ./miniperl -w -Ilib -Idist/Exporter/lib -MExporter -e '<?>' || sh -c 'echo >&2 Failed to build miniperl.  Please run make minitest; exit 1'
panic: corrupt saved stack index -2145689840.

And nope, its all fucked, I give up, you can't step-ladder stages, they're fucked.