diff --git a/cmake/FindLLVM.cmake b/cmake/FindLLVM.cmake index ee45accb..0c77e241 100644 --- a/cmake/FindLLVM.cmake +++ b/cmake/FindLLVM.cmake @@ -1,4 +1,4 @@ -find_program(LLVMCONFIG NAMES llvm-config-3.9 llvm-config) +find_program(LLVMCONFIG NAMES llvm-config-6.0 llvm-config-5.0 llvm-config-4.0 llvm-config-3.9 llvm-config) if( NOT LLVMCONFIG ) message(FATAL_ERROR "llvm-config not found, try installing llvm-dev llvm") diff --git a/doc/how-to-build.txt b/doc/how-to-build.txt index 766d5664..92323213 100644 --- a/doc/how-to-build.txt +++ b/doc/how-to-build.txt @@ -23,7 +23,9 @@ Required for FAIL*: "-D__NO_MATH_INLINES -D__STRICT_ANSI__" or "--c_compiler clang++" (the latter requires the clang++ compiler). - optional: - * LLVM 3.9 (needed for several importers in tools/import-trace): llvm-3.9-dev + * LLVM 3.9, 4.0, 5.0, or 6.0 (needed for several importers in + tools/import-trace): llvm-3.9-dev, llvm-4.0-dev, llvm-5.0-dev or + llvm-6.0-dev - built with "make REQUIRES_RTTI=1" (the Debian/Ubuntu packages already come built this way) - details below @@ -289,8 +291,9 @@ Database backend setup: MySQL / MariaDB Building LLVM from sources ========================================================================================= If your Linux distribution does not provide a library package for LLVM 3.9 or -newer, and you need LLVM support in FAIL*, you may need to build LLVM from the -sources and install it, e.g., locally in your home. +newer (the following steps work for LLVM 3.9), and you need LLVM support in +FAIL*, you may need to build LLVM from the sources and install it, e.g., +locally in your home. 1. Download the source tarball of LLVM 3.9 from http://llvm.org (or use the git repository http://llvm.org/git/llvm.git and checkout release_39) diff --git a/src/core/util/CMakeLists.txt b/src/core/util/CMakeLists.txt index c4c50632..09204e5a 100644 --- a/src/core/util/CMakeLists.txt +++ b/src/core/util/CMakeLists.txt @@ -79,7 +79,7 @@ add_library(fail-util ${SRCS}) add_dependencies(fail-util fail-comm) target_link_libraries(fail-util fail-comm ${ADDITIONAL_LIBS} ${PROTOBUF_LIBRARY} ${Boost_LIBRARIES} ${LibIberty_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBDWARF_LIBRARIES} ${LIBELF_LIBRARIES}) -option(BUILD_LLVM_DISASSEMBLER "Build the LLVM-based disassembler (LLVM 3.9 preferred, other versions may not work)" OFF) +option(BUILD_LLVM_DISASSEMBLER "Build the LLVM-based disassembler (LLVM 3.9, 4.0, 5.0 or 6.0 preferred, other versions may not work)" OFF) if (BUILD_LLVM_DISASSEMBLER) add_subdirectory(llvmdisassembler) endif (BUILD_LLVM_DISASSEMBLER) diff --git a/src/core/util/llvmdisassembler/LLVMDisassembler.cpp b/src/core/util/llvmdisassembler/LLVMDisassembler.cpp index 093db2a7..bb42b002 100644 --- a/src/core/util/llvmdisassembler/LLVMDisassembler.cpp +++ b/src/core/util/llvmdisassembler/LLVMDisassembler.cpp @@ -4,6 +4,14 @@ using namespace fail; using namespace llvm; using namespace llvm::object; +// In LLVM 3.9, llvm::Triple::getArchTypeName() returns const char*, since LLVM +// 4.0 it returns StringRef. This overload catches the latter case. +__attribute__((unused)) +static std::ostream& operator<<(std::ostream& stream, const llvm::StringRef& s) +{ + stream << s.str(); + return stream; +} LLVMtoFailTranslator *LLVMDisassembler::getTranslator() { if (ltofail == 0) { diff --git a/src/core/util/llvmdisassembler/LLVMDisassembler.hpp b/src/core/util/llvmdisassembler/LLVMDisassembler.hpp index e0623106..ee47830b 100644 --- a/src/core/util/llvmdisassembler/LLVMDisassembler.hpp +++ b/src/core/util/llvmdisassembler/LLVMDisassembler.hpp @@ -23,7 +23,6 @@ #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/TargetSelect.h" -#include "llvm/Support/MemoryObject.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/ADT/StringExtras.h"