1
1
Fork
You've already forked SUX
0
This is a simple unix-like operating system for the SuperH cpu architecture.
  • C 71.4%
  • Makefile 20.6%
  • Assembly 4.1%
  • Linker Script 3.9%
Find a file
2026年05月30日 23:21:21 +03:00
kernel initial commit 2026年05月30日 20:32:44 +03:00
.gdbinit initial commit 2026年05月30日 20:32:44 +03:00
Makefile feat: specify c23 as the c standard in makefile 2026年05月30日 23:21:21 +03:00
README.md doc: added links to sh manuals in README.md 2026年05月30日 20:43:33 +03:00

SUX: Superh Unix

This is a simple unix-like operating system for the superh CPU architecture. It currently supports only the r2d qemu board.

Roadmap

  • Serial Output
  • Virtual Memory
  • Traps & System Calls
  • Scheduling
  • Filesystem
  • Graphics
  • Networking
  • Dreamcast port
  • Porting software
    • GCC Toolchain
    • Text editor eg. vi, ed
    • Doom

Building

First, you will need a sh4-elf cross-compiler

$ make

To run the OS in qemu:

$ make qemu-run

Cross-Compiler

Prerequisites

In order to build GNU binutils and GCC, you need the following dependencies:

  • autotools and make
  • bison
  • flex
  • libgmp3-dev
  • libmpc-dev
  • libmpfr-dev
  • texinfo
  • libcloog

Dowonload and extract the latest versions of binutils, gcc, and gdb if you plan to build it, see [#GDB].

The PREFIX environment variable is the location where gcc & binutils will be installed.

export PREFIX="/your/path/to/cross/compiler"

You can set it to $HOME/.local/cross, and load it in your .profile like this: Note, putting in in .profile, will require you to re-login. To avoid this, you can place it in .bashrc, .zshrc, or whatever shell config you have.

export PATH="$HOME/.local/cross:$PATH"

Binutils

Create a build directory alongside the extracted binutils source code. Do not create it in the binutils source code directory.

mkdir binutils-objdir
cd binutils-objdir

Replace $version with the binutils version you have dowonloaded.

../binutils-$version/configure -v --target=sh4-elf --prefix="$PREFIX" --with-sysroot --disable-werror --disable-libssp --disable-tls --disable-shared --enable-static --disable-nls
make -j$(nproc)
make install

GCC

As with binutils, we create a build directory alongside the source code of gcc.

mkdir gcc-objdir
cd gcc-objdir

Then, compile gcc. Replace $version with your gcc version.

../gcc-$version/configure -v --target=sh4-elf --prefix="$PREFIX" --enable-checking=release --enable-languages=c --with-cpu=m4-single-only --with-multilib-list=m4-single-only,m4-nofpu,m4 --with-endian=little --without-headers --disable-libssp --disable-tls --disable-shared --enable-static --disable-nls
make all-gcc -j$(nproc)
make all-target-libgcc -j$(nproc)
make install-gcc
make install-target-libgcc

GDB

Some linux distributions provide a gdb-multiarch package that you can use instead. Just set set architecture sh when you start it. The provided .gdbinit file already sets it.

If you want to compile gdb, the process is similar to gcc.

You will need some extra dependencies:

  • libncurses-dev
  • libsource-highlight-dev
mkdir gdb-objdir
cd gdb-objdir
../gdb-$version/configure --target=sh4-elf --host=x86_64-linux-gnu --prefix="$PREFIX" --disable-werror --enable-tui --enable-source-highlight
make all-gdb -j$(nproc)
make install-gdb

See also