Cleanup of Dyninst build dependencies (#238)

- Refactor elfutils build folders. Move build artifacts to the "external" subfolders
- Remove reference to unused DYNINST configuration
- Declare Dyninst interfaces with other external declarations
- Updated cmake warning message
- Update the deprecation warning for "DYNINST_BUILD_${dep}" to make it clearer that the option is being translated to the new option, "ROCPROFSYS_BUILD_${dep}"
Este commit está contenido en:
David Galiffi
2025-06-13 17:19:46 -04:00
cometido por GitHub
padre 8535da17c8
commit eaaec2cc3b
Se han modificado 8 ficheros con 52 adiciones y 226 borrados
-3
Ver fichero
@@ -143,9 +143,6 @@ string(REGEX REPLACE "([a-zA-Z])-([0-9])" "\\1\\2" CPACK_DEBIAN_PACKAGE_RELEASE
"${CPACK_DEBIAN_PACKAGE_RELEASE}")
string(REPLACE "-" "~" CPACK_DEBIAN_PACKAGE_RELEASE "${CPACK_DEBIAN_PACKAGE_RELEASE}")
if(DYNINST_USE_OpenMP)
list(APPEND _DEBIAN_PACKAGE_DEPENDS libgomp1)
endif()
if(ROCPROFSYS_USE_PAPI AND NOT ROCPROFSYS_BUILD_PAPI)
list(APPEND _DEBIAN_PACKAGE_DEPENDS libpapi-dev libpfm4)
endif()
-4
Ver fichero
@@ -44,10 +44,6 @@
include_guard(GLOBAL)
# always provide Dyninst::Boost even if it is empty
rocprofiler_systems_add_interface_library(rocprofiler-systems-boost
"Boost interface library")
if(NOT BUILD_BOOST)
find_package(Boost)
endif()
+26 -24
Ver fichero
@@ -28,9 +28,6 @@
include_guard(GLOBAL)
# always provide Dyninst::ElfUtils even if it is a dummy
rocprofiler_systems_add_interface_library(ElfUtils "ElfUtils interface library")
if(NOT BUILD_ELFUTILS)
find_package(Elfutils)
endif()
@@ -98,6 +95,7 @@ if(NOT BUILD_ELFUTILS)
endif()
# -------------- SOURCE BUILD -------------------------------------------------
if(LibElf_FOUND
AND LibDwarf_FOUND
AND (NOT ENABLE_DEBUGINFOD OR LibDebuginfod_FOUND))
@@ -149,24 +147,21 @@ else()
"ElfUtils will only build with the GNU compiler")
endif()
set(_eu_root ${TPL_STAGING_PREFIX})
set(_eu_inc_dirs $<BUILD_INTERFACE:${_eu_root}/include>
$<INSTALL_INTERFACE:${INSTALL_LIB_DIR}/${TPL_INSTALL_INCLUDE_DIR}>)
set(_eu_lib_dirs $<BUILD_INTERFACE:${_eu_root}/lib>
$<INSTALL_INTERFACE:${INSTALL_LIB_DIR}/${TPL_INSTALL_LIB_DIR}>)
set(_eu_libs
$<BUILD_INTERFACE:${_eu_root}/lib/libdw${CMAKE_SHARED_LIBRARY_SUFFIX}>
$<BUILD_INTERFACE:${_eu_root}/lib/libelf${CMAKE_SHARED_LIBRARY_SUFFIX}>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${INSTALL_LIB_DIR}/${TPL_INSTALL_LIB_DIR}/libdw${CMAKE_SHARED_LIBRARY_SUFFIX}>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${INSTALL_LIB_DIR}/${TPL_INSTALL_LIB_DIR}/libelf${CMAKE_SHARED_LIBRARY_SUFFIX}>
)
set(_eu_root ${TPL_STAGING_PREFIX}/elfutils)
set(_eu_inc_dirs $<BUILD_INTERFACE:${_eu_root}/include>)
set(_eu_lib_dirs $<BUILD_INTERFACE:${_eu_root}/lib>)
set(_eu_libs $<BUILD_INTERFACE:${_eu_root}/lib/libdw${CMAKE_SHARED_LIBRARY_SUFFIX}>
$<BUILD_INTERFACE:${_eu_root}/lib/libelf${CMAKE_SHARED_LIBRARY_SUFFIX}>)
set(_eu_build_byproducts "${_eu_root}/lib/libdw${CMAKE_SHARED_LIBRARY_SUFFIX}"
"${_eu_root}/lib/libelf${CMAKE_SHARED_LIBRARY_SUFFIX}")
file(MAKE_DIRECTORY "${_eu_root}/lib")
file(MAKE_DIRECTORY "${_eu_root}/include")
include(ExternalProject)
externalproject_add(
ElfUtils-External
PREFIX ${PROJECT_BINARY_DIR}/elfutils
rocprofiler-systems-elfutils-build
PREFIX ${_eu_root}
URL ${ElfUtils_DOWNLOAD_URL}
"https://sourceware.org/elfutils/ftp/${ELFUTILS_DOWNLOAD_VERSION}/elfutils-${ELFUTILS_DOWNLOAD_VERSION}.tar.bz2"
"https://mirrors.kernel.org/sourceware/elfutils/${ELFUTILS_DOWNLOAD_VERSION}/elfutils-${ELFUTILS_DOWNLOAD_VERSION}.tar.bz2"
@@ -175,19 +170,25 @@ else()
${CMAKE_COMMAND} -E env CC=${CMAKE_C_COMPILER} CFLAGS=-fPIC\ -O3
CXX=${CMAKE_CXX_COMPILER} CXXFLAGS=-fPIC\ -O3
[=[LDFLAGS=-Wl,-rpath='$$ORIGIN']=] <SOURCE_DIR>/configure
--enable-install-elfh --prefix=${TPL_STAGING_PREFIX} --disable-libdebuginfod
--enable-install-elfh --prefix=${_eu_root} --disable-libdebuginfod
--disable-debuginfod --enable-thread-safety ${ElfUtils_CONFIG_OPTIONS}
--libdir=${TPL_STAGING_PREFIX}/lib
--libdir=${_eu_root}/lib
BUILD_COMMAND make install
BUILD_BYPRODUCTS ${_eu_build_byproducts}
INSTALL_COMMAND "")
# target for re-executing the installation
add_custom_target(
install-elfutils-external
rocprofiler-systems-elfutils-install
COMMAND make install
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/elfutils/src/ElfUtils-External
WORKING_DIRECTORY ${${_eu_root}}/src/ElfUtils-External
COMMENT "Installing ElfUtils...")
install(
DIRECTORY ${_eu_root}/lib/
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
FILES_MATCHING
PATTERN "*${CMAKE_SHARED_LIBRARY_SUFFIX}*")
endif()
# -------------- EXPORT VARIABLES ---------------------------------------------
@@ -208,10 +209,11 @@ set(ElfUtils_LIBRARIES
${_eu_libs}
CACHE FILEPATH "elfutils library files" FORCE)
target_include_directories(ElfUtils SYSTEM INTERFACE ${ElfUtils_INCLUDE_DIRS})
target_compile_definitions(ElfUtils INTERFACE ${ElfUtils_DEFINITIONS})
target_link_directories(ElfUtils INTERFACE ${ElfUtils_LIBRARY_DIRS})
target_link_libraries(ElfUtils INTERFACE ${ElfUtils_LIBRARIES})
target_include_directories(rocprofiler-systems-elfutils SYSTEM
INTERFACE ${ElfUtils_INCLUDE_DIRS})
target_compile_definitions(rocprofiler-systems-elfutils INTERFACE ${ElfUtils_DEFINITIONS})
target_link_directories(rocprofiler-systems-elfutils INTERFACE ${ElfUtils_LIBRARY_DIRS})
target_link_libraries(rocprofiler-systems-elfutils INTERFACE ${ElfUtils_LIBRARIES})
rocprofiler_systems_message(STATUS "ElfUtils includes: ${ElfUtils_INCLUDE_DIRS}")
rocprofiler_systems_message(STATUS "ElfUtils library dirs: ${ElfUtils_LIBRARY_DIRS}")
+9 -22
Ver fichero
@@ -5,7 +5,7 @@ foreach(dep BOOST TBB ELFUTILS LIBIBERTY)
if(DYNINST_BUILD_${dep})
message(
WARNING
"DYNINST_BUILD_${dep} is deprecated. Use ROCPROFSYS_BUILD_${dep} instead."
"DYNINST_BUILD_${dep} is deprecated. Using ROCPROFSYS_BUILD_${dep} instead."
)
set(ROCPROFSYS_BUILD_${dep} ON)
endif()
@@ -58,10 +58,11 @@ if(TARGET rocprofiler-systems-tbb-build AND TARGET external-prebuild)
endif()
include(DyninstElfUtils)
if(TARGET ElfUtils-External AND TARGET external-prebuild)
set_target_properties(ElfUtils-External PROPERTIES JOB_POOL_COMPILE external_deps_pool
JOB_POOL_LINK external_deps_pool)
add_dependencies(external-prebuild ElfUtils-External)
if(TARGET rocprofiler-systems-elfutils-build AND TARGET external-prebuild)
set_target_properties(
rocprofiler-systems-elfutils-build PROPERTIES JOB_POOL_COMPILE external_deps_pool
JOB_POOL_LINK external_deps_pool)
add_dependencies(external-prebuild rocprofiler-systems-elfutils-build)
endif()
include(DyninstLibIberty)
@@ -92,9 +93,10 @@ if(NOT TARGET Dyninst::Boost AND TARGET rocprofiler-systems-boost)
"Created imported target Dyninst::Boost linked to rocprofiler-systems-boost")
endif()
if(NOT TARGET Dyninst::ElfUtils AND TARGET ElfUtils)
if(NOT TARGET Dyninst::ElfUtils AND TARGET rocprofiler-systems-elfutils)
add_library(Dyninst::ElfUtils INTERFACE IMPORTED)
set_target_properties(Dyninst::ElfUtils PROPERTIES INTERFACE_LINK_LIBRARIES ElfUtils)
set_target_properties(Dyninst::ElfUtils PROPERTIES INTERFACE_LINK_LIBRARIES
rocprofiler-systems-elfutils)
message(STATUS "Created imported target Dyninst::ElfUtils linked to ElfUtils")
endif()
@@ -115,18 +117,3 @@ if(NOT TARGET Dyninst::LibIberty AND TARGET rocprofiler-systems-libiberty)
"Created imported target Dyninst::LibIberty linked to rocprofiler-systems-libiberty"
)
endif()
# for packaging
install(
DIRECTORY ${TPL_STAGING_PREFIX}/lib/
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
FILES_MATCHING
PATTERN "*${CMAKE_SHARED_LIBRARY_SUFFIX}*"
PATTERN "*${CMAKE_STATIC_LIBRARY_SUFFIX}*")
install(
DIRECTORY ${TPL_STAGING_PREFIX}/tbb/lib/
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
FILES_MATCHING
PATTERN "*${CMAKE_SHARED_LIBRARY_SUFFIX}*"
PATTERN "*${CMAKE_STATIC_LIBRARY_SUFFIX}*")
+3 -9
Ver fichero
@@ -21,10 +21,6 @@
include_guard(GLOBAL)
# always provide Dyninst::LibIberty even if it is empty
rocprofiler_systems_add_interface_library(rocprofiler-systems-libiberty
"LibIberty interface library")
if(NOT UNIX)
return()
endif()
@@ -48,6 +44,7 @@ if(NOT BUILD_LIBIBERTY)
endif()
# -------------- SOURCE BUILD -------------------------------------------------
if(LibIberty_FOUND)
set(_li_root ${LibIberty_ROOT_DIR})
set(_li_inc_dirs ${LibIberty_INCLUDE_DIRS})
@@ -71,12 +68,9 @@ else()
set(_li_project_name rocprofiler-systems-libiberty-build)
set(_li_working_dir ${_li_root}/src/${_li_project_name})
set(_li_inc_dirs $<BUILD_INTERFACE:${_li_root}/include>)
set(_li_lib_dirs $<BUILD_INTERFACE:${_li_root}/lib>
$<INSTALL_INTERFACE:${INSTALL_LIB_DIR}/${TPL_INSTALL_LIB_DIR}>)
set(_li_lib_dirs $<BUILD_INTERFACE:${_li_root}/lib>)
set(_li_libs
$<BUILD_INTERFACE:${_li_root}/lib/libiberty${CMAKE_STATIC_LIBRARY_SUFFIX}>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${INSTALL_LIB_DIR}/${TPL_INSTALL_LIB_DIR}/libiberty${CMAKE_STATIC_LIBRARY_SUFFIX}>
)
$<BUILD_INTERFACE:${_li_root}/lib/libiberty${CMAKE_STATIC_LIBRARY_SUFFIX}>)
set(_li_build_byproducts "${_li_root}/lib/libiberty${CMAKE_STATIC_LIBRARY_SUFFIX}")
file(MAKE_DIRECTORY "${_li_root}/lib")
+6 -4
Ver fichero
@@ -33,10 +33,6 @@
include_guard(GLOBAL)
# always provide Dyninst::TBB even if it is a dummy
rocprofiler_systems_add_interface_library(rocprofiler-systems-tbb
"Threading Building Blocks")
if(TBB_FOUND)
return()
endif()
@@ -241,6 +237,12 @@ else()
${CMAKE_COMMAND} -DLIBDIR=${TBB_LIBRARY_DIRS} -DINCDIR=${TBB_INCLUDE_DIRS}
-DPREFIX=${TBB_ROOT_DIR} -P ${CMAKE_CURRENT_LIST_DIR}/DyninstTBBInstall.cmake
COMMENT "Installing TBB...")
install(
DIRECTORY ${TPL_STAGING_PREFIX}/tbb/lib/
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
FILES_MATCHING
PATTERN "*${CMAKE_SHARED_LIBRARY_SUFFIX}*")
endif()
foreach(_DIR_TYPE INCLUDE LIBRARY)
-144
Ver fichero
@@ -1,144 +0,0 @@
# ======================================================================================
# elfutils.cmake
#
# Configure elfutils for rocprofiler-systems
#
# ----------------------------------------
#
# Accepts the following CMake variables
#
# ElfUtils_ROOT_DIR - Base directory the of elfutils installation
# ElfUtils_INCLUDEDIR - Hint directory that contains the elfutils headers files
# ElfUtils_LIBRARYDIR - Hint directory that contains the elfutils library files
# ElfUtils_MIN_VERSION - Minimum acceptable version of elfutils
#
# Directly exports the following CMake variables
#
# ElfUtils_ROOT_DIR - Computed base directory the of elfutils installation
# ElfUtils_INCLUDE_DIRS - elfutils include directories ElfUtils_LIBRARY_DIRS - Link
# directories for elfutils libraries ElfUtils_LIBRARIES - elfutils library files
#
# NOTE: The exported ElfUtils_ROOT_DIR can be different from the value provided by the
# user in the case that it is determined to build elfutils from source. In such a case,
# ElfUtils_ROOT_DIR will contain the directory of the from-source installation.
#
# See Modules/FindLibElf.cmake and Modules/FindLibDwarf.cmake for details
#
# ======================================================================================
include_guard(GLOBAL)
include(ExternalProject)
# Minimum acceptable version of elfutils NB: We need >=0.178 because libdw isn't
# thread-safe before then
set(_min_version 0.178)
set(ElfUtils_MIN_VERSION
${_min_version}
CACHE STRING "Minimum acceptable elfutils version")
if(${ElfUtils_MIN_VERSION} VERSION_LESS ${_min_version})
rocprofiler_systems_message(
FATAL_ERROR
"Requested version ${ElfUtils_MIN_VERSION} is less than minimum supported version (${_min_version})"
)
endif()
# If we didn't find a suitable version on the system, then download one from the web
set(ElfUtils_DOWNLOAD_VERSION
"0.188"
CACHE STRING "Version of elfutils to download and install")
# make sure we are not downloading a version less than minimum
if(${ElfUtils_DOWNLOAD_VERSION} VERSION_LESS ${ElfUtils_MIN_VERSION})
rocprofiler_systems_message(
FATAL_ERROR
"elfutils download version is set to ${ElfUtils_DOWNLOAD_VERSION} but elfutils minimum version is set to ${ElfUtils_MIN_VERSION}"
)
endif()
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
set(ElfUtils_C_COMPILER
"${CMAKE_C_COMPILER}"
CACHE FILEPATH "C compiler used to compiler ElfUtils")
else()
find_program(
ElfUtils_C_COMPILER
NAMES gcc
PATH_SUFFIXES bin)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(ElfUtils_CXX_COMPILER
"${CMAKE_CXX_COMPILER}"
CACHE FILEPATH "C++ compiler used to compiler ElfUtils")
else()
find_program(
ElfUtils_CXX_COMPILER
NAMES g++
PATH_SUFFIXES bin)
endif()
find_program(
MAKE_COMMAND
NAMES make gmake
PATH_SUFFIXES bin)
if(NOT ElfUtils_C_COMPILER OR NOT ElfUtils_CXX_COMPILER)
rocprofiler_systems_message(
FATAL_ERROR
"ElfUtils requires the GNU C and C++ compilers. ElfUtils_C_COMPILER: ${ElfUtils_C_COMPILER}, ElfUtils_CXX_COMPILER: ${ElfUtils_CXX_COMPILER}"
)
endif()
set(_eu_root ${PROJECT_BINARY_DIR}/external/elfutils)
set(_eu_inc_dirs $<BUILD_INTERFACE:${_eu_root}/include>)
set(_eu_lib_dirs $<BUILD_INTERFACE:${_eu_root}/lib>)
set(_eu_libs $<BUILD_INTERFACE:${_eu_root}/lib/libdw${CMAKE_STATIC_LIBRARY_SUFFIX}>
$<BUILD_INTERFACE:${_eu_root}/lib/libelf${CMAKE_STATIC_LIBRARY_SUFFIX}>)
set(_eu_build_byproducts "${_eu_root}/lib/libdw${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${_eu_root}/lib/libelf${CMAKE_STATIC_LIBRARY_SUFFIX}")
externalproject_add(
rocprofiler-systems-elfutils-build
PREFIX ${PROJECT_BINARY_DIR}/external/elfutils
URL ${ElfUtils_DOWNLOAD_URL}
"https://sourceware.org/elfutils/ftp/${ElfUtils_DOWNLOAD_VERSION}/elfutils-${ElfUtils_DOWNLOAD_VERSION}.tar.bz2"
"https://mirrors.kernel.org/sourceware/elfutils/${ElfUtils_DOWNLOAD_VERSION}/elfutils-${ElfUtils_DOWNLOAD_VERSION}.tar.bz2"
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND
${CMAKE_COMMAND} -E env CC=${ElfUtils_C_COMPILER}
CFLAGS=-fPIC\ -O3\ -Wno-error=null-dereference CXX=${ElfUtils_CXX_COMPILER}
CXXFLAGS=-fPIC\ -O3\ -Wno-error=null-dereference
[=[LDFLAGS=-Wl,-rpath='$$ORIGIN']=] <SOURCE_DIR>/configure --enable-install-elfh
--prefix=${_eu_root} --disable-libdebuginfod --disable-debuginfod --disable-nls
--enable-thread-safety --enable-silent-rules ${ElfUtils_CONFIG_OPTIONS}
--libdir=${_eu_root}/lib
BUILD_COMMAND ${MAKE_COMMAND} install -s
BUILD_BYPRODUCTS "${_eu_build_byproducts}"
INSTALL_COMMAND "")
# target for re-executing the installation
add_custom_target(
rocprofiler-systems-elfutils-install
COMMAND ${MAKE_COMMAND} install -s
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/external/elfutils/src/ElfUtils-External
COMMENT "Installing ElfUtils...")
# -------------- EXPORT VARIABLES ---------------------------------------------
set(ElfUtils_ROOT_DIR
${_eu_root}
CACHE PATH "Base directory the of elfutils installation" FORCE)
set(ElfUtils_INCLUDE_DIRS
${_eu_inc_dirs}
CACHE PATH "elfutils include directory" FORCE)
set(ElfUtils_LIBRARY_DIRS
${_eu_lib_dirs}
CACHE PATH "elfutils library directory" FORCE)
set(ElfUtils_INCLUDE_DIR
${ElfUtils_INCLUDE_DIRS}
CACHE PATH "elfutils include directory" FORCE)
set(ElfUtils_LIBRARIES
${_eu_libs}
CACHE FILEPATH "elfutils library files" FORCE)
+8 -16
Ver fichero
@@ -15,6 +15,14 @@ rocprofiler_systems_add_interface_library(rocprofiler-systems-threading
rocprofiler_systems_add_interface_library(
rocprofiler-systems-dyninst
"Provides flags and libraries for Dyninst (dynamic instrumentation)")
rocprofiler_systems_add_interface_library(rocprofiler-systems-boost
"Boost interface library (for Dyninst)")
rocprofiler_systems_add_interface_library(rocprofiler-systems-elfutils
"ElfUtils interface library (for Dyninst)")
rocprofiler_systems_add_interface_library(rocprofiler-systems-libiberty
"LibIberty interface library (for Dyninst)")
rocprofiler_systems_add_interface_library(
rocprofiler-systems-tbb "Threading Building Blocks interface library (for Dyninst)")
rocprofiler_systems_add_interface_library(rocprofiler-systems-rocm
"Provides flags and libraries for ROCm")
rocprofiler_systems_add_interface_library(rocprofiler-systems-mpi
@@ -29,8 +37,6 @@ rocprofiler_systems_add_interface_library(rocprofiler-systems-papi "Enable PAPI
rocprofiler_systems_add_interface_library(rocprofiler-systems-ompt "Enable OMPT support")
rocprofiler_systems_add_interface_library(rocprofiler-systems-python
"Enables Python support")
rocprofiler_systems_add_interface_library(rocprofiler-systems-elfutils
"Provides ElfUtils")
rocprofiler_systems_add_interface_library(rocprofiler-systems-perfetto
"Enables Perfetto support")
rocprofiler_systems_add_interface_library(rocprofiler-systems-timemory
@@ -211,20 +217,6 @@ endif()
rocprofiler_systems_target_compile_definitions(
rocprofiler-systems-ompt INTERFACE ROCPROFSYS_USE_OMPT=$<BOOL:${ROCPROFSYS_USE_OMPT}>)
# ----------------------------------------------------------------------------------------#
#
# ElfUtils
#
# ----------------------------------------------------------------------------------------#
include(ElfUtils)
target_include_directories(rocprofiler-systems-elfutils SYSTEM
INTERFACE ${ElfUtils_INCLUDE_DIRS})
target_compile_definitions(rocprofiler-systems-elfutils INTERFACE ${ElfUtils_DEFINITIONS})
target_link_directories(rocprofiler-systems-elfutils INTERFACE ${ElfUtils_LIBRARY_DIRS})
target_link_libraries(rocprofiler-systems-elfutils INTERFACE ${ElfUtils_LIBRARIES})
# ----------------------------------------------------------------------------------------#
#
# Dyninst