How to compile Haiku on Haiku?

All,

Quick question regading compiling Haiku - perhaps I’m missing something…?

I am trying to compile the Haiku source tree as per instructions at https://www.haiku-os.org/guides/building/configure. I want to fix the e-mail issue and start contributing to Haiku.

I have cloned the Git master branch, run ./configure from the Terminal, and am then running “jam” from the Terminal.

The build gets to the ~230th target and then fails with “BUILD FAILURE” and no other (useful) output that I can discern:

InitScript1 /boot/home/dev/haiku/generated/haiku.image-copy-files
BuildHaikuImageUserGroupFile /boot/home/dev/haiku/generated/objects/common/passwd
BuildHaikuImageUserGroupFile /boot/home/dev/haiku/generated/objects/common/group
InitScript1 /boot/home/dev/haiku/generated/haiku.image-extract-files

BUILD FAILURE:
…failed updating 7 target(s)…
…skipped 14473 target(s)…
…updated 230 target(s)…

…am I missing something? I’m following the instructions in the above page to the letter but the build just keeps stopping.

Thanks in advance,

Dave

I should note I’ve tried setarch x86 and there’s no difference.

Attempting to compile just the mail daemon results in:

MergeObjectFromObjects1 /boot/home/dev/haiku/generated/objects/haiku_host/x86_gcc2/release/build/libbe/app/app_kit.o
/packages/gcc-2.95.3_2014_10_14-4/.self/develop/tools/i586-pc-haiku/bin/ld: /boot/home/dev/haiku/generated/objects/haiku_host/x86_gcc2/release/build/libbe/app/Application.o: unrecognized relocation (0x2b) in section `.text’
/packages/gcc-2.95.3_2014_10_14-4/.self/develop/tools/i586-pc-haiku/bin/ld: final link failed: Bad value

Here is my “cheat sheet” for setting up a new build environment for gcc2hybrid. I do this on a seperate data partition, not the boot partition.

cd to your project folder (in my case /Data/haiku)
git clone https://git.haiku-os.org/buildtools
git clone https://github.com/yourID/haiku
cd haiku
mkdir generated.x86gcc2
cd generated.x86gcc2
…/configure --build-cross-tools x86_gcc2 …/…/buildtools

Then if you want to build a complete image (you may need to alter -j4 to match your # of cpus):
jam -q -j4 @nightly-raw

Or if you just want to build one application/server, cd to that source directory and run (use your full generated.x86gcc2 path)
jam -sHAIKU_OUTPUT_DIR=/Data/haiku/haiku/generated.x86gcc2

I also create generated.x86 and generated.x86_64 build targets by booting into an x86 or x86_64 Haiku install and doing the same (replacing x86_gcc2 with x86 or x86_64 as needed). This is the way I found works best for me through trial and error but others more experienced developers may have other ideas.

3 Likes

Thank you very much for your help! I managed to get a build working and I can run a tweaked version of the mail daemon - so thanks!

3 Likes

This is a strange way of doing it. The canonical one is to go in your generated dir and run something like “jam -q app_server” (just like make, you can give jam a target name and it will build it).

Also, building the buildtools is normally not needed when building on Haiku, in that case you can use the host buildtools.

1 Like

[quote=“PulkoMandy, post:5, topic:5433”]
This is a strange way of doing it. The canonical one is to go in your generated dir and run something like “jam -q app_server” (just like make, you can give jam a target name and it will build it).[/quote]
Ah, that is good to know. What about components that are not part of the build yet like SoftwareUpdater, I assume those will not work?

So then would this be correct?

cd to your project folder (in my case /Data/haiku)
git clone https://github.com/yourID/haiku
cd haiku
mkdir generated.x86gcc2
cd generated.x86gcc2
…/configure
jam -q -j4 @nightly-raw

[quote=“Perelandra0x309, post:6, topic:5433, full:true”]
Ah, that is good to know. What about components that are not part of the build yet like SoftwareUpdater, I assume those will not work?[/quote]

If I don’t know the name of a ‘target’, I too just enter the folder of the source of my target and do a “jam -q” there.
It’ll build everything needed for it, including libs etc. For example, changes to Tracker often also need the newly compiled libtracker.so. So to try out your modified Tracker, you copy the Tracker binary and the newly compiled libtracker.so and put it in a “lib” folder where you have your modified Tracker.

The old SHIFT+ALT+ click on the path to your generated binary and libs makes finding the built stuff easy.

Forking the github may have issues due to missing tags, IIRC. Others know more about that. The guide says to use “git clone https://git.haiku-os.org/haiku”.

Here is my cheatsheet for setting up a gcc2hybrid build:

git clone https://git.haiku-os.org/haiku
cd haiku
mkdir -p generated
cd generated
/Source-Haiku/haiku/configure -j8 --use-gcc-pipe --distro-compatibility official --include-gpl-addons --include-patented-code --target-arch x86_gcc2 --target-arch x86
cd ..

mkdir -p generated.x86
cd generated.x86
/Source-Haiku/haiku/configure -j8 --use-gcc-pipe --distro-compatibility official --include-gpl-addons --include-patented-code --target-arch x86
cd ..

This readme talks about it and doesn’t word it in a way that it is unusual: haiku/ReadMe.Compiling.md at master · haiku/haiku · GitHub

Big thanks to @Perelandra0x309 for his write up. The ReadMe.Compiling also references obsolete “trunk” which is confusing.

Yes , I want to continue this conversation from over 4 years ago because I tried to compile Haiku x86_64 on Haiku x86_64 and found this but did not make any progress because I missed that elusive step-by-step guide. So, I made my own guide and will publish it here. I will obviously risk the comments from the Haiku community for this, but so be it!
STEP BY STEP GUIDE:
This howto is based on the instructions given on Compiling for x86_64 | Haiku Project
and is only for compiling a x86_64 image. For other images see the Haiku documentation.

This is done on a machine running Haiku x86_64 and the resulting image can be burned to a cd or used to create a bootable USB drive.
The terminal commands are given directly after the numbers list bullet (e.g. the dot after 3. is NOT part of the command!!).
A fast internet connection is required.
The replies by the system are shown in italics.
Only final responses of the system are shown. Intermediate responses are streaming ones and are not shown.

  1. open /boot/home/
    0.1 cd ~

  2. mkdir compile
    THIS CAN BE ANY NAME YOU WISH

  3. cd compile/

  4. git clone https://review.haiku-os.org/haiku.git
    Cloning into ‘haiku’…
    remote: Counting objects: 14367, done
    remote: Finding sources: 100% (756372/756372)
    remote: Finding sources: 100% (756372/756372)MiB | 81.00 KiB/s
    Receiving objects: x%(XXXXXX/756372) , YY.ZZ MiB | NN KiB/s
    THIS IS VERY SLOW, SO BE PATIENT…
    100% (756372/756372), 397.61 MiB | 1.33MiB/s ,done.
    Resolving deltas: 100% (577909/577909), done.
    Updating files : 100%(32217/32217), done.

  5. git clone https://review.haiku-os.org/buildtools.git
    Cloning into ‘buildtools’ …
    THIS IS A SLOW PROCESS. WAIT UNTIL IT SHOWS THE RESULTS BELOW
    remote: Counting objects: 292317, done
    remote: Finding sources: 100% (292317/292317)
    remote: Total 292317 (delta 170645), reused 292284 (delta 170645)
    Receiving objects: 100% (292317/292317), 370.23 MiB | 1.76 MiB/s, done.
    Resolving deltas: 100% (170645/170645), done.
    Updating files: 100% (121130/121130), done.

  6. cd haiku; mkdir generated.x86_64;

  7. cd generated.x86_64

  8. …/configure --cross-tools-source …/…/buildtools --build-cross-tools x86_64

    AND WAIT FOR A WHILE ON MY MACHINE IT STARTED AT 17:32 …17:57 = 25 MINUTES

  9. jam -q -j2 @nightly-anyboot
    THIS CREATES AN ISO FILE TO BURN TO CD OR USB STICK.

    THE NUMBER AFTER -j IS THE NUMBER OF CORES OF YOUR CPU. I LEFT IT AT 2.MORE CORES,LESS TIME TO WAIT.
    AND WAIT FOR A WHILE ON MY MACHINE IT STARTED AT 17:59 …18:43=44 MINUTES
    THIS COMPILES ALL THE FILES NEEDED AND PUTS THEM INTO THE IMAGE.
    THE IMAGE IS LOCATED AT
    /boot/home/compile/haiku/generated.x86_64/haiku-nightly-anyboot.iso
    IT CAN BE BURNED TO CD OR USB STICK.

7 Likes

You missed to mention the step where you cd’d to the haiku source tree just before the 5. step, this could make a newbee scratch his/her head.

3 Likes

If you want to help, indicate the folder you mean by cd to … and not “the haiku source tree”.
You know why? Because I am scratching my head and I am a newby (he) :bowing_man: :scream:I have added cd haiku now. Thanks (him/her) @khallebal

2 Likes

Fair enough, i thought you were an experienced user .:innocent:

1 Like

Building Haiku on Haiku… how can I build just the OS as a .hpkg file?

I’m trying to test out some experimental code on my laptop from Gerrit, and would like to get a new Haiku.hpkg to install that custom version of the OS. I recall this is possible, but I can’t recall where I saw it. I’ve checked the docs but didn’t see mention of just the OS for installing on the OS.

Just ask jam nicely!

jam -q -jN @nightly-raw haiku.hpkg

or whatever other packages (e.g. haiku_devel.hpkg, haiku_extras.hpkg).

2 Likes

Trying to compile shows a lot of errors about undefined symbols which appear to be math related: __divi3, __umoddi3, __moddi3_moddi3. Which library am I missing?

This is part of libgcc, shipped with gcc.
If you started from an existing build directory, you may need to update it:

../haiku/configure --update

So I’m trying to test this code [link] but building all of Haiku is failing. The code is in the path “src/add-ons/accelerants/intel_extreme/mode.cpp”. I was able to run jam -q -j6 @nightly-raw intel_extreme which created objects/haiku/x86_64/release/add-ons/kernel/drivers/graphics/intel_extreme/intel_extreme. The code had the directory “accelerants”, and this is just “drivers”, is this binary a result of that source code file?

I assume this still works even if compiling from Haiku? I did try that without effect, and the Software Updater shows no newer dev tools. I’m on hrev56001. I’ll update though, see what happens.

The accelerant and driver are two different files.

If you want to build the accelerant you need to do something like jam -qj6 intel_extreme.accelerant. Otherwise you build the driver.

This is due to the 32-bit BIOS bootloader needing the full cross-tools to be built, and as of now it’s still included in haiku.hpkg (though that may change.) You can get around this by commenting out line 31 in build/jam/packages/Haiku.

2 Likes