about summary refs log tree commit diff homepage
path: root/tools
diff options
context:
space:
mode:
authorRichard Trembecký <richardt@centrum.sk>2016-05-01 16:38:21 +0200
committerDan Liew <delcypher@gmail.com>2017-05-24 14:24:47 +0100
commitd3a467d8999e6e52892b13c2bc93ac829ee1b7c9 (patch)
tree99493da4b33f50eb0c27a237213c615520efbd95 /tools
parent92367dec2ee00cb708454e4c33ff34d80eddb878 (diff)
downloadklee-d3a467d8999e6e52892b13c2bc93ac829ee1b7c9.tar.gz
llvm: make KLEE compile against LLVM 3.5 and 3.6
Based on work by @ccadeptic23 and @delcypher.
Formatting fixed by @snf.
Fix compiler warning by @martijnthe.
Further fixes by @mchalupa.

Refactored, so that changes can be reviewed -- no massive changes in
whitespace and in the surrounding code.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/klee/Makefile10
-rw-r--r--tools/klee/main.cpp16
2 files changed, 23 insertions, 3 deletions
diff --git a/tools/klee/Makefile b/tools/klee/Makefile
index 8d50403f..2930427c 100644
--- a/tools/klee/Makefile
+++ b/tools/klee/Makefile
@@ -13,7 +13,13 @@ TOOLNAME = klee
 include $(LEVEL)/Makefile.config
 
 USEDLIBS = kleeCore.a kleeBasic.a kleeModule.a  kleaverSolver.a kleaverExpr.a kleeSupport.a 
-LINK_COMPONENTS = jit bitreader bitwriter ipo linker engine
+LINK_COMPONENTS = bitreader bitwriter ipo linker engine
+
+ifeq ($(shell python -c "print($(LLVM_VERSION_MAJOR).$(LLVM_VERSION_MINOR) >= 3.6)"), True)
+LINK_COMPONENTS += mcjit
+else
+LINK_COMPONENTS += jit
+endif
 
 ifeq ($(shell python -c "print($(LLVM_VERSION_MAJOR).$(LLVM_VERSION_MINOR) >= 3.3)"), True)
 LINK_COMPONENTS += irreader
@@ -36,4 +42,4 @@ endif
 
 ifeq ($(HAVE_ZLIB),1)
   LIBS += -lz
-endif
\ No newline at end of file
+endif
diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp
index 1ac33617..a91c9fd1 100644
--- a/tools/klee/main.cpp
+++ b/tools/klee/main.cpp
@@ -385,7 +385,12 @@ llvm::raw_fd_ostream *KleeHandler::openOutputFile(const std::string &filename) {
   llvm::raw_fd_ostream *f;
   std::string Error;
   std::string path = getOutputFilename(filename);
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3,5)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+  std::error_code ec;
+  f = new llvm::raw_fd_ostream(path.c_str(), ec, llvm::sys::fs::F_None);
+  if (ec)
+    Error = ec.message();
+#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
   f = new llvm::raw_fd_ostream(path.c_str(), Error, llvm::sys::fs::F_None);
 #elif LLVM_VERSION_CODE >= LLVM_VERSION(3,4)
   f = new llvm::raw_fd_ostream(path.c_str(), Error, llvm::sys::fs::F_Binary);
@@ -1038,9 +1043,14 @@ static llvm::Module *linkWithUclibc(llvm::Module *mainModule, StringRef libDir)
   SmallString<128> uclibcBCA(libDir);
   llvm::sys::path::append(uclibcBCA, KLEE_UCLIBC_BCA_NAME);
 
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+  Twine uclibcBCA_twine(uclibcBCA.c_str());
+  if (!llvm::sys::fs::exists(uclibcBCA_twine))
+#else
   bool uclibcExists=false;
   llvm::sys::fs::exists(uclibcBCA.c_str(), uclibcExists);
   if (!uclibcExists)
+#endif
     klee_error("Cannot find klee-uclibc : %s", uclibcBCA.c_str());
 
   Function *f;
@@ -1265,7 +1275,11 @@ int main(int argc, char **argv, char **envp) {
     klee_error("error loading program '%s': %s", InputFile.c_str(),
                Buffer.getError().message().c_str());
 
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+  auto mainModuleOrError = getLazyBitcodeModule(std::move(Buffer.get()), ctx);
+#else
   auto mainModuleOrError = getLazyBitcodeModule(Buffer->get(), ctx);
+#endif
 
   if (!mainModuleOrError) {
     klee_error("error loading program '%s': %s", InputFile.c_str(),