BenjaminSnyder/bugsy
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
SOME CHANGE FOR ADVANCED SWE
The bugsy compiler
Coded in OCaml, takes a c like, graphics language, bugsy, and compiles it into LLVM IR.
It needs the OCaml llvm library, which is most easily installed through opam.
Install LLVM and its development libraries, the m4 macro preprocessor,
and opam, then use opam to install llvm.
The version of the OCaml llvm library should match the version of the LLVM
system installed on your system.
The default LLVM package is 4.0.4, so we install the matching OCaml
library using opam.
=========================================================================
Dockerfile
=========================================================================
# Based on 20.04 LTS
FROM ubuntu:focal
ENV TZ=America/New_York
RUN apt-get -yq update
RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata
RUN DEBIAN_FRONTEND="noninteractive" apt-get -y upgrade && \
apt-get -yq --no-install-suggests --no-install-recommends install \
ocaml \
menhir \
llvm-10 \
llvm-10-dev \
m4 \
git \
aspcud \
ca-certificates \
python2.7 \
pkg-config \
cmake \
opam \
libglew-dev \
freeglut3-dev
RUN ln -s /usr/bin/lli-10 /usr/bin/lli
RUN ln -s /usr/bin/llc-10 /usr/bin/llc
RUN opam init --disable-sandboxing
RUN opam update
RUN opam install -y \
llvm.10.0.0 \
ocamlfind \
ocamlbuild
WORKDIR /root
ENTRYPOINT ["opam", "config", "exec", "--"]
CMD ["bash"]
=======================================================================
9. To run and test, navigate to the bugsy folder. Once there, run
make ; ./testall.sh
bugsy should build without any complaints and all tests should
pass.
IF RUNNING ./testall.sh FAILS ON SOME TESTS, check to make sure you
have symlinked the correct executable from your llvm installation.
For example, if the executable is named lli-[version], then the
previous step should have looked something like:
sudo ln -s /usr/local/opt/llvm/bin/lli-3.7 /usr/bin/lli
As before, you may also modify the path to lli in testall.sh
------------------------------
To run and test:
$ make
ocamlbuild -clean
Finished, 0 targets (0 cached) in 00:00:00.
00:00:00 0 (0 ) STARTING -------- |rm -rf testall.log *.diff bugsy.native scanner.ml parser.ml parser.mli
rm -rf _build/builtins.o
rm -rf *.cmx *.cmi *.cmo *.cmx *.o *.s *.ll *.out *.exe
rm -rf _build tmp
ocamlbuild -I src -use-ocamlfind -pkgs llvm,llvm.analysis -cflags -w,+a-4-42 \
bugsy.native
Finished, 25 targets (0 cached) in 00:00:01.
cc -c -o _build/builtins.o src/builtins.c -lm
$ ./scripts/testall.sh
test-add1...OK
test-arith1...OK
test-arith2...OK
.
.
.
test-circle...OK
test-ellipse...OK
test-moveBy...OK
test-rectangle...OK
test-regagon...OK
test-rotateBy...OK
test-scaleBy...OK
test-square...OK
test-triangle...OK
...
fail-array...OK
fail-assign1...OK
fail-assign2...OK