Building a sandboxed kernel

M. Warner Losh imp at bsdimp.com
Sun Jul 23 16:56:21 UTC 2006


In message: <3320CEAC-8A5C-407D-9867-C2A22820A599 at bleepsoft.com>
            "R. Tyler Ballance" <tyler at bleepsoft.com> writes:
: -----BEGIN PGP SIGNED MESSAGE-----
: Hash: SHA1
: 
: >>
: >> Between varying versions of userland tools (like config(8)) and path
: >> troubles, I'm wondering what tips anybody has to doing non-standard
: >> builds of the kernel (non-standard being not in /usr/src and not the
: >> host arch)
: >>
: >> Currently the make command I'm using, which doesn't work, is (/usr/
: >> obj is chmod'd 777):
: >>
: >> make TARGET_ARCH=iguana DESTDIR=/home/tyler/iguana buildkernel
: >>
: >> Any suggestions?
: >
: > You don't have to use /usr/obj for all your builds:
: >
: >     % mkdir -p /home/tyler/obj/iguana
: >     % env MAKEOBJDIRPREFIX=/home/tyler/obj/iguana \
: >       make TARGET_ARCH=iguana \
: >            DESTDIR=/home/tyler/iguana \
: >       buildkernel
: >
: > The trick here is to use MAKEOBJDIRPREFIX to change the default object
: > directory prefix from `/usr/obj' to whatever suits your own setup.
: 
: 
: This doesn't solve the problem of different versions of userland  
: tools required. For example, my machne is RELENG_6, but I'm  
: developing against the -CURRENT branch of code synced up in perforce.  
: Does one necessarily need a -CURRENT userland to develop with the - 
: CURRENT code base? All arguments of being able to test the code that  
: is built are moot since the testing of my code will all occur within  
: a virtualized (Qemu) machine environment.
: 
: I'm sure the difference in versions between RELENG_6 and CURRENT  
: aren't too great, but what about developing with CURRENT code on  
: RELENG_5? I guess the basic question is, how can I maintain my normal  
: workstation environment while using a toolset appropriate for  
: building CURRENT? (Does it even matter really?)

Doesn't matter.

I often do the following:

setenv TARGET arm			# this may be iguana for you
setenv TARGET_ARCH arm
setenv MAKEOBJDIRPREFIX /home/imp/obj
cd p4/imp_arm
make buildworld
make buildenv				# from here on out is in a subshell
cd ../arm/src/sys/arm/conf
config KB920X
cd ../compile/KB920X
make depend && make

You'll notice that I built in a tree that had all the arm patches
applied, and got a 'buildenv' there, but then build the kernel out of
a different tree.  This is a -current p4 tree for both imp_arm and
arm, but I do this on a RELENG_6 system.  I've done it in the recent
past on a 5.3 system too.

TARGET is MACHINE and TARGET_ARCH is MACHINE_ARCH.  MACHINE is the
kernel architecture, while MACHINE_ARCH is the CPU architecture
(TARGET_CPU is the specific CPU that we're optimizing for).  Chances
are excellent we'll have TARGET_ARCH armel and armeb shortly.  Right
now we have a hack ARM_BIG_ENDIAN used to control big vs little
endian, but since MACHINE_ARCH gets encoded into packages, I think we
need to move it there so binary packages do the right thing.  But
that's a WIP in my tree right now...

Warner


More information about the freebsd-hackers mailing list