tech-toolchain archive

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

Re: Cross-building on ubuntu

As promised, notes on cross-compiling a kernel for NetBSD 4.0.1 on a ubuntu 
8.10 host.  I’ve been away from NetBSD for a while (since v1.6), so apologies 
if the following is well known/obvious to regulars:

1.  Unpack sources somewhere convenient.  

2.  Ensure both g++ and ncurses-dev are installed.  
(‘sudo apt-get install g++’ and ‘sudo apt-get install ncurses-dev’ respectively)

3.  Ensure that bash is used as the shell rather than /bin/sh.  Obscure shell 
script errors result if not.  ‘HOST_SH=/bin/bash; export HOST_SH’ 

4.  glob.c in tools/compat relies on ARG_MAX being defined.  As discussed in 
various places 
GLIBC>=2.8 no longer define ARG_MAX.  I couldn’t determine the best place to 
apply the fix, so I simply added it to the top of glob.c.  Presumably there’s a 
.h file somewhere that I ought to put it in?

5.  It is possible for a stack overrun to occur in parts of binutils 
(particularly ar).  Applying the patch at: in 
gnu/dist/binutils makes it work again.  Note that this patch doesn’t quite 
apply cleanly and the hunk that contains the definition of _bfd_ar_spacepad() 
needs to be tweaked/applied manually. 

It is then possible to execute something like:
/bin/bash ./ –m i386 –O ~/obj –U tools kernel=GENERIC

…and get a functioning kernel at the end of it.  I’ve not yet tried building a 
full distribution.



--- On Wed, 3/12/08, Hubert Feyrer <> wrote:

> From: Hubert Feyrer <>
> Subject: Re: Cross-building on ubuntu
> To: "David Forbes" <>
> Cc:
> Date: Wednesday, 3 December, 2008, 10:44 AM
> On Wed, 3 Dec 2008, David Forbes wrote:
> > I've recently being trying to cross-build NetBSD
> from a
> > ubuntu 8.10 system.  In general, the system
> works
> > well and I've managed to get it working to the
> point of
> > a building a usable i386/GENERIC kernel.
> >  
> > However, I did have to solve a number of snags along
> the
> > way, to which the solutions were in varied locations
> across
> > the internet.  Is there a document/wiki that I should
> > contribute my notes to?
> I think sharing your experiences on this list would be good
> for a start.
> FWIW, I'm doing release builds of the netbsd-5 and the
> HEAD branches on OpenSuse 10.2. The former works fine, the
> latter seems broken right now (or was so when I checked
> yesterday).
>  - Hubert

Home | Main Index | Thread Index | Old Index