# Howto create a crosscompiler/64bits kernel on 32bit install.

## okapi

Here's a little howto on how to create a crosscompiler and a 64bits kernel on a 32bit install running on amd64.

```
emerge sys-devel/crossdev
```

Build your crosscompiler.

```
crossdev -t x86_64-pc-linux-gnu
```

Clean up your kernel source tree. (This step is very important because 32bits configs are different than 64bits)

```
make ARCH=x86_64 CROSS_COMPILE=x86_64-pc-linux-gnu- mrproper
```

Configure your kernel.

```
make ARCH=x86_64 CROSS_COMPILE=x86_64-pc-linux-gnu- menuconfig
```

Note:

It is a good idea to use the option General Setup  ---> Local version - append to kernel release with somthing like -x86_64 if you dont want to overwrite you running kernel and modules.

Don't forget to set Executable file formats / Emulations  --->IA32 Emulation or be a fool!

Compile your kernel.

```
make ARCH=x86_64 CROSS_COMPILE=x86_64-pc-linux-gnu-
```

```
make ARCH=x86_64 CROSS_COMPILE=x86_64-pc-linux-gnu- modules_install
```

```
make ARCH=x86_64 CROSS_COMPILE=x86_64-pc-linux-gnu- install
```

Create a new Grub or Lilo entry.

And Voila! You now have a 64bits Kernel and a 64bits crosscompiler.

----------

## satanskin

Just to make things extremely clear, is this for running on a 64-bit processor or a 32-bit processor to compile 64-bit binaries?

----------

## okapi

 *satanskin wrote:*   

> Just to make things extremely clear, is this for running on a 64-bit processor or a 32-bit processor to compile 64-bit binaries?

 

I recently changed my MoBo and Cpu. I have a Athlon64 running in 32bit on my old athlon-xp install.

----------

## Skotlex

*brushes dust off topic* Ahem, it's been five years, but this guide is exactly what I was looking for. I've been searching for a while on a way to test out a 64-bit kernel on an otherwise pure 32-bit system.

I hope the guide still works (I will try it in a while), but I have two questions that should be addressed for those who want to follow this:

Will using modules work as normally, or must this kernel be static and have all modules compiled in?

What about nvidia graphic cards users? Is there some guide/right method of compilation, or you shouldn't even try? Or is nouveau the only way?

EDIT: So here are my findings:

1. If you want a crosscompiler ONLY for building your 64bit kernel, you can change the command:

```
crossdev -t x86_64-pc-linux-gnu
```

for 

```
crossdev -t x86_64-pc-linux-gnu -s1
```

As that will only give you a GCC capable of producing 64bit executables.

2. Current kernels have a 'Cross-compiler tool prefix' (CONFIG_CROSS_COMPILE) which is a good way to store the CROSS_COMPILE variable. By setting CONFIG_CROSS_COMPILE=x86_64-pc-linux-gnu-, you can change the compilation commands from:

```
make ARCH=x86_64 CROSS_COMPILE=x86_64-pc-linux-gnu-
```

to

```
make ARCH=x86_64
```

3. nvidia-drivers seems to be a hassle to compile, because the X11 driver should be compiled in 32bit while the kernel module in 64bit :/ I just dumped that and changed to Nouveau, that was way easier.

All in all, this guide still works.

----------

## alex6

This guide still work 10 years after but I'm surprised in all this time there is still no workaround for nvidia !!!!

----------

## fberger

The recipe is still working in 2017. Thanks.

```
$ uname -a

Linux - 4.10.11-gentoo-x86_64 #1 SMP PREEMPT - x86_64 Intel(R) Core(TM) i5 CPU M 520 @ 2.40GHz GenuineIntel GNU/Linux
```

----------

## kosik

 *okapi wrote:*   

> Here's a little howto on how to create a crosscompiler and a 64bits kernel on a 32bit install running on amd64.
> 
> ```
> emerge sys-devel/crossdev
> ```
> ...

 

How many headaches has this 12 years old post solved? Many, I guess! After working around the gold linker and some specialities I have in make.conf it worked like a charme in 2017.

Thanks, dude. I owe you a beer...

----------

## kosik

 *fberger wrote:*   

> The recipe is still working in 2017. Thanks.
> 
> ```
> $ uname -a
> 
> ...

 

Whoa, I didn't read through the whole thread... but this, Sir, is awesome! ...see my post above.

----------

