diff --git a/enzyme/CMakeLists.txt b/enzyme/CMakeLists.txt index 833d9fa4a2aa9..08e2df0081a56 100644 --- a/enzyme/CMakeLists.txt +++ b/enzyme/CMakeLists.txt @@ -6,7 +6,7 @@ SET(CMAKE_CXX_FLAGS_RELEASE "-O2") SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") set(CMAKE_CXX_STANDARD 11) -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.5) set(ENZYME_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(ENZYME_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) @@ -14,6 +14,20 @@ set(ENZYME_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(LLVM_SHLIBEXT "${CMAKE_SHARED_MODULE_SUFFIX}") message( LLVM_SHLIBEXT = ${LLVM_SHLIBEXT} ) +get_filename_component(LLVM_ABSOLUTE_DIR + "${LLVM_DIR}" + REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") + +set(LLVM_DIR "${LLVM_ABSOLUTE_DIR}" CACHE FILEPATH "b" FORCE) + +message("found llvm dir " ${LLVM_DIR}) + +get_filename_component(LLVM_ABSOLUTE_LIT + "${LLVM_EXTERNAL_LIT}" + REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") + + set(LLVM_EXTERNAL_LIT "${LLVM_ABSOLUTE_LIT}" CACHE FILEPATH "a" FORCE) +message("found llvm lit " ${LLVM_EXTERNAL_LIT}) find_package(LLVM REQUIRED CONFIG) list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}") @@ -21,6 +35,9 @@ include(AddLLVM) add_definitions(${LLVM_DEFINITIONS}) include_directories(${LLVM_INCLUDE_DIRS}) +message("found llvm include directory here " ${LLVM_INCLUDE_DIRS}) +message("found llvm definitions " ${LLVM_DEFINITIONS}) +message("found llvm version " ${LLVM_VERSION_MAJOR}) add_subdirectory(Enzyme) add_subdirectory(test) diff --git a/enzyme/Enzyme/CMakeLists.txt b/enzyme/Enzyme/CMakeLists.txt index f145437863e08..77c9a4b29c8fb 100644 --- a/enzyme/Enzyme/CMakeLists.txt +++ b/enzyme/Enzyme/CMakeLists.txt @@ -2,8 +2,8 @@ # set(LLVM_LINK_COMPONENTS Core Support) #endif() -if (${LLVM_VERSION_MAJOR} LESS_EQUAL 7) -add_llvm_loadable_module( LLVMEnzyme +if (${LLVM_VERSION_MAJOR} LESS 8) + add_llvm_loadable_module( LLVMEnzyme-${LLVM_VERSION_MAJOR} Enzyme.cpp DEPENDS intrinsics_gen @@ -11,7 +11,7 @@ add_llvm_loadable_module( LLVMEnzyme opt ) else() -add_llvm_library( LLVMEnzyme + add_llvm_library( LLVMEnzyme-${LLVM_VERSION_MAJOR} Enzyme.cpp MODULE DEPENDS diff --git a/enzyme/test/CMakeLists.txt b/enzyme/test/CMakeLists.txt index 12e6b9b397ef7..60f263e9e769b 100644 --- a/enzyme/test/CMakeLists.txt +++ b/enzyme/test/CMakeLists.txt @@ -5,7 +5,7 @@ configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py ) -set(ENZYME_TEST_DEPS LLVMEnzyme) +set(ENZYME_TEST_DEPS LLVMEnzyme-${LLVM_VERSION_MAJOR}) set(ENZYME_TESTSUITES) list(APPEND ${CMAKE_CURRENT_BINARY_DIR}/lit.cfg) diff --git a/enzyme/test/lit.site.cfg.py.in b/enzyme/test/lit.site.cfg.py.in index c5cd80d0c8152..4d51ef02d78c0 100644 --- a/enzyme/test/lit.site.cfg.py.in +++ b/enzyme/test/lit.site.cfg.py.in @@ -1,6 +1,7 @@ @LIT_SITE_CFG_IN_HEADER@ #config.llvm_src_root = "@LLVM_SOURCE_DIR@" +config.llvm_ver = "@LLVM_VERSION_MAJOR@" config.llvm_obj_root = "@LLVM_BINARY_DIR@" config.llvm_tools_dir = "@LLVM_TOOLS_BINARY_DIR@" config.llvm_libs_dir = "@LLVM_LIBS_DIR@" @@ -37,7 +38,7 @@ config.excludes = ['Inputs'] config.substitutions.append(('%shlibext', config.llvm_shlib_ext)) config.substitutions.append(('%loadEnzyme', '' - + ' -load=@ENZYME_BINARY_DIR@/Enzyme/LLVMEnzyme' + config.llvm_shlib_ext + + ' -load=@ENZYME_BINARY_DIR@/Enzyme/LLVMEnzyme-' + config.llvm_ver + config.llvm_shlib_ext )) # Let the main config do the real work.