diff options
author | Martin Nowack <m.nowack@imperial.ac.uk> | 2023-02-23 21:47:53 +0000 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2023-03-17 22:38:16 +0000 |
commit | 3ef5c9d0cd51babb7c4ec2d7bb76d0cb7e47a65c (patch) | |
tree | a2cb9e4c193d674b4f49634d0f546b65ce547860 /cmake/find_bitcode_compiler.cmake | |
parent | 7a4a9b9b47d2fe9b90cee95d68d89faa24a118d4 (diff) | |
download | klee-3ef5c9d0cd51babb7c4ec2d7bb76d0cb7e47a65c.tar.gz |
[cmake] Use LLVM's CMake functionality only
LLVM became more complex, use LLVM's CMake functionality directly instead of replicating this behaviour in KLEE's build system. Use the correct build flags provided by LLVM itself. This is influenced by the way LLVM is built in the first place. Remove older CMake support (< 3.0).
Diffstat (limited to 'cmake/find_bitcode_compiler.cmake')
-rw-r--r-- | cmake/find_bitcode_compiler.cmake | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/cmake/find_bitcode_compiler.cmake b/cmake/find_bitcode_compiler.cmake deleted file mode 100644 index 615931f3..00000000 --- a/cmake/find_bitcode_compiler.cmake +++ /dev/null @@ -1,96 +0,0 @@ -#===------------------------------------------------------------------------===# -# -# The KLEE Symbolic Virtual Machine -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -#===------------------------------------------------------------------------===# -# -# This file tries to find compilers to build LLVM bitcode. -# It is implicitly dependent on `find_llvm.cmake` already being run in the -# same scope. -# -#===------------------------------------------------------------------------===# - -message(STATUS "Looking for bitcode compilers") - -find_program( - LLVMCC - NAMES "clang-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}" "clang" "llvm-gcc" - # Give the LLVM tools directory higher priority than the system directory. - HINTS "${LLVM_TOOLS_BINARY_DIR}" -) -if (LLVMCC) - message(STATUS "Found ${LLVMCC}") -else() - message(FATAL_ERROR "Failed to find C bitcode compiler") -endif() - -find_program( - LLVMCXX - NAMES "clang++-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}" "clang++" "llvm-g++" - # Give the LLVM tools directory higher priority than the system directory. - HINTS "${LLVM_TOOLS_BINARY_DIR}" -) -if (LLVMCXX) - message(STATUS "Found ${LLVMCXX}") -else() - message(FATAL_ERROR "Failed to find C++ bitcode compiler") -endif() - -# Check `llvm-dis` is available -set(LLVM_DIS_TOOL "${LLVM_TOOLS_BINARY_DIR}/llvm-dis") -if (NOT EXISTS "${LLVM_DIS_TOOL}") - message(FATAL_ERROR - "The llvm-dis tool cannot be found at \"${LLVM_DIS_TOOL}\"") -endif() - -# Test compiler -function(test_bitcode_compiler COMPILER SRC_EXT) - message(STATUS "Testing bitcode compiler ${COMPILER}") - set(SRC_FILE "${CMAKE_BINARY_DIR}/test_bitcode_compiler.${SRC_EXT}") - file(WRITE "${SRC_FILE}" "int main(int argc, char** argv) { return 0;}") - set(BC_FILE "${SRC_FILE}.bc") - execute_process( - COMMAND - "${COMPILER}" - "-c" - "-emit-llvm" - "-o" "${BC_FILE}" - "${SRC_FILE}" - RESULT_VARIABLE COMPILE_INVOKE_EXIT_CODE - ) - if ("${COMPILE_INVOKE_EXIT_CODE}" EQUAL 0) - message(STATUS "Compile success") - else() - message(FATAL_ERROR "Compilation failed") - endif() - - message(STATUS "Checking compatibility with LLVM ${LLVM_PACKAGE_VERSION}") - # Check if the LLVM version we are using is compatible - # with this compiler by invoking the `llvm-dis` tool - # on the generated bitcode. - set(LL_FILE "${SRC_FILE}.ll") - execute_process( - COMMAND - "${LLVM_DIS_TOOL}" - "-o" "${LL_FILE}" - "${BC_FILE}" - RESULT_VARIABLE LLVM_DIS_INVOKE_EXIT_CODE - ) - if ("${LLVM_DIS_INVOKE_EXIT_CODE}" EQUAL 0) - message(STATUS "\"${COMPILER}\" is compatible") - else() - message(FATAL_ERROR "\"${COMPILER}\" is not compatible with LLVM ${LLVM_PACKAGE_VERSION}") - endif() - - # Remove temporary files. It's okay to not remove these on failure - # as they will be useful for developer debugging. - file(REMOVE "${SRC_FILE}") - file(REMOVE "${BC_FILE}") - file(REMOVE "${LL_FILE}") -endfunction() - -test_bitcode_compiler("${LLVMCC}" "c") -test_bitcode_compiler("${LLVMCXX}" "cxx") |