Skip to content

About

Self-hosted MiniLang compiler written in MiniLang, producing native Windows x64 PE32+ and Linux x64 ELF64 executables.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

142 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MiniLang self-hosted compiler

License: Apache-2.0 Language: MiniLang

This compiler is written in MiniLang and compiles .ml programs to native Windows x64 (PE32+) and Linux x64 (ELF64) executables. It can rebuild itself. The Python reference compiler provides the bootstrap implementation and a second code-generation path.

Download the latest native compiler packages or read the binary installation guide. Version 1.3.2 includes Windows and Linux packages with SHA-256 sidecars; see the release notes and changelog.

Quick start with a release package

Extract the whole Windows ZIP or Linux tar archive. The package includes std/, an example and the compiler executable. From its directory, on Windows:

.\mlc.exe examples/hello.ml hello.exe --target windows-x64 -I .
.\hello.exe

On Linux:

./mlc examples/hello.ml hello --target linux-x64 -I .
./hello

The output target defaults to Windows x64 on either host. Set --target linux-x64 for Linux programs. The generated executable runs on its selected target OS. See README-BINARY.md for package contents, verification, platform requirements and native media deployment.

Build the compiler from source

A fresh checkout needs a bootstrap compiler. Put MiniLangCompilerPy beside this repository or pass an existing native compiler to the build script. The scripts stage and smoke-test the output before installing it.

Windows PowerShell:

.\build.ps1
.\build\mlc_win64.exe --version
.\build\mlc_win64.exe hello.ml hello.exe -I .

Linux shell:

./build.sh
./build/mlc_linux_x64 --version
./build/mlc_linux_x64 hello.ml hello --target linux-x64 -I .

Create hello.ml with print "Hello from MiniLang!" before compiling the last command. build.ps1 -Compiler PATH and ./build.sh --compiler PATH select a bootstrap compiler explicitly. The Windows script uses a local native compiler if available and otherwise the sibling Python compiler. The Linux script follows the same pattern for build/mlc_linux_x64 and the sibling Python compiler. Run -NoReplace on Windows or --no-replace on Linux to keep an existing compiler untouched while inspecting the new build.

Language and compiler features

  • Classes with single inheritance, virtual dispatch, override, super, constructors, visibility, abstract/final members and inherited interfaces. See the OOP guide.
  • Functions, closures, optional checked types, structs, enums, arrays, bytes, packages, imports and conditional compilation.
  • Native threads, tasks and synchronization with a shared garbage-collected heap on Windows and Linux.
  • Standard-library modules, native FFI, typed inline x64 assembly, and error/try propagation.
  • Monolithic compilation and a memory-bounded .mlo object/link pipeline. The compiler chooses a path for the import graph; --object-pipeline or --no-object-pipeline forces one for verification or measurement.

The language reference covers syntax and runtime behavior. Generated compiler API and std API documentation are checked in.

Compile a project

.\build\mlc_win64.exe src/main.ml build/app.exe -I . -I src
.\build\mlc_win64.exe --project minilang.toml
.\build\mlc_win64.exe --help

The same conservative TOML manifest works with both compilers:

[project]
entry = "src/main.ml"
output = "build/app.exe"
include = ["src", "vendor"]
target = "windows-x64"
incremental = true
cache_dir = ".minilang-cache"

Paths are relative to the manifest. The native compiler accepts a shared TOML subset; see the incremental-build guide for manifest syntax, cache validation and reuse limits. Direct builds can use --incremental-cache DIR. Use --no-incremental to bypass caches for one build.

Option Use
--target windows-x64|linux-x64 Select the output platform.
-I DIR Add an import root; repeat as needed.
-DNAME[=VALUE] Set a typed conditional-compilation option.
--subsystem windows Build a Windows GUI application.
--object-pipeline Force .mlo object generation and linking.
--asm, --asm-data Emit an assembly listing and optional data sections.
--heap-reserve SIZE, --gc-limit SIZE Configure the native runtime.
--profile-calls, --pgo-profile FILE Collect call counts and guide inlining.
--profile-compiler Report compiler phase timings.

For the same supported inputs, options and target, the Python compiler, self-hosted monolithic compiler and self-hosted .mlo pipeline are expected to emit identical target bytes. Version 1.3.2 restored this for the OOP regression programs on both targets. See the parity guide, OOP regression and release verification matrix.

Documentation and development

Topic Document
Classes and interfaces OOP guide
Language syntax, standard library and FFI Language reference
Binary packages and checksums Binary installation
Incremental builds Guide
Typed inline assembly Guide
Native crypto, checksums and CPU features Native primitives
Compression and platform services Platform services
Executable packing Packing guide
Generated APIs Compiler · Standard library
Changes and releases Changelog · Releases

After building the compiler, run the native regression suite on Windows:

.\scripts\run_tests.ps1

Both compiler implementations and their documentation were developed with the assistance of generative AI. Licensed under Apache 2.0; see third-party notices for bundled or generated-code components that require attribution.

About

Self-hosted MiniLang compiler written in MiniLang, producing native Windows x64 PE32+ and Linux x64 ELF64 executables.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages