Re: [PureDarwin] Re: Re : Re: Re : Re: Building XNU?

31 views
Skip to first unread message

daid kahl

unread,
May 27, 2011, 1:29:29 PM5/27/11
to pured...@googlegroups.com
Just some notes on chroot itself.

Of course you can RTFM, but I can give a simple description, since I
use chroot all the time building a Gentoo system. So I will use that
as an example.

So I put in a Live CD and boot from it. My root is presently the Live
CD root after I have booted fully. So I download some base code
(compiled baselayout, gcc, the toolchain, and so on) and extract it,
say, onto the partition I want to make into Linux.

Now suppose I try to compile something with gcc. Well my PATH is
determined by the present environment, so clearly I will use the Live
CD gcc if it exists. Furthermore, while relative path structure will
work (for example, if one was in the directory /mnt/gentoo/usr/local
and something wanted ../bin then it will hit /mnt/gentoo/usr/bin but
if it wants /usr/bin it will get stuff from the Live CD!).

So if you change the root (chroot) and source the profile (sets up the
new environment), then you are essentially inside a different system.
The main thing you gain here is a way to either cross compile, or a
way to work on a system from inside that system, even before the
system can successfully boot.

Anyway, I never worked much on this project. I think I managed to get
a booting system on a USB key. My MacBook died last month, and I
never use Mac OS anyway, so even in the future once I finish my PhD
the chance I get into the project is not so huge. But it's very
interesting in any case.

Cheers,
daid

2011/5/26 Mountainstorm <mountai...@googlemail.com>:
> you may be correct about the darwinbuild thing.  I've been playing
> around with darwinbuild again and just tried:
>
> sudo darwinbuild -nochroot xnu
>
> and, it appears to have worked ... I don't know why and if I'm honest
> I'm not completely sure what difference not using chroot makes but ...
> yay?  I now have a nice tidy mach_kernel, system.kext, plus all the
> headers in a nice clean folder structure.
>
> A couple of questions:
>
> 1. how (via darwinbuild) can I specify build options e.g. the
> equivalent of ARCH_CONFIGS, do I do it via exporting the variables
> into the current shell?
> 2. if I want to build my own project in the darwinbuild environment
> how do I?  I've compiled AppleI386GenericPlatform (imported from
> Darwin 8) and when darwin boots its complaining about not being able
> to patch the classes parent vtables.  I suspect its due to compiling
> against the wrong platform but cant see how I'd change the xcodeproj
> SDK to be my darwin build env.
> 3. why did you leave the puredarwin project ... and is there anyone
> else left?
>
> Thanks for your help
>
> Rich
>
>

daid kahl

unread,
May 27, 2011, 1:35:19 PM5/27/11
to pured...@googlegroups.com
Or perhaps a better example on chroot, if I can follow what you are
doing in this case.

If you are building from inside a Mac OS box a new Darwin system, if
you do nochroot, it uses all the Mac OS toolchain items, environment,
and so on. If it succeeds this tells you that the code itself you
wanted to build is configured correctly, and, lo and behold, your Mac
OS toolchain isn't broken (no surprise there).

But if it won't build with chroot, that means that the Darwin
environment is missing critical pieces. This could be from A to Z.
Programs, environment, configuration. Blah. In any case, you know
from the chroot vs. nochroot that, basically, the Darwin toolchain (or
parts of that) are your critical issue.

~daid

Aladin

unread,
May 30, 2011, 5:47:24 AM5/30/11
to pured...@googlegroups.com
Thanks for the info, daid.

In the "context" of PureDarwin, using a chroot for building binaries via DarwinBuild is necessary, it's all about "purity" (e.g. http://www.puredarwin.org/developers/macports/purity).

Building something outside of the chroot will create static and dynamic dependencies on libraries which could not be available (the path is often different too), except on Mac OS X.

But in fact, the story just begins here, even if dependencies are satisfied for a binary built in the chroot (in terms of existence), sometimes (often to be sarcastic) there are function calls inside a binary which cannot link to a library, because this library does not contain any reference of these function calls. This is why many patches were needed in Darwin 9, from creating just an empty function (just to satisfy the link) to filling it or sometimes to even alterate the prototype (e.g. http://code.google.com/p/puredarwin/source/browse/#hg%2Fpatches); this was also needed for several MacPorts projects.

One goal which cannot fully be achieved is http://www.puredarwin.org/developers/darwinbuild/darwinbuildonpuredarwin mainly because of XCode dependencies.

Reply all
Reply to author
Forward
0 new messages