microsoft / SLAyer

SLAyer is an automatic formal verification tool that uses separation logic to verify memory safety of C programs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

installing on linux

joewilliams opened this issue · comments

FWIW this is the procedure I used to get SLAyer running on a freshly installed VM with Ubuntu 14.04.1 LTS.

I started with the following per the ocaml website:

sudo add-apt-repository --yes ppa:avsm/ppa
sudo apt-get update -qq
sudo apt-get install -y ocaml ocaml-native-compilers camlp4-extra opam pkg-config build-essential m4
opam init
eval $(opam config env)
opam switch install 4.02.3
export OCAMLLIB=/home/joe/.opam/4.02.3/lib/ocaml/
opam install ocamlbuild ocamlfind 
mv /usr/local/lib/ocaml  /usr/local/lib/ocaml.old
sudo ln -s /home/joe/.opam/4.02.3/lib/ocaml /usr/local/lib/ocaml
opam install camlidl

camlidl seems to hardcode /usr/local/lib/ocaml in the configure/Makefile.

Then followed did the following:

git clone https://github.com/Microsoft/SLAyer.git
cd SLAyer/
git submodule init
git submodule update
. config.sh
cd src/
make

I seemed to need to modify a Makefile, ~/SLAyer/tools/Z3/build/api/ml/Makefile to:

CAMLIDL=-I/home/joe/.opam/4.02.3/lib/camlidl rather than the path from ocamlc -where.

cd ~/SLAyer/tools/Z3/build/api/ml/
make
cd ~/SLAyer/src
make

This failed, I then had to remove the repo and try again, afterwards it then complied fully. I assume this is something getting screwed up in the ENV or various library paths during the initial install attempt that restarting from scratch seems to fix. Unfortunately I am not sure what it is.

cd ..
rm -rf SLAyer/
git clone git clone https://github.com/Microsoft/SLAyer.git
git clone https://github.com/Microsoft/SLAyer.git
eval $(opam config env)
cd SLAyer/src/
git submodule init
git submodule update
. config.sh
cd src/
export OCAMLLIB=/home/joe/.opam/4.02.3/lib/ocaml
make
joe@ubuntu:~/SLAyer$ ./bin/slayer -version
SLAyer  debug (Z3 dll v4.3.2)

From there slayer runs but exits quietly but with an exit code of 1. strace -f shows that this is due to nothing called frontend on the path. Which #1 seems to be about.

For the heck of it I created a frontend file:

joe@ubuntu:~/SLAyer$ cat /usr/local/bin/frontend
echo $@

Which tells me it's trying to run frontend $MYCFILENAME -fe_norm true. Seems like without some sort of special frontend client it's not very usable on linux at least.

Also possibly worth noting, cygpath isn't installed:

joe@ubuntu:~/SLAyer$ . config.sh
cygpath: command not found
cygpath: command not found

Also, best I can tell something like cp /home/joe/SLAyer/src/../tools/Z3/build/api/ml/* /home/joe/.opam/4.02.3/lib/ocaml/ doesn't seem to help.

Thanks for open sourcing this project. Hope this helps others!

FWIW this is the procedure I used to get SLAyer running on a freshly installed VM with Ubuntu 14.04.1
LTS.

I started with the following per the ocaml website:

sudo add-apt-repository --yes ppa:avsm/ppa
sudo apt-get update -qq
sudo apt-get install -y ocaml ocaml-native-compilers camlp4-extra opam pkg-config build-essential m4

Here I think that you should only have to specify opam, or did you try that unsuccessfully?

opam init
eval $(opam config env)
opam switch install 4.02.3
export OCAMLLIB=/home/joe/.opam/4.02.3/lib/ocaml/

If opam is working as expected on your machine, this last line should not be needed, odd.

opam install ocamlbuild ocamlfind
mv /usr/local/lib/ocaml /usr/local/lib/ocaml.old
sudo ln -s /home/joe/.opam/4.02.3/lib/ocaml /usr/local/lib/ocaml

Likewise, if opam is working as expected, these last two lines should not be needed, odd.

opam install camlidl

camlidl seems to hardcode /usr/local/lib/ocaml in the configure/Makefile.

I think that the make "install" "BINDIR=%{bin}%" "OCAMLLIB=%{lib}%/camlidl" line in camlidl's opam file should automatically override these settings with the correct directories under ~/.opam .

Then followed did the following:

git clone https://github.com/Microsoft/SLAyer.git
cd SLAyer/
git submodule init
git submodule update
. config.sh

Ah, sorry, config.sh is cygwin specific and is used for non-opam installation of ocaml. Other than adding .../SLAyer/bin and .../SLAyer/tools/Z3/build to PATH, it is redundant when using opam.

cd src/
make

I seemed to need to modify a Makefile, ~/SLAyer/tools/Z3/build/api/ml/Makefile to:

CAMLIDL=-I/home/joe/.opam/4.02.3/lib/camlidl rather than the path from ocamlc -where.

This may be due to config.sh breaking opam's settings.

cd ~/SLAyer/tools/Z3/build/api/ml/
make
cd ~/SLAyer/src
make

This failed, I then had to remove the repo and try again, afterwards it then complied fully. I assume this is
something getting screwed up in the ENV or various library paths during the initial install attempt that
restarting from scratch seems to fix. Unfortunately I am not sure what it is.

The slayer makefiles are not smart enough to recover from most failed Z3 builds. Manually executing make clean_z3 and retrying make should be enough and a bit faster than re-cloning.

cd ..
rm -rf SLAyer/
git clone git clone https://github.com/Microsoft/SLAyer.git
git clone https://github.com/Microsoft/SLAyer.git
eval $(opam config env)
cd SLAyer/src/
git submodule init
git submodule update
. config.sh
cd src/
export OCAMLLIB=/home/joe/.opam/4.02.3/lib/ocaml
make
joe@ubuntu:~/SLAyer$ ./bin/slayer -version
SLAyer debug (Z3 dll v4.3.2)

From there slayer runs but exits quietly but with an exit code of 1. strace -f shows that this is due to nothing
called frontend on the path. Which #1 seems to be about.

For the heck of it I created a frontend file:

joe@ubuntu:~/SLAyer$ cat /usr/local/bin/frontend
echo $@

Which tells me it's trying to run frontend $MYCFILENAME -fe_norm true. Seems like without some sort of
special frontend client it's not very usable on linux at least.

Yes, this is issue #1, the frontend could not be open-sourced, for any platform. Part of the frontend implementation is contained in Frontend.ml and frontend_esp.ml, although this code cannot currently be built as there are missing closed-source dependencies. But it could provide info on what the expected interface of the frontend is. Starting from Frontend.ml will lead to the implementation of the command-line interface. The main point is that frontend file.c is expected to produce a file named file.sil which contains a Marshaled value of type Program.Prog.t.

Also possibly worth noting, cygpath isn't installed:

joe@ubuntu:~/SLAyer$ . config.sh
cygpath: command not found
cygpath: command not found

Also, best I can tell something like cp /home/joe/SLAyer/src/../tools/Z3/build/api/ml/*
/home/joe/.opam/4.02.3/lib/ocaml/ doesn't seem to help.

Yes, cygpath is specific to cygwin, and not needed elsewhere. Sorry, this is totally not clear currently.

Thanks for open sourcing this project. Hope this helps others!

Thanks for sharing your experience!

Thanks for sharing. I used the following compilation process and compiled successfully without the need of removing SLAyer

git clone https://github.com/Microsoft/SLAyer.git
cd SLAyer/
git submodule init
git submodule update
export OCAMLLIB=$(ocamlc -where)
cd src; make