Giter VIP home page Giter VIP logo

coolang's Introduction

Coolang

Coolang is a compiler for the COOL language with an LLVM backend.

Build Status

Building Coolang

Prerequisites

Linux

  • CMake 3.10 (or more recent)
  • a C++17 compiler
  • LLVM 8 and Clang 8
    • see https://apt.llvm.org/
    • you can use the auto-install script they provide if you want, just specify version 8. But you really only need: clang-8, llvm-8, and llvm-8-dev
  • also install the libedit-dev package since llvm fails to link if it's not installed

Windows

  • CMake 3.10 (or more recent)
  • Visual studio 2017 (or more recent)
  • LLVM 8 and Clang 8
    • Options for how to get Clang 8
      • Download the installer from here and run http://releases.llvm.org/download.html
        • Confusingly, the installer is called LLVM-8.0.1-... but it doesn't install the LLVM development libs, we'll do that later
      • Or if you use the chocolatey package manager:
        • choco install llvm --version=8.0.1
        • this also calls itself LLVM but doesn't include development libs
    • Options for how to get LLVM 8 development libs
      • Download a pre-built binary from here: https://github.com/vovkos/llvm-package-windows/releases/tag/llvm-8.0.0
        • note these are built for Visual Studio 15 and 14 (aka 2017 and 2015) but Visual Studio 2019 (aka 16) can still use them
        • Choose one to download based on your Visual Studio version and compile options (x86, and msvcrt-dbg are default for Visual Studio 2017, for 2019 the defaults are amd64, and msvcrt-dbg)
        • Extract to somewhere CMake will look for packages ("C:\Program Files (x86)" or "C:\Program Files" by default)
      • Or install LLVM using vcpkg
        • Note LLVM is huge and vcpkg will take ~1hour to build and install it even on a fast machine
        • If vcpkg has updated their LLVM version at head to 9 or later you may need to reset your vcpkg client to a previous version that still uses llvm 8, see https://github.com/microsoft/vcpkg/commits/master/ports/llvm
        • later when running CMake you'll need to set your -DCMAKE_TOOLCHAIN_FILE as usual for vcpkg
      • Or build from source and install
        • Same warning as with using vcpkg this will probably take even longer than 1hour

Build and run tests

On windows if you installed a pre-built LLVM binary and it's a "release" version (i.e. doesn't end in -dbg) you'll need to use:

  • cmake --build . --config Release instead of cmake --build .
  • .\Release\coolang.exe hello.cl instead of .\Debug\coolang.exe hello.cl
$ mkdir build
$ cd build
$ cmake ..
$ cmake --build .
$ ctest --verbose

then compile a hello world program

Linux
$ echo "class Main inherits IO { main() : Object { out_string(\"Hello, world\\n\") }; };" > hello.cl
$ ./coolang hello.cl
$ ./hello
Hello, world
Windows
$ [IO.File]::WriteAllLines((Join-Path -Path (Resolve-Path .) -ChildPath "hello.cl"), "class Main inherits IO { main() : Object { out_string(`"Hello, world`\n`") }; };")
$ .\Debug\coolang.exe hello.cl
$ .\hello.exe
Hello, world

This is not an official Google product.ย 

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.