How to merely compile the kernel and boot in x86-64 platform for Haiku?

I want to learn haiku kernel in x86-64 platform, but the whole system source code is relatively large.
I want to just compile the kernel and boot, then writes them to disk images.This is very handy for learning kernel.

What should I do?

I’d still checkout the full branch for the source, which you will find here: https://github.com/haiku/haiku . You can either do that graphically (there is a ‘checkout’ or download button), or open Terminal and check it out that way.

Now, as for compiling the kernel only. This should be as simple as jam -q -a -j3 Kernel (if I remember right). Haiku uses jam as its compiler; the q switch means quit if an error is encountered, the a allows compiling one application, and j denotes how many threads to use. Typically, that’s +1 the cores of your machine. So, if it has 2 cores (standard now days), you’d use j3. It’s been a few months since I last played with jam when I used to develop and maintain Poem (an unofficial Haiku derivative), but if I’m remembering that right, that ought to work. If not, let me know and I’ll try to run through it and see if it works.

As for creating a boot image, I believe you’ll have to compile the whole thing (and that is a simple jam -q -j5 @anyboot-image on Haiku, provided you have a matching Nightly. You can, of course, cut down the amount of stuff to compile by editing out their entries in the Jamfiles per folder and then the Build scripts in build (I think it was?) if you know what you are doing. For instance, you can cut out apps, documentation, most of the preferences, etc. to get a very lightweight/minimal build and from there cut down the Anyboot image size from 300 to whatever fits it all. But that last part will be tricky to estimate, and making sure your edits make sense is very important when Haiku assembles the image for you – be careful as you can break your build. I’d recommend to use the Pe editor with syntax highlighting, if not an IDE for Be/Haiku that you could find. My advice is to backup the originals first if you’re going to do this, or just compile the whole thing and wait 35 minutes on a quad; 1.5 hrs. on a slow dual-core. If you are using a VM or hypervisor (not bare metal), I’d highly recommend kvm to get the most speed out of it. All that said, compile time really varies based on your hardware, speed, and patience level.

Either way, good luck and enjoy Haiku! :slight_smile:

hkkerneldev@ubuntu:~$ git clone https://git.haiku-os.org/buildtools
hkkerneldev@ubuntu:~$ cd buildtools/jam/
hkkerneldev@ubuntu:~/buildtools/jam$ make 
hkkerneldev@ubuntu:~/buildtools/jam$ sudo ./jam0 install
hkkerneldev@ubuntu:~/buildtools/jam$ cd ..
hkkerneldev@ubuntu:~/buildtools$ cd ..
hkkerneldev@ubuntu:~$ mkdir haiku20160511
hkkerneldev@ubuntu:~$ cd haiku20160511/
hkkerneldev@ubuntu:~/haiku20160511$ git clone https://git.haiku-os.org/haiku
hkkerneldev@ubuntu:~/haiku20160511$ cd haiku
hkkerneldev@ubuntu:~/haiku20160511/haiku$ mkdir x86_64
hkkerneldev@ubuntu:~/haiku20160511/haiku$ cd x86_64/
hkkerneldev@ubuntu:~/haiku20160511/haiku/x86_64$ ./../configure --use-xattr-ref -j2 --build-cross-tools x86_64 ./../../../buildtools

binutils and gcc for cross compilation have been built successfully!
hkkerneldev@ubuntu:~/haiku20160511/haiku/x86_64$ jam -q -a -j3 Kernel
Starting build of type regular ... 
qrencode support not available on x86_64 
/home/hkkerneldev/haiku20160511/haiku/src/add-ons/kernel/debugger/disasm/x86_64/Jamfile: No such file or directory
/home/hkkerneldev/haiku20160511/haiku/src/bin/debug/ltrace/arch/x86_64/Jamfile: No such file or directory
Skipping setjmp_test2.S test on non-x86 
don't know how to make Kernel
...patience...
...found 1 target(s)...
...can't find 1 target(s)...

“As for creating a boot image, I believe you’ll have to compile the whole thing”

I’m ready to extract and modify the source code which belongs to the booting portion of the kernel portion. So do not compile all the code.
To accomplish this, I need to understand the entire compilation process,but the jamfile dazzled me,I may need to read slowly the Jamfile. :smiley:

Build the kernel this way:

jam -q kernel

Build the bios boot loader this way:

jam -q haiku_loader

Now this isn’t easily bootable as is. Maybe try the floppy: jam -q haiku-boot-floppy.
An alternative target is haiku-image.

You usually give Jam the name of the target you want to build. In the case of the Kernel, the target is defined in http://cgit.haiku-os.org/haiku/tree/src/system/kernel/Jamfile#n110

So you can run:

jam -q -j4 kernel_x86_64

The "-q" tells Jam to quit immediately when there is an error (otherwise it would still try to build as much things as possible). The "-j4" is for a parallel build.

Thanks all.