about summary refs log tree commit diff homepage
path: root/Dockerfile
diff options
context:
space:
mode:
authorDan Liew <daniel.liew@imperial.ac.uk>2016-11-01 22:47:30 +0000
committerDan Liew <delcypher@gmail.com>2016-11-07 22:16:29 +0000
commit7e75b491d389c15d48a5cfc455ba9442d7c108ed (patch)
tree09502118849cb0fc85723d09ceed88ce2ff50fab /Dockerfile
parent48abc42627315f3435e60ee3d95c1749c667519f (diff)
downloadklee-7e75b491d389c15d48a5cfc455ba9442d7c108ed.tar.gz
Implement a CMake based build system for KLEE.
This is based off intial work by @jirislaby in #481. However it
has been substantially modified.

Notably it includes a separate build sytem to build the runtimes which
is inspired by the old build system. The reason for doing this is
because CMake is not well suited for building the runtime:

* CMake is configured to use the host compiler, not the bitcode
  compiler. These are not the same thing.

* Building the runtime using `add_custom_command()` is flawed
  because we can't automatically get transitive depencies (i.e.
  header file dependencies) unless the CMake generator is makefiles.
  (See `IMPLICIT_DEPENDS` of `add_custom_command()` in CMake).

So for now we have a very simple build system for building the runtimes.
In the future we can replace this with something more sophisticated if
we need it.

Support for all features of the old build system are implemented apart
from recording the git revision and showing it in the output of
`klee --help`.

Another notable change is the CMake build system works much better with
LLVM installs which don't ship with testing tools. The build system
will download the sources for `FileCheck` and `not` tools if the
corresponding binaries aren't available and will build them. However
`lit` (availabe via `pip install lit`) and GTest must already be
installed.

Apart from better support for testing a significant advantage of the
new CMake build system compared to the existing "Autoconf/Makefile"
build system is that it is **not** coupled to LLVM's build system
(unlike the existing build system). This means that LLVM's
autoconf/Makefiles don't need to be installed somewhere on the system.

Currently all tests pass.

Support has been implemented in TravisCI and the Dockerfile for
building with CMake.

The existing "Autoconf/Makefile" build system has been left intact
and so both build systems can coexist for a short while. We should
remove the old build system as soon as possible though because it
creates an unnecessary maintance burden.
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile42
1 files changed, 16 insertions, 26 deletions
diff --git a/Dockerfile b/Dockerfile
index 6ee9a9ac..f1cce2ee 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -13,7 +13,8 @@ ENV LLVM_VERSION=3.4 \
     KLEE_UCLIBC=klee_uclibc_v1.0.0 \
     KLEE_SRC=/home/klee/klee_src \
     COVERAGE=0 \
-    BUILD_DIR=/home/klee/klee_build
+    BUILD_DIR=/home/klee/klee_build \
+    USE_CMAKE=1
 
 RUN apt-get update && \
     apt-get -y --no-install-recommends install \
@@ -57,25 +58,7 @@ WORKDIR /home/klee
 
 # Copy across source files needed for build
 RUN mkdir ${KLEE_SRC}
-ADD configure \
-    LICENSE.TXT \
-    Makefile \
-    Makefile.* \
-    README.md \
-    MetaSMT.mk \
-    TODO.txt \
-    ${KLEE_SRC}/
-ADD .travis ${KLEE_SRC}/.travis/
-ADD autoconf ${KLEE_SRC}/autoconf/
-ADD docs ${KLEE_SRC}/docs/
-ADD include ${KLEE_SRC}/include/
-ADD lib ${KLEE_SRC}/lib/
-ADD runtime ${KLEE_SRC}/runtime/
-ADD scripts ${KLEE_SRC}/scripts/
-ADD test ${KLEE_SRC}/test/
-ADD tools ${KLEE_SRC}/tools/
-ADD unittests ${KLEE_SRC}/unittests/
-ADD utils ${KLEE_SRC}/utils/
+ADD / ${KLEE_SRC}
 
 # Set klee user to be owner
 RUN sudo chown --recursive klee: ${KLEE_SRC}
@@ -87,9 +70,12 @@ RUN mkdir -p ${BUILD_DIR}
 RUN cd ${BUILD_DIR} && ${KLEE_SRC}/.travis/solvers.sh
 
 # Install testing utils (use TravisCI script)
-RUN cd ${BUILD_DIR} && mkdir testing-utils && cd testing-utils && \
+RUN cd ${BUILD_DIR} && mkdir test-utils && cd test-utils && \
     ${KLEE_SRC}/.travis/testing-utils.sh
 
+# FIXME: All these hacks need to be removed. Once we no longer
+# need to support KLEE's old build system they can be removed.
+
 # FIXME: This is a nasty hack so KLEE's configure and build finds
 # LLVM's headers file, libraries and tools
 RUN sudo mkdir -p /usr/lib/llvm-${LLVM_VERSION}/build/Release/bin && \
@@ -108,13 +94,13 @@ RUN sudo mkdir -p /usr/lib/llvm-${LLVM_VERSION}/build/Release/bin && \
 # FIXME: This is **really gross**. The Official Ubuntu LLVM packages don't ship
 # with ``FileCheck`` or the ``not`` tools so we have to hack building these
 # into KLEE's build system in order for the tests to pass
-RUN cd ${KLEE_SRC}/tools && \
+RUN [ "X${USE_CMAKE}" != "X1" ] && ( cd ${KLEE_SRC}/tools && \
     for tool in FileCheck not; do \
         svn export \
         http://llvm.org/svn/llvm-project/llvm/branches/release_34/utils/${tool} ${tool} ; \
         sed -i 's/^USEDLIBS.*$/LINK_COMPONENTS = support/' ${tool}/Makefile; \
     done && \
-    sed -i '0,/^PARALLEL_DIRS/a PARALLEL_DIRS += FileCheck not' Makefile
+    sed -i '0,/^PARALLEL_DIRS/a PARALLEL_DIRS += FileCheck not' Makefile ) || echo "Skipping hack"
 
 # FIXME: The current TravisCI script expects clang-${LLVM_VERSION} to exist
 RUN sudo ln -s /usr/bin/clang /usr/bin/clang-${LLVM_VERSION} && \
@@ -131,12 +117,16 @@ RUN mv /etc/sudoers.bak /etc/sudoers && \
 USER klee
 
 # Add KLEE binary directory to PATH
-RUN echo 'export PATH=$PATH:'${BUILD_DIR}'/klee/Release+Asserts/bin' >> /home/klee/.bashrc
+RUN [ "X${USE_CMAKE}" != "X1" ] && \
+  (echo 'export PATH=$PATH:'${BUILD_DIR}'/klee/Release+Asserts/bin' >> /home/klee/.bashrc) || \
+  (echo 'export PATH=$PATH:'${BUILD_DIR}'/klee/bin' >> /home/klee/.bashrc)
 
 # Link klee to /usr/bin so that it can be used by docker run
 USER root
-RUN for exec in ${BUILD_DIR}/klee/Release+Asserts/bin/* ; do ln -s ${exec} /usr/bin/`basename ${exec}`; done
+RUN [ "X${USE_CMAKE}" != "X1" ] && \
+  (for executable in ${BUILD_DIR}/klee/Release+Asserts/bin/* ; do ln -s ${executable} /usr/bin/`basename ${executable}`; done) || \
+  (for executable in ${BUILD_DIR}/klee/bin/* ; do ln -s ${executable} /usr/bin/`basename ${executable}`; done)
 
 # Link klee to the libkleeRuntest library needed by docker run
-RUN ln -s ${BUILD_DIR}/klee/Release+Asserts/lib/libkleeRuntest.so /usr/lib/libkleeRuntest.so.1.0
+RUN [ "X${USE_CMAKE}" != "X1" ] && (ln -s ${BUILD_DIR}/klee/Release+Asserts/lib/libkleeRuntest.so /usr/lib/libkleeRuntest.so.1.0) || echo "Skipping hack"
 USER klee