The following build instructions assume you are on a fresh new Ubuntu 20.10 VM. I personally recommend VMware products because they make it painless to set up a new VM. I used VMware Fusion to test on a macOS host, or VMware Workstation to test on a Windows host.
-
Install git
$ sudo apt install git -
Clone this repo
$ git clone https://github.com/ivanrodriguez3753/CoolCompilerProject.git -
cd into the cloned repo and run the dependency script
$ cd CoolCompilerProject
$ chmod +x installDependenciesUbuntu20.10.sh
$ ./installDependenciesUbuntu20.10.sh -
In order to avoid using environment variables, follow the unix/linux file system conventions by sym-linking the newly installed clang with the expected 'clang' and 'clang++' commands:
$ sudo ln -s /usr/bin/clang-11 /usr/bin/clang
$ sudo ln -s /usr/bin/clang++-11 /usr/bin/clang++ -
All dependencies should be good to go. Now we can build the CoolCompilerProject (and test project) following the usual build-from-source steps:
$ mkdir build
$ cd build
$ cmake ..
$ make -
To run the compiler, cd into ~/build/src and run the executable with the optional --ast flag and with the required filename.cl parameter. If the input file is well-formed, it will produce filename.ll
$ cd src
$ ./CoolCompilerProject hello-world.cl -
To run the test project, copy the apporpriate reference compiler into a new file named "cool". The reference compiler and its destination are in ~root/tests/resources. Then run the tests executable
$ cd ~root/tests/resources
$ cp cool-linux-x64-64 cool
$ chmod a+x cool
$ cd ../../build/tests
$ ./tests -
Since the CoolCompiler targets LLVM, we need to take the output file and run it through clang
$ clang hello-world.ll
$ ./a.out