Building 32 bit (Intel X86) kernel module on a 64 bit (Intel x86_64) machine

Building 32 bit (Intel X86) kernel module on a 64 bit (Intel x86_64) machine

Ori Berger linux-il at orib.net
Tue Jul 14 11:39:57 IDT 2009


Dan Shimshoni wrote:
> I want to add that "make ARCH=i686" (on the 64 bit machine) gave me errors
> (and also trying to passing various gcc 32 bit arch flags ).
>   
What errors  you got will be very helpful in getting to a solution - my 
guess would be link problems and/or wrong Makefile configuration
> It seems to me that both these tools are more complicated then needed.
> Does anyone know a better way for achieving this ? for example, building
> binutils on the x86_64 machine (maybe with a specific 32 bit flag, and
> maybe also building glibc with a flag specifying the target is intel
> x86 machine is a must ?), and then building gcc against this libraries
> ?
>   
If you're looking for the simplest solution, run a 32-bit environment - 
either in a virtual machine (virtual box, kvm, qemu or even vmware) or a 
chroot environment (google "debootstrap"). The virtual machine solution 
has the property that you'll also be able to test said kernel module and 
not just compile it.

Kernel modules will very often only work against the exact kernel 
version for which they were compiled. You're in for redoing the work if 
you upgrade the kernel on the 32-bit machine.



More information about the Linux-il mailing list