This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
developersguide:crosscompiling [2016/02/24 22:33] lazarstricevic Added Ubuntu version |
developersguide:crosscompiling [2021/04/12 06:43] (current) marceloalencar [Build compatibility] Update Debian 10 |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Crosscompiling MINIX with build.sh ====== | + | ====== Cross-compiling MINIX 3 ====== |
| <div round info> | <div round info> | ||
| Line 7: | Line 7: | ||
| </div> | </div> | ||
| - | ===== Build compatibility ===== | + | Cross-compilation is the act of building MINIX from another operating system. Since MINIX now uses the build.sh framework from NetBSD, cross-compilation should work on most mainstream UNIX-compatible systems. A build compatibility table is available at the end of this document. |
| - | ^ Host platform ^ Buildable MINIX architectures | | + | ===== Install dependencies ===== |
| - | | Ubuntu 14.04 x86 32-bit | x86 32-bit / ARMv7 | | + | |
| - | | Ubuntu 14.04 x86 64-bit | x86 32-bit / ARMv7 | | + | Before attempting to cross-compile MINIX, you need a working C toolchain, Git and some additional software on your host platform. |
| - | | Arch Linux x86 32-bit | x86 32-bit | | + | |
| - | | Arch Linux x86 64-bit | x86 32-bit / ARMv7 | | + | For Debian-based operating systems, run the following command as super-user: |
| - | | Mac OS X Lion x86 64-bit | x86 32-bit / ARMv7 | | + | |
| - | | FreeBSD 10-CURRENT x86 32-bit | x86 32-bit / ARMv7 | | + | <code> |
| - | | FreeBSD 10-CURRENT x86 64-bit | x86 32-bit / ARMv7 | | + | # apt-get install build-essential curl git zlibc zlib1g zlib1g-dev |
| + | </code> | ||
| + | |||
| + | **Note**: Also on Ubuntu, if you get an error stating that "'/lib/cpp' fails sanity check", you need to install the GNU C++ compiler: | ||
| + | |||
| + | <code> | ||
| + | $ sudo apt-get install g++ | ||
| + | </code> | ||
| + | |||
| + | **Note**: On FreeBSD and Minix ([[developersguide:minixonarm#building_minix_arm |compiling for ARM on x86, e.g.)]], if you get a message along the lines of "Skipping image creation: missing tool 'mcopy'", please install the emulators/mtools package. | ||
| ===== Getting the sources ===== | ===== Getting the sources ===== | ||
| - | The first step to crosscompile MINIX is to obtain the sources and build the cross-compilation tools. MINIX has adopted NetBSD's ''build.sh'' script to create the cross-compiler. There are some wrapper scripts that will build a ready-to-boot system from scratch (i.e. just the minix source tree) for either x86 or ARM. | + | Once the required tools are installed, the next step is to obtain the sources. Run the following commands in a terminal: |
| <code> | <code> | ||
| - | $ git clone git://git.minix3.org/minix minixsrc | + | $ mkdir minix |
| - | $ cd minixsrc | + | $ cd minix |
| + | $ git clone git://git.minix3.org/minix src | ||
| + | $ cd src | ||
| </code> | </code> | ||
| - | NOTE: The releasetools script will generate object files and put them //outside// the source directory; it will move up out of the git repo and start touching stuff there. I.e., if you've cloned to ~/foo/minixsrc/ and build from there, things will start showing up in ~/foo/ as an artifact of the build process. You probably don't want this (and the build process probably shouldn't do this...), so if that's a problem for you, try double-wrapping it: instead of cloning to ~/foo/minixsrc/ try creating a "minix" container directory and cloning to ~/foo/minix/src. | + | NOTE: The releasetools script will generate object files and put them //outside// the source directory; i.e., if you've cloned to ~/minix/src/ and build from there, things will start showing up in ~/minix/ as an artifact of the build process. |
| - | ===== Crossbuilding for x86 ===== | + | ===== Cross-building for x86 ===== |
| - | The wrapper script for x86 generates a harddisk image ready to boot - except that it currently relies on an outside multiboot implementation. KVM provides this. It's very convenient also for passing args from the outside into the VM. The script produces a lot of output and will take a long time the first time - it generates a cross-toolchain from scratch based on LLVM. | + | It's time to build MINIX itself. There are some wrapper scripts that will build ready-to-boot images from scratch (i.e. just the minix source tree) for either x86 or ARM. These scripts produce a lot of output and will take a while to complete the first time - a cross-toolchain based on LLVM is built from scratch. |
| <code> | <code> | ||
| Line 49: | Line 60: | ||
| </code> | </code> | ||
| - | The printed kvm command line loads all the boot modules in the right order, sets the right variables (minix needs to know the rootdevname) and sets the console for serial. | + | A command line for running the result in a KVM virtual machine is printed at the end of the process. |
| - | ===== Crossbuilding for ARM ===== | + | ===== Cross-building for ARM ===== |
| A similar procedure exists for ARM. Please see [[.:MinixOnARM]] for much more information. | A similar procedure exists for ARM. Please see [[.:MinixOnARM]] for much more information. | ||
| ===== Using build.sh directly ===== | ===== Using build.sh directly ===== | ||
| + | |||
| + | Please refer to NetBSD's documentation on build.sh for details. | ||
| From a source directory: | From a source directory: | ||
| Line 71: | Line 84: | ||
| Among the tools that are built are ''gcc'', ''binutils'', and ''gmake''. The sources for these tools are not provided by us. Instead, they are downloaded on-the-fly as tarballs from the minix webserver | Among the tools that are built are ''gcc'', ''binutils'', and ''gmake''. The sources for these tools are not provided by us. Instead, they are downloaded on-the-fly as tarballs from the minix webserver | ||
| - | **Note**: For Cross compiling on Ubuntu , an extra library is to be installed , i.e the zlibc To install it run the following command : | ||
| - | |||
| - | <code> | ||
| - | $ sudo apt-get install zlibc zlib1g zlib1g-dev | ||
| - | </code> | ||
| - | |||
| - | **Note**: Also on Ubuntu, if you get an error stating that "'/lib/cpp' fails sanity check", you need to install the GNU C++ compiler: | ||
| - | |||
| - | <code> | ||
| - | $ sudo apt-get install g++ | ||
| - | </code> | ||
| - | |||
| - | **Note**: Again on Ubuntu, ''build.sh'' (i.e. ''fetch.sh'') requires ''curl'' tool, which needs to be installed: | ||
| - | |||
| - | <code> | ||
| - | $ sudo apt-get install curl | ||
| - | </code> | ||
| - | |||
| - | **Note**: On FreeBSD and Minix ([[developersguide:minixonarm#building_minix_arm |compiling for ARM on x86, e.g.)]], if you get a message along the lines of "Skipping image creation: missing tool 'mcopy'", please install the emulators/mtools package. | ||
| ===== Building world ===== | ===== Building world ===== | ||
| Line 137: | Line 131: | ||
| |Option name |value |example |Description | | |Option name |value |example |Description | | ||
| - | |COPTS |c flags |COPTS=-g |**c** compiler **opt**tions | | + | |COPTS |c flags |COPTS=-g |**c** compiler **opt**ions | |
| Line 183: | Line 177: | ||
| $ mount /dev/loop0p5 /mnt | $ mount /dev/loop0p5 /mnt | ||
| </code> | </code> | ||
| + | |||
| + | ===== Build compatibility ===== | ||
| + | |||
| + | ^ Host platform ^ Version ^ Buildable MINIX architectures ^ Version ^ Updated | | ||
| + | | Ubuntu x86 32-bit | 14.04 | x86 32-bit / ARMv7 | 3.4.0rc | 2016-02 | | ||
| + | | Ubuntu x86 64-bit | 14.04 | x86 32-bit / ARMv7 | 3.4.0rc | 2016-02 | | ||
| + | | Arch Linux x86 32-bit | | x86 32-bit | 3.2.1 | 2013-08 | | ||
| + | | Arch Linux x86 64-bit | | x86 32-bit / ARMv7 | 3.2.1 | 2013-08 | | ||
| + | | Mac OS X Lion x86 64-bit | | x86 32-bit / ARMv7 | 3.2.1 | 2013-08 | | ||
| + | | Mac OS X Maverick x86 64-bit | | x86 32-bit / ARMv7 | 3.3.0 | 2014-10 | | ||
| + | | FreeBSD x86 32-bit | 10-CURR. | x86 32-bit / ARMv7 | 3.2.1 | 2013-08 | | ||
| + | | FreeBSD x86 64-bit | 10-CURR. | x86 32-bit / ARMv7 | 3.2.1 | 2013-08 | | ||
| + | | Windows Subsystem for Linux 64-bit | 10.14393 | x86 32-bit / ARMv7 | 3.4.0rc | 2016-08 | | ||
| + | | Debian x86 32-bit | 8.8.0 | x86 32-bit | 3.3.0 | 2017-05 | | ||
| + | | Debian x86 64-bit ((Apply [[https://github.com/Stichting-MINIX-Research-Foundation/minix/pull/301|this]] patch)) | 10.9.0 | x86 32-bit / ARMv7 | 3.4.0rc | 2021-03 | | ||