Giter Site home page Giter Site logo

nlvm's Introduction

Introduction

NLVM (the nim-level virtual machine?) is in its present incarnation an llvm (http://llvm.org) IR generator for the Nim language (http://nim-lang.org).

In some distant future, it would be nice if (in no particular order):

  • it could compile itself
  • it generated executables
  • it implemented more core Nim features (bounds checking etc)
  • it had fewer bugs than the reference nim compiler
  • it had a nice automated test suite
  • someone found it useful
  • earth survived humans

When I started on this little project, I knew neither llvm-ir nor Nim. Therefore, I'd specially like to thank the friendly folks at the #nim channel on freenode that never seemed to tire of my nooby questions. Also, thanks to all tutorial writers out there, on llvm, programming and other topics for providing such fine sources of copy-pa... er, inspiration!

Questions, patches, improvement suggestions and reviews welcome. When you find bugs, feel free to fix them as well :)

Fork and enjoy!

Jacek Sieka (arnetheduck on gmail point com), 2016-01-19

Compile instructions

To do what I do, you will need:

  • Linux
  • A C/C++ compiler (ironically, I happen to use gcc most of the time)

Start with a clone:

cd $SRC
git clone https://github.com/arnetheduck/nlvm.git
cd nlvm && git submodule update --init

Compile llvm shared library:

cd $SRC
wget http://llvm.org/releases/3.6.1/llvm-3.6.1.src.tar.xz
tar xvf llvm-3.6.1.src.tar.xz
cd llvm-3.6.1.src
mkdir build
cd build
../configure --disable-optimized --enable-debug-runtime --enable-targets=x86_64 --enable-shared 
make

Compile nim:

cd $SRC/nlvm/Nim
./bootstrap.sh

Compile nlvm:

cd $SRC/nlvm/nlvm
../Nim/bin/nim c nlvm

Run nlvm:

cd $SRC/nlvm/nlvm
LD_LIBRARY_PATH=$SRC/llvm-3.6.1.src/build/Debug+Asserts/lib ./nlvm c xxx.nim

Optimize with llvm (assuming llvm is in your $PATH):

opt -O3 nimcache/xxx.bc | llvm-dis

Compile with llvm (assuming llvm is in your $PATH):

llc xxx.bc
as xxx.s -o xxx.o
ld xxx.o -o xxx

Random notes

  • I have no hopes of keeping up with upstream, so I've pinned it at a particular commit with the submodule - patches welcome to update to new upstream versions

nlvm's People

Contributors

arnetheduck avatar

Watchers

Andreas Rumpf avatar James Cloos avatar  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.