Recently I decided to get back into playing Dwarf Fortress, which if you don’t know is an extremely addictive game I highly recommend you check out.
However I ran in to problems right away trying to run it, the first being that Dwarf Fortress requires 32 bit libraries and I have a 64 bit system, this was easily fixed by adding a text file in /etc/portage/package.use/ with the full package name (I.E media-libs/libsdl) and abi_x86_32 then running emerge again, this compile the 32 bit version of the needed library.
The second problem I had not encountered before, since the /usr/lib32/libz.so is actually a ld script there is a bug where bash being 64 bit loads the 64 bit library instead right before execution causing it to fail loading, this is fixed by setting the LD_PRELOAD environment variable to /lib32/libz.so.1 I put the following in the df shell script:
LD_PRELOAD=/lib32/libz.so.1 export LD_PRELOAD
P.S the libz bug may effect other distributions as well, fix is the same just double check the path to libz is correct.