Re: i386 -> x86_64 cross compile failure (binutils bug?)

Steven Rostedt
2005-12-09T21:25:17Z

On Fri, 2005-12-09 at 15:58 -0500, Lee Revell wrote:
> Also, isn't it a bug for the Makefile not to pass -m64 if I specify
> ARCH=x86_64? If I don't change the CFLAGS I get:
>
> $ make ARCH=x86_64
> CHK include/linux/version.h
> CC arch/x86_64/kernel/asm-offsets.s
> arch/x86_64/kernel/asm-offsets.c:1: error: code model 'kernel' not
> supported in the 32 bit mode
> make[1]: *** [arch/x86_64/kernel/asm-offsets.s] Error 1
> make: *** [prepare0] Error 2

Lee,

For my x86_64, I gave up on trying to do it through the normal path
(having a plain debian unstable system), and finally just downloaded the
gcc toolchain (gcc, binutils, and glibc) and built them as cross
compilers with the prefix x86_64-linux-

For binutils I made a directory binutils_x86_64 and in there I used:

../binutils-2.16/configure --prefix=/usr/local/x86_64 --target=x86_64-linux

For gcc (first pass) I used:

../gcc-4.0.2/configure --prefix=/usr/local/x86_64 --target=x86_64-linux \
--enable-shared --disable-threads --enable-languages=c

That's enough to get a gcc that builds the kernel.

Then I built glibc, and then once again the gcc with:

../gcc-4.0.2/configure --prefix=/usr/local/x86_64 --target=x86_64-linux \
--enable-shared --with-headers=/usr/local/x86_64/include \
--with-libs=/usr/local/x86_64/lib --disable-multilib \
--enable-languages=c

Probably not the best way, but it worked for me ;-)

Now I also installed a hack make program in /usr/local/bin that is used first:

---
#!/bin/sh

if [ ! -z $__MY_MAKE_RUNNING__ ]; then
/usr/bin/make $*
exit $?
fi

__MY_MAKE_RUNNING__=1
export __MY_MAKE_RUNNING__

pwd=`pwd | sed -ne '/\/home\/rostedt\/work\/kernels\//p'`

if [ -z $pwd ]; then
m="intmake"
else
m="amdmake"
fi

# prove to me that I'm running the right one
echo $m
$m $*
---

with amdmake in /usr/local/bin:
---
PATH=$PATH:/usr/local/x86_64/bin/ make CROSS_COMPILE=x86_64-linux- ARCH=x86_64 $*
---

and intmake also in /usr/local/bin:
---
make ARCH=i386 $*
---

So now all the kernels in my /home/rostedt/work/kernels are built with
the cross compiling x86_64 and all other kernels for intel i386. I know
this is a major hack, but I don't have time to pretty this up!

-- Steve