You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update llvm-hello-world + add examples for load-llvm-ir and build-type-hierarchy with phasar
* Add examples on how to build a call-graph
* Update CG examples to include the reverse-CG + add example for alias info
* Add taint analysis example
* Add IDE linear constant analysis example
* Build and run example programs in CI
* Fixing small isuues
* Fix examples path in CI
* Install phasar to custom location in CI
* Set env for install and examples-build in CI
* Next attempt to fix CI
* Adding simple example on how to write an IFDS analysis
* Improve TaintConfigUtilities to provide API that *returns* affected facts, instead of inserting them into an already-existing set
* minor
* Small simplification
* Add example on how to write an IDE linear constant analysis based on the corresponding Wiki entry
* Update readmes
* Fix broken compile due to merge
* minor restructure in README.md
* cleanup readme
It is recommended to compile PhASAR yourself in order to get the full C++ experience and to have full control over the build mode.
5
+
However, you may also want to try out one of the pre-built versions of PhASAR or the Docker container.
6
+
7
+
As a shortcut for the very first PhASAR build on your system, you can use our [bootstrap](./bootstrap.sh) script.
8
+
Please note that you must have python installed for the script to work properly.
9
+
10
+
```bash
11
+
./bootstrap.sh
12
+
```
13
+
14
+
Note: If you want to do changes within PhASAR, it is recommended to build it in Debug mode:
15
+
16
+
```bash
17
+
./bootstrap.sh -DCMAKE_BUILD_TYPE=Debug
18
+
```
19
+
20
+
The bootstrap script may ask for superuser permissions (to install the dependencies); however it is not recommended to start the whole script with `sudo`.
21
+
22
+
For subsequent builds, see [Compiling PhASAR](#compiling-phasar-if-not-already-done-using-the-installation-scripts).
23
+
24
+
### Compiling PhASAR (if not already done using the bootstrap script)
25
+
26
+
Set the system's variables for the C and C++ compiler to clang:
27
+
28
+
```bash
29
+
export CC=/usr/local/bin/clang
30
+
export CXX=/usr/local/bin/clang++
31
+
```
32
+
33
+
You may need to adjust the paths according to your system. When you cloned PhASAR from Github you need to initialize PhASAR's submodules before building it:
34
+
35
+
```bash
36
+
git submodule update --init
37
+
```
38
+
39
+
If you downloaded PhASAR as a compressed release (e.g. .zip or .tar.gz) you can use the `init-submodules-release.sh` script that manually clones the required submodules:
40
+
41
+
```bash
42
+
utils/init-submodules-release.sh
43
+
```
44
+
45
+
Navigate into the PhASAR directory. The following commands will do the job and compile the PhASAR framework:
46
+
47
+
```bash
48
+
mkdir build
49
+
cd build/
50
+
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..
51
+
ninja -j $(nproc)# or use a different number of cores to compile it
52
+
sudo ninja install # only if you wish to install PhASAR system wide
53
+
```
54
+
55
+
When you have used the `bootstrap.sh` script to install PhASAR, the above steps are already done.
56
+
Use them as a reference if you wish to modify PhASAR and recompile it.
57
+
58
+
After compilation using cmake the following two binaries can be found in the build/tools directory:
59
+
60
+
+`phasar-cli` - the PhASAR command-line tool (previously called `phasar-llvm`) that provides access to analyses that are already implemented within PhASAR. Use this if you don't want to build an own tool on top of PhASAR.
61
+
+`myphasartool` - an example tool that shows how tools can be build on top of PhASAR
62
+
63
+
Please be careful and check if errors occur during the compilation.
64
+
65
+
When using CMake to compile PhASAR the following optional parameters can be used:
66
+
67
+
| Parameter : Type| Effect |
68
+
|-----------|--------|
69
+
|**BUILD_SHARED_LIBS** : BOOL | Build shared libraries -- Not recommended anymore. You may want to use PHASAR_BUILD_DYNLIB instead (default is OFF) |
70
+
|**PHASAR_BUILD_DYNLIB** : BOOL | Build one fat shared library (default is OFF) |
71
+
|**CMAKE_BUILD_TYPE** : STRING | Build PhASAR in 'Debug', 'RelWithDebInfo' or 'Release' mode (default is 'Debug') |
72
+
|**CMAKE_INSTALL_PREFIX** : PATH | Path where PhASAR will be installed if "ninja install” is invoked or the “install” target is built (default is /usr/local/phasar) |
73
+
|**PHASAR_CUSTOM_CONFIG_INSTALL_DIR** : PATH | If set, customizes the directory, where configuration files for PhASAR are installed (default is /usr/local/.phasar-config)|
74
+
|**PHASAR_ENABLE_DYNAMIC_LOG** : BOOL|Makes it possible to switch the logger on and off at runtime (default is ON)|
|**CMAKE_CXX_STANDARD** : INT|Build phasar in C++17 or C++20 mode (default is 17)|
83
+
84
+
You can use these parameters either directly or modify the installer-script `bootstrap.sh`
85
+
86
+
#### A Remark on Compile Time
87
+
88
+
C++'s long compile times are always a pain. As shown in the above, when using cmake the compilation can easily be run in parallel, resulting in shorter compilation times. Make use of it!
89
+
90
+
### Running a Test Solver
91
+
92
+
To test if everything works as expected please run the following command:
You can find the `phasar-cli` tool in the build-tree under `tools/phasar-cli`.
97
+
98
+
If you obtain output other than a segmentation fault or an exception terminating the program abnormally everything works as expected.
99
+
100
+
### Building PhASAR on a MacOS System
101
+
102
+
Due to unfortunate updates to MacOS and the handling of C++, especially on the newer M1 processors, we can't support native development on Mac.
103
+
The easiest solution to develop PhASAR on a Mac right now is to use [dockers development environments](https://docs.docker.com/desktop/dev-environments/). Clone this repository as described in their documentation. Afterwards, you have to login once manually, as a root user by running `docker exec -it -u root <container name> /bin/bash` to complete the rest of the build process as described in this readme (install submodules, run bootstrap.sh, ...).
104
+
Now you can just attach your docker container to VS Code or any other IDE, which supports remote development.
105
+
106
+
## Installation
107
+
108
+
PhASAR can be installed using the installer scripts as explained in the following.
109
+
However, you do not need to install PhASAR in order to use it.
110
+
111
+
### Installing PhASAR on an Ubuntu System
112
+
113
+
In the following, we would like to give an complete example of how to install
114
+
PhASAR using an Ubuntu or Unix-like system.
115
+
116
+
Therefore, we provide an installation script. To install PhASAR, just navigate to the top-level
117
+
directory of PhASAR and use the following command:
118
+
119
+
```bash
120
+
./bootstrap.sh --install
121
+
```
122
+
123
+
The bootstrap script may ask for superuser permissions.
124
+
125
+
Done!
126
+
127
+
If You have already built phasar, you can just invoke
PhASAR is a LLVM-based static analysis framework written in C++. It allows users
13
+
to specify arbitrary data-flow problems which are then solved in a
14
+
fully-automated manner on the specified LLVM IR target code. Computing points-to
15
+
information, call-graph(s), etc. is done by the framework, thus you can focus on
16
+
what matters.
17
+
18
+
You can find available literature on PhASAR [here](https://github.com/secure-software-engineering/phasar/wiki/Useful-Literature#papers-on-phasar).
19
+
20
+
### How do I get started with PhASAR?
21
+
22
+
We have some documentation on PhASAR in our [***Wiki***](https://github.com/secure-software-engineering/phasar/wiki). You probably would like to read
23
+
this README first.
24
+
<!-- and then have a look on the material provided on <https://phasar.org/>
25
+
as well. -->
26
+
Please also have a look on PhASAR's project directory and notice the project directory [examples](./examples/) as well as the custom tool `tools/example-tool/myphasartool.cpp`.
27
+
28
+
**NEW:** You can find PhASAR's API reference [here](https://secure-software-engineering.github.io/phasar/).
29
+
30
+
10
31
## Secure Software Engineering Group
11
32
12
33
PhASAR is primarily developed and maintained by the Secure Software Engineering Group at Heinz Nixdorf Institute (University of Paderborn) and Fraunhofer IEM.
@@ -33,155 +54,13 @@ Although phasar currently does not make use of C++-20 features (except for some
33
54
34
55
PhASAR is currently set up to support LLVM-15.0.*
35
56
36
-
## What is PhASAR?
37
-
38
-
PhASAR is a LLVM-based static analysis framework written in C++. It allows users
39
-
to specify arbitrary data-flow problems which are then solved in a
40
-
fully-automated manner on the specified LLVM IR target code. Computing points-to
41
-
information, call-graph(s), etc. is done by the framework, thus you can focus on
42
-
what matters.
43
-
44
57
## Breaking Changes
45
58
46
59
To keep PhASAR in a state that it is well suited for state-of-the-art research in static analysis, as well as for productive use, we have to make breaking changes. Please refer to [Breaking Changes](./BreakingChanges.md) for detailed information on what was broken recently and how to migrate.
47
60
48
-
## How do I get started with PhASAR?
49
-
50
-
We have some documentation on PhASAR in our [***Wiki***](https://github.com/secure-software-engineering/phasar/wiki). You probably would like to read
51
-
this README first.
52
-
<!-- and then have a look on the material provided on <https://phasar.org/>
53
-
as well. -->
54
-
Please also have a look on PhASAR's project directory and notice the project directory `examples/` as well as the custom tool `tools/example-tool/myphasartool.cpp`.
55
-
56
61
## Building PhASAR
57
62
58
-
It is recommended to compile PhASAR yourself in order to get the full C++ experience and to have full control over the build mode.
59
-
However, you may also want to try out one of the pre-built versions of PhASAR or the Docker container.
60
-
61
-
As a shortcut for the very first PhASAR build on your system, you can use our [bootstrap](./bootstrap.sh) script.
62
-
Please note that you must have python installed for the script to work properly.
63
-
64
-
```bash
65
-
./bootstrap.sh
66
-
```
67
-
68
-
Note: If you want to do changes within PhASAR, it is recommended to build it in Debug mode:
69
-
70
-
```bash
71
-
./bootstrap.sh -DCMAKE_BUILD_TYPE=Debug
72
-
```
73
-
74
-
The bootstrap script may ask for superuser permissions (to install the dependencies); however it is not recommended to start the whole script with `sudo`.
75
-
76
-
For subsequent builds, see [Compiling PhASAR](#compiling-phasar-if-not-already-done-using-the-installation-scripts).
77
-
78
-
### Compiling PhASAR (if not already done using the bootstrap script)
79
-
80
-
Set the system's variables for the C and C++ compiler to clang:
81
-
82
-
```bash
83
-
export CC=/usr/local/bin/clang
84
-
export CXX=/usr/local/bin/clang++
85
-
```
86
-
87
-
You may need to adjust the paths according to your system. When you cloned PhASAR from Github you need to initialize PhASAR's submodules before building it:
88
-
89
-
```bash
90
-
git submodule update --init
91
-
```
92
-
93
-
If you downloaded PhASAR as a compressed release (e.g. .zip or .tar.gz) you can use the `init-submodules-release.sh` script that manually clones the required submodules:
94
-
95
-
```bash
96
-
utils/init-submodules-release.sh
97
-
```
98
-
99
-
Navigate into the PhASAR directory. The following commands will do the job and compile the PhASAR framework:
100
-
101
-
```bash
102
-
mkdir build
103
-
cd build/
104
-
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..
105
-
ninja -j $(nproc)# or use a different number of cores to compile it
106
-
sudo ninja install # only if you wish to install PhASAR system wide
107
-
```
108
-
109
-
When you have used the `bootstrap.sh` script to install PhASAR, the above steps are already done.
110
-
Use them as a reference if you wish to modify PhASAR and recompile it.
111
-
112
-
After compilation using cmake the following two binaries can be found in the build/tools directory:
113
-
114
-
+`phasar-cli` - the PhASAR command-line tool (previously called `phasar-llvm`) that provides access to analyses that are already implemented within PhASAR. Use this if you don't want to build an own tool on top of PhASAR.
115
-
+`myphasartool` - an example tool that shows how tools can be build on top of PhASAR
116
-
117
-
Please be careful and check if errors occur during the compilation.
118
-
119
-
When using CMake to compile PhASAR the following optional parameters can be used:
120
-
121
-
| Parameter : Type| Effect |
122
-
|-----------|--------|
123
-
|**BUILD_SHARED_LIBS** : BOOL | Build shared libraries -- Not recommended anymore. You may want to use PHASAR_BUILD_DYNLIB instead (default is OFF) |
124
-
|**PHASAR_BUILD_DYNLIB** : BOOL | Build one fat shared library (default is OFF) |
125
-
|**CMAKE_BUILD_TYPE** : STRING | Build PhASAR in 'Debug', 'RelWithDebInfo' or 'Release' mode (default is 'Debug') |
126
-
|**CMAKE_INSTALL_PREFIX** : PATH | Path where PhASAR will be installed if "ninja install” is invoked or the “install” target is built (default is /usr/local/phasar) |
127
-
|**PHASAR_CUSTOM_CONFIG_INSTALL_DIR** : PATH | If set, customizes the directory, where configuration files for PhASAR are installed (default is /usr/local/.phasar-config)|
128
-
|**PHASAR_ENABLE_DYNAMIC_LOG** : BOOL|Makes it possible to switch the logger on and off at runtime (default is ON)|
|**CMAKE_CXX_STANDARD** : INT|Build phasar in C++17 or C++20 mode (default is 17)|
137
-
138
-
You can use these parameters either directly or modify the installer-script `bootstrap.sh`
139
-
140
-
#### A Remark on Compile Time
141
-
142
-
C++'s long compile times are always a pain. As shown in the above, when using cmake the compilation can easily be run in parallel, resulting in shorter compilation times. Make use of it!
143
-
144
-
### Running a Test Solver
145
-
146
-
To test if everything works as expected please run the following command:
You can find the `phasar-cli` tool in the build-tree under `tools/phasar-cli`.
151
-
152
-
If you obtain output other than a segmentation fault or an exception terminating the program abnormally everything works as expected.
153
-
154
-
### Building PhASAR on a MacOS System
155
-
156
-
Due to unfortunate updates to MacOS and the handling of C++, especially on the newer M1 processors, we can't support native development on Mac.
157
-
The easiest solution to develop PhASAR on a Mac right now is to use [dockers development environments](https://docs.docker.com/desktop/dev-environments/). Clone this repository as described in their documentation. Afterwards, you have to login once manually, as a root user by running `docker exec -it -u root <container name> /bin/bash` to complete the rest of the build process as described in this readme (install submodules, run bootstrap.sh, ...).
158
-
Now you can just attach your docker container to VS Code or any other IDE, which supports remote development.
159
-
160
-
## Installation
161
-
162
-
PhASAR can be installed using the installer scripts as explained in the following.
163
-
However, you do not need to install PhASAR in order to use it.
164
-
165
-
### Installing PhASAR on an Ubuntu System
166
-
167
-
In the following, we would like to give an complete example of how to install
168
-
PhASAR using an Ubuntu or Unix-like system.
169
-
170
-
Therefore, we provide an installation script. To install PhASAR, just navigate to the top-level
171
-
directory of PhASAR and use the following command:
172
-
173
-
```bash
174
-
./bootstrap.sh --install
175
-
```
176
-
177
-
The bootstrap script may ask for superuser permissions.
178
-
179
-
Done!
180
-
181
-
If You have already built phasar, you can just invoke
182
-
```bash
183
-
sudo ninja install
184
-
```
63
+
Please refer to [BUILD.md](./BUILD.md) for instructions on how to build PhASAR.
Shows, how you can use PhASAR to load and manage a LLVM IR module.
4
+
5
+
## Build
6
+
7
+
This example program can be built using cmake.
8
+
It assumes, that you have installed PhASAR on your system. If you did not install PhASAR to a default location, you can specify `-Dphasar_ROOT=your/path/to/phasar` when invoking `cmake`, replacing "your/path/to/phasar" by the actual path where you have installed PhASAR.
9
+
10
+
```bash
11
+
# Invoked from the 00-load-llvm-ir root folder:
12
+
$ mkdir -p build &&cd build
13
+
$ cmake ..
14
+
$ cmake --build .
15
+
```
16
+
17
+
## Test
18
+
19
+
You can test the example program on the target programs from [llvm-hello-world/target](../../llvm-hello-world/target/).
0 commit comments