Commit 876f0072 authored by Jeremy Schwartz's avatar Jeremy Schwartz Committed by Jeremy Schwartz
Browse files

Rewrite Build System & Update Include Paths

parent 5e5106a1
# Don't track build directories
icgrep*build
build
libllv*
llvm*build
debug*build
......
# Copyright (c) 2019 International Characters.
# This software is licensed to the public under the Open Software License 3.0.
cmake_minimum_required(VERSION 2.8)
project(parabix)
enable_testing()
### Build Options ###
option(ENABLE_MULTIPLEXING "Compiling the Multiplexing Module")
option(DISABLE_DUAL_ABI "Disable GCC Dual ABI support" OFF)
option(CARRYPACK_MANAGER "Use CarryPack Manager to reduce space required for carries. For testing only." OFF)
option(USE_ADDRESS_SANITIZER "Enables use of address sanitizer in debug mode if available" OFF)
# Ensure custom FindXYZ.cmake files are found
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
### Versioning ###
set(Parabix_REVISION "svn")
include(VersionFromVCS)
add_version_info_from_vcs(Parabix_REVISION)
message(STATUS "Parabix Revision: ${Parabix_REVISION}")
### Import Dependency: LLVM ###
find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} in: ${LLVM_DIR}")
set(LLVM_ALL_TARGETS X86)
llvm_map_components_to_libnames(REQ_LLVM_LIBRARIES ${LLVM_ALL_TARGETS} mcjit native IRReader Linker)
include_directories(${LLVM_INCLUDE_DIRS})
link_directories(${LLVM_LIBRARY_DIRS})
add_definitions(${LLVM_DEFINITIONS})
math(EXPR LLVM_VERSION_INTEGER "${LLVM_VERSION_MAJOR} * 10000 + ${LLVM_VERSION_MINOR} * 100 + ${LLVM_VERSION_PATCH}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLLVM_VERSION_INTEGER=${LLVM_VERSION_INTEGER}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLLVM_VERSION_major=${LLVM_VERSION_MAJOR} -DLLVM_VERSION_MINOR=${LLVM_VERSION_MINOR}")
message(STATUS "LLVM Version Integer: ${LLVM_VERSION_INTEGER}")
### Import Dependency: Boost ###
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.61 REQUIRED COMPONENTS system filesystem iostreams)
message(STATUS "Found Boost_LIBRARY_DIR: ${Boost_LIBRARY_DIR}")
include_directories("${Boost_INCLUDE_DIRS}")
link_directories(${Boost_LIBRARY_DIR})
### Import Dependency: Z3 ###
if(ENABLE_MULTIPLEXING)
message(STATUS "Enabling Multiplexing")
find_package(Z3 REQUIRED)
include_directories(${Z3_INCLUDE_DIRS})
# target_link_libraries(PabloADT ${Z3_LIBRARIES})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MULTIPLEXING")
endif()
### Project Configuration ###
# Use C++ 11, fail if unable to do so.
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
# Add include directories.
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
# Place compiled exutables in build/bin.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
# Use @rpath for dylibs on macOS
set(CMAKE_MACOSX_RPATH ON)
# Enable all warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-fvisibility-inlines-hidden" SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG)
if(SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden")
endif()
# Disable RunTime Type Information
if(MSVC) # using Visual Studio C++
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
else() # using Clang, GCC, Intel C++, etc
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
endif()
# Disable Dual ABI support
if(DISABLE_DUAL_ABI)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()
set(CMAKE_REQUIRED_FLAGS)
# Define parabix version
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPARABIX_VERSION='\"${Parabix_REVISION}\"'")
# Use gold linker on Linux:gcc
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold")
endif()
endif()
# Release & Debug flags
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls")
# no pie disables the generation of position-independent executables, which is a default security feature of newer compiles
# that prevents addr2line from being able to resolve which line corresponds to the code at run time. This in turn prevents
# CreateAssert from being able to provide the compilation call stack for each JIT'ed assertion error.
CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_LINK_OPTIONS_NO_PIE COMPILER_SUPPORTS_NO_PIE)
if (COMPILER_SUPPORTS_NO_PIE)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CMAKE_CXX_LINK_OPTIONS_NO_PIE}")
endif()
# Use address sanitizer if desiered
unset(HAS_ADDRESS_SANITIZER)
if (USE_ADDRESS_SANITIZER)
CHECK_INCLUDE_FILE_CXX("sanitizer/asan_interface.h" HAS_ADDRESS_SANITIZER)
if (HAS_ADDRESS_SANITIZER)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DHAS_ADDRESS_SANITIZER -fsanitize=address")
endif()
endif()
### Functions ###
# Sets the output name for a given target.
# Naming scheme is "parabix_<target>" with any '.' replaced with a '_'
function(parabix_set_library_name NAME)
string(REPLACE "." "_" DELIMITED_NAME ${NAME})
string(CONCAT LIBRARY_NAME "parabix_" ${DELIMITED_NAME})
set_target_properties(${NAME} PROPERTIES OUTPUT_NAME ${LIBRARY_NAME})
endfunction(parabix_set_library_name)
### Add Subdirectories ###
# Framework Libraries
add_subdirectory(lib/codegen)
add_subdirectory(lib/grep)
add_subdirectory(lib/idisa)
add_subdirectory(lib/kernel/core)
add_subdirectory(lib/kernel/pipeline)
add_subdirectory(lib/kernel/util)
add_subdirectory(lib/pablo)
add_subdirectory(lib/pablo/parse)
add_subdirectory(lib/re/adt)
add_subdirectory(lib/re/cc)
add_subdirectory(lib/re/compile)
add_subdirectory(lib/re/parse)
add_subdirectory(lib/toolchain)
add_subdirectory(lib/ucd/compile)
add_subdirectory(lib/ucd/core)
add_subdirectory(lib/ucd/data)
add_subdirectory(lib/util)
# Executables
add_subdirectory(tools/base64)
add_subdirectory(tools/editd)
add_subdirectory(tools/gb18030)
add_subdirectory(tools/icgrep)
add_subdirectory(tools/idisa_test)
add_subdirectory(tools/transcoders)
add_subdirectory(tools/wc)
# add_subdirectory(tools/wc/wc-pablo)
add_subdirectory(tools/xml)
add_subdirectory(tools/ztf8)
# Find the libunwind library
#
# LIBUNWIND_FOUND - True if libunwind was found.
# LIBUNWIND_LIBRARIES - The libraries needed to use libunwind
# LIBUNWIND_INCLUDE_DIR - Location of unwind.h and libunwind.h
FIND_PATH(LIBUNWIND_INCLUDE_DIR libunwind.h)
SET(LIBUNWIND_FOUND TRUE)
if(NOT LIBUNWIND_INCLUDE_DIR)
SET(LIBUNWIND_FOUND FALSE)
elseif(NOT EXISTS "${LIBUNWIND_INCLUDE_DIR}/unwind.h")
SET(LIBUNWIND_FOUND FALSE)
SET(LIBUNWIND_INCLUDE_DIR "")
endif()
FIND_LIBRARY(LIBUNWIND_GENERIC_LIBRARY "unwind")
if (NOT LIBUNWIND_GENERIC_LIBRARY)
SET(LIBUNWIND_FOUND FALSE)
endif ()
SET(LIBUNWIND_LIBRARIES ${LIBUNWIND_GENERIC_LIBRARY})
# For some reason, we have to link to two libunwind shared object files:
# one arch-specific and one not.
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
SET(LIBUNWIND_ARCH "arm")
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64")
SET(LIBUNWIND_ARCH "x86_64")
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
SET(LIBUNWIND_ARCH "x86")
endif()
if (LIBUNWIND_ARCH)
FIND_LIBRARY(LIBUNWIND_SPECIFIC_LIBRARY "unwind-${LIBUNWIND_ARCH}")
if (NOT LIBUNWIND_SPECIFIC_LIBRARY)
SET(LIBUNWIND_FOUND FALSE)
endif ()
SET(LIBUNWIND_LIBRARIES ${LIBUNWIND_LIBRARIES} ${LIBUNWIND_SPECIFIC_LIBRARY})
endif(LIBUNWIND_ARCH)
MARK_AS_ADVANCED(LIBUNWIND_LIBRARIES LIBUNWIND_INCLUDE_DIR)
# Try to find PAPI headers and libraries.
#
# Usage of this module as follows:
#
# find_package(PAPI)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# PAPI_PREFIX Set this variable to the root installation of
# libpapi if the module has problems finding the
# proper installation path.
#
# Variables defined by this module:
#
# PAPI_FOUND System has PAPI libraries and headers
# PAPI_LIBRARIES The PAPI library
# PAPI_INCLUDE_DIRS The location of PAPI headers
find_path(PAPI_PREFIX
NAMES include/papi.h
)
find_library(PAPI_LIBRARIES
# Pick the static library first for easier run-time linking.
NAMES libpapi.a papi
HINTS ${PAPI_PREFIX}/lib ${HILTIDEPS}/lib
)
find_path(PAPI_INCLUDE_DIRS
NAMES papi.h
HINTS ${PAPI_PREFIX}/include ${HILTIDEPS}/include
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PAPI DEFAULT_MSG
PAPI_LIBRARIES
PAPI_INCLUDE_DIRS
)
mark_as_advanced(
PAPI_PREFIX_DIRS
PAPI_LIBRARIES
PAPI_INCLUDE_DIRS
)
IF (Z3_INCLUDE_DIR)
SET(Z3_FIND_QUIETLY TRUE)
ENDIF (Z3_INCLUDE_DIR)
FIND_PATH(Z3_INCLUDE_DIR z3.h z3++.h)
SET(Z3_NAMES z3 libz3 ltz3 libz3 lz3)
FIND_LIBRARY(Z3_LIBRARY NAMES ${Z3_NAMES} )
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Z3 DEFAULT_MSG Z3_LIBRARY Z3_INCLUDE_DIR)
IF(Z3_FOUND)
SET(Z3_LIBRARIES ${Z3_LIBRARY})
SET(Z3_INCLUDE_DIRS ${Z3_INCLUDE_DIR})
ELSE(Z3_FOUND)
SET(Z3_LIBRARIES)
ENDIF(Z3_FOUND)
MARK_AS_ADVANCED(Z3_LIBRARY Z3_INCLUDE_DIR)
# Adds version control information to the variable VERS. For
# determining the Version Control System used (if any) it inspects the
# existence of certain subdirectories under SOURCE_DIR (if provided as an
# extra argument, otherwise uses CMAKE_CURRENT_SOURCE_DIR).
function(add_version_info_from_vcs VERS)
SET(SOURCE_DIR ${ARGV1})
if("${SOURCE_DIR}" STREQUAL "")
SET(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
endif()
string(REPLACE "svn" "" result "${${VERS}}")
if( EXISTS "${SOURCE_DIR}/.svn" )
set(result "${result}svn")
# FindSubversion does not work with symlinks. See PR 8437
if( NOT IS_SYMLINK "${SOURCE_DIR}" )
find_package(Subversion)
endif()
if( Subversion_FOUND )
subversion_wc_info( ${SOURCE_DIR} Project )
if( Project_WC_REVISION )
set(SVN_REVISION ${Project_WC_REVISION} PARENT_SCOPE)
set(result "${result}-r${Project_WC_REVISION}")
endif()
if( Project_WC_URL )
set(LLVM_REPOSITORY ${Project_WC_URL} PARENT_SCOPE)
endif()
endif()
else()
find_program(git_executable NAMES git git.exe git.cmd)
if( git_executable )
# Run from a subdirectory to force git to print an absoute path.
execute_process(COMMAND ${git_executable} rev-parse --git-dir
WORKING_DIRECTORY ${SOURCE_DIR}/cmake
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_dir
ERROR_QUIET)
if(git_result EQUAL 0)
# Try to get a ref-id
string(STRIP "${git_dir}" git_dir)
set(result "${result}git")
if( EXISTS ${git_dir}/svn )
# Get the repository URL
execute_process(COMMAND
${git_executable} svn info
WORKING_DIRECTORY ${SOURCE_DIR}
TIMEOUT 5
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_output
ERROR_QUIET)
if( git_result EQUAL 0 )
string(REGEX MATCH "URL: ([^ \n]*)" svn_url ${git_output})
if(svn_url)
set(LLVM_REPOSITORY ${CMAKE_MATCH_1} PARENT_SCOPE)
endif()
endif()
# Get the svn revision number for this git commit if one exists.
execute_process(COMMAND ${git_executable} svn find-rev HEAD
WORKING_DIRECTORY ${SOURCE_DIR}
TIMEOUT 5
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_head_svn_rev_number
OUTPUT_STRIP_TRAILING_WHITESPACE)
if( git_result EQUAL 0 AND git_output)
set(SVN_REVISION ${git_head_svn_rev_number} PARENT_SCOPE)
set(git_svn_rev "-svn-${git_head_svn_rev_number}")
else()
set(git_svn_rev "")
endif()
endif()
# Get the git ref id
execute_process(COMMAND
${git_executable} rev-parse --short HEAD
WORKING_DIRECTORY ${SOURCE_DIR}
TIMEOUT 5
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_ref_id
OUTPUT_STRIP_TRAILING_WHITESPACE)
if( git_result EQUAL 0 )
set(GIT_COMMIT ${git_ref_id} PARENT_SCOPE)
set(result "${result}${git_svn_rev}-${git_ref_id}")
else()
set(result "${result}${git_svn_rev}")
endif()
endif()
endif()
endif()
set(${VERS} ${result} PARENT_SCOPE)
endfunction(add_version_info_from_vcs)
......@@ -6,7 +6,7 @@
#define CBUILDER_H
#include <toolchain/toolchain.h>
#include <IR_Gen/FunctionTypeBuilder.h>
#include <codegen/FunctionTypeBuilder.h>
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/Constants.h>
#include <llvm/ADT/Triple.h>
......
#ifndef FUNCTIONTYPEBUILDER_H
#define FUNCTIONTYPEBUILDER_H
#include <IR_Gen/TypeBuilder.h>
#include <codegen/TypeBuilder.h>
// NOTE: Currently, LLVM TypeBuilder can deduce FuntionTypes for up to 5 arguments. The following
// templates have no limit but should be deprecated if the TypeBuilder ever supports n-ary functions.
......
......@@ -6,16 +6,17 @@
*/
#ifndef GREP_ENGINE_H
#define GREP_ENGINE_H
#include <grep_interface.h>
#include <kernels/callback.h>
#include <cc/multiplex_CCs.h>
#include "../../tools/icgrep/grep_interface.h" // TODO: consider moving grep_interface to this library
#include <string>
#include <vector>
#include <sstream>
#include <atomic>
#include <boost/filesystem.hpp>
#include <re/parsers/GLOB_parser.h>
#include <kernels/linebreak_kernel.h>
#include <re/cc/multiplex_CCs.h>
#include <re/parse/GLOB_parser.h>
#include <kernel/util/callback.h>
#include <kernel/util/linebreak_kernel.h>
namespace re { class CC; }
namespace re { class RE; }
......
......@@ -6,7 +6,7 @@
#define GREP_KERNEL_H
#include <pablo/pablo_kernel.h> // for PabloKernel
#include <cc/alphabet.h>
#include <re/cc/alphabet.h>
namespace IDISA { class IDISA_Builder; }
namespace re { class RE; }
......
......@@ -6,7 +6,7 @@
* This software is licensed to the public under the Open Software License 3.0.
*/
#include <IR_Gen/idisa_sse_builder.h>
#include <idisa/idisa_sse_builder.h>
#include <toolchain/toolchain.h>
namespace IDISA {
......
......@@ -6,7 +6,7 @@
* This software is licensed to the public under the Open Software License 3.0.
* icgrep is a trademark of International Characters.
*/
#include "CBuilder.h"
#include <codegen/CBuilder.h>
#include <llvm/IR/DerivedTypes.h>
namespace llvm { class Constant; }
namespace llvm { class LoadInst; }
......
......@@ -6,7 +6,7 @@
* This software is licensed to the public under the Open Software License 3.0.
* icgrep is a trademark of International Characters.
*/
#include <IR_Gen/idisa_builder.h>
#include <idisa/idisa_builder.h>
namespace IDISA {
const unsigned I64_width = 64;
......
......@@ -6,7 +6,7 @@
* This software is licensed to the public under the Open Software License 3.0.
*/
#include <IR_Gen/idisa_i64_builder.h>
#include <idisa/idisa_i64_builder.h>
namespace IDISA {
......
......@@ -6,7 +6,7 @@
* This software is licensed to the public under the Open Software License 3.0.
*/
#include <IR_Gen/idisa_builder.h>
#include <idisa/idisa_builder.h>
namespace IDISA {
......
......@@ -5,7 +5,7 @@
#ifndef TRACEGEN_H
#define TRACEGEN_H
#include "idisa_builder.h"
#include <idisa/idisa_builder.h>
#include <string>
class TraceTool {
......
#ifndef KERNEL_BUILDER_H
#define KERNEL_BUILDER_H
#include <kernels/core/kernel.h>
#include <IR_Gen/idisa_builder.h>
#include <kernel/core/kernel.h>
#include <idisa/idisa_builder.h>
namespace kernel {
......
......@@ -8,7 +8,7 @@
#include <llvm/IR/Type.h> // for Type
#include <llvm/IR/DerivedTypes.h> // for Type
#include <kernels/core/ptrwrapper.hpp>
#include <kernel/core/ptrwrapper.hpp>
namespace IDISA { class IDISA_Builder; }
namespace llvm { class Value; }
......
#ifndef OPTIMIZATIONBRANCH_H
#define OPTIMIZATIONBRANCH_H
#include <kernels/core/kernel.h>
#include <kernel/core/kernel.h>
namespace llvm { class Value; }
......
#ifndef PIPELINE_BUILDER_H
#define PIPELINE_BUILDER_H
#include <kernels/pipeline_kernel.h>
#include <kernel/pipeline/pipeline_kernel.h>
class BaseDriver;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment