Serenity Operating System
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Toolchain: Add QEMU build script and improve documentation

Added a script to build QEMU from source as part of the Toolchain.
The script content could be in BuildIt.sh but has been put in
a seperate file to make the build optional.

Added PATH=$PATH to sudo calls to hand over the Toolchain's PATH
setup by UseIt.sh. This enabled the script's to use the QEMU
contained in the SerenityOS toolchain.

Deleted old documentation in Meta and replaced it by a new
documentation in the Toolchain folder.

authored by

Emanuel Sprung and committed by
Andreas Kling
3042c942 2d190721

+215 -103
+1 -1
Kernel/makeall.sh
··· 105 105 fi 106 106 done 107 107 108 - sudo -E ./build-image-qemu.sh 108 + sudo -E PATH=$PATH ./build-image-qemu.sh
+1 -1
Kernel/sync.sh
··· 1 1 #!/bin/sh 2 2 3 - sudo -E ./build-image-qemu.sh 3 + sudo -E PATH=$PATH ./build-image-qemu.sh
-101
Meta/BuildInstructions.md
··· 1 - # Building the Serenity operating system 2 - 3 - Let's start with a quick guide to building the i686-pc-serenity toolchain. 4 - 5 - I keep my toolchain in /opt/cross (so /opt/cross/bin needs to be in $PATH) and my Serenity sources are in $HOME/src/serenity 6 - 7 - You need to adjust these so they fit your system. 8 - 9 - ## Dependencies: 10 - 11 - First off, GCC needs MPFR, MPC and GMP. On Ubuntu, this is as simple as: 12 - 13 - sudo apt install libmpfr-dev libmpc-dev libgmp-dev 14 - 15 - For Serenity, we will need e2fsprogs and QEMU: 16 - 17 - sudo apt install e2fsprogs qemu-system-i386 18 - 19 - Note: there is a problem with the PS/2 keyboard/mouse emulation in QEMU 2.11.1 as packaged in Ubuntu's LTS releases. If you have any strange behaviour with missing keyboard inputs or jittery mouse movement, try building QEMU from source. 2.12.1, 3.0.1, 3.1.0, and 4.0.0 are all confirmed as working when built from source. 20 - 21 - ## Binutils: 22 - 23 - Download GNU binutils-2.32 and apply the patch serenity/Meta/binutils-2.32-serenity.patch 24 - 25 - Make a build directory next to the binutils source directory. 26 - 27 - In the build directory, run configure: 28 - 29 - ../binutils-2.32/configure \ 30 - --prefix=/opt/cross \ 31 - --target=i686-pc-serenity \ 32 - --with-sysroot=$HOME/src/serenity/Root \ 33 - --disable-nls 34 - 35 - 36 - Then build and install: 37 - 38 - make 39 - sudo make install 40 - 41 - ## Serenity LibC and LibM headers: 42 - 43 - Before we can build GCC, we need to put the Serenity LibC headers where GCC can find them. So go into serenity/LibC/ and install them: 44 - 45 - ./install.sh 46 - 47 - Then do the same in serenity/LibM/: 48 - 49 - ./install.sh 50 - 51 - Don't worry about any error messages from the above commands. We only care about copying the headers to the right place at this time. 52 - 53 - ## GCC (part 1): 54 - 55 - Okay, then let's build GCC. 56 - 57 - Download GNU GCC-8.3.0 and apply the patch serenity/Meta/gcc-8.3.0-serenity.patch 58 - 59 - Make a build directory next to the GCC source directory. 60 - 61 - In the build directory, run configure: 62 - 63 - ../gcc-8.3.0/configure \ 64 - --prefix=/opt/cross \ 65 - --target=i686-pc-serenity \ 66 - --with-sysroot=$HOME/src/serenity/Root \ 67 - --with-newlib \ 68 - --enable-languages=c,c++ 69 - 70 - Then build and install: 71 - 72 - make all-gcc all-target-libgcc 73 - sudo make install-gcc install-target-libgcc 74 - 75 - ## Serenity LibC for GCC: 76 - 77 - Now let's go into serenity/LibC/ and build the C library. This is required in order to complete the GCC build. 78 - 79 - make 80 - ./install.sh 81 - 82 - The C library is now installed in serenity/Root/ and we can build GCC's libstdc++... 83 - 84 - ## GCC (part 2): 85 - 86 - Go back to the GCC build directory and finish building libstdc++: 87 - 88 - make all-target-libstdc++-v3 89 - sudo make install-target-libstdc++-v3 90 - 91 - ## Serenity (Full build) 92 - 93 - If everything worked out, you now have the i686-pc-serenity toolchain ready and we can build Serenity. 94 - 95 - Go into serenity/Kernel and build it: 96 - 97 - ./makeall.sh 98 - 99 - Then take it for a spin: 100 - 101 - ./run
+3
Toolchain/.gitignore
··· 1 + # Created by QEMU build 2 + config-temp 3 + config.log
+66
Toolchain/BuildQemu.sh
··· 1 + #!/bin/bash 2 + set -e 3 + 4 + # This file will need to be run in bash, for now. 5 + 6 + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 7 + 8 + echo "$DIR" 9 + 10 + TARGET=i686-pc-serenity 11 + PREFIX="$DIR/Local" 12 + SYSROOT="$DIR/../Root" 13 + 14 + QEMU300_MD5SUM="6a5c8df583406ea24ef25b239c3243e0" 15 + QEMU410_MD5SUM="cdf2b5ca52b9abac9bacb5842fa420f8" 16 + 17 + QEMU_VERSION="qemu-4.1.0" 18 + QEMU_MD5SUM="${QEMU410_MD5SUM}" 19 + 20 + echo PREFIX is "$PREFIX" 21 + echo SYSROOT is "$SYSROOT" 22 + 23 + mkdir -p "$DIR/Tarballs" 24 + 25 + source "$DIR/UseIt.sh" 26 + 27 + pushd "$DIR/Tarballs" 28 + 29 + md5="$(md5sum $QEMU_VERSION.tar.xz | cut -f1 -d' ')" 30 + echo "qemu md5='$md5'" 31 + if [ ! -e "$QEMU_VERSION.tar.xz" ] || [ "$md5" != "$QEMU_MD5SUM" ] ; then 32 + rm -f qemu-3.0.0.tar.xz 33 + curl -O "https://download.qemu.org/$QEMU_VERSION.tar.xz" 34 + 35 + if [ "$md5" != "$QEMU_MD5SUM" ] ; then 36 + echo "qemu md5 sum mismatching, please run script again." 37 + exit 1 38 + fi 39 + else 40 + echo "Skipped downloading $QEMU_VERSION" 41 + fi 42 + 43 + if [ ! -d "$QEMU_VERSION" ]; then 44 + echo "Extracting qemu..." 45 + tar -xf "$QEMU_VERSION.tar.xz" 46 + else 47 + echo "Skipped extracting qemu" 48 + fi 49 + popd 50 + 51 + mkdir -p "$PREFIX" 52 + mkdir -p "$DIR/Build/qemu" 53 + 54 + if [ -z "$MAKEJOBS" ]; then 55 + MAKEJOBS=$(nproc) 56 + fi 57 + 58 + pushd "$DIR/Build/" 59 + pushd qemu 60 + "$DIR"/Tarballs/$QEMU_VERSION/configure --prefix="$PREFIX" \ 61 + --target-list=i386-softmmu \ 62 + --enable-gtk || exit 1 63 + make -j "$MAKEJOBS" || exit 1 64 + make install || exit 1 65 + popd 66 + popd
+144
Toolchain/README.md
··· 1 + # Serenity Toolchain - Building the Serenity operating system 2 + 3 + This directory contains all toolchain related files. E.g. build scripts for 4 + the cross compilation toolchain and build toolchain for ports. 5 + 6 + - [Serenity Toolchain - Building the Serenity operating system](#serenity-toolchain---building-the-serenity-operating-system) 7 + - [Cross Compile Toolchain](#cross-compile-toolchain) 8 + - [Dependencies](#dependencies) 9 + - [Serenity (Full build)](#serenity-full-build) 10 + - [Running SerenityOS in an emulator](#running-serenityos-in-an-emulator) 11 + - [QEMU installation / compilation](#qemu-installation--compilation) 12 + - [Passing custom arguments to QEMU](#passing-custom-arguments-to-qemu) 13 + 14 + ## Cross Compile Toolchain 15 + 16 + The cross compile toolchain contains 17 + 18 + - binutils 2.32 19 + 20 + - GCC 8.3.0 21 + 22 + These are built from source with some patches applied. 23 + 24 + ### Dependencies 25 + 26 + - Build Essentials 27 + 28 + ```bash 29 + sudo apt install build-essential curl libmpfr-dev libmpc-dev libgmp-dev 30 + ``` 31 + 32 + - GCC 8 33 + 34 + ```bash 35 + sudo add-apt-repository ppa:ubuntu-toolchain-r/test 36 + sudo apt-get install gcc-8 g++-8 37 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8 38 + ``` 39 + 40 + - e2fsprogs 41 + 42 + ```bash 43 + sudo apt install e2fsprogs 44 + ``` 45 + 46 + ## Serenity (Full build) 47 + 48 + If everything worked out, you now have the **i686-pc-serenity** toolchain ready and we can build Serenity. 49 + 50 + Go into `Kernel/` folder and build it: 51 + 52 + ```bash 53 + ./makeall.sh 54 + ``` 55 + 56 + Then take it for a spin: 57 + 58 + ```bash 59 + ./run 60 + ``` 61 + 62 + See next chapter for more options on running SerenityOS in an emulator. 63 + 64 + ## Running SerenityOS in an emulator 65 + 66 + To run SerenityOS in a specific emulator, call the `./run` command in the `Kernel/` folder: 67 + 68 + ```bash 69 + ./run 70 + ``` 71 + 72 + There are several emulators supported to run SerenityOS in: 73 + 74 + - Bochs 75 + 76 + ```bash 77 + sudo apt install bochs 78 + ``` 79 + 80 + Add the `b` argument to the run script, to use bochs emulator: 81 + 82 + ```bash 83 + ./run b 84 + ``` 85 + 86 + - QEMU 87 + QEMU with networking enabled is used by default, when no extra argument is passed to the run script. 88 + There are some extra arguments to run QEMU emulator with specific settings: 89 + 90 + Add the `qn` argument to the run script to use QEMU without networking: 91 + 92 + ```bash 93 + ./run qn 94 + ``` 95 + 96 + Add the `qgrub` argument to the run script to use QEMU with grub bootloader: 97 + 98 + ```bash 99 + ./run qgrub 100 + ``` 101 + 102 + Add the `qtext` argument to the run script to use QEMU with textmode: 103 + 104 + ```bash 105 + ./run qtext 106 + ``` 107 + 108 + Note: there is a problem with the PS/2 keyboard/mouse emulation in QEMU 2.11.1 as packaged in Ubuntu's LTS releases. 109 + If you have any strange behaviour with missing keyboard inputs or jittery mouse movement, try building QEMU from 110 + source as described in [QEMU](#qemu-installation--compilation). 2.12.1, 3.0.1, 3.1.0, and 4.0.0 are all confirmed as working when built from source. 111 + 112 + ### QEMU installation / compilation 113 + 114 + If your distribution contains a QEMU version > 2.11.1, then you can just install it via 115 + 116 + ```bash 117 + sudo apt install qemu-system-i386 qemu-utils 118 + ``` 119 + 120 + If that is not the case, you can build QEMU from sources with the provided script `BuildQemu.sh`. 121 + To do so, some build dependencies have to be installed first: 122 + 123 + ```bash 124 + sudo apt-get build-dep qemu 125 + sudo apt-get install libgtk-3-dev 126 + ``` 127 + 128 + The source-repositories of your distribution have to be enabled to install the build-dep's. 129 + 130 + `BuildQemu.sh` has been tested with QEMU 3.0.0 and 4.1.0 (which is default). If you 131 + want to build QEMU 3.0.0, change the variable `QEMU_VERSION` and `QEMU_MD5SUM` accordingly: 132 + 133 + ```bash 134 + QEMU_VERSION="qemu-3.0.0" 135 + QEMU_MD5SUM="${QEMU300_MD5SUM}" 136 + ``` 137 + 138 + ### Passing custom arguments to QEMU 139 + 140 + You can modify the environment variable `SERENITY_EXTRA_QEMU_ARGS` to your needs or hand it over directly before the run command: 141 + 142 + ```bash 143 + SERENITY_EXTRA_QEMU_ARGS="-nographic" ./run qtext 144 + ```