cksystemsteaching/selfie logo

cksystemsteaching/selfie

Free

An educational software system of a tiny self-compiling C compiler, a tiny self-executing RISC-V emulator, and a tiny self-hosting RISC-V hypervisor.

FreeFree tier
Type
Open Source
Company
University of Salzburg

About cksystemsteaching/selfie

Selfie is an educational software system from the Computational Systems Group at the University of Salzburg. It provides a self-contained 64-bit implementation of a self-compiling C compiler (starc), a self-executing RISC-V emulator (mipster), and a self-hosting RISC-V hypervisor (hypster), all in a single 12KLOC file. The system is designed for teaching the design and implementation of compilers, runtime systems, operating systems, and virtual machine monitors. It compiles a tiny subset of C called C* to the RISC-U subset of RISC-V, generates ELF binaries that run on real RISC-V hardware, and includes a garbage collector, disassembler, linker, profiler, debugger with replay, L1 caches, and minimal OS support via RISC-V system calls.

Key Features

self-compiling C compiler (starc) that compiles C* to RISC-U
self-executing RISC-V emulator (mipster) that can run itself
self-hosting RISC-V hypervisor (hypster) that creates RISC-V virtual machines
tiny C* library (libcstar) utilized by selfie
single-file implementation (12KLOC) for simplicity
generates ELF binaries compatible with real RISC-V hardware and QEMU
includes a conservative self-collecting garbage collector
includes simple in-memory linker, disassembler, L1 caches, profiler, and debugger with replay
minimal operating system support via RISC-V system calls built into emulator and hypervisor
designed as 64-bit system but also compiles on 32-bit systems

Pros & Cons

Pros
  • self-contained educational tool with minimal dependencies
  • single-file implementation makes it easy to study and modify
  • supports both emulation and execution on real RISC-V hardware
  • includes a wide range of system components (compiler, emulator, hypervisor, garbage collector, debugger)
  • actively maintained with classroom slides and autograder support
  • free and open source under a permissive license
Cons
  • primarily educational, not intended for production use
  • limited to RISC-V architecture (specifically RISC-U subset)
  • requires a 64-bit system (LP64) or 32-bit compatibility for compilation
  • may have a steep learning curve for beginners unfamiliar with systems programming

Best For

teaching compilers and programming language designteaching runtime systems and operating systemsteaching virtual machine monitors and hypervisorsunderstanding self-reference in systems codeacademic coursework and assignments in systems engineeringprototyping and experimentation with RISC-V systems

FAQ

What is the purpose of Selfie?
Selfie is an educational platform for teaching undergraduate and graduate students the design and implementation of programming languages and runtime systems, focusing on self-reference in systems code.
What components does Selfie include?
Selfie includes a self-compiling C compiler (starc), a self-executing RISC-V emulator (mipster), a self-hosting RISC-V hypervisor (hypster), and a tiny C* library (libcstar), all in a single 12KLOC file.
Can Selfie run on real hardware?
Yes, Selfie generates ELF binaries that run on real RISC-V hardware as well as on QEMU and are compatible with the official RISC-V toolchain.
Is Selfie free to use?
Yes, Selfie is open source and free to use.