Sortix nightly manual
This manual documents Sortix nightly, a development build that has not been officially released. You can instead view this document in the latest official manual.
NAMEcross-development — operating system development from another operating system
DESCRIPTIONThe development(7) manual page describes the primary way of building the operating system, which is under itself. The secondary way is to cross-compile it from a sufficiently similar operating system such as Linux with the GNU tools installed. The build system assumes the presence of some GNU extensions in the standard command line tools. This document will detail the process of bootstrapping a Sortix system from another operating system.
cd /latest/source/code && man share/man/man7/cross-development.7
OverviewTo build Sortix you need to get these programs from your operating system vendor or compile them yourself:
- GRUB (for iso creation)
- xorriso (for iso creation)
- mtools (for iso creation) (if on UEFI systems)
- mandoc (for html manuals if building a release directory)
- Retrieving the source code.
- Installing the build tools.
- Creating a cross-compiler.
- Cross-compiling the operating system.
Source CodeYou can find the latest Sortix source code at https://sortix.org/source/
VariablesThis document will use meta-syntactic shell variables to denote where you have choice. These are simply convenient shorthands that lets this document refer to your choices. You shouldn't use real shell variables but just textually replace them with your choices when you run commands.
- The path to the directory containing the Sortix source code. This could for instance be /home/user/sortix.
- The Sortix target platform. This could for instance be x86_64-sortix.
- The directory path where the cross-toolchain will be installed. This could for instance be /home/user/opt/sortix-toolchain.
Sortix DirectoryYou can put the Sortix source code wherever you'd like. It is typically git cloned from your home directory and the source code will appear in ~/sortix. This place will contain the operating system code. We'll refer to that location as $SORTIX.
Target PlatformYou need to decide what the platform your final Sortix system will run on. You can currently decide between i686-sortix and x86_64-sortix. In this guide we will refer to that platform triplet as $SORTIX_PLATFORM. If you want to build another platform afterwards, then repeat the steps with the other platform.
Cross-PrefixYou should install your cross-toolchain into a useful and isolated directory such as $HOME/opt/sortix-toolchain. This allows you to easily dispose of the directory and keeps it isolated from the rest of the system. We'll refer to that location as $CROSS_PREFIX.
PATHYou need to add $CROSS_PREFIX/bin and $CROSS_PREFIX/sbin to your PATH variable:
Cross-toolchain DependenciesYou need to install these libraries (and the development packages) before building binutils and gcc:
Cross-toolchainYou can build the full cross-toolchain containing the build tools and the cross-compiler (binutils and gcc) by running:
cd "$SORTIX" && make clean-cross-toolchain && make PREFIX="$CROSS_PREFIX" TARGET=$SORTIX_PLATFORM install-cross-toolchain
Build ToolsThe above install-cross-toolchain command already built the build tools needed to bootstrap the operating system.
cd "$SORTIX" && make clean-build-tools && make PREFIX="$CROSS_PREFIX" install-build-tools
Building SortixWith the build tools and cross-compiler in the PATH is it now possible to build the operating system as described in development(7) by setting HOST to your value of $SORTIX_PLATFORM. This tells the build system you are cross-compiling and it will run the appropriate cross-compiler. For instance, to build an bootable cdrom image using a x86_64-sortix cross-compiler you can run:
cd "$SORTIX" && make HOST=x86_64-sortix sortix.iso
Additional Required ReadingThe development(7) manual page documents how to develop Sortix and how to use the build system. This manual page only documents how to set up a cross-development environment and is not sufficient to develop Sortix.
TroubleshootingIf producing a bootable cdrom with grub-mkrescue(1) gives the error
xorriso: FAILURE: Cannot find path '/efi.img' in loaded ISO image