@@ -42,17 +42,18 @@ dependencies:
42
42
43
43
## From scratch
44
44
45
- We recommend using Linux or OSX on a computer with at least 1 GB of memory.
45
+ We recommend using Linux or OSX on a computer with at least 4 GB of memory.
46
46
47
47
On Ubuntu 18.04, the installation process for our C semantics can be summarized as:
48
48
``` sh
49
49
sudo apt-get install --yes \
50
- maven git openjdk-8-jdk flex libgmp-dev \
50
+ maven git openjdk-8-jdk flex libgmp-dev libffi-dev \
51
51
libmpfr-dev build-essential cmake zlib1g-dev \
52
- libclang-3.9-dev llvm-3.9 diffutils libuuid-tiny-perl \
52
+ diffutils libuuid-tiny-perl \
53
53
libstring-escape-perl libstring-shellquote-perl \
54
54
libgetopt-declare-perl opam pkg-config \
55
- libapp-fatpacker-perl
55
+ libapp-fatpacker-perl liblocal-lib-perl \
56
+ clang-6.0 libclang-6.0-dev
56
57
git clone https://github.com/kframework/c-semantics.git
57
58
cd c-semantics
58
59
git submodule update --init --recursive
@@ -62,101 +63,78 @@ make -j4 --output-sync=line
62
63
```
63
64
The build artifacts will be placed inside the ` dist ` directory.
64
65
65
-
66
66
## Detailed instructions
67
67
68
68
### 1. Install basic dependencies.
69
- - The GNU C compiler (GCC), Make, diff, and patch. On OSX, these programs are generally part
70
- of XCode. On Ubuntu, these programs are part of the "build-essential" and "diffutils" packages
71
- and can be installed with the following:
72
- ```
73
- $ sudo apt-get install build-essential diffutils
69
+ - The GNU C compiler (GCC), Make, diff, patch, CMake, Maven, and libraries.
70
+ ``` sh
71
+ sudo apt-get install build-essential diffutils bison cmake maven pkg-config \
72
+ libgmp-dev libffi-dev libmpfr-dev flex
74
73
```
75
74
- If using Windows, you'll probably want to install cygwin.
76
75
77
76
### 2. Install Perl 5 and required modules.
78
77
- Perl 5 will likely already be installed on most Linux and Mac OS X machines.
79
78
But if not, use your package manager to install it.
80
79
- For Windows, see here: < http://www.perl.org/get.html >
81
- - Install the following Perl modules using ` cpan ` (or ` ppm ` with ActiveState
82
- Perl in Windows):
80
+ - Install the following Perl modules:
83
81
- App::FatPacker
84
82
- Getopt::Declare
85
83
- String::Escape
86
84
- String::ShellQuote
87
85
- UUID::Tiny
86
+ - local::lib
88
87
89
- You can also install them using apt-get with
88
+ The easiest way is to install them using apt-get:
90
89
```
91
- $ sudo apt-get install libuuid-tiny-perl libxml-libxml-perl libgetopt-declare-perl libstring-escape-perl libstring-shellquote-perl libapp-fatpacker-perl
90
+ $ sudo apt-get install libuuid-tiny-perl libxml-libxml-perl libgetopt-declare-perl libstring-escape-perl libstring-shellquote-perl libapp-fatpacker-perl liblocal-lib-perl
92
91
```
93
92
94
- Alternately , to install these modules using cpan:
93
+ Alternatively , to install these modules using cpan:
95
94
```
96
- $ sudo cpan -i Getopt::Declare String::Escape String::ShellQuote App::FatPacker
95
+ $ sudo cpan -i Getopt::Declare String::Escape String::ShellQuote App::FatPacker local::lib
97
96
```
98
- ### 3. Install K.
99
- - This version of the C semantics should be compatible with the latest version
100
- of Runtime Verification's version of the K Framework (< https://github.com/runtimeverification/k > ).
101
- - Ensure ` kompile ` and ` krun ` are included in your ` $PATH ` . For example, if you
102
- downloaded the K Framework to ` ~/k ` (and add this to your ` ~/.bashrc ` to make
103
- this permanent):
104
- ```
105
- $ export PATH=$PATH:~/k/bin
97
+
98
+ ### 3. Install OCaml
99
+ We use ocaml for the C parser and for K OCaml backend. Install OCaml using
100
+ ``` sh
101
+ sudo apt-get install --yes opam
106
102
```
107
103
108
- ### 4. Install OCaml K backend.
109
- - This is a proprietary component used to compile and execute programs written in K.
110
- It is Copyright Runtime Verification, Inc. and subject to the Runtime Verification
111
- Licenses (< https://runtimeverification.com/licensing/ > ).
112
- A completely free executable version of the C semantics is not available at this time.
113
- From the K source root, you can install it by running:
104
+ ### 3. Clone the semantics
114
105
```
115
- $ mvn dependency:copy -Dartifact=com.runtimeverification.rv_match:ocaml-backend:1.0-SNAPSHOT -DoutputDirectory=k-distribution/target/release/k/lib/java
106
+ git clone --depth=1 https://github.com/kframework/c-semantics.git
107
+ cd c-semantics
116
108
```
117
109
118
- ### 5. Install OCaml.
119
- - We use a modified version of the C parser from the CIL project, which is
120
- written in OCaml.
121
- - We also now default to using OCaml to execute the C semantics.
122
-
123
- For execution the unreleased 4.03 is required, and compiling the semantics
124
- uses ocamlfind to locate require OCaml packages.
125
- This is most easily managed with opam - https://opam.ocaml.org/
126
- To install the required dependencies using OPAM, run
127
110
111
+ ### 4. Install K
112
+ An appropriate version of K framework is a submodule of the c-semantics repository.
113
+ To build it, first update all the submodules:
128
114
```
129
- k-configure-opam-dev
130
- eval `opam config env`
115
+ git submodule update --init --recursive
131
116
```
132
-
133
- To check if OCaml is installed:
117
+ then build K:
134
118
```
135
- $ ocamlfind ocamlopt -version
136
- Objective Caml version 4.03.0+dev10-2015-07-29
137
-
138
- #
119
+ pushd .build/k
120
+ mvn package -DskipTests -DskipKTest -Dhaskell.backend.skip -Dllvm.backend.skip
121
+ ```
122
+ and install the dependencies of K's OCaml backend:
123
+ ```
124
+ ./k-distribution/src/main/scripts/bin/k-configure-opam-dev
125
+ popd
126
+ eval `opam config env`
139
127
```
140
128
141
- (Press ctrl-d to exit.)
142
-
143
- (For the parser alone versions 3.11, 3.12, and 4.00 all work, probably many
144
- more as well, and no special dependency handling is required.
145
- Installing with your OS package manger or from https://ocaml.org/ will work.
146
- On Ubuntu, ` apt-get install ocaml ` )
147
-
148
- ### 6. Download our C semantics.
149
- Use the following command if ` git ` is installed:
129
+ ### 5. Install Clang
130
+ We use Clang to parse C++ programs. Install Clang 6.0 using
150
131
```
151
- $ git clone --depth=1 https://github.com/kframework/c-semantics.git
132
+ sudo apt-get install --yes clang-6.0 libclang-6.0-dev
152
133
```
153
- Otherwise, download the latest stable version from github here:
154
- < https://github.com/kframework/c-semantics/releases/tag/latest >
155
134
156
- ### 7. Build our C tool.
157
- - Run ` make -j4 ` in the project root directory.
158
- - This should take roughly 10 minutes on non-windows machines, and up to
159
- 60 minutes on windows.
135
+ ### 6. Build our C tool.
136
+ - Run ` make ` (or ` make -j4 ` if you have enough memory) in the project root directory.
137
+ - The build takes about 30 minutes.
160
138
- The ` make ` process creates a ` dist/ ` directory which you can copy elsewhere
161
139
to install the C tool, or simply leave it where it is. Either way, you will
162
140
probably want to add it to your ` $PATH ` :
@@ -174,3 +152,11 @@ Hello world
174
152
See [ README.md] ( README.md ) for a summary of the features supported by the ` kcc `
175
153
tool.
176
154
155
+ ### 8. Subsequent builds
156
+ When building in a fresh shell after all dependencies are installed, before the ` make ` command, run
157
+ ```
158
+ eval $(opam config env)
159
+ eval $(perl -I "~/perl5/lib/perl5" -Mlocal::lib)
160
+ ```
161
+
162
+
0 commit comments