Skip to content

FrancoGiachetta/mathic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

199 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧮 Mathic

A programming language with builtin symbolic algebra capabilities, powered by LLVM/MLIR

Installation

🔧 Dependencies

  • Rust 1.94.0 or higher
  • LLVM/MLIR 21.x.x

LLVM/MLIR Installation

There are many ways of installing LLVM. Choose the one that fits your needs.

MacOS (Homebrew)

brew install llvm@21

After installation, set the environment variables:

export LIBRARY_PATH=/opt/homebrew/lib
export LLVM_SYS_211_PREFIX=$(brew --prefix llvm@21)
export MLIR_SYS_210_PREFIX=$(brew --prefix llvm@21)
export TABLEGEN_210_PREFIX=$(brew --prefix llvm@21)

Building from Source

⚠️ Note: Building LLVM from source requires at least 6GB of RAM and ~20GB of disk space. Ensure these requirements are met, as the build process is likely to fail otherwise.

  1. Clone LLVM Project
git clone https://github.com/llvm/llvm-project.git
cd llvm-project
git checkout llvmorg-21.1.7
mkdir build && cd build
  1. Configure Build
cmake -G Ninja ../llvm \
   -DLLVM_ENABLE_PROJECTS="mlir" \
   -DCMAKE_BUILD_TYPE=RelWithDebInfo \
   -DLLVM_ENABLE_ASSERTIONS=On \
   -DLLVM_BUILD_LLVM_DYLIB=On \
   -DLLVM_LINK_LLVM_DYLIB=On \
   -DMLIR_BUILD_MLIR_C_DYLIB=On \
   -DLLVM_TARGETS_TO_BUILD=host \
   -DCMAKE_INSTALL_PREFIX=/opt/llvm-21

if you have mold installed, you can add this flag which will make linking much faster:

-DLLVM_USE_LINKER=mold

For more info about building from source, check: https://llvm.org/docs/GettingStarted.html

  1. Build and Install
ninja install

You'll need to export the required environment variables as well:

export LLVM_SYS_211_PREFIX=<path-to-install-prefix>
export MLIR_SYS_210_PREFIX=<path-to-install-prefix>
export TABLEGEN_210_PREFIX=<path-to-install-prefix>

If you used to command above, the prefix will be /opt/llvm-21

Installing Mathic

You can install mathic using cargo. If the installation fails due to disk quota issues (common when /tmp is limited), change the target directory:

CARGO_TARGET_DIR=<custom-path> cargo install mathic

Once the binary has been built, you can delete that directory.

Note: Ensure the required environment variables are set, otherwise the build will fail.

Usage

You can run a program using this command:

euler <path-to-file>.mth

📖 Current Status

⚠️ This project is in early development. Features are being added incrementally. Due to this, you are welcome to test it and create issues.

For more details, see the docs.

Built with ❤️ and 🦀 Rust

About

A programming language with builtin symbolic algebra.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors