How to compile Haiku on Haiku?


#1

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


#2

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


#3

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.


#4

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!


#5

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.


#6

[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


#7

[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 ..

#8

This readme talks about it and doesn’t word it in a way that it is unusual: https://github.com/haiku/haiku/blob/master/ReadMe.Compiling.md

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