How to set up Alive2 on Ubuntu 20.04 LTS from scratch
This blog shares about how to set up Alive2 on Ubuntu 20.04 LTS from scratch. It took me several days to make it work properly T_T. Anyway, let’s start.
According to Alive2 Github page, Alive2 needs recent versions of:
I’ll elaborate how to set these up one by one, but at first, given a newly installed Ubuntu, we need to install some necessary packages.
- git, for cloning repos from Github
- Ninja, for building repos cloned
- Python3 (I think Ubuntu contains installed Python3 by default)
- python-is-python3. This package allows you call
Thus all the commands you will need are:
sudo apt-get install git
It’d be better to use gcc-10 for supporting some c++ 20 features. Thanks to this blog, How to Install GCC (build-essential) on Ubuntu 20.04, to configure gcc-10 on our Ubuntu, we need following commands:
sudo apt install g++-10
After executing successfully, by checking
g++ -v you would see gcc version is 10.2.0.
re2c is not hard to install.
sudo apt-get install re2c is enough.
Github page of Z3 is pretty exhaustive. After cloning the repo, you should run following commands at repo folder.
One thing needs to notice is that if you want to remove z3 for some reason in the future, you might need CheckInstall for removing installed package. Thus, if you use CheckInstall to install, those commands should become:
After cloning LLVM repo,
cd our working directory to the new generated repo (normally the folder name is
llvm-project) and execute
Commands above would build LLVM with ninja. Some problems would occur if you run
sudo ninja. Finally, to install LLVM into system, you should run
To test if LLVM works well, you should run
After cloning Alive2,
cd working directory into the new generated repo (the name is
alive2 by default) and run following commands
Notice, the argument named
-DCMAKE_PREFIX_PATH should be pointed the build folder we created in LLVM section.
If everything works well, by running
we should pass all test. If so, congratulations! You alive2 is set and ready to go~ You could run commands such as
~/llvm/build/bin/llvm-lit -vv -Dopt=$HOME/alive2/build/opt-alive.sh ~/llvm/llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sge-to-icmp-sle.ll
~/llvm/build/bin/llvm-lit -vv -Dopt=$HOME/alive2/build/opt-alive.sh ~/llvm/llvm/test/Transforms
to see results. Finally, if you see some errors like ‘filecheck error: \< stdin> is empty’ when you running Alive2 on
/test/Transforms folder, don’t be panic. Some files contain bug that make Alive2 exit beforehand. Those files are reported at here. You could check them by clicking, for example.
1da2c7d25c09 on the page and redirect to files.