User:Aslantis/Multilib on targets without official multilib profiles
If you are here, you're needing multilib capabilities, but your architecture/target doesn't offer a multilib profile! This is a collection of ways to achieve this of varying quality-- if you know of any I missed, I appreciate additions.
Making a custom profile
Should be possible, I tried it once and couldn't get this working. I'll try to revisit this later.
The very hackish way with crossdev that might make gentoo devs cry
Self explanatory title.
First off, we're going to need to install a toolchain capable of compiling 32-bit code your system can run. An example for installing a powerpc32 toolchain on a powerpc64 install:
root #
crossdev --target powerpc-unknown-linux-gnu
Because 32-bit and 64-bit libraries are completely separate, this means you can install a different libc implementation for your 32-bit libraries! For example, you can have a glibc /lib and a musl /lib64 and vice reversa.
Next, you're going to need to do some setup for your multilib prefix. Follow Sam's gist and do everything until you get to the 'Chroot in' segment.
Next, you're probably going to want the actual libraries you need. These are base things you will probably want, install any additional library dependencies that you need.
root #
powerpc-unknown-linux-gnu-emerge --noreplace --ask glibc gcc linux-headers
If you're alright with running 32-bit applications in a chroot, you can just chroot! The directory you are looking for is /usr/${CHOST}/
.
root #
chroot /usr/powerpc-unknown-linux-gnu /bin/my-32bit-app
When running applications in a chroot, it will look for your application relative to the specified chroot directory. From the program's point of view, its root will be the given chroot directory. If you need to access your 'real system' from inside the chroot, you can do this with an --rbind mount.
For the rest of us, if you want to run 32-bit applications along your system ones, you'll probably want to populate your /lib
with the libraries you need. You can copy over libraries from /usr/${CHOST}/lib/
to your system's /lib
. The bare minimum for c/c++ programs is anything related to libc, libstdc++, and libgcc. While you can just move everything into /lib
and make /usr/${CHOST}/lib/
a symbolic link to /lib
, doing so is strongly discouraged because uninstalling your crossdev toolchain, or doing things with crossdev-emerge, runs the risk of removing or corrupting your /lib
, which is not good™.
With the proper libraries in place, you should be able to run any 32-bit application! You should also have a fully functioning 32-bit toolchain, and have a safe way to install 32-bit applications via crossdev-emerge. Feel free to install things with crossdev-emerge, and move the binaries you want to your system's $PATH, i.e. in /usr/local/bin/
.