Skip to content

Commit

Permalink
Merge branch 'release-1.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
zvonimir committed Oct 21, 2013
2 parents 124d341 + 545d64d commit f377011
Show file tree
Hide file tree
Showing 145 changed files with 23,938 additions and 1,429 deletions.
18 changes: 18 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,21 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

==============================================================================
Copyrights and Licenses for Third Party Software Distributed with SMACK:
==============================================================================
SMACK contains code written by third parties. Such software will have its own
individual LICENSE.TXT file in the directory in which it appears. This file
will describe the copyrights, license, and restrictions which apply to that
code.

The following pieces of software have additional or alternate copyrights,
licenses, and/or restrictions:

Program Directories
------- -----------
poolalloc include/assistDS
include/dsa
lib/AssistDS
lib/DSA
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ include $(LEVEL)/Makefile.common
#
format:
astyle --options=astyle.conf $$(find lib -name "*.cpp")
astyle --options=astyle.conf $$(find include -name "*.h")
astyle --options=astyle.conf $$(find include -name "*.h")

distclean:: clean
${RM} -f Makefile.common Makefile.config
5 changes: 4 additions & 1 deletion Makefile.common.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set the name of the project here
PROJECT_NAME := smack
PROJ_VERSION := 1.0
PROJ_VERSION := 1.3.0

# Set this variable to the top of the LLVM source tree.
LLVM_SRC_ROOT = @LLVM_SRC@
Expand All @@ -18,6 +18,9 @@ PROJ_OBJ_ROOT := $(subst //,/,@abs_top_builddir@)
# Set the root directory of this project's install prefix
PROJ_INSTALL_ROOT := @prefix@

# Do not install the archive files
NO_INSTALL_ARCHIVES=1

# Configuration file to set paths specific to local installation of LLVM
include $(PROJ_OBJ_ROOT)/Makefile.llvm.config

Expand Down
2 changes: 1 addition & 1 deletion Makefile.llvm.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ PROJ_SRC_DIR := $(call realpath, $(PROJ_SRC_ROOT)/$(patsubst $(PROJ_OBJ_ROOT)%,%
prefix := $(PROJ_INSTALL_ROOT)
PROJ_prefix := $(prefix)
ifndef PROJ_VERSION
PROJ_VERSION := 1.0
PROJ_VERSION := 1.3.0
endif

PROJ_bindir := $(PROJ_prefix)/bin
Expand Down
1 change: 1 addition & 0 deletions Makefile.llvm.rules
Original file line number Diff line number Diff line change
Expand Up @@ -2186,6 +2186,7 @@ install-local::
'(' -name '*.py' \
-o -name '*.rb' \
-o -name 'boogie' \
-o -name 'corral' \
')' -print | grep -v CVS | \
grep -v .svn` ; do \
instdir=`dirname "$(DESTDIR)$(PROJ_includedir)/$$scr"` ; \
Expand Down
174 changes: 31 additions & 143 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,161 +9,49 @@ additions and extensions to SMACK relatively easy. Furthermore, the open
architecture of SMACK encourages prototyping custom software verifiers on top
of SMACK.

## A Quick Demo

## Requirements
SMACK can verify C programs, such as the following:

### Dependencies
// simple.c
#include "smack.h"

SMACK depends on the following projects:
* [LLVM](http://www.llvm.org) (release [3.2](http://llvm.org/releases/download.html#3.2)),
[clang](http://clang.llvm.org) (release [3.2](http://llvm.org/releases/download.html#3.2))
* [Boogie](http://boogie.codeplex.com), [Z3](http://z3.codeplex.com/)
* [Python](http://www.python.org) (version 2.7)
int incr(int x) {
return x + 1;
}

To configure, build, and install LLVM and clang, follow their [Getting Started
Quickly](http://llvm.org/docs/GettingStarted.html#getting-started-quickly-a-summary)
summary. You have to build and install LLVM and clang from sources since SMACK
does not build properly with their packaged versions. SMACK supports only major
LLVM releases and not the latest version found on its Subversion repository.
Therefore, instead of checking out LLVM from SVN, download its sources for the
required release as noted above.
int main(void) {
int a;

### Supported Platforms
a = 1;
a = incr(a);
__SMACK_assert(a == 2);
return 0;
}

SMACK is known to work on the following platforms:
* Linux (Ubuntu)
* MacOS
* Cygwin
To do so, SMACK invokes [Clang](http://clang.llvm.org) to compile `simple.c`
into LLVM bitcode `simple.bc`:

**Note for Cygwin users:**
You should configure LLVM/clang with the --enable-shared option (which may also
require the --enable-optimized option). Then when configuring SMACK you should
use these options as well.
clang -c -Wall -emit-llvm -O0 -g -I../../include/smack simple.c -o simple.bc

then translates the bitcode `simple.bc` to a program in the
[Boogie](http://boogie.codeplex.com) verification language,

## Getting Started Quickly (on Linux)
smackgen.py simple.bc -o simple.bpl

To get you started with SMACK quickly, we provide a reference installation
script that downloads and installs Z3, Boogie, LLVM/clang, and SMACK. Simply
download
[build-linux.sh](http://github.com/smackers/smack/blob/master/bin/build-linux.sh)
and execute it.
and finally verifies `simple.bpl` with the [Boogie Verifier](http://boogie.codeplex.com)

Note that this script is primarily provided as a reference and we do not expect
it will work out-of-the-box on all platforms and required software
combinations. You can still give it a try and modify it based on your specific
needs.
Boogie simple.bpl

**Known problems:**
Z3 source code cannot be cloned from codeplex using git sometimes. This is a
known
[problem](http://z3.codeplex.com/wikipage?title=Git%20HTTPS%20cloning%20errors).
In that case you can manually download Z3's sources from its codeplex site.
concluding that the original program `simple.c` is verified to be correct.
While SMACK is designed to be a *modular* verifier, for our convenience, this
whole process has also been wrapped into a single command in SMACK:

smack-verify.py simple.c -o simple.bpl

which equally reports that the program `simple.c` is verified.

## Getting Started with SMACK

### Installation Guide

1. Checkout SMACK:

```
cd where-you-want-smack-source-to-live
git clone [email protected]:smackers/smack.git
```

2. Configure SMACK:

```
cd where-you-want-to-build-smack
mkdir build (for building without polluting the source dir)
cd build
../smack/configure --with-llvmsrc=<directory> --with-llvmobj=<directory> --prefix=<directory>
```

Options for configure are:
* --with-llvmsrc=<directory> : Tell SMACK where the LLVM source tree is located [required].
* --with-llvmobj=<directory> : Tell SMACK where the LLVM object tree is located [required].
* --prefix=<directory> : Specify full pathname of where you want SMACK installed [required].
* --enable-optimized : Compile with optimizations enabled [default is NO].
* --enable-assertions : Compile with assertion checks enabled [default is YES].

3. Build and install SMACK:

```
make
make install
```

If everything goes well, you should now have lib/libsmack.a and lib/smack.so
(or smack.dylib on MacOS, or smack.dll on Cygwin) in the SMACK installation
directory.

4. Create an environment variable called BOOGIE containing a Boogie invocation
command for your platform. For example:

```
export BOOGIE="mono /home/john/Boogie/Binaries/Boogie.exe"
```

**Important note:**
LLVM/clang binaries (e.g., clang, llvm-link, opt) should all be in your path,
as well as your smack-install-dir/bin directory!


### Running Regression Tests

To make sure SMACK has been installed properly, run its regression tests.
Go to smack/test directory and compile the regression tests by running
`make`. You should get a number of LLVM bitcode files, one per test.
Execute the regression test script with `./regtest.py`. All tests should pass.


## SMACK Tools

Currently, SMACK comes with the following tools in the bin directory:
* llvm2bpl is a bare-bone translator from LLVM bitcode into Boogie.
* smack-check is tool for statically checking properties of programs written in
C/C++. For a given input program, the tool checks for violations of
user-provided assertions.

Type `llvm2bpl.py -h` or `smack-check.py -h` for a full list of supported
command line options.


## The SMACK Checker User Guide

Next, we illustrate how to check the following simple C program using the SMACK
checker:
```
// simple.c
#include "smack.h"
int incr(int x) {
return x + 1;
}
int main(void) {
int a;
a = 1;
a = incr(a);
__SMACK_assert(a == 2);
return 0;
}
```
Note that this example can also be found in the smack/examples/simple
directory.

First, compile the example into an LLVM bitcode file using clang:
```
clang -c -Wall -emit-llvm -O0 -g -I../../headers simple.c -o simple.bc
```
We use the -g flag to compile with debug information enabled, which the SMACK
checker leverages to generate more informative error traces.
Then, run the SMACK checker on the generated bitcode file:
```
smack-check.py simple -o simple.bpl
```
SMACK should report no errors for this example.
## Further Information

For requirements, installation, usage, and whatever else, please consult the
[SMACK Wiki on Github](https://github.com/smackers/smack/wiki).
23 changes: 23 additions & 0 deletions autoconf/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,29 @@ AC_ARG_ENABLE(libffi,AS_HELP_STRING(
*) AC_MSG_ERROR([Invalid setting for --enable-libffi. Use "yes" or "no"]) ;;
esac],
llvm_cv_enable_libffi=no)

dnl **************************************************************************
dnl * Set the location of various third-party software packages
dnl **************************************************************************

dnl Specify the location of the poolalloc project
AC_ARG_WITH(poolallocsrc,
AS_HELP_STRING([--with-poolallocsrc],
[Specify location of Pool Allocation source code]),
AC_SUBST(poolallocsrc,"$withval"),
AC_SUBST(poolallocsrc,"$LLVM_SRC_ROOT/projects/poolalloc"
))

AC_ARG_WITH(poolallocobj,
AS_HELP_STRING([--with-poolallocobj],
[Specify location of Pool Allocation object code]),
AC_SUBST(poolallocobj,"$withval"),
AC_SUBST(poolallocobj,"$LLVM_OBJ_ROOT/projects/poolalloc"
))

dnl Ensure that all pathnames are absolute pathnames
poolallocsrc=`cd $poolallocsrc && pwd`
poolallocobj=`cd $poolallocobj && pwd`

dnl===-----------------------------------------------------------------------===
dnl===
Expand Down
Loading

0 comments on commit f377011

Please sign in to comment.