Skip to content

Dyninst build - Refactor elfutils build folders #238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions cmake/ConfigCPack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 0 additions & 4 deletions cmake/DyninstBoost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
50 changes: 26 additions & 24 deletions cmake/DyninstElfUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -98,6 +95,7 @@ if(NOT BUILD_ELFUTILS)
endif()

# -------------- SOURCE BUILD -------------------------------------------------

if(LibElf_FOUND
AND LibDwarf_FOUND
AND (NOT ENABLE_DEBUGINFOD OR LibDebuginfod_FOUND))
Expand Down Expand Up @@ -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"
Expand All @@ -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 ---------------------------------------------
Expand All @@ -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}")
Expand Down
31 changes: 9 additions & 22 deletions cmake/DyninstExternals.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Expand All @@ -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}*")
12 changes: 3 additions & 9 deletions cmake/DyninstLibIberty.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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})
Expand All @@ -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")
Expand Down
10 changes: 6 additions & 4 deletions cmake/DyninstTBB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
144 changes: 0 additions & 144 deletions cmake/ElfUtils.cmake

This file was deleted.

Loading
Loading