cdbbe14062
This is __cxa_guard_acquire, __cxa_guard_release, and __cxa_guard_abort. We put these symbols in a 'fake' libstdc++ to trick gcc into thinking it has libstdc++. These symbols are necessary for C++ programs and not C programs, so, seems file. There's no way to tell gcc that, for example, the standard lib it should use is libc++ or libc. So, this is what we have for now. When threaded code enters a block that is trying to call the constructor for a block-scope static, the compiler will emit calls to these methods to handle the "call_once" nature of block-scope statics. The compiler creates a 64-bit guard variable, which it checks the first byte of to determine if the variable should be intialized or not. If the compiler-generated code reads that byte as a 0, it will call __cxa_guard_acquire to try and be the thread to call the constructor for the static variable. If the first byte is 1, it will assume that the variable's constructor was called, and go on to access it. __cxa_guard_acquire uses one of the 7 implementation defined bytes of the guard variable as an atomic 8 bit variable. To control a state machine that lets each entering thread know if they gained 'initialization rights', someone is working on the varaible, someone is working on the varaible and there's at least one thread waiting for it to be intialized, or if the variable was initialized and it's time to access it. We only store a 1 to the byte the compiler looks at in __cxa_guard_release, and use a futex to handle waiting. |
||
---|---|---|
.. | ||
Patches | ||
.gitignore | ||
BuildFuseExt2.sh | ||
BuildIt_x86_64.sh | ||
BuildIt.sh | ||
BuildPython.sh | ||
BuildQemu.sh | ||
CMakeToolchain.txt | ||
ComputeDependenciesHash.sh | ||
README.md |
Serenity Toolchain - Building the Serenity operating system
This directory contains all toolchain related files. E.g. build scripts for the cross compilation toolchain and build toolchain for ports.
Cross Compile Toolchain
The cross compile toolchain contains
-
binutils 2.32
-
GCC 8.3.0
These are built from source with some patches applied.
Dependencies
-
Build Essentials
sudo apt install build-essential curl libmpfr-dev libmpc-dev libgmp-dev
-
GCC 8
sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get install gcc-8 g++-8 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
-
e2fsprogs
sudo apt install e2fsprogs
Serenity (Full build)
If everything worked out, you now have the i686-pc-serenity toolchain ready and we can build Serenity.
Go into Kernel/
folder and build it:
./makeall.sh
Then take it for a spin:
./run
See next chapter for more options on running SerenityOS in an emulator.
Running SerenityOS in an emulator
To run SerenityOS in a specific emulator, call the ./run
command in the Kernel/
folder:
./run
There are several emulators supported to run SerenityOS in:
-
Bochs
sudo apt install bochs
Add the
b
argument to the run script, to use bochs emulator:./run b
-
QEMU QEMU with networking enabled is used by default, when no extra argument is passed to the run script. There are some extra arguments to run QEMU emulator with specific settings:
Add the
qn
argument to the run script to use QEMU without networking:./run qn
Add the
qgrub
argument to the run script to use QEMU with grub bootloader:./run qgrub
Add the
qtext
argument to the run script to use QEMU with textmode:./run qtext
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 as described in QEMU. 2.12.1, 3.0.1, 3.1.0, and 4.0.0 are all confirmed as working when built from source.
QEMU installation / compilation
If your distribution contains a QEMU version > 2.11.1, then you can just install it via
sudo apt install qemu-system-i386 qemu-utils
If that is not the case, you can build QEMU from sources with the provided script BuildQemu.sh
.
To do so, some build dependencies have to be installed first:
sudo apt-get build-dep qemu
sudo apt-get install libgtk-3-dev
The source-repositories of your distribution have to be enabled to install the build-dep's.
BuildQemu.sh
has been tested with QEMU 3.0.0 and 4.1.0 (which is default). If you
want to build QEMU 3.0.0, change the variable QEMU_VERSION
and QEMU_MD5SUM
accordingly:
QEMU_VERSION="qemu-3.0.0"
QEMU_MD5SUM="${QEMU300_MD5SUM}"
Passing custom arguments to QEMU
You can modify the environment variable SERENITY_EXTRA_QEMU_ARGS
to your needs or hand it over directly before the run command:
SERENITY_EXTRA_QEMU_ARGS="-nographic" ./run qtext