Course: COMS 4115 Programming Languages and Translators (Fall 2020)
Website: https://www.rayb.info/fall2020
University: Columbia University
Instructor: Prof. Baishakhi Ray
- Announcement Date: Thursday, October 1, 2020
- Due Date: Monday, October 5, 2020 by 11:59 PM. No extensions!
- Total Points: 5
This assignment involves setting up your environment in preparation for future programming assignments. Here, we will create a virtual machine (optional) and set up LLVM.
If you do not have an environment or VM available for setting up LLVM, we suggest requesting for a virtual machine or setting up your own machine. Please choose exactly one of the following options if the previous statement applies to you.
We have allocated Google Cloud (GCloud) credits for each student. Please email or create a private Piazza post to the TAs expressing your interest in requesting for GCloud credits, and you will be sent a $100 GCloud coupon by email.
- Follow these initial instructions to redeem your course coupon.
- Create a project for this class, and give it a name (e.g., "coms4115"). This will likely have to be created within the columbia organization.
- Navigate to Compute Engine (while in the context of the new project), and create a virtual machine to match the specification shown below (you may select your own name). The most notable changes are:
- Leave the region/zone to
us-central1andus-central1-a. - Machine type:
n1-standard-4 - Click "change'' under boot disk to select
Ubuntu 18.04 LTS, and add at least 120 GB of persistent hard disk (HDD). - Leave the defaults for the remaining options:
Compute Engine Default Service Account,Allow default access, and unchecked boxes forAllow HTTP trafficandAllow HTTPS traffic.
- Leave the region/zone to
- Upon creation of the VM, SSH into the machine by clicking the SSH button next to the instance in Compute Engine, or add your SSH keys to log in using your own terminal. More information on access can be found here.
IMPORTANT: You must shut down your instance when not in use. There are not enough credits to keep the server running continuously. Ensure it is shut down when not in use so that you do not lose credits unintentionally. There should be enough credits for about 850 hours of compute time.
Note that the GCloud VMs will have the same Ubuntu base image, and you can install necessary libraries on top of LLVM Clang in the future.
You may choose to use other open-source software to create your VMs. If you do so, please follow these steps:
- Create Ubuntu 18.04.3 Virtual Machine by using either VMware Workstation 15 Player or Oracle VM VirtualBox to install Ubuntu 18.04.3.
- At least 8 GB memory is required for the virtual machine, and 12 GB memory is recommended.
- At least 120 GB hard disk is required.
- Install the necessary packages (which can also be installed by running the
setup.shshell script we provide):sudo apt updatesudo apt upgradesudo apt install build-essential subversion cmake python3-devsudo apt install libncurses5-dev libxml2-dev libedit-dev swigsudo apt install doxygen graphviz xz-utils git
LLVM provides compiler technologies designed for compile-time and runtime optimization. Clang is a C/C++ compiler front-end that leverages the LLVM back-end infrastructure. In this course, you will build new modules on top of the LLVM/Clang compiler framework.
You need to build LLVM and Clang by following the instructions found in the LLVM/Clang website. You can also run the build-llvm.sh shell script we have provided, which will execute all of the required commands for you.
- Build LLVM and Clang from the LLVM source in debug mode. Note that it may take a few hours for building to complete, so we recommend you do not complete this at the last minute.
- For this repository, we added the LLVM source from this commit; you may use this reference for all future assignments.
Here is a non-exhaustive list of problems you might face during the setup process and how you would resolve them:
- If you face a problem with
cmakeversion compatibility, refer to this solution. - Before building LLVM and Clang, add 8 GB of swap space in Ubuntu, as building LLVM and Clang will consume all of the memory. This blog shows how to add swap space. Run
sudo swapoff -ato first deactivate the swap space before creating the swap file. - In case of out-of-memory issues during linking, add the
-DLLVM_USE_LINKER=goldparameter incmaketo use the gold linker. The gold linker is faster and uses less memory. - If there is any error during the building of LLVM and Clang, you can simply rerun
maketo perform an incremental build.
Finally, here are some valuable suggestions:
- Use
make -j <cores>to take advantage of multiple CPU cores (e.g.,make -j 4uses 4 cores). Keep in mind, however, that adding more cores may consume more memory. - Feel free to play around (and familiarize yourself) with the LLVM/Clang examples.
For this programming assignment, please follow these steps for submission:
- After building Clang and LLVM, rerun the
makecommand. - Redirect the output of this command to a file called <uni>.txt. where <uni> is your Columbia UNI number. For example, if your UNI is foobar123, then your file will be called foobar123.txt. Make sure that the <uni>.txt file lives inside the top-level directory of the repository. We will be grading this file, and as long as you have successfully completed the build and redirected the output to this file, you will receive full credit.
- Push this file to the remote repository on the master branch (assuming you have Git set up).
If you have any questions about this programming assignment, please post them in the Piazza forum for the course, and an instructor will reply to them as soon as possible. Any updates to the assignment itself will be available in Piazza.
This assignment belongs to Columbia University. It may be freely used for educational purposes.
