CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
149 lines
6.1 KiB
CMake
149 lines
6.1 KiB
CMake
# ======================================================================================
|
|
# binutils.cmake
|
|
#
|
|
# Configure binutils for Dyninst
|
|
#
|
|
# ----------------------------------------
|
|
#
|
|
# Directly exports the following CMake variables
|
|
#
|
|
# binutils_ROOT_DIR - Computed base directory the of binutils installation
|
|
# binutils_LIBRARY_DIRS - Link directories for binutils libraries binutils_LIBRARIES
|
|
# - binutils library files binutils_INCLUDE - binutils include files
|
|
#
|
|
# NOTE: The exported binutils_ROOT_DIR can be different from the value provided by the
|
|
# user in the case that it is determined to build binutils from source. In such a case,
|
|
# binutils_ROOT_DIR will contain the directory of the from-source installation.
|
|
#
|
|
# See Modules/Findbinutils.cmake for details
|
|
#
|
|
# ======================================================================================
|
|
|
|
include_guard(GLOBAL)
|
|
|
|
set(TPL_STAGING_PREFIX ${PROJECT_BINARY_DIR}/external/tpls)
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${TPL_STAGING_PREFIX}/lib)
|
|
|
|
# always provide Dyninst::binutils even if it is empty
|
|
add_library(binutils::binutils IMPORTED INTERFACE)
|
|
|
|
if(NOT UNIX)
|
|
return()
|
|
endif()
|
|
|
|
timemory_message(STATUS "Attempting to build binutils as external project")
|
|
|
|
file(GLOB_RECURSE _TIMEMORY_BINUTILS_BUILD_BYPRODUCTS_GLOB
|
|
${PROJECT_BINARY_DIR}/external/binutils/src/binutils-external/*.o
|
|
${PROJECT_BINARY_DIR}/external/binutils/src/binutils-external/*.a)
|
|
|
|
set(_TIMEMORY_BINUTILS_BUILD_BYPRODUCTS
|
|
${_TIMEMORY_BINUTILS_BUILD_BYPRODUCTS_GLOB})
|
|
|
|
foreach(
|
|
_FILE
|
|
${PROJECT_BINARY_DIR}/external/binutils/src/binutils-external/opcodes/libopcodes.a
|
|
${PROJECT_BINARY_DIR}/external/binutils/src/binutils-external/opcodes/.libs/libopcodes.a
|
|
${PROJECT_BINARY_DIR}/external/binutils/src/binutils-external/libsframe/.libs/libsframe.a
|
|
${PROJECT_BINARY_DIR}/external/binutils/src/binutils-external/bfd/.libs/libbfd.a
|
|
${PROJECT_BINARY_DIR}/external/binutils/src/binutils-external/libiberty/libiberty.a)
|
|
if(NOT "${_FILE}" IN_LIST _TIMEMORY_BINUTILS_BUILD_BYPRODUCTS)
|
|
list(APPEND _TIMEMORY_BINUTILS_BUILD_BYPRODUCTS ${_FILE})
|
|
endif()
|
|
endforeach()
|
|
|
|
find_program(
|
|
MAKE_COMMAND
|
|
NAMES make gmake
|
|
PATH_SUFFIXES bin REQUIRED)
|
|
|
|
# bfd can invoke makeinfo; use a no-op so Texinfo is not required for static libs.
|
|
find_program(_TIMEMORY_BINUTILS_MAKEINFO_NOOP NAMES true)
|
|
if(NOT _TIMEMORY_BINUTILS_MAKEINFO_NOOP)
|
|
set(_TIMEMORY_BINUTILS_MAKEINFO_NOOP /usr/bin/true)
|
|
endif()
|
|
|
|
set(binutils_CONFIG_FLAGS
|
|
"--with-system-zlib=yes --without-zstd"
|
|
CACHE STRING "Extra config flags for binutils")
|
|
mark_as_advanced(binutils_CONFIG_FLAGS)
|
|
|
|
# needed for configure command
|
|
string(REPLACE " " ";" _binutils_CONFIG_FLAGS "${binutils_CONFIG_FLAGS}")
|
|
|
|
include(ExternalProject)
|
|
externalproject_add(
|
|
binutils-external
|
|
PREFIX ${PROJECT_BINARY_DIR}/external/binutils
|
|
URL ${TIMEMORY_BINUTILS_DOWNLOAD_URL}
|
|
https://ftpmirror.gnu.org/gnu/binutils/binutils-2.46.0.tar.gz
|
|
https://mirrors.kernel.org/sourceware/binutils/releases/binutils-2.46.0.tar.gz
|
|
BUILD_IN_SOURCE 1
|
|
CONFIGURE_COMMAND
|
|
${CMAKE_COMMAND} -E env CC=${CMAKE_C_COMPILER}
|
|
CFLAGS=-fPIC\ -O3\ -Wno-error
|
|
CXX=${CMAKE_CXX_COMPILER}
|
|
CXXFLAGS=-fPIC\ -O3\ -Wno-error
|
|
MAKEINFO=${_TIMEMORY_BINUTILS_MAKEINFO_NOOP}
|
|
<SOURCE_DIR>/configure --prefix=${TPL_STAGING_PREFIX} ${_binutils_CONFIG_FLAGS}
|
|
BUILD_COMMAND
|
|
${MAKE_COMMAND} MAKEINFO=${_TIMEMORY_BINUTILS_MAKEINFO_NOOP} all-libiberty all-bfd
|
|
all-opcodes all-libsframe
|
|
INSTALL_COMMAND ""
|
|
CONFIGURE_HANDLED_BY_BUILD TRUE
|
|
BUILD_BYPRODUCTS "${_TIMEMORY_BINUTILS_BUILD_BYPRODUCTS}")
|
|
|
|
add_custom_command(
|
|
OUTPUT ${TPL_STAGING_PREFIX}/lib/libbfd.a ${TPL_STAGING_PREFIX}/lib/libopcodes.a
|
|
${TPL_STAGING_PREFIX}/lib/libiberty.a ${TPL_STAGING_PREFIX}/lib/libsframe.a
|
|
COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${TPL_STAGING_PREFIX}/lib
|
|
COMMAND
|
|
install ARGS -C
|
|
${PROJECT_BINARY_DIR}/external/binutils/src/binutils-external/bfd/.libs/libbfd.a
|
|
${PROJECT_BINARY_DIR}/external/binutils/src/binutils-external/opcodes/libopcodes.a
|
|
${PROJECT_BINARY_DIR}/external/binutils/src/binutils-external/libiberty/libiberty.a
|
|
${PROJECT_BINARY_DIR}/external/binutils/src/binutils-external/libsframe/.libs/libsframe.a
|
|
${TPL_STAGING_PREFIX}/lib/
|
|
DEPENDS binutils-external
|
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/external/binutils/src/binutils-external
|
|
COMMENT "Installing binutils...")
|
|
|
|
add_custom_target(binutils-install ALL DEPENDS
|
|
${TPL_STAGING_PREFIX}/lib/libbfd.a
|
|
${TPL_STAGING_PREFIX}/lib/libopcodes.a
|
|
${TPL_STAGING_PREFIX}/lib/libiberty.a
|
|
${TPL_STAGING_PREFIX}/lib/libsframe.a)
|
|
|
|
foreach(_NAME bfd opcodes iberty sframe)
|
|
set(_FILE
|
|
${TPL_STAGING_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}
|
|
)
|
|
|
|
add_library(binutils::${_NAME}-library STATIC IMPORTED)
|
|
set_property(TARGET binutils::${_NAME}-library PROPERTY IMPORTED_LOCATION ${_FILE})
|
|
add_dependencies(binutils::${_NAME}-library binutils-install)
|
|
endforeach()
|
|
|
|
find_package(ZLIB)
|
|
|
|
target_include_directories(
|
|
binutils::binutils
|
|
INTERFACE
|
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/external/binutils/src/binutils-external>
|
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/external/binutils/src/binutils-external/include>
|
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/external/binutils/src/binutils-external/bfd>
|
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/external/binutils/src/binutils-external/opcodes>
|
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/external/binutils/src/binutils-external/libiberty>
|
|
)
|
|
target_link_libraries(
|
|
binutils::binutils
|
|
INTERFACE $<BUILD_INTERFACE:binutils::bfd-library>
|
|
$<BUILD_INTERFACE:binutils::iberty-library>
|
|
$<BUILD_INTERFACE:binutils::opcodes-library>
|
|
$<BUILD_INTERFACE:binutils::sframe-library>
|
|
$<BUILD_INTERFACE:$<IF:$<TARGET_EXISTS:ZLIB::ZLIB>,ZLIB::ZLIB,z>>
|
|
$<BUILD_INTERFACE:${CMAKE_DL_LIBS}>)
|
|
|
|
unset(_TIMEMORY_BINUTILS_BUILD_BYPRODUCTS)
|
|
unset(_TIMEMORY_BINUTILS_MAKEINFO_NOOP)
|