Discussion forum for David Beazley

Write a Compiler (Summer 2017)


I have some information about various logistics and setup details for the upcoming “Write a Compiler” course, August 28-September 1, 2017.

In the course, we write a compiler for a small language that looks syntactically similar to Go. The final project consists of about 3000-3500 lines of Python. LLVM is used for code generation–both to create static executables and for just-in-time compilation.

For the best results in this class, bring a laptop on which you are comfortable writing code. The project minimally involves the following dependencies:

For best results, I’d recommend installing the Anaconda 4.4 distribution. It already includes all of the necessary LLVM components. Make sure your laptop also includes a C compiler (e.g., XCode on a Mac).

For creating static standalone executables (e.g., a.out or .exe files), you will need to have LLVM-4.0 and it’s associated version of clang installed. Be aware that clang can be installed on many Linux distros using a package-manager, but it’s often an older version that won’t work. On Windows, you can download clang at http://releases.llvm.org/download.html#4.0.0. You’ll probably want the 64-bit version.

If you don’t care about static compilation, you can make a JIT compiler instead. For that, the Anaconda Python distribution and llvmlite module are sufficient. You’ll still need a C compiler, to make a runtime library, but it doesn’t have to be clang (e.g., gcc or Visual C++ will work fine).

In prior courses, most people have used Mac/Linux machines. If you’re going to use Windows, it can still work, but you’ll need to install Visual C/C++ and I’ll have to help you with some compiler flags. You might also be able to use the Windows Subsystem for Linux as an alternative. You can install the Linux Anaconda Distribution under WSL. I’m pretty good at fiddling around with setup on such things so don’t worry if you’re not sure–we’ll make it work over the course of the 5 days.