Overview
These are the main components in the CIS 341 tool chain:
- LLVM compiler version 9.0.0 available here. There
are many LLVM-related utilities. We mostly care about:
- clang - the C/C++ compiler and assembler
- llc - stand alone LLVM IR compiler and optimizer
- OCaml compiler and tools: We recommend
using opam and installing OCaml following
these instructions
- ocamlc - the ocaml compiler (version 4.06.0 or later)
- ocamlbuild - an ocaml-compatible build system
- menhir - an LR1 parser generator
- ocamlformat - an OCaml code prettifier
- Code editors / Development Environments:
- We recommend using Vim or Emacs following the instructions for setting up your environment from Real World OCaml (in particular, the merlin tool)
- There are other alternatives
- (Optional) a version control system:
We recommend that you use a version control system to periodically
back up your progress on the course projects.
Please do not make your project solutions public!
Platforms
Your project configuration and development environment depends on your machine's platform. Follow the platform-specific instructions for working on Eniac, or using OSX, linux , or Windows below.
For help with tool chain configuration, please post to Piazza.
The compiler we build will generate x86 assembly code, so if you want to run the programs natively, you must develop on a machine with and Intel or AMD processor.
On Eniac
You can do all of your development on Eniac, and we will be testing your projects there. It provides a linux environment, but the default installations of llc and ocamlc are out of date. The course account ~cis341/bin directory contains up-to-date versions of the course software.
When working on eniac, make sure that /home1/c/cis341/bin and /home1/c/cis341/share/bin are both in your PATH environment variable before /usr/bin. (You will need to edit your .login or .bashrc, etc., as appropriate to ensure that this is the case.)
Check that your set-up on Eniac is correct like this:
> which llc /home1/c/cis341/share/bin/llc llc --version LLVM (http://llvm.org/): LLVM version 9.0.0 ... > which ocaml /home1/c/cis341/bin/ocaml > ocaml Objective Caml version 4.06.0 #
OS X Only Setup
First, make sure that you have a c compiler and command line tools: Install Xcode via the App Store. Or install just the "Command Line Tools", which should be available through the Apple Developers Download Site (login with your Apple ID required).
Next, follow the instructions below (following the OS X specific parts).
On Linux and OS X (after the OS X only setup)
1. LLVM tools
From precompiled binaries (easier):
- Download the appropriate bundle from http://releases.llvm.org/
- Extract the bundle
tar -xf bundle-filename
- Move the resulting directories to some place in your path. If you own
the machine, you can do something like:
cd clang-directory sudo cp -R * /usr/local/
From source (harder): Follow the instructions here http://llvm.org/docs/GettingStarted.html .
2. OCaml and its tools
We recommend using OPAM. Follow the installation istructions from Real World OCaml.
Once opam is installed, upgrade to ocaml version 4.09.0 and then install ocamlbuild and menhir like this:
> opam install ocamlbuild > opam install menhir
Using Microsoft Windows
We recommend using a virtual machine running linux. However, if you want to try to get the compilation infrastructure running on Windows, you can try the following instructions. Please contact us if you want to use Windows and we will do our best to help. (None of the course staff use Windows.)
LLVM / Clang
You should install following software before installing OCaml.
- Cygwin
- Follow the installation instructions at www.cygwin.com.
- Install the Clang package
OCaml
- Follow the instructions: OCaml for windows
Other IDEs
- Eclipse + OCaIDE: You can try following the CIS120 instructions, but they're getting out dated.
- Visual Studio Code has a plugin for OCaml, also see this blog post
- The atom editor also has a plugin