Wiedi in Wonderland

Building illumos-gate on OmniOS

Thu 02 July 2015

Illumos-gate is the source repository of illumos. It is comparable with the Linux kernel in that you usually don't install from illumos-gate direclty but one of the distributions like SmartOS, OmniOS or OpenIndiana.

Unlike Linux the stable interface is not at the syscall layer but libc. So it kinda makes sense that the repository also contains some userland software like libc and core utilities that make the operating system.

Illumos has strict requirements for its build environment. Currently you need a specific version of gcc. In the past the only distribution where you could do a clean build of unmodified illumos-gate was OpenIndiana. Thanks to Dan McDonald it recently became also possible to build on OmniOS.

For detailed information see the "How to build illumos" page in the wiki. If you are starting out with OpenIndiana Ryan Zezeski has very helpful instructions. These are the steps I used on OmniOS.

Install dependencies

First start out by making sure you have all required software installed:

sudo pkg install -v \
 pkg:/developer/astdev \
 pkg:/developer/build/make \
 pkg:/developer/build/onbld \
 pkg:/developer/gcc44 \
 pkg:/developer/sunstudio12.1 \
 pkg:/developer/gnu-binutils \
 pkg:/developer/java/jdk \
 pkg:/developer/lexer/flex \
 pkg:/developer/object-file \
 pkg:/developer/parser/bison \
 pkg:/developer/versioning/mercurial \
 pkg:/developer/versioning/git \
 pkg:/developer/library/lint \
 pkg:/library/glib2 \
 pkg:/library/libxml2 \
 pkg:/library/libxslt \
 pkg:/library/nspr/header-nspr \
 pkg:/library/perl-5/xml-parser \
 pkg:/library/security/trousers \
 pkg:/runtime/perl \
 pkg:/runtime/perl-64 \
 pkg:/runtime/perl/module/sun-solaris \
 pkg:/system/library/math \
 pkg:/system/library/install \
 pkg:/system/library/dbus \
 pkg:/system/library/libdbus \
 pkg:/system/library/libdbus-glib \
 pkg:/system/library/mozilla-nss/header-nss \
 pkg:/system/header \
 pkg:/system/management/snmp/net-snmp \
 pkg:/text/gnu-gettext \

Get the code

Next clone the repository:

cd ~
git clone git://github.com/illumos/illumos-gate.git
cd illumos-gate

Closed source binaries

Some closed source binaries are still required:

wget -c \
 https://download.joyent.com/pub/build/illumos/on-closed-bins.i386.tar.bz2 \
tar xjvpf on-closed-bins.i386.tar.bz2
tar xjvpf on-closed-bins-nd.i386.tar.bz2

Setup illumos.sh environment file

The build environment is configured in a script that is passed to nightly.sh as an argument. Start out by copying the example:

cp usr/src/tools/env/illumos.sh .

Then adjust it to your needs. My diff looks like this:

--- usr/src/tools/env/illumos.sh        Sat May 30 16:58:22 2015
+++ illumos.sh  Mon Jun  1 14:18:16 2015
@@ -58,10 +58,10 @@

 # This is a variable for the rest of the script - GATE doesn't matter to
 # nightly itself
-export GATE='testws'
+export GATE='illumos-gate'

 # CODEMGR_WS - where is your workspace at (or what should nightly name it)
-export CODEMGR_WS="$HOME/ws/$GATE"

 # Maximum number of dmake jobs.  The recommended number is 2 + NCPUS,
 # where NCPUS is the number of logical CPUs on your build system.
@@ -206,7 +206,9 @@
 # exists to make it easier to test new versions of the compiler.
 export BUILD_TOOLS='/opt'
 #export ONBLD_TOOLS='/opt/onbld'
-export SPRO_ROOT='/opt/SUNWspro'
+# Help OmniOS find lint
+export SPRO_ROOT='/opt'

 # This goes along with lint - it is a series of the form "A [y|n]" which
@@ -230,15 +232,26 @@

 # Comment this out to disable support for IPP printing, i.e. if you
 # don't want to bother providing the Apache headers this needs.

 # Comment this out to disable support for SMB printing, i.e. if you
 # don't want to bother providing the CUPS headers this needs.

 # If your distro uses certain versions of Perl, make sure either Makefile.master
 # contains your new defaults OR your .env file sets them.
 # These are how you would override for building on OmniOS r151012, for example.
-#export PERL_VERSION=5.16.1
-#export PERL_ARCH=i86pc-solaris-thread-multi-64int
-#export PERL_PKGVERS=-5161
+export PERL_VERSION=5.16.1
+export PERL_ARCH=i86pc-solaris-thread-multi-64int
+export PERL_PKGVERS=-5161
+# OmniOS places GCC 4.4.4 differently.
+export GCC_ROOT=/opt/gcc-4.4.4/
+export ONNV_BUILDNUM=151014
+# GCC only
+export CW_NO_SHADOW=1
+export ONLY_LINT_DEFS=-I${SPRO_ROOT}/sunstudio12.1/prod/include/lint
+export __GNUC=""

Also copy nightly.sh and make it executeable:

cp usr/src/tools/scripts/nightly.sh .
chmod +x nightly.sh

I am not sure why this is needed:

sudo ln -s /opt/sunstudio12.1/ /opt/SUNWspro


Now all you need to start a build is:

./nightly.sh illumos.sh


If all went well you now have a working development environment and already did your first build. Next you can start making changes. The usual workflow is documented in the excellent illumos developer's guide.

For code review illumos also has a reviewboard which can be used instead of webrev since a few months.

Finally there is also a chapter on getting code upstream.