[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Compile Kernel 32 bits on an 64 bits machine: initramfs



I acknowledge that this is a late answer, hope it still helps.

On Mon, Jun 08, 2015 at 05:45:52PM +0100, pietrop wrote:
> I am running a Debian 8 machine and I need to compile a 32 bits kernel
> using this system, I have managed to compile the kernel using the
> package linux-source-3.16 and it boots fine exporting CFLAGS=-m32 
> to cross compile.
> 
> Basically:
> 
> export CFLAGS=-m32
> make
> make modules_install
> make install

What looks like a successful cross compile, is horribly broken. The
kernel build involves many more architecture specific things than
invoking a compiler. So merely adding -m32 to CFLAGS gets you some parts
build for amd64 and others for i386. I'm surprised it worked at all.

> What's your reckon ? If my thought is correct where could I find a
> pre-generated initramfs to use with such kernel version, or do you have
> any other solution ?

Projects differ in how they do cross compilation and for Linux there are
two key aspects to going cross. You set two variables when invoking
make. The keys to set are ARCH= and CROSS_COMPILE=. I don't know the
correct value for ARCH of hand, because it seems to be the same for
amd64 and i386: x86, so there likely is another fiddle to distinguish
them. You should set CROSS_COMPILE to "i586-linux-gnu-" and ensure that
you have such a toolchain. One way to get that toolchain (and yes, it is
more than just i586-linux-gnu-gcc) when you already do have multilib is
to use Guillem's fake cross toolchains. See
https://lists.debian.org/debian-devel/2013/08/msg00305.html for details.
For more information on cross compiling Linux, see the comments in the
toplevel Makefile.

Helmut


Reply to: