From 7e75b491d389c15d48a5cfc455ba9442d7c108ed Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 1 Nov 2016 22:47:30 +0000 Subject: 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. --- lib/Basic/CMakeLists.txt | 14 ++++++++++++++ lib/CMakeLists.txt | 14 ++++++++++++++ lib/Core/CMakeLists.txt | 29 +++++++++++++++++++++++++++++ lib/Expr/CMakeLists.txt | 23 +++++++++++++++++++++++ lib/Module/CMakeLists.txt | 20 ++++++++++++++++++++ lib/Solver/CMakeLists.txt | 32 ++++++++++++++++++++++++++++++++ lib/Support/CMakeLists.txt | 20 ++++++++++++++++++++ 7 files changed, 152 insertions(+) create mode 100644 lib/Basic/CMakeLists.txt create mode 100644 lib/CMakeLists.txt create mode 100644 lib/Core/CMakeLists.txt create mode 100644 lib/Expr/CMakeLists.txt create mode 100644 lib/Module/CMakeLists.txt create mode 100644 lib/Solver/CMakeLists.txt create mode 100644 lib/Support/CMakeLists.txt (limited to 'lib') diff --git a/lib/Basic/CMakeLists.txt b/lib/Basic/CMakeLists.txt new file mode 100644 index 00000000..13f76d42 --- /dev/null +++ b/lib/Basic/CMakeLists.txt @@ -0,0 +1,14 @@ +#===------------------------------------------------------------------------===# +# +# The KLEE Symbolic Virtual Machine +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +#===------------------------------------------------------------------------===# +klee_add_component(kleeBasic + CmdLineOptions.cpp + ConstructSolverChain.cpp + KTest.cpp + Statistics.cpp +) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt new file mode 100644 index 00000000..8a074932 --- /dev/null +++ b/lib/CMakeLists.txt @@ -0,0 +1,14 @@ +#===------------------------------------------------------------------------===# +# +# The KLEE Symbolic Virtual Machine +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +#===------------------------------------------------------------------------===# +add_subdirectory(Basic) +add_subdirectory(Support) +add_subdirectory(Expr) +add_subdirectory(Solver) +add_subdirectory(Module) +add_subdirectory(Core) diff --git a/lib/Core/CMakeLists.txt b/lib/Core/CMakeLists.txt new file mode 100644 index 00000000..05e2cffa --- /dev/null +++ b/lib/Core/CMakeLists.txt @@ -0,0 +1,29 @@ +#===------------------------------------------------------------------------===# +# +# The KLEE Symbolic Virtual Machine +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +#===------------------------------------------------------------------------===# +klee_add_component(kleeCore + AddressSpace.cpp + CallPathManager.cpp + Context.cpp + CoreStats.cpp + ExecutionState.cpp + Executor.cpp + ExecutorTimers.cpp + ExecutorUtil.cpp + ExternalDispatcher.cpp + ImpliedValue.cpp + Memory.cpp + MemoryManager.cpp + PTree.cpp + Searcher.cpp + SeedInfo.cpp + SpecialFunctionHandler.cpp + StatsTracker.cpp + TimingSolver.cpp + UserSearcher.cpp +) diff --git a/lib/Expr/CMakeLists.txt b/lib/Expr/CMakeLists.txt new file mode 100644 index 00000000..6ea77544 --- /dev/null +++ b/lib/Expr/CMakeLists.txt @@ -0,0 +1,23 @@ +#===------------------------------------------------------------------------===# +# +# The KLEE Symbolic Virtual Machine +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +#===------------------------------------------------------------------------===# +klee_add_component(kleaverExpr + ArrayCache.cpp + Assigment.cpp + Constraints.cpp + ExprBuilder.cpp + Expr.cpp + ExprEvaluator.cpp + ExprPPrinter.cpp + ExprSMTLIBPrinter.cpp + ExprUtil.cpp + ExprVisitor.cpp + Lexer.cpp + Parser.cpp + Updates.cpp +) diff --git a/lib/Module/CMakeLists.txt b/lib/Module/CMakeLists.txt new file mode 100644 index 00000000..a952ed17 --- /dev/null +++ b/lib/Module/CMakeLists.txt @@ -0,0 +1,20 @@ +#===------------------------------------------------------------------------===# +# +# The KLEE Symbolic Virtual Machine +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +#===------------------------------------------------------------------------===# +klee_add_component(kleeModule + Checks.cpp + InstructionInfoTable.cpp + IntrinsicCleaner.cpp + KInstruction.cpp + KModule.cpp + LowerSwitch.cpp + ModuleUtil.cpp + Optimize.cpp + PhiCleaner.cpp + RaiseAsm.cpp +) diff --git a/lib/Solver/CMakeLists.txt b/lib/Solver/CMakeLists.txt new file mode 100644 index 00000000..8add4ad6 --- /dev/null +++ b/lib/Solver/CMakeLists.txt @@ -0,0 +1,32 @@ +#===------------------------------------------------------------------------===# +# +# The KLEE Symbolic Virtual Machine +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +#===------------------------------------------------------------------------===# +klee_add_component(kleaverSolver + CachingSolver.cpp + CexCachingSolver.cpp + ConstantDivision.cpp + CoreSolver.cpp + DummySolver.cpp + FastCexSolver.cpp + IncompleteSolver.cpp + IndependentSolver.cpp + MetaSMTSolver.cpp + PCLoggingSolver.cpp + QueryLoggingSolver.cpp + SMTLIBLoggingSolver.cpp + Solver.cpp + SolverImpl.cpp + SolverStats.cpp + STPBuilder.cpp + STPSolver.cpp + ValidatingSolver.cpp + Z3Builder.cpp + Z3Solver.cpp +) + +target_link_libraries(kleaverSolver PRIVATE ${KLEE_SOLVER_LIBRARIES}) diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt new file mode 100644 index 00000000..4bf7ea7d --- /dev/null +++ b/lib/Support/CMakeLists.txt @@ -0,0 +1,20 @@ +#===------------------------------------------------------------------------===# +# +# The KLEE Symbolic Virtual Machine +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +#===------------------------------------------------------------------------===# +klee_add_component(kleeSupport + CompressionStream.cpp + ErrorHandling.cpp + MemoryUsage.cpp + PrintVersion.cpp + RNG.cpp + Time.cpp + Timer.cpp + TreeStream.cpp +) + +target_link_libraries(kleeSupport PRIVATE ${ZLIB_LIBRARIES}) -- cgit 1.4.1