Improve cross-development(7).
This commit is contained in:
parent
92106d4d34
commit
b54e09ebaf
|
@ -7,25 +7,38 @@
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The
|
The
|
||||||
.Xr development 7
|
.Xr development 7
|
||||||
manual pages describes the primary way of building the operating system, which
|
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
|
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
|
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
|
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
|
tools. This document will detail the process of bootstrapping a Sortix system
|
||||||
from another operating system.
|
from another operating system.
|
||||||
.Ss Overview
|
.Ss Overview
|
||||||
To build Sortix you need these components:
|
To build Sortix you need to get these programs from your operating system vendor
|
||||||
|
or compile them yourself:
|
||||||
.Bl -bullet -compact
|
.Bl -bullet -compact
|
||||||
.It
|
.It
|
||||||
Sortix source code
|
|
||||||
.It
|
|
||||||
Sortix binutils
|
|
||||||
.It
|
|
||||||
Sortix gcc
|
|
||||||
.It
|
|
||||||
GRUB (for iso creation)
|
GRUB (for iso creation)
|
||||||
.It
|
.It
|
||||||
xorriso (for iso creation)
|
xorriso (for iso creation)
|
||||||
|
.It
|
||||||
|
mtools (for iso creation) (if on UEFI systems)
|
||||||
|
.El
|
||||||
|
.Pp
|
||||||
|
GRUB with BIOS support is required. If you are on an UEFI system, you may need
|
||||||
|
to install further files to get BIOS support. For instance, on an apt-based
|
||||||
|
system you might install the
|
||||||
|
.Sy grub-pc-bin
|
||||||
|
package.
|
||||||
|
.Pp
|
||||||
|
You will also need the source code for:
|
||||||
|
.Bl -bullet -compact
|
||||||
|
.It
|
||||||
|
Sortix
|
||||||
|
.It
|
||||||
|
Sortix binutils
|
||||||
|
.It
|
||||||
|
Sortix gcc
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
The overall process is:
|
The overall process is:
|
||||||
|
@ -55,19 +68,43 @@ This is a compiler toolchain that has been modified to support Sortix. The
|
||||||
toolchain is sometimes updated and you will need the latest toolchain to keep
|
toolchain is sometimes updated and you will need the latest toolchain to keep
|
||||||
building the latest code.
|
building the latest code.
|
||||||
.Ss Variables
|
.Ss Variables
|
||||||
This document will use shell variables to denote where you have choice. You
|
This document will use meta-syntactic shell variables to denote where you have
|
||||||
would typically set them up like this:
|
choice. These are simply convenient shorthands that lets this document refer
|
||||||
.Bd -literal
|
to your choices. You shouldn't use real shell variables but just textually
|
||||||
# The Sortix source code is in /home/user/sortix
|
replace them with your choices when you run commands.
|
||||||
# The cross-compiler is installed in /home/user/opt/x86_64-sortix
|
.Bl -tag -width "$SORTIX_PLATFORM" -offset indent
|
||||||
SORTIX_PLATFORM=x86_64-sortix
|
.It Sy $SORTIX
|
||||||
CROSS_PREFIX=/home/user/opt/x86_64-sortix
|
The path to the directory containing the Sortix source code. This could for
|
||||||
SORTIX_SYSROOT=/home/user/sortix/sysroot
|
instance be
|
||||||
export PATH="/home/user/opt/x86_64-sortix/bin:$PATH"
|
.Pa /home/user/sortix .
|
||||||
export PATH="/home/user/opt/x86_64-sortix/sbin:$PATH"
|
.It Sy $SORTIX_PLATFORM
|
||||||
.Ed
|
The Sortix target platform. This could for instance be
|
||||||
|
.Sy x86_64-sortix .
|
||||||
|
.It Sy $CROSS_PREFIX
|
||||||
|
The directory path where the cross-toolchain will be installed. This could
|
||||||
|
for instance be
|
||||||
|
.Pa /home/user/opt/x86_64-sortix .
|
||||||
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
The following sections describe these variables in detail.
|
The following sections describe these variables in detail.
|
||||||
|
.Ss Sortix Directory
|
||||||
|
You 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
|
||||||
|
.Pa ~/sortix .
|
||||||
|
This place will contain the operating system code. We'll refer to that location
|
||||||
|
as
|
||||||
|
.Sy $SORTIX.
|
||||||
|
.Pp
|
||||||
|
Don't store the source code for the cross-toolchain (binutils and gcc) here.
|
||||||
|
Store the source code for those programs somewhere else, such as in
|
||||||
|
.Pa ~/src .
|
||||||
|
It doesn't make any sense to store the cross toolchain within the Sortix
|
||||||
|
directory. The only toolchain that belongs here is the native toolchain that
|
||||||
|
runs on Sortix (and not on your current operating system).
|
||||||
|
.Pp
|
||||||
|
Don't make a sortix directory and git clone inside it, you redundantly get a
|
||||||
|
.Pa ~/sortix/sortix
|
||||||
|
directory instead.
|
||||||
.Ss Target Platform
|
.Ss Target Platform
|
||||||
You need to decide what the platform your final Sortix system will run on. You
|
You need to decide what the platform your final Sortix system will run on. You
|
||||||
can currently decide between
|
can currently decide between
|
||||||
|
@ -75,17 +112,17 @@ can currently decide between
|
||||||
and
|
and
|
||||||
.Sy x86_64-sortix .
|
.Sy x86_64-sortix .
|
||||||
In this guide we will refer to that platform triplet as
|
In this guide we will refer to that platform triplet as
|
||||||
.Ev SORTIX_PLATFORM .
|
.Sy $SORTIX_PLATFORM .
|
||||||
If you want to build another platform afterwards, then you will have to follow
|
If you want to build another platform afterwards, then you will have to follow
|
||||||
this guide again.
|
this guide again.
|
||||||
.Ss Cross-environment
|
.Ss Cross-Prefix
|
||||||
You should install your cross-toolchain into a useful and isolated directory
|
You should install your cross-toolchain into a useful and isolated directory
|
||||||
such as
|
such as
|
||||||
.Pa $HOME/opt/$SORTIX_PLATFORM .
|
.Pa $HOME/opt/$SORTIX_PLATFORM .
|
||||||
This allows you to easily dispose of the directory and keeps it isolated from
|
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
|
the rest of the system. We'll refer to that location as
|
||||||
.Ev CROSS_PREFIX.
|
.Sy $CROSS_PREFIX.
|
||||||
.Pp
|
.Ss PATH
|
||||||
You need to add
|
You need to add
|
||||||
.Pa $CROSS_PREFIX/bin
|
.Pa $CROSS_PREFIX/bin
|
||||||
and
|
and
|
||||||
|
@ -110,15 +147,12 @@ You need to install some additional build tools as they are needed to build the
|
||||||
operating system. The installed build tools must be in sync with the source
|
operating system. The installed build tools must be in sync with the source
|
||||||
code as described in
|
code as described in
|
||||||
.Xr development 7 .
|
.Xr development 7 .
|
||||||
Assuming the source code is in
|
You can install the build utilities by running:
|
||||||
.Pa ~/sortix ,
|
|
||||||
you can install them by running:
|
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
cd ~/sortix &&
|
cd "$SORTIX" &&
|
||||||
make PREFIX="$CROSS_PREFIX" clean-build-tools &&
|
make clean-build-tools &&
|
||||||
make PREFIX="$CROSS_PREFIX" build-tools &&
|
make PREFIX="$CROSS_PREFIX" build-tools &&
|
||||||
make PREFIX="$CROSS_PREFIX" install-build-tools &&
|
make PREFIX="$CROSS_PREFIX" install-build-tools
|
||||||
make distclean
|
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
These tools produce platform independent output so you may wish to install them
|
These tools produce platform independent output so you may wish to install them
|
||||||
|
@ -136,14 +170,16 @@ or where it suits you in your
|
||||||
Building the compiler requires the standard library headers being available.
|
Building the compiler requires the standard library headers being available.
|
||||||
This can be satisfies by creating a system root with the system headers:
|
This can be satisfies by creating a system root with the system headers:
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
cd ~/sortix &&
|
cd "$SORTIX" &&
|
||||||
|
make distclean &&
|
||||||
make sysroot-base-headers HOST=$SORTIX_PLATFORM
|
make sysroot-base-headers HOST=$SORTIX_PLATFORM
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
This will create a system root at
|
This will create a system root at
|
||||||
.Pa ~/sortix/sysroot .
|
.Pa $SORTIX/sysroot .
|
||||||
Refer to that directory as
|
The system root directory is always the
|
||||||
.Ev SORTIX_SYSROOT .
|
.Pa sysroot
|
||||||
|
subdirectory of the main source code directory.
|
||||||
.Ss Cross-toolchain Dependencies
|
.Ss Cross-toolchain Dependencies
|
||||||
You need to install these libraries (and the development packages) before
|
You need to install these libraries (and the development packages) before
|
||||||
building binutils and gcc:
|
building binutils and gcc:
|
||||||
|
@ -170,7 +206,7 @@ you can build binutils out-of-directory by running:
|
||||||
cd ~/src/binutils-build &&
|
cd ~/src/binutils-build &&
|
||||||
../sortix-binutils/configure \\
|
../sortix-binutils/configure \\
|
||||||
--target=$SORTIX_PLATFORM \\
|
--target=$SORTIX_PLATFORM \\
|
||||||
--with-sysroot="$SORTIX_SYSROOT" \\
|
--with-sysroot="$SORTIX/sysroot" \\
|
||||||
--prefix="$CROSS_PREFIX" \\
|
--prefix="$CROSS_PREFIX" \\
|
||||||
--disable-werror &&
|
--disable-werror &&
|
||||||
make &&
|
make &&
|
||||||
|
@ -189,7 +225,7 @@ you can build gcc out-of-directory by running:
|
||||||
cd ~/src/gcc-build &&
|
cd ~/src/gcc-build &&
|
||||||
../sortix-gcc/configure \\
|
../sortix-gcc/configure \\
|
||||||
--target=$SORTIX_PLATFORM \\
|
--target=$SORTIX_PLATFORM \\
|
||||||
--with-sysroot="$SORTIX_SYSROOT" \\
|
--with-sysroot="$SORTIX/sysroot" \\
|
||||||
--prefix="$CROSS_PREFIX" \\
|
--prefix="$CROSS_PREFIX" \\
|
||||||
--enable-languages=c,c++ &&
|
--enable-languages=c,c++ &&
|
||||||
make all-gcc all-target-libgcc &&
|
make all-gcc all-target-libgcc &&
|
||||||
|
@ -198,8 +234,9 @@ you can build gcc out-of-directory by running:
|
||||||
.Pp
|
.Pp
|
||||||
You can remove the temporary
|
You can remove the temporary
|
||||||
.Pa ~/src/gcc-build
|
.Pa ~/src/gcc-build
|
||||||
directory when finished. Notice how special make targets are used to not build
|
directory when finished. Notice how special make targets are used to
|
||||||
all of gcc.
|
selectively build only parts of gcc. It is not possible or desirable to build
|
||||||
|
all of gcc here.
|
||||||
.Ss Building Sortix
|
.Ss Building Sortix
|
||||||
With the build tools and cross-compiler in the
|
With the build tools and cross-compiler in the
|
||||||
.Ev PATH
|
.Ev PATH
|
||||||
|
@ -208,14 +245,14 @@ is it now possible to build the operating system as described in
|
||||||
by setting
|
by setting
|
||||||
.Ev HOST
|
.Ev HOST
|
||||||
to your value of
|
to your value of
|
||||||
.Ev SORTIX_PLATFORM .
|
.Sy $SORTIX_PLATFORM .
|
||||||
This tells the build system you are cross-compiling and it will run the
|
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
|
appropriate cross-compiler. For instance, to build an bootable cdrom image
|
||||||
using a
|
using a
|
||||||
.Sy x86_64-sortix
|
.Sy x86_64-sortix
|
||||||
cross-compiler you can run:
|
cross-compiler you can run:
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
cd ~/sortix &&
|
cd "$SORTIX" &&
|
||||||
make HOST=x86_64-sortix sortix.iso
|
make HOST=x86_64-sortix sortix.iso
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
|
|
Loading…
Reference in New Issue