libdwarf: compile locally if not present
Change-Id: I70d1f653f4fc4ee4daeaa2c9c6bdbf1416e43c9b
This commit is contained in:
committed by
Masamichi Takagi
parent
0f8f6d298e
commit
39780917af
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +1,6 @@
|
|||||||
[submodule "ihk"]
|
[submodule "ihk"]
|
||||||
path = ihk
|
path = ihk
|
||||||
url = https://github.com/RIKEN-SysSoft/ihk.git
|
url = https://github.com/RIKEN-SysSoft/ihk.git
|
||||||
|
[submodule "executer/user/lib/libdwarf/libdwarf"]
|
||||||
|
path = executer/user/lib/libdwarf/libdwarf
|
||||||
|
url = https://github.com/bgerofi/libdwarf.git
|
||||||
|
|||||||
@ -4,7 +4,7 @@ if (NOT CMAKE_BUILD_TYPE)
|
|||||||
set (CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type: Debug Release..." FORCE)
|
set (CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type: Debug Release..." FORCE)
|
||||||
endif (NOT CMAKE_BUILD_TYPE)
|
endif (NOT CMAKE_BUILD_TYPE)
|
||||||
|
|
||||||
enable_language(C ASM)
|
enable_language(C ASM CXX)
|
||||||
|
|
||||||
project(mckernel C ASM)
|
project(mckernel C ASM)
|
||||||
set(MCKERNEL_VERSION "1.7.0")
|
set(MCKERNEL_VERSION "1.7.0")
|
||||||
@ -34,6 +34,7 @@ include(GNUInstallDirs)
|
|||||||
include(CMakeParseArguments)
|
include(CMakeParseArguments)
|
||||||
include(Kbuild)
|
include(Kbuild)
|
||||||
include(CheckCCompilerFlag)
|
include(CheckCCompilerFlag)
|
||||||
|
include(AutoconfHelper)
|
||||||
|
|
||||||
CHECK_C_COMPILER_FLAG(-Wno-implicit-fallthrough IMPLICIT_FALLTHROUGH)
|
CHECK_C_COMPILER_FLAG(-Wno-implicit-fallthrough IMPLICIT_FALLTHROUGH)
|
||||||
if(IMPLICIT_FALLTHROUGH)
|
if(IMPLICIT_FALLTHROUGH)
|
||||||
@ -135,6 +136,17 @@ if (NOT LIBIBERTY)
|
|||||||
message(FATAL_ERROR "error: couldn't find libiberty")
|
message(FATAL_ERROR "error: couldn't find libiberty")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# ignore libdwarf installed by libdwarf-devel-*.rpm because dwarf.h is located in /usr/include/libdwarf
|
||||||
|
execute_process(COMMAND bash -c "[[ -f /usr/include/libdwarf/dwarf.h ]] && echo YES" OUTPUT_VARIABLE BAD_DWARF_H OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if (BAD_DWARF_H STREQUAL "YES")
|
||||||
|
message("WARNING: ignoring libdwarf installed by libdwarf-devel-*.rpm")
|
||||||
|
else()
|
||||||
|
find_library(LIBDWARF dwarf)
|
||||||
|
endif()
|
||||||
|
if (NOT LIBDWARF)
|
||||||
|
message("WARNING: libdwarf will be compiled locally")
|
||||||
|
endif()
|
||||||
|
|
||||||
if (ENABLE_QLMPI)
|
if (ENABLE_QLMPI)
|
||||||
find_package(MPI REQUIRED)
|
find_package(MPI REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
383
cmake/modules/AutoconfHelper.cmake
Normal file
383
cmake/modules/AutoconfHelper.cmake
Normal file
@ -0,0 +1,383 @@
|
|||||||
|
# Helper functions for translating autoconf projects. Several functions
|
||||||
|
# are lifted from the Mono sources
|
||||||
|
|
||||||
|
include (CheckCSourceCompiles)
|
||||||
|
include (CheckIncludeFile)
|
||||||
|
include (TestBigEndian)
|
||||||
|
include (CheckFunctionExists)
|
||||||
|
include (CheckTypeSize)
|
||||||
|
include (CheckCSourceRuns)
|
||||||
|
|
||||||
|
|
||||||
|
# Function to get the version information from the configure.ac file in the
|
||||||
|
# current directory. Its argument is the name of the library as passed to
|
||||||
|
# AC_INIT. It will set the variables ${LIBNAME}_VERSION and ${LIBNAME}_SOVERSION
|
||||||
|
function (ac_get_version libname)
|
||||||
|
string(TOUPPER "${libname}" libname_upper)
|
||||||
|
|
||||||
|
# Read the relevant content from configure.ac
|
||||||
|
file (STRINGS configure.ac tmp_configure_ac
|
||||||
|
REGEX "${libname_upper}_[_A-Z]+=[ \\t]*[0-9]+")
|
||||||
|
|
||||||
|
# Product version
|
||||||
|
string (REGEX REPLACE ".+MAJOR[_A-Z]+=([0-9]+).+MINOR[_A-Z]+=([0-9]+).+MICRO[_A-Z]+=([0-9]+).*"
|
||||||
|
"\\1.\\2.\\3" ${libname_upper}_VERSION "${tmp_configure_ac}")
|
||||||
|
|
||||||
|
# Library version for libtool
|
||||||
|
string (REGEX REPLACE ".+CURRENT=([0-9]+).+REVISION=([0-9]+).+AGE=([0-9]+).*"
|
||||||
|
"\\1.\\2.\\3" ${libname_upper}_SOVERSION "${tmp_configure_ac}")
|
||||||
|
|
||||||
|
# Checks if the string needs to be displayed
|
||||||
|
set (${libname_upper}_DISPLAYSTR_AUX
|
||||||
|
"Found ${libname} version ${${libname_upper}_VERSION}, soversion ${${libname_upper}_SOVERSION} from configure.ac"
|
||||||
|
)
|
||||||
|
if ((NOT ${libname_upper}_DISPLAYSTR) OR (NOT ${libname_upper}_DISPLAYSTR STREQUAL ${libname_upper}_DISPLAYSTR_AUX))
|
||||||
|
set (${libname_upper}_DISPLAYSTR ${${libname_upper}_DISPLAYSTR_AUX}
|
||||||
|
CACHE INTERNAL "Version string from ${libname}" FORCE)
|
||||||
|
message (STATUS ${${libname_upper}_DISPLAYSTR})
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Export the result to the caller
|
||||||
|
set(${libname_upper}_VERSION "${${libname_upper}_VERSION}" PARENT_SCOPE)
|
||||||
|
set(${libname_upper}_SOVERSION "${${libname_upper}_SOVERSION}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# Also from mono's source code
|
||||||
|
# Implementation of AC_CHECK_HEADERS
|
||||||
|
# In addition, it also records the list of variables in the variable
|
||||||
|
# 'autoheader_vars', and for each variable, a documentation string in the
|
||||||
|
# variable ${var}_doc
|
||||||
|
function(ac_check_headers)
|
||||||
|
foreach (header ${ARGV})
|
||||||
|
string(TOUPPER ${header} header_var)
|
||||||
|
string(REPLACE "." "_" header_var ${header_var})
|
||||||
|
string(REPLACE "/" "_" header_var ${header_var})
|
||||||
|
set(header_var "HAVE_${header_var}")
|
||||||
|
check_include_file (${header} ${header_var})
|
||||||
|
set("${header_var}_doc" "Define to 1 if you have the <${header}> header file." PARENT_SCOPE)
|
||||||
|
if (${header_var})
|
||||||
|
set("${header_var}_defined" "1" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
set("${header_var}_val" "1" PARENT_SCOPE)
|
||||||
|
set (autoheader_vars ${autoheader_vars} ${header_var})
|
||||||
|
endforeach()
|
||||||
|
set (autoheader_vars ${autoheader_vars} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Function taken from mono's source code
|
||||||
|
function (ac_check_funcs)
|
||||||
|
foreach (func ${ARGV})
|
||||||
|
string(TOUPPER ${func} var)
|
||||||
|
set(var "HAVE_${var}")
|
||||||
|
set(${var})
|
||||||
|
check_function_exists (${func} ${var})
|
||||||
|
set("${var}_doc" "Define to 1 if you have the '${func}' function." PARENT_SCOPE)
|
||||||
|
if (${var})
|
||||||
|
set("${var}_defined" "1" PARENT_SCOPE)
|
||||||
|
set(${var} yes PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
set("${var}_val" "1" PARENT_SCOPE)
|
||||||
|
set (autoheader_vars ${autoheader_vars} ${var})
|
||||||
|
endforeach()
|
||||||
|
set (autoheader_vars ${autoheader_vars} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# Specifically, this macro checks for stdlib.h', stdarg.h',
|
||||||
|
# string.h', and float.h'; if the system has those, it probably
|
||||||
|
# has the rest of the ANSI C header files. This macro also checks
|
||||||
|
# whether string.h' declares memchr' (and thus presumably the
|
||||||
|
# other mem' functions), whether stdlib.h' declare free' (and
|
||||||
|
# thus presumably malloc' and other related functions), and whether
|
||||||
|
# the ctype.h' macros work on characters with the high bit set, as
|
||||||
|
# ANSI C requires.
|
||||||
|
function (ac_header_stdc)
|
||||||
|
if (STDC_HEADERS)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
message(STATUS "Looking for ANSI-C headers")
|
||||||
|
set(code "
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <float.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
void *ptr;
|
||||||
|
free((void*)1);
|
||||||
|
ptr = memchr((void*)1, 0, 0);
|
||||||
|
|
||||||
|
return (int)ptr;
|
||||||
|
}
|
||||||
|
")
|
||||||
|
# FIXME Check the ctype.h high bit
|
||||||
|
CHECK_C_SOURCE_COMPILES("${code}" STDC_HEADERS)
|
||||||
|
if (STDC_HEADERS)
|
||||||
|
set(STDC_HEADERS 1 PARENT_SCOPE)
|
||||||
|
message(STATUS "Looking for ANSI-C headers - found")
|
||||||
|
else()
|
||||||
|
message(STATUS "Looking for ANSI-C headers - not found")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# Also from the mono sources, kind of implements AC_SYS_LARGEFILE
|
||||||
|
function (ac_sys_largefile)
|
||||||
|
CHECK_C_SOURCE_RUNS("
|
||||||
|
#include <sys/types.h>
|
||||||
|
#define BIG_OFF_T (((off_t)1<<62)-1+((off_t)1<<62))
|
||||||
|
int main (int argc, char **argv) {
|
||||||
|
int big_off_t=((BIG_OFF_T%2147483629==721) &&
|
||||||
|
(BIG_OFF_T%2147483647==1));
|
||||||
|
return big_off ? 0 : 1;
|
||||||
|
}
|
||||||
|
" HAVE_LARGE_FILE_SUPPORT)
|
||||||
|
|
||||||
|
# Check if it makes sense to define _LARGE_FILES or _FILE_OFFSET_BITS
|
||||||
|
if (HAVE_LARGE_FILE_SUPPORT)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set (_LARGE_FILE_EXTRA_SRC "
|
||||||
|
#include <sys/types.h>
|
||||||
|
int main (int argc, char **argv) {
|
||||||
|
return sizeof(off_t) == 8 ? 0 : 1;
|
||||||
|
}
|
||||||
|
")
|
||||||
|
CHECK_C_SOURCE_RUNS ("#define _LARGE_FILES\n${_LARGE_FILE_EXTRA_SRC}"
|
||||||
|
HAVE_USEFUL_D_LARGE_FILES)
|
||||||
|
if (NOT HAVE_USEFUL_D_LARGE_FILES)
|
||||||
|
if (NOT DEFINED HAVE_USEFUL_D_FILE_OFFSET_BITS)
|
||||||
|
set (SHOW_LARGE_FILE_WARNING TRUE)
|
||||||
|
endif ()
|
||||||
|
CHECK_C_SOURCE_RUNS ("#define _FILE_OFFSET_BITS 64\n${_LARGE_FILE_EXTRA_SRC}"
|
||||||
|
HAVE_USEFUL_D_FILE_OFFSET_BITS)
|
||||||
|
if (HAVE_USEFUL_D_FILE_OFFSET_BITS)
|
||||||
|
set (_FILE_OFFSET_BITS 64 PARENT_SCOPE)
|
||||||
|
elseif (SHOW_LARGE_FILE_WARNING)
|
||||||
|
message (WARNING "No 64 bit file support through off_t available.")
|
||||||
|
endif ()
|
||||||
|
else ()
|
||||||
|
set (_LARGE_FILES 1 PARENT_SCOPE)
|
||||||
|
endif ()
|
||||||
|
endfunction ()
|
||||||
|
|
||||||
|
|
||||||
|
# Quick way to set some basic variables
|
||||||
|
# FIXME add support for variable number of arguments: only package and version are mandatory
|
||||||
|
# arguments are package version bug_report tarname url
|
||||||
|
function (ac_init)
|
||||||
|
set(package ${ARGV0})
|
||||||
|
set(version ${ARGV1})
|
||||||
|
set(bug_report ${ARGV2})
|
||||||
|
set(tarname ${ARGV3})
|
||||||
|
set(url ${ARGV4})
|
||||||
|
set(PACKAGE_NAME "\"${package}\"" PARENT_SCOPE)
|
||||||
|
set(PACKAGE_VERSION "\"${version}\"" PARENT_SCOPE)
|
||||||
|
set(VERSION "\"${version}\"" PARENT_SCOPE)
|
||||||
|
if(version)
|
||||||
|
set(PACKAGE_STRING "\"${package} ${version}\"" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(PACKAGE_STRING "\"${package}\"" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(PACKAGE_BUGREPORT "\"${bug_report}\"" PARENT_SCOPE)
|
||||||
|
|
||||||
|
if(NOT tarname)
|
||||||
|
string(REGEX REPLACE "[^a-zA-Z0-9_]" "-" tarname "${package}")
|
||||||
|
endif()
|
||||||
|
set(PACKAGE_TARNAME "\"${tarname}\"" PARENT_SCOPE)
|
||||||
|
|
||||||
|
set(PACKAGE_URL "\"${url}\"" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# Checks for the const keyword, defining "HAS_CONST_SUPPORT"
|
||||||
|
# If it does not have support, defines "const" to 0 in the parent scope
|
||||||
|
function (ac_c_const)
|
||||||
|
CHECK_C_SOURCE_COMPILES(
|
||||||
|
"int main(int argc, char **argv){const int r = 0;return r;}"
|
||||||
|
HAS_CONST_SUPPORT)
|
||||||
|
if (NOT HAS_CONST_SUPPORT)
|
||||||
|
set(const 0 PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# Inline keyword support. Defines "inline" in the parent scope to the
|
||||||
|
# compiler internal keyword for inline in C
|
||||||
|
# TODO write a better test!
|
||||||
|
function (ac_c_inline)
|
||||||
|
if (MSVC)
|
||||||
|
set (inline __inline)
|
||||||
|
elseif(CMAKE_COMPILER_IS_GNUC)
|
||||||
|
set (inline __inline__)
|
||||||
|
endif()
|
||||||
|
set(inline "${inline}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# Test if you can safely include both <sys/time.h> and <time.h>
|
||||||
|
function (ac_header_time)
|
||||||
|
CHECK_C_SOURCE_COMPILES(
|
||||||
|
"#include <sys/time.h>\n#include <time.h>\nint main(int argc, char **argv) { return 0; }"
|
||||||
|
TIME_WITH_SYS_TIME)
|
||||||
|
set(TIME_WITH_SYS_TIME ${TIME_WITH_SYS_TIME} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian
|
||||||
|
# (Intel), setting "WORDS_BIGENDIAN" to 1 if big endian
|
||||||
|
function (ac_c_bigendian)
|
||||||
|
TEST_BIG_ENDIAN(HOST_BIGENDIAN)
|
||||||
|
if (HOST_BIGENDIAN)
|
||||||
|
set(WORDS_BIGENDIAN 1 PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# Check for off_t, setting "off_t" in the parent scope
|
||||||
|
function(ac_type_off_t)
|
||||||
|
CHECK_TYPE_SIZE("off_t" SIZEOF_OFF_T)
|
||||||
|
if (NOT SIZEOF_OFF_T)
|
||||||
|
set(off_t "long int")
|
||||||
|
endif()
|
||||||
|
set(off_t ${off_t} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# Check for size_t, setting "size_t" in the parent scope
|
||||||
|
function(ac_type_size_t)
|
||||||
|
CHECK_TYPE_SIZE("size_t" SIZEOF_SIZE_T)
|
||||||
|
if (NOT SIZEOF_SIZE_T)
|
||||||
|
set(size_t "unsigned int")
|
||||||
|
endif()
|
||||||
|
set(size_t ${size_t} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# Define "TM_IN_SYS_TIME" to 1 if <sys/time.h> declares "struct tm"
|
||||||
|
function(ac_struct_tm)
|
||||||
|
CHECK_C_SOURCE_COMPILES(
|
||||||
|
"#include <sys/time.h>\nint main(int argc, char **argv) { struct tm x; return 0; }"
|
||||||
|
TM_IN_SYS_TIME
|
||||||
|
)
|
||||||
|
if (TM_IN_SYS_TIME)
|
||||||
|
set (TM_IN_SYS_TIME 1 PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# Obtain size of an 'type' and define as SIZEOF_TYPE
|
||||||
|
function (ac_check_sizeof typename)
|
||||||
|
string(TOUPPER "SIZEOF_${typename}" varname)
|
||||||
|
string(REPLACE " " "_" varname "${varname}")
|
||||||
|
string(REPLACE "*" "p" varname "${varname}")
|
||||||
|
CHECK_TYPE_SIZE("${typename}" ${varname} BUILTIN_TYPES_ONLY)
|
||||||
|
if(NOT ${varname})
|
||||||
|
set(${varname} 0 PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# Check if the type exists, defines HAVE_<type>
|
||||||
|
function (ac_check_type typename)
|
||||||
|
string(TOUPPER "${typename}" varname)
|
||||||
|
string(REPLACE " " "_" varname "${varname}")
|
||||||
|
string(REPLACE "*" "p" varname "${varname}")
|
||||||
|
CHECK_TYPE_SIZE("${typename}" ${varname})
|
||||||
|
if (NOT "${varname}" STREQUAL "")
|
||||||
|
set("HAVE_${varname}" 1 PARENT_SCOPE)
|
||||||
|
set("${varname}" "${typename}" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set("${varname}" "unknown" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# Verifies if each type on the list exists, using the given prelude
|
||||||
|
function (ac_check_types type_list prelude)
|
||||||
|
foreach(typename ${type_list})
|
||||||
|
string(TOUPPER "HAVE_${typename}" varname)
|
||||||
|
string(REPLACE " " "_" varname "${varname}")
|
||||||
|
string(REPLACE "*" "p" varname "${varname}")
|
||||||
|
CHECK_C_SOURCE_COMPILES("${prelude}\n ${typename} foo;" ${varname})
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(ac_path_prog variable prog_to_check_for value_if_not_found env_var)
|
||||||
|
find_program(${variable} NAMES ${prog_to_check_for} PATHS ENV ${env_var} NO_DEFAULT_PATH)
|
||||||
|
if(NOT ${variable})
|
||||||
|
message(STATUS "Looking for ${prog_to_check_for} - not found")
|
||||||
|
set(${variable} ${value_if_not_fount} PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
message(STATUS "Looking for ${prog_to_check_for} - ${variable}")
|
||||||
|
set(${variable} ${${variable}} PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# check if function func exists in library lib
|
||||||
|
function(ac_check_lib lib func)
|
||||||
|
string(TOUPPER "HAVE_${func}" varname)
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ${lib})
|
||||||
|
check_function_exists(${func} ${varname})
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# check if source compiles without linking
|
||||||
|
function(ac_try_compile SOURCE VAR)
|
||||||
|
set(CMAKE_TMP_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp)
|
||||||
|
if(NOT DEFINED "${VAR}")
|
||||||
|
file(WRITE
|
||||||
|
"${CMAKE_TMP_DIR}/src.c"
|
||||||
|
"${SOURCE}\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
if(NOT CMAKE_REQUIRED_QUIET)
|
||||||
|
message(STATUS "Performing Test ${VAR}")
|
||||||
|
endif()
|
||||||
|
# Set up CMakeLists.txt for static library:
|
||||||
|
file(WRITE
|
||||||
|
${CMAKE_TMP_DIR}/CMakeLists.txt
|
||||||
|
"add_library(compile STATIC src.c)"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Configure:
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
||||||
|
WORKING_DIRECTORY ${CMAKE_TMP_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Build:
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_TMP_DIR}
|
||||||
|
RESULT_VARIABLE RESVAR
|
||||||
|
OUTPUT_VARIABLE OUTPUT
|
||||||
|
ERROR_VARIABLE OUTPUT
|
||||||
|
)
|
||||||
|
|
||||||
|
# Set up result:
|
||||||
|
if(RESVAR EQUAL 0)
|
||||||
|
set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
|
||||||
|
if(NOT CMAKE_REQUIRED_QUIET)
|
||||||
|
message(STATUS "Performing Test ${VAR} - Success")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||||
|
"Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n"
|
||||||
|
"${OUTPUT}\n"
|
||||||
|
"Source file was:\n${SOURCE}\n")
|
||||||
|
else()
|
||||||
|
if(NOT CMAKE_REQUIRED_QUIET)
|
||||||
|
message(STATUS "Performing Test ${VAR} - Failed")
|
||||||
|
endif()
|
||||||
|
set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
|
||||||
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||||
|
"Performing C SOURCE FILE Test ${VAR} failed with the following output:\n"
|
||||||
|
"${OUTPUT}\n"
|
||||||
|
"Source file was:\n${SOURCE}\n")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
64
cmake/modules/FindLibElf.cmake
Normal file
64
cmake/modules/FindLibElf.cmake
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
# - Try to find libelf
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# LIBELF_FOUND - system has libelf
|
||||||
|
# LIBELF_INCLUDE_DIRS - the libelf include directory
|
||||||
|
# LIBELF_LIBRARIES - Link these to use libelf
|
||||||
|
# LIBELF_DEFINITIONS - Compiler switches required for using libelf
|
||||||
|
#
|
||||||
|
# This module reads hints about search locations from variables:
|
||||||
|
#
|
||||||
|
# LIBELF_ROOT - Preferred installation prefix
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Bernhard Walle <bernhard.walle@gmx.de>
|
||||||
|
#
|
||||||
|
# Redistribution and use is allowed according to the terms of the New
|
||||||
|
# BSD license.
|
||||||
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
if (LIBELF_LIBRARIES AND LIBELF_INCLUDE_DIRS)
|
||||||
|
set (LibElf_FIND_QUIETLY TRUE)
|
||||||
|
endif (LIBELF_LIBRARIES AND LIBELF_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
find_path (LIBELF_INCLUDE_DIRS
|
||||||
|
NAMES
|
||||||
|
libelf/libelf.h libelf.h
|
||||||
|
HINTS
|
||||||
|
${LIBELF_ROOT}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
include
|
||||||
|
libelf/include
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library (LIBELF_LIBRARIES
|
||||||
|
NAMES
|
||||||
|
elf libelf
|
||||||
|
HINTS
|
||||||
|
${LIBELF_ROOT}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
lib
|
||||||
|
libelf/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
include (FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set LIBELF_FOUND to TRUE if all listed variables are TRUE
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibElf DEFAULT_MSG
|
||||||
|
LIBELF_LIBRARIES
|
||||||
|
LIBELF_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES elf)
|
||||||
|
include(CheckCXXSourceCompiles)
|
||||||
|
check_cxx_source_compiles("#include <libelf.h>
|
||||||
|
int main() {
|
||||||
|
Elf *e = (Elf*)0;
|
||||||
|
size_t sz;
|
||||||
|
elf_getshdrstrndx(e, &sz);
|
||||||
|
return 0;
|
||||||
|
}" ELF_GETSHDRSTRNDX)
|
||||||
|
unset(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
|
||||||
|
mark_as_advanced(LIBELF_INCLUDE_DIRS LIBELF_LIBRARIES ELF_GETSHDRSTRNDX)
|
||||||
@ -8,7 +8,7 @@ include_directories(
|
|||||||
"${PROJECT_BINARY_DIR}/ihk/linux/include"
|
"${PROJECT_BINARY_DIR}/ihk/linux/include"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_subdirectory(lib)
|
||||||
add_library(libmcexec STATIC arch/${ARCH}/archdep.S)
|
add_library(libmcexec STATIC arch/${ARCH}/archdep.S)
|
||||||
SET_TARGET_PROPERTIES(libmcexec PROPERTIES OUTPUT_NAME mcexec)
|
SET_TARGET_PROPERTIES(libmcexec PROPERTIES OUTPUT_NAME mcexec)
|
||||||
set_property(TARGET libmcexec PROPERTY POSITION_INDEPENDENT_CODE ON)
|
set_property(TARGET libmcexec PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|||||||
3
executer/user/lib/CMakeLists.txt
Normal file
3
executer/user/lib/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
if (NOT LIBDWARF)
|
||||||
|
add_subdirectory(libdwarf)
|
||||||
|
endif()
|
||||||
144
executer/user/lib/libdwarf/CMakeLists.txt
Normal file
144
executer/user/lib/libdwarf/CMakeLists.txt
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
if (NOT LIBDWARF)
|
||||||
|
# view folders on supported IDEs
|
||||||
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
||||||
|
# used when finding libelf
|
||||||
|
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
|
||||||
|
|
||||||
|
find_package(LibElf REQUIRED)
|
||||||
|
list(APPEND CMAKE_REQUIRED_INCLUDES ${LIBELF_INCLUDE_DIRS})
|
||||||
|
include(AutoconfHelper)
|
||||||
|
|
||||||
|
ac_init()
|
||||||
|
ac_c_bigendian()
|
||||||
|
ac_check_headers(sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h inttypes.h stdint.h unistd.h)
|
||||||
|
ac_check_headers(alloca.h elf.h elfaccess.h libelf.h libelf/libelf.h sys/types.h sys/elf_386.h sys/elf_amd64.h sys/elf_sparc.h sys/ia64/elf.h)
|
||||||
|
|
||||||
|
# The default libdwarf is the one with struct Elf
|
||||||
|
message(STATUS "Assuming struct Elf for the default libdwarf.h")
|
||||||
|
|
||||||
|
# Find out where the elf header is.
|
||||||
|
if(HAVE_ELF_H)
|
||||||
|
set(HAVE_LOCATION_OF_LIBELFHEADER "<elf.h>")
|
||||||
|
elseif(HAVE_LIBELF_H)
|
||||||
|
set(HAVE_LOCATION_OF_LIBELFHEADER "<libelf.h>")
|
||||||
|
elseif(HAVE_LIBELF_LIBELF_H)
|
||||||
|
set(HAVE_LOCATION_OF_LIBELFHEADER "<libelf/libelf.h>")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
ac_check_lib(${LIBELF_LIBRARIES} elf64_getehdr)
|
||||||
|
ac_check_lib(${LIBELF_LIBRARIES} elf64_getshdr)
|
||||||
|
|
||||||
|
ac_try_compile("
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
__uint32_t p;
|
||||||
|
p = 3;
|
||||||
|
return 0;
|
||||||
|
}"
|
||||||
|
HAVE___UINT32_T)
|
||||||
|
|
||||||
|
ac_try_compile("
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
__uint64_t p;
|
||||||
|
p = 3;
|
||||||
|
return 0;
|
||||||
|
}"
|
||||||
|
HAVE___UINT64_T)
|
||||||
|
|
||||||
|
ac_try_compile("
|
||||||
|
#include <sys/types.h>
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
__uint32_t p;
|
||||||
|
p = 3;
|
||||||
|
return 0;
|
||||||
|
}"
|
||||||
|
HAVE___UINT32_T_IN_SYS_TYPES_H)
|
||||||
|
|
||||||
|
ac_try_compile("
|
||||||
|
#include <sys/types.h>
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
__uint64_t p;
|
||||||
|
p = 3;
|
||||||
|
return 0;
|
||||||
|
}"
|
||||||
|
HAVE___UINT64_T_IN_SYS_TYPES_H)
|
||||||
|
|
||||||
|
check_c_source_runs("
|
||||||
|
static unsigned foo( unsigned x, __attribute__ ((unused)) int y)
|
||||||
|
{
|
||||||
|
unsigned x2 = x + 1;
|
||||||
|
return x2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
unsigned y = 0;
|
||||||
|
y = foo(12,y);
|
||||||
|
return 0;
|
||||||
|
}"
|
||||||
|
HAVE_UNUSED_ATTRIBUTE)
|
||||||
|
|
||||||
|
message(STATUS "Checking compiler supports __attribute__ unused... ${HAVE_UNUSED_ATTRIBUTE}")
|
||||||
|
|
||||||
|
ac_try_compile("
|
||||||
|
#include <zlib.h>
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
Bytef dest[100];
|
||||||
|
uLongf destlen = 100;
|
||||||
|
Bytef *src = 0;
|
||||||
|
uLong srclen = 3;
|
||||||
|
int res = uncompress(dest,&destlen,src,srclen);
|
||||||
|
if (res == Z_OK) {
|
||||||
|
/* ALL IS WELL */
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}"
|
||||||
|
HAVE_ZLIB)
|
||||||
|
message(STATUS "Checking zlib.h usability... ${HAVE_ZLIB}")
|
||||||
|
set(dwfzlib $<$<BOOL:${HAVE_ZIB}>:"z")
|
||||||
|
|
||||||
|
configure_file(libdwarf/libdwarf/libdwarf.h.in libdwarf.h COPYONLY)
|
||||||
|
configure_file(libdwarf/libdwarf/config.h.in.cmake config.h)
|
||||||
|
set(DWARF_CONFIGURATION_FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||||
|
|
||||||
|
set(DWARF_SOURCES dwarf_abbrev.c dwarf_alloc.c dwarf_arange.c dwarf_die_deliv.c dwarf_dnames.c dwarf_dsc.c dwarf_elf_access.c dwarf_error.c
|
||||||
|
dwarf_form.c dwarf_frame.c dwarf_frame2.c dwarf_funcs.c dwarf_gdbindex.c dwarf_global.c dwarf_groups.c dwarf_harmless.c dwarf_init_finish.c dwarf_leb.c
|
||||||
|
dwarf_line.c dwarf_loc.c dwarf_macro.c dwarf_macro5.c dwarf_original_elf_init.c dwarf_pubtypes.c dwarf_query.c dwarf_ranges.c dwarf_string.c dwarf_tied.c
|
||||||
|
dwarf_str_offsets.c
|
||||||
|
dwarf_tsearchhash.c dwarf_types.c dwarf_util.c dwarf_vars.c dwarf_weaks.c dwarf_xu_index.c dwarf_print_lines.c malloc_check.c pro_alloc.c pro_arange.c
|
||||||
|
pro_die.c pro_encode_nm.c pro_error.c pro_expr.c pro_finish.c pro_forms.c pro_funcs.c pro_frame.c pro_init.c pro_line.c pro_reloc.c pro_reloc_stream.c
|
||||||
|
pro_reloc_symbolic.c pro_pubnames.c pro_section.c pro_types.c pro_vars.c pro_macinfo.c pro_weaks.c)
|
||||||
|
|
||||||
|
set(DWARF_HEADERS dwarf.h dwarf_abbrev.h dwarf_alloc.h dwarf_arange.h dwarf_base_types.h dwarf_die_deliv.h dwarf_dnames.h dwarf_dsc.h
|
||||||
|
dwarf_elf_access.h dwarf_error.h dwarf_frame.h dwarf_funcs.h dwarf_gdbindex.h dwarf_global.h dwarf_harmless.h dwarf_incl.h dwarf_line.h dwarf_loc.h
|
||||||
|
dwarf_macro.h dwarf_macro5.h dwarf_opaque.h dwarf_reloc_arm.h dwarf_reloc_mips.h dwarf_reloc_ppc.h dwarf_reloc_ppc64.h dwarf_reloc_x86_64.h dwarf_tsearch.h
|
||||||
|
dwarf_str_offsets.h
|
||||||
|
dwarf_types.h dwarf_util.h dwarf_vars.h dwarf_weaks.h dwarf_xu_index.h dwgetopt.h libdwarfdefs.h malloc_check.h pro_alloc.h pro_arange.h pro_die.h
|
||||||
|
pro_encode_nm.h pro_error.h pro_expr.h pro_frame.h pro_incl.h pro_line.h pro_macinfo.h pro_opaque.h pro_reloc.h pro_reloc_stream.h pro_reloc_symbolic.h
|
||||||
|
pro_section.h pro_types.h pro_util.h)
|
||||||
|
|
||||||
|
SET(__SRCS "")
|
||||||
|
FOREACH(f ${DWARF_SOURCES})
|
||||||
|
LIST(APPEND __SRCS "libdwarf/libdwarf/${f}")
|
||||||
|
ENDFOREACH(f)
|
||||||
|
SET(DWARF_SOURCES ${__SRCS})
|
||||||
|
|
||||||
|
set(GENNAMES_SOURCES
|
||||||
|
libdwarf/libdwarf/gennames.c
|
||||||
|
libdwarf/libdwarf/dwgetopt.c
|
||||||
|
libdwarf/libdwarf/dwarf.h)
|
||||||
|
add_executable(gennames ${GENNAMES_SOURCES})
|
||||||
|
set(GENNAMES_OUTPUT dwarf_names.c dwarf_names.h dwarf_names_enum.h dwarf_names_new.h)
|
||||||
|
|
||||||
|
add_custom_command(OUTPUT ${GENNAMES_OUTPUT}
|
||||||
|
COMMAND gennames -s -i ${CMAKE_CURRENT_SOURCE_DIR}/libdwarf/libdwarf/ -o .
|
||||||
|
DEPENDS gennames libdwarf/libdwarf/libdwarf.h.in)
|
||||||
|
|
||||||
|
add_library(dwarf STATIC ${DWARF_SOURCES} ${GENNAMES_OUTPUT} ${DWARF_CONFIGURATION_FILES})
|
||||||
|
target_include_directories(dwarf PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/libdwarf/libdwarf/")
|
||||||
|
target_include_directories(dwarf BEFORE PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
|
endif()
|
||||||
1
executer/user/lib/libdwarf/libdwarf
Submodule
1
executer/user/lib/libdwarf/libdwarf
Submodule
Submodule executer/user/lib/libdwarf/libdwarf added at ab9230b2b8
Reference in New Issue
Block a user