Skip to content

Commit f44de9f

Browse files
author
Matthieu Lemerre
committed
Upd to rc3
1 parent 2f42324 commit f44de9f

File tree

487 files changed

+33048
-14557
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

487 files changed

+33048
-14557
lines changed

Dockerfile.alpine

+6-5
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,24 @@
1919
# #
2020
##########################################################################
2121

22-
# Build with docker build -f release/Dockerfile -t codexmin .
23-
# Debug with docker run -ti num sh
24-
# Finish with docker cp codexmin:/home/ocaml/codex/_build/default/binsec/binsec_codex.exe .
22+
# Build with docker build -f Dockerfile.alpine -t codexalpine .
23+
# Debug with docker run -ti codexalpine sh
24+
# Finish with docker cp codexalpine:/home/ocaml/codex/_build/default/binsec/binsec_codex.exe .
2525

2626
# Start with an alpine linux image with opam in it, for musl
2727
FROM ocamlpro/ocaml:4.14 as first
28+
RUN opam update
2829
RUN opam switch create optstatic --packages=ocaml-variants.4.14.1+options,ocaml-option-static,ocaml-option-flambda,ocaml-option-no-flat-float-array
2930
RUN opam switch optstatic
3031
RUN eval $(opam env)
31-
RUN opam install binsec bheap
32+
RUN opam install binsec bheap
3233
# C++ is needed for cudd.
3334
RUN sudo apk add g++
3435
RUN opam install mlcuddidl
3536
RUN opam install camlp-streams
3637
# bash needed for core, needed for ppx_inline_test.
3738
RUN sudo apk add bash
38-
RUN opam install qcheck-core ppx_inline_test unionFind
39+
RUN opam install qcheck-core ppx_inline_test unionFind pacomb patricia-tree
3940

4041

4142
# Install the patched Frama-C. This is cached if ext/frama_c_with_cudd does not change.

Dockerfile.debian

+12-14
Original file line numberDiff line numberDiff line change
@@ -19,48 +19,48 @@
1919
# #
2020
##########################################################################
2121

22-
# Build with docker build -t codexmin .
23-
# Run with docker run -ti codexmin bash
22+
# Build with: docker build -f Dockerfile.debian -t codexdebian .
23+
# Run with docker run -ti codexdebian bash
2424
# When a container runs:
25-
# Get frama_c_codex.exe with docker cp container:/home/opam/libase/_build/default/frama-c/frama_c_codex.exe .
26-
# Get binsec_codex.exe with docker cp container:/home/opam/libase/_build/default/binsec/binsec_codex.exe .
25+
# Get frama_c_codex.exe with docker cp container:/home/opam/codex/_build/default/frama-c/frama_c_codex.exe .
26+
# Get binsec_codex.exe with docker cp container:/home/opam/codex/_build/default/binsec/binsec_codex.exe .
2727
FROM ocaml/opam:debian-11-ocaml-4.14 as first
2828
ENV DEBIAN_FRONTEND=noninteractive
2929
# Installs binsec, then frama-c dependencies.
30-
RUN sudo apt-get update && sudo apt-get -y install --no-install-recommends libgmp-dev liblmdb-dev && \
30+
RUN sudo apt-get update && sudo apt-get -y install --no-install-recommends bc libgmp-dev liblmdb-dev && \
3131
sudo apt-get install -y --no-install-recommends pkg-config autoconf graphviz libexpat1-dev zlib1g-dev \
3232
libcairo2-dev libexpat1-dev libgtk-3-dev libgtksourceview-3.0-dev \
3333
libgnomecanvas2-dev cmake time z3 gcc-multilib && sudo apt-get clean
3434
# Install binsec and dependencies (libgmp, needed by zarith)
3535
RUN opam install binsec
3636
# Install Codex dependencies (including sexplib, optinonally used by frama-c dependencies)
37-
RUN opam install mlcuddidl lmdb sexplib ppx_sexp_conv
37+
RUN opam install mlcuddidl lmdb sexplib ppx_sexp_conv pacomb bheap qcheck-core ppx_inline_test
3838
# Install the Frama-C dependencies
3939
# RUN opam install --deps-only frama-c && opam install yojson=2.0.0
4040
# Install minimal frama-c dependencies.
41-
RUN opam install yojson=2.0.0 ppx_deriving_yojson ppx_import
41+
RUN opam install yojson=2.0.0 ppx_deriving_yojson ppx_import yaml ppx_deriving_yaml patricia-tree
4242
# Compile a patched version of Frama-C to support cudd.
4343
# The patched version also prevents the dynamic loading of JSON configuration, so that frama_c_codex.exe can be used as a standalone binary.
44-
RUN curl https://www.frama-c.com/download/frama-c-26.1-Iron.tar.gz -o frama-c-26.1-Iron.tar.gz
44+
RUN curl https://www.frama-c.com/download/frama-c-27.1-Cobalt.tar.gz -o frama-c-27.1-Cobalt.tar.gz
4545
COPY --chown=opam:opam nix/patch-frama-c.patch patch-frama-c.patch
4646
# Install frama-C, without the plugins to make the compilation faster.
4747
# We also remove the plugins so that the frama_c_codex.exe binary will not try loading them.
48-
RUN tar xzf frama-c-26.1-Iron.tar.gz \
48+
RUN tar xzf frama-c-27.1-Cobalt.tar.gz \
4949
&& cd frama-c* \
5050
&& patch -Np1 -i ../patch-frama-c.patch \
5151
&& rm -R src/plugins \
5252
&& eval $(opam env) && make && make install \
5353
&& cd .. && rm -Rf frama-c*
5454
# Install more odvtk dependencies
55-
RUN sudo apt install libev-dev libssl-dev -y
55+
RUN sudo apt-get install libev-dev libssl-dev -y
5656
RUN opam install dream
5757
# Now install codex.
5858
RUN opam clean -a -c -s --logs && \
5959
rm -Rf opam-repository/.git && \
6060
rm -Rf opam-repository && \
6161
rm -Rf .opam/repo
62-
COPY --chown=opam:opam . /home/opam/libase
63-
RUN cd libase && eval $(opam env) && dune build binsec/binsec_codex.exe && cd frama-c && make build
62+
COPY --chown=opam:opam . /home/opam/codex
63+
RUN cd codex && eval $(opam env) && dune build
6464
# Optional: this further slims down the new image, which becomes kind of binary-only.
6565
# Works and allows a substantial gain in space, but currently the script for binsec call dune exec binsec_codex.exe, which tries to rebuild the binary and remove it.
6666
# RUN cd .opam && \
@@ -79,8 +79,6 @@ RUN cd libase && eval $(opam env) && dune build binsec/binsec_codex.exe && cd fr
7979
## COPY --from=first /home/opam /home/opam
8080
##
8181
## EXPOSE 8080
82-
# For an even slimmer version, we could just keep the binsec_codex.exe and frama_c_codex.exe executables.
83-
# This does not work for frama_c_codex.exe; maybe use appimage for that.
8482

8583

8684
# Local Variables:

Makefile

+79-15
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,83 @@
1919
# #
2020
##########################################################################
2121

22-
test.opt:
22+
# See "make help" for a list of targets and brief documentation
23+
24+
# set to ON/OFF to toggle ANSI escape sequences
25+
COLOR = ON
26+
27+
# padding for help on targets
28+
# should be > than the longest target
29+
HELP_PADDING = 20
30+
31+
ifeq ($(COLOR),ON)
32+
color_yellow = \033[93;1m
33+
color_orange = \033[33m
34+
color_red = \033[31m
35+
color_green = \033[32m
36+
color_blue = \033[34;1m
37+
color_reset = \033[0m
38+
endif
39+
40+
test.opt: ## Build and run frama-c/codex on root/test.c
2341
cd frama-c && make test.opt
42+
.PHONY: test.opt
2443

25-
dune:
44+
tests.opt: ## Build and run frama-c/codex on all tests
45+
cd frama-c && make tests.opt
46+
.PHONY: tests.opt
47+
48+
test.diff: ## Same as test.opt, but shows a diff with installed version of codex
49+
cd frama-c && make test.diff
50+
.PHONY: test.diff
51+
52+
dune: ## Build the project with dune
2653
dune build
54+
.PHONY: dune
2755

28-
binsec:
56+
binsec: ## Build binsec_codex.exe
2957
dune build binsec/binsec_codex.exe
30-
3158
.PHONY: binsec
3259

60+
frama_c_codex: ## Build frama_c_codex.exe
61+
dune build frama-c/frama_c_codex.exe
62+
dune build -p codex,frama_c_codex
63+
.PHONY: frama_c_codex
64+
65+
frama_c_codex_plugin: ## Build the codex frama-c plugin
66+
dune build frama-c/frama_c_codex.exe
67+
dune build -p codex,frama_c_codex,frama_c_codex_plugin
68+
.PHONY: frama_c_codex_plugin
69+
70+
clean: ## Remove build files and executable
71+
dune clean
72+
.PHONY: clean
73+
74+
doc: ## Build the documentation (accessible at _build/default/_doc/_html)
75+
dune build --display short @doc-private
76+
@echo "$(color_yellow)Browse doc at _build/default/_doc/_html/index.html$(color_reset)"
77+
.PHONY: doc
78+
3379
docker:
3480
docker build -t codex .
3581

36-
# Static version of BINSEC/Codex && FramaC/Codex.
37-
binsec_codex.exe frama_c_codex.exe: Dockerfile.alpine
82+
.PHONY: binsec_codex.exe frama_c_codex.exe
83+
binsec_codex.exe frama_c_codex.exe: Dockerfile.alpine ## Build static version of BINSEC/Codex && FramaC/Codex.
3884
docker build -f Dockerfile.alpine -t codexstatic .
3985
docker run --name my_container --detach codexstatic && docker cp my_container:/home/ocaml/codex/_build/default/binsec/binsec_codex.exe . && docker rm my_container
4086
docker run --name my_container --detach codexstatic && docker cp my_container:/home/ocaml/codex/_build/default/frama-c/frama_c_codex.exe . && docker rm my_container
4187

42-
4388
install-opam:
4489
opam init --compiler 4.14.1
4590

4691
# We need a patched version of Frama-C. If you have opam,
4792
# just type make opam-install-frama-c-with-cudd.
48-
opam-install-frama-c-with-cudd:
93+
opam-install-frama-c-with-cudd: ## Install patched version of frama-c for codex
4994
cd ext/frama_c_with_cudd && make
95+
.PHONY: opam-install-frama-c-with-cudd
5096

51-
dependency_graph.png:
97+
.PHONY: dependency_graph.png
98+
dependency_graph.png: ## Generate the library dependency graph
5299
dune-deps -x ext -x utils --no-ext | tred | dot -Tpng > $@
53100

54101
################ Rules to update headers and check that we did not forgot any file
@@ -62,14 +109,15 @@ FIND_EXCLUDE += -not -path './benchmarks/*'
62109

63110
UPDATED_EXTENSIONS = mli ml c h
64111

65-
update_headers:
112+
.PHONY: update_headers
113+
update_headers: ## Update file headers using headache
66114
echo '$(patsubst %, -o -name "%", $(UPDATED_EXTENSIONS))'
67115
find . $(FIND_EXCLUDE) -type f \
68116
\( -name "*.ml" -o -name "*.mli" -o -name "*.mll" -o -name "*.mly" \
69117
-o -name "*.c" -o -name "*.h" \
70118
-o -name "dune" -o -name "dune-project" -o -name "Makefile" \
71-
-o -name "Dockerfile.*" -o -name "*.ini" \) \
72-
-exec headache -c headers/headache_config.txt -h headers/CEA_LGPL21 {} \;
119+
-o -name "Dockerfile.*" -o -name "*.ini" -o -name "*.el" \) \
120+
-exec headache -c headers/headache_config.txt -h headers/CEA_LGPL21 {} \;
73121

74122

75123

@@ -86,6 +134,7 @@ EXTRA_EXCLUDE += -not -name 'dune-project'
86134
EXTRA_EXCLUDE += -not -name 'Makefile'
87135
EXTRA_EXCLUDE += -not -name 'Dockerfile.*'
88136
EXTRA_EXCLUDE += -not -name '*.ini'
137+
EXTRA_EXCLUDE += -not -name '*.el'
89138
EXTRA_EXCLUDE += -not -path './*.exp_dump'
90139
EXTRA_EXCLUDE += -not -path './*.dump'
91140
EXTRA_EXCLUDE += -not -path './*.result'
@@ -94,7 +143,22 @@ EXTRA_EXCLUDE += -not -path './*.exe'
94143
EXTRA_EXCLUDE += -not -path './*.orig'
95144
EXTRA_EXCLUDE += -not -path './*.patch'
96145

97-
98-
check_missing_files:
146+
.PHONY: check_missing_files
147+
check_missing_files: ## Check for files not update by update_headers
99148
@echo "Generating the list of files whose headers we do not maintain"
100-
find . -type f $(EXTRA_EXCLUDE) -print
149+
find . -type f $(EXTRA_EXCLUDE) -print
150+
151+
source-distrib:
152+
CUR=`git log -1 | head -n 1 | cut -d ' ' -f 2`; \
153+
cd `mktemp -d --suffix codex` && \
154+
git clone $(PWD) codex-$$CUR && \
155+
rm -Rf codex-$$CUR/.git && \
156+
rm -Rf codex-$$CUR/tests && \
157+
rm -Rf codex-$$CUR/frama-c/tests && \
158+
tar czf codex-$$CUR.tar.gz codex-$$CUR && \
159+
echo "Created file "`pwd`"/codex-"$$CUR".tar.gz"
160+
161+
.PHONY: help
162+
help:: ## Show this help
163+
@echo "$(color_yellow)make codex:$(color_reset) list of useful targets :"
164+
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " $(color_blue)%-$(HELP_PADDING)s$(color_reset) %s\n", $$1, $$2}'

README.org

+40-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,41 @@ The simplest way to try Binsec/Codex and Frama-C/Codex is to download the compil
3434

3535
(note that framac_codex.exe is a stripped version of Frama-C, with no plugins and support for compiler builtins removed)
3636

37-
** From source code
37+
** Install from source
38+
39+
The easiest way is to use opam ( https://opam.ocaml.org/ ).
40+
41+
Just locally pin the package with:
42+
43+
#+begin_src shell
44+
$ opam pin . -n
45+
#+end_src
46+
47+
You can then install the different packages:
48+
49+
#+begin_src shell
50+
$ opam install codex # For the codex library
51+
$ opam install binsec_codex # For the binsec_codex executable
52+
$ opam install frama_c_codex # For the frama_c_codex executable.
53+
#+end_src
54+
55+
You can also install the Frama-c/Codex plugin if you already have a version of Frama-C installed.
56+
57+
#+begin_src shell
58+
$ opam install frama_c_codex_plugin
59+
#+end_src
60+
61+
*** Testing your frama_c_codex installation
62+
63+
You can test that frama_c_codex is working by typing:
64+
65+
#+begin_src shell
66+
frama_c_codex -no-plugin-autoload -machdep x86_32 -codex test.c -codex-use-type-domain -codex-type-file frama-c/test.types -codex-html-dump output.html
67+
#+end_src
68+
69+
This should output an output.html with the results of the analysis, that you can inspect using your browser.
70+
71+
** Working from source code locally
3872

3973
*** Prerequisites
4074

@@ -49,21 +83,22 @@ Install opam:
4983
Install the dependencies:
5084

5185
#+begin_src shell
52-
opam install frama-c binsec lmdb llvm qcheck-core ppx_inline_test sexplib mlcuddidl bheap
86+
opam install frama-c binsec lmdb qcheck-core ppx_inline_test sexplib mlcuddidl bheap pacomb
5387
#+end_src
5488

55-
*** Installing the codex library
89+
Note: there is a bug in Frama-C >= 28.0 that breaks some of the testsg, so stick to 27.1 if this matters to you (e.g. if you develop new Codex features).
90+
91+
*** Building the codex library
5692

5793
#+begin_src shell
5894
dune build
5995
#+end_src
6096

61-
*** Installing Binsec/Codex
97+
*** Building Binsec/Codex
6298

6399
#+begin_src shell
64100
opam install binsec
65101
dune build binsec/binsec_codex.exe
66-
dune install binsec/binsec_codex.exe
67102
#+end_src
68103

69104
*** Installing Frama-C/Codex

binsec/analysis_settings.ml

-70
This file was deleted.

0 commit comments

Comments
 (0)