Giter VIP home page Giter VIP logo

llvm_dart's Introduction


使用 LLVM 作为后端,dart 为前端实现一个简易的编程语言。

通过 dart FFI 和 ffi_gen 调用 LLVM-C 接口; 在dart端处理词法分析、构建模块并生成 .o 目标文件然后使用clang完成链接,生成一个可执行文件。

llvm version: >= 16.0.6

在根文件夹下可以简单运行:

dart run bin/run.dart stack_com

stack_com.kc 在 kc/bin 文件夹下

测试 所有kc文件:

dart test test/test_all_test.dart 

在运行之前要做一些准备

windows

需要安装Visual Studio, Window SDK, msys2

安装 msys2:

msys2 三种环境: clang64(推荐) mingw64 ucrt64

选择一个配置环境:
打开cmd/pwsh

pacman:

clang64
pacman -S mingw-w64-clang-x86_64-toolchain mingw-w64-clang-x86_64-llvm mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-ninja mingw-w64-clang-x86_64-zstd mingw-w64-clang-x86_64-zlib

clang64toolchain默认包含clang,其他环境使用gcc,所以这里需要在mingw64环境下装一个clang:

pacman -S mingw-w64-x86_64-clang

pacboy:

首先安装 pactoys:

pacman -S pactoys

使用:p省略前缀:

clang64:

pacboy -S toolchain:p llvm:p ninja:p cmake:p zlib:p zstd:p
pacman -S mingw-w64-x86_64-lldb

lldb调试使用,mingw64lldb好像支持中文,比较好用

接着进入llvm_lang目录:

cmake -S. -B build -G Ninja
ninja -C build install
cd ..

注意在执行dart run bin/run.dart 时,确保和上面是同一个环境

调试

参数添加-g开启调试; 如果不是clang64环境,lldb好像有些问题,可以使用gdb

Mac

直接使用brew安装

brew install llvm

之后使用 vscode 打开 llvm_lang项目运行install完成安装。

dart 调试

windows msys2 需要添加环境变量

clang64添加到环境PATH

修改.vscode\launch.json:

下面<msys2-path>替换为真实路径

"env":{
    "PATH":"<msys2-path>\\clang64\\bin;${env:PATH}",
},

llvm_dart's People

Contributors

sersr avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.