Subject: Re: Kernel cross-compiling howto
To: None <tech-kern@netbsd.org>
From: Florian Stoehr <netbsd@wolfnode.de>
List: tech-kern
Date: 12/25/2004 14:42:33
> On Fri, Dec 24, 2004 at 03:57:16PM +0100, Florian Stoehr wrote:
>> Hi,
>
> Hi,
>
> first off, why did you send it to tech-kern? Not that I *really* care, but
> netbsd-users or similar lists sounds better for such sort of mails ;)
>
>>
>> since I shot myself in the foot cross-compiling a kernel yesterday and
>> had
>> to figure things out (I found no documentation except VERY old mailing
>> list entries), I wrote a litte howto. As far as I see, this one worked.
>>
>> Maybe someone can proof the steps here and add it to the Kernel FAQ on
>> the
>> website?
>>
>> Hehe ... my Xmas-present to NeBSD ;-)
> hehe
>
>>
>> -Florian
>>
>> Now the howto:
>>
>>
>>
>> In order to cross-compile the kernel, a toolchain for the
>> destination architecture is needed first.
>>
>> We assume NetBSD source is in /usr/src.
>> We will build a kernel for sgimips on a i386 in this howto,
>> so replace "sgimips" with your platform of choice.
>>
>> We store the toolchain in the /usr/TOOLS directory.
>>
>> First create the toolchain directories:
>>
>> mkdir /usr/TOOLS
>>
>> Now build the toolchain:
>>
>> cd /usr/src
>> ./build.sh -T ../TOOLS -m sgimips tools
>>
>> A new kernel config file "MYKERNEL" for sgimips was
>> created in the /usr/src/sys/arch/sgimips/conf directory.
>>
>> Configure the new kernel:
>>
>> cd /usr/src/sys/arch/sgimips/conf
>> /usr/TOOLS/bin/nbconfig MYKERNEL
>>
>> Now "make depend" the kernel:
>>
>> cd ../compile
> compile/ ? Not compile/MYKERNEL ? It should not make a difference if you
> crosscompile or compile nativly, imho. So, is that right? If yes, why?
>
>> /usr/TOOLS/bin/nbmake-sgimips depend
>>
>> Finally, let's make the kernel:
>>
>> /usr/TOOLS/bin/nbmake-sgimips
>>
>> One thing to remember: If you want to keep toolchains for
>> several architectures (toolchain-SGIMIPS, toolchain-SPARC, ...),
>> note that if you RENAME the toolchain directory OR MOVE THE
>> DIRECTORY, you have to adjust the "bin/nbmake-<platform>"
>> script.
>>
>> Make sure you call "nbmake-<platform>", not just "nbmake".
>>
>>
>>
>

Hi,

I sent to tech-kern because "users" seemed to me not to be the right place
for kernel cross-compiling issues (? perhaps ?).

I got many replies, so I learned that build.sh itself is capable of
doing the kernel-only crosscompile, futhermore there are instructions
under "crosscompiling NetBSD" -> but the toolchain moving seems not
mentioned there.

Yep, you're right, I missed the "compile/MYKERNEL", sure.

Unfortunately, there is no link to the cross compiling howto in the
kernel FAQ -> maybe it'd be good to put a link to the cross-compiling
howto there?

But unfortunately, I didn't get any info about the toolchain moving
instructions I gave - perhaps adjusting the script is not enough?

Still I wonder why "nbmake" will not work - I saw this in another
kernel-crosscompiling mail in the archive (although that was old and
used build.sh -t to build the toolchain which seems depreacted).

-Florian