Files
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

315 lines
11 KiB
CMake

# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
if(THEROCK_ENABLE_COMPILER)
if(NOT DEFINED THEROCK_BUILD_COMGR_TESTS)
set(THEROCK_BUILD_COMGR_TESTS ${THEROCK_BUILD_TESTING})
endif()
##############################################################################
# amd-llvm
# Everything built as part of LLVM installs to lib/llvm
# This includes the device-libs, since they must be findable by the compiler
# frontend.
##############################################################################
set(_extra_llvm_cmake_args)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
list(APPEND _extra_llvm_cmake_args "-DLLVM_ENABLE_PEDANTIC=OFF")
endif()
# Disable pre-compiled headers under clang as they cause conflicts related to
# differing optimization levels. This is a workaround.
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
list(APPEND _extra_llvm_cmake_args "-DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON")
endif()
# Building Flang is very memory-intensive on systems with many cores. Allow
# users to specify the level of concurrency for these tasks so they can
# reduce the risk of running out of memory.
if(FLANG_PARALLEL_COMPILE_JOBS)
message(STATUS "Flang build concurrency level set to ${FLANG_PARALLEL_COMPILE_JOBS}")
list(APPEND _extra_llvm_cmake_args "-DFLANG_PARALLEL_COMPILE_JOBS=${FLANG_PARALLEL_COMPILE_JOBS}")
else()
message(WARNING "Flang concurrency is unlimited. Memory usage may be much higher. Set -DFLANG_PARALLEL_COMPILE_JOBS to reduce memory use.")
endif()
# LLVM linking is also very memory intensive. Allow users to adjust the number
# of parallel link jobs.
if(LLVM_PARALLEL_LINK_JOBS)
message(STATUS "LLVM parallel link jobs set to ${LLVM_PARALLEL_LINK_JOBS}")
list(APPEND _extra_llvm_cmake_args "-DLLVM_PARALLEL_LINK_JOBS=${LLVM_PARALLEL_LINK_JOBS}")
else()
message(WARNING "LLVM parallel link jobs is unlimited. Memory usage may be much higher. Set -DLLVM_PARALLEL_LINK_JOBS to reduce memory use.")
endif()
# If the compiler is not pristine (i.e. has patches), then there will be a
# ".amd-llvm.smrev" file present which must be used instead of the auto
# computed git revision. If present, this will have a stable hash of
# revision plus applied patches suitable for run to run compiler
# fingerprinting.
set(LLVM_SMREV_FILE "${CMAKE_CURRENT_SOURCE_DIR}/.amd-llvm.smrev")
if(EXISTS "${LLVM_SMREV_FILE}")
file(STRINGS "${LLVM_SMREV_FILE}" LLVM_SMREV_LINES)
list(GET LLVM_SMREV_LINES 0 LLVM_SMREV_REPO)
list(GET LLVM_SMREV_LINES 1 LLVM_SMREV_REVISION)
message(STATUS "Using stable amd-llvm revision info: Repo='${LLVM_SMREV_REPO}', Revision='${LLVM_SMREV_REVISION}'")
endif()
therock_cmake_subproject_declare(amd-llvm
USE_DIST_AMDGPU_TARGETS
NO_INSTALL_RPATH # See manual handling in the pre_hook.
EXTERNAL_SOURCE_DIR "amd-llvm"
# Note that LLVM top level CMakeLists.txt is in the llvm subdir of the
# monorepo.
CMAKE_LISTS_RELPATH "llvm"
INTERFACE_PROGRAM_DIRS
lib/llvm/bin
CMAKE_ARGS
# Version configuration
# Note that if LLVM_SMREV_REPO and LLVM_FORCE_VC_REVISION are empty,
# LLVM will compute the tip of tree revision, which is appropriate for
# pristine checkouts.
-DLLVM_APPEND_VC_REV=ON
"-DLLVM_FORCE_VC_REPOSITORY=${LLVM_SMREV_REPO}"
"-DLLVM_FORCE_VC_REVISION=${LLVM_SMREV_REVISION}"
# LIBCXX
-DLIBCXX_ENABLE_SHARED=OFF
-DLIBCXX_ENABLE_STATIC=ON
-DLIBCXX_INSTALL_LIBRARY=OFF
-DLIBCXX_INSTALL_HEADERS=OFF
-DLIBCXXABI_ENABLE_SHARED=OFF
-DLIBCXXABI_ENABLE_STATIC=ON
# Features
-DLLVM_INCLUDE_TESTS=${THEROCK_ENABLE_LLVM_TESTS}
-DTHEROCK_BUILD_COMGR_TESTS=${THEROCK_BUILD_COMGR_TESTS}
-DUSE_NEW_HOSTCALL_IMPL=${THEROCK_USE_NEW_HOSTCALL_IMPL}
-DLLVM_ENABLE_ZLIB=FORCE_ON
-DLLVM_ENABLE_Z3_SOLVER=OFF
-DLLVM_ENABLE_LIBXML2=OFF
-DCLANG_DEFAULT_LINKER=lld
-DCLANG_DEFAULT_RTLIB=compiler-rt
-DCLANG_DEFAULT_UNWINDLIB=libgcc
-DCLANG_ENABLE_AMDCLANG=ON
-DLLVM_INSTALL_TOOLCHAIN_ONLY=OFF
-DLLVM_BUILD_LLVM_C_DYLIB=OFF
# Build optimizations
-DLLVM_BUILD_EXAMPLES=${THEROCK_ENABLE_LLVM_TESTS}
-DLLVM_INCLUDE_EXAMPLES=${THEROCK_ENABLE_LLVM_TESTS}
-DLLVM_TOOL_LLVM_JITLINK_BUILD=${THEROCK_ENABLE_LLVM_TESTS}
# Coverage tools (needed for code coverage builds)
-DLLVM_TOOL_LLVM_COV_BUILD=ON
-DLLVM_TOOL_LLVM_PROFDATA_BUILD=ON
# Clang features.
-DCLANG_ENABLE_ARCMT=OFF
-DCLANG_ENABLE_STATIC_ANALYZER=OFF
-DCLANG_ENABLE_CLANGD=OFF
-DCLANG_TIDY_ENABLE_STATIC_ANALYZER=OFF
-DCLANG_TOOL_CLANG_LINKER_WRAPPER_BUILD=${THEROCK_CONDITION_IS_NON_WINDOWS}
-DOPENMP_ENABLE_LIBOMPTARGET=${THEROCK_CONDITION_IS_NON_WINDOWS}
-DLIBOMPTARGET_BUILD_DEVICE_FORTRT=${THEROCK_CONDITION_IS_NON_WINDOWS}
-DOFFLOAD_EXTERNAL_PROJECT_UNIFIED_ROCR=${THEROCK_CONDITION_IS_NON_WINDOWS}
-DLIBOMPTARGET_EXTERNAL_PROJECT_HSA_PATH=${THEROCK_ROCM_SYSTEMS_SOURCE_DIR}/projects/rocr-runtime
-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath
-DRUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${THEROCK_CONDITION_IS_NON_WINDOWS}
-DRUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES=openmp
# ASAN features.
# Note that building AMDGPU ASAN extensions depends on various runtime headers
# (since it instruments them). These paths must line up and will be an error
# in the compiler-rt build if not found.
"-DSANITIZER_AMDGPU=${THEROCK_CONDITION_IS_NON_WINDOWS}"
"-DSANITIZER_HSA_INCLUDE_PATH=${THEROCK_ROCM_SYSTEMS_SOURCE_DIR}/projects/rocr-runtime/runtime/hsa-runtime/inc"
"-DSANITIZER_COMGR_INCLUDE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/amd-llvm/amd/comgr/include"
# ASAN
-DTHEROCK_SANITIZER=${THEROCK_SANITIZER}
# compiler-rt debug mode
"-DCOMPILER_RT_DEBUG=${THEROCK_COMPILER_RT_DEBUG}"
${_extra_llvm_cmake_args}
BUILD_DEPS
rocm-cmake
RUNTIME_DEPS
${THEROCK_BUNDLED_ZLIB}
${THEROCK_BUNDLED_ZSTD}
${THEROCK_BUNDLED_NUMACTL}
${THEROCK_BUNDLED_ELFUTILS}
${THEROCK_BUNDLED_LIBDRM}
# The entire LLVM install tree is placed inside of the overall ROCM lib/llvm
# directory.
INSTALL_DESTINATION "lib/llvm"
INTERFACE_LINK_DIRS
"lib/llvm/lib"
INTERFACE_INSTALL_RPATH_DIRS
"lib/llvm/lib"
)
# LLVM is too large to glob by default; opt in with THEROCK_DEV_PROJECTS.
if(THEROCK_DEV_PROJECTS AND "amd-llvm" IN_LIST THEROCK_DEV_PROJECTS)
therock_cmake_subproject_glob_c_sources(amd-llvm SUBDIRS .)
endif()
therock_cmake_subproject_provide_package(amd-llvm AMDDeviceLibs lib/llvm/lib/cmake/AMDDeviceLibs)
therock_cmake_subproject_provide_package(amd-llvm Clang lib/llvm/lib/cmake/clang)
therock_cmake_subproject_provide_package(amd-llvm LLD lib/llvm/lib/cmake/lld)
therock_cmake_subproject_provide_package(amd-llvm LLVM lib/llvm/lib/cmake/llvm)
therock_cmake_subproject_activate(amd-llvm)
# Comgr's gtest suite needs a googletest provider. therock-googletest is
# declared before compiler/ (see the root CMakeLists.txt) so amd-comgr can
# depend on the single shared instance rather than a compiler-local copy.
set(_comgr_gtest_deps)
if(THEROCK_BUILD_COMGR_TESTS)
set(_comgr_gtest_deps therock-googletest)
endif()
##############################################################################
# amd-comgr
# A client of libLLVM which provides an in-process compiler API to the HIP
# runtime. LLVM/Clang/LLD are statically linked and hidden behind comgr's
# version script, avoiding symbol interposition issues.
##############################################################################
set(_comgr_hotswap_cmake_args)
if(THEROCK_ENABLE_HOTSWAP)
list(APPEND _comgr_hotswap_cmake_args -DCOMGR_ENABLE_HOTSWAP_TRANSPILE=ON)
if(NOT WIN32)
list(APPEND _comgr_hotswap_cmake_args
-DHOTSWAP_BUILD_TOOL=ON
"-DHOTSWAP_TOOL_HSA_INCLUDE_ROOT=${THEROCK_ROCM_SYSTEMS_SOURCE_DIR}/projects/rocr-runtime/runtime/hsa-runtime")
endif()
endif()
therock_cmake_subproject_declare(amd-comgr
USE_DIST_AMDGPU_TARGETS
NO_INSTALL_RPATH # See manual handling in the pre_hook.
EXTERNAL_SOURCE_DIR "amd-llvm/amd/comgr"
BINARY_DIR "amd-comgr"
BACKGROUND_BUILD
CMAKE_ARGS
# Statically link LLVM/Clang into comgr. Combined with comgr's
# -fvisibility=hidden and version script (local: *;), this hides all LLVM
# symbols inside libamd_comgr.so, preventing symbol interposition without
# requiring namespace isolation via dlmopen.
-DCOMGR_STATIC_LLVM=ON
-DTHEROCK_BUILD_COMGR_TESTS=${THEROCK_BUILD_COMGR_TESTS}
"-DLLVM_VERSION_SUFFIX=-rocm${ROCM_MAJOR_VERSION}"
-DLLVM_ENABLE_SYMBOL_VERSIONING=ON
${_comgr_hotswap_cmake_args}
BUILD_DEPS
rocm-cmake
${_comgr_gtest_deps}
RUNTIME_DEPS
amd-llvm
${THEROCK_BUNDLED_ZSTD}
INTERFACE_LINK_DIRS
"lib"
INTERFACE_INSTALL_RPATH_DIRS
"lib"
)
therock_cmake_subproject_provide_package(amd-comgr amd_comgr lib/cmake/amd_comgr)
therock_cmake_subproject_activate(amd-comgr)
if(THEROCK_BUILD_COMGR_TESTS)
if(WIN32)
set(_llvm_lit_script "${CMAKE_BINARY_DIR}/compiler/amd-llvm/build/bin/llvm-lit.py")
else()
set(_llvm_lit_script "${CMAKE_BINARY_DIR}/compiler/amd-llvm/build/bin/llvm-lit")
endif()
therock_cmake_subproject_build_test(amd-comgr
COMMAND
"${Python3_EXECUTABLE}" "${_llvm_lit_script}"
"${CMAKE_BINARY_DIR}/compiler/amd-comgr/build/test-lit" -v
COMMAND
"${CMAKE_CTEST_COMMAND}"
--test-dir "${CMAKE_BINARY_DIR}/compiler/amd-comgr/build"
--output-on-failure
COMMAND
"${CMAKE_COMMAND}"
--build "${CMAKE_BINARY_DIR}/compiler/amd-comgr/build"
--target test-unit
)
endif()
therock_test_validate_shared_lib(
PATH amd-comgr/dist/lib
LIB_NAMES
libamd_comgr.so
)
##############################################################################
# hipcc
# Provides hipcc and hipconfig
##############################################################################
therock_cmake_subproject_declare(hipcc
USE_DIST_AMDGPU_TARGETS
EXTERNAL_SOURCE_DIR "amd-llvm/amd/hipcc"
BINARY_DIR "hipcc"
BACKGROUND_BUILD
CMAKE_ARGS
-DHIPCC_BACKWARD_COMPATIBILITY=OFF
BUILD_DEPS
rocm-cmake
RUNTIME_DEPS
amd-llvm
)
therock_cmake_subproject_activate(hipcc)
therock_provide_artifact(amd-llvm
TARGET_NEUTRAL
DESCRIPTOR artifact-amd-llvm.toml
COMPONENTS
dbg
dev
doc
lib
run
SUBPROJECT_DEPS
amd-llvm
hipcc
amd-comgr
)
endif(THEROCK_ENABLE_COMPILER)
if(THEROCK_ENABLE_HIPIFY)
##############################################################################
# HIPIFY
##############################################################################
therock_cmake_subproject_declare(hipify
USE_DIST_AMDGPU_TARGETS
NO_INSTALL_RPATH # See manual handling in the pre_hook.
EXTERNAL_SOURCE_DIR "hipify"
BACKGROUND_BUILD
INTERFACE_PROGRAM_DIRS
bin
CMAKE_ARGS
-DHIPIFY_INSTALL_CLANG_HEADERS=OFF
BUILD_DEPS
rocm-cmake
RUNTIME_DEPS
amd-llvm
)
therock_cmake_subproject_glob_c_sources(hipify
SUBDIRS
src
)
therock_cmake_subproject_activate(hipify)
therock_provide_artifact(hipify
TARGET_NEUTRAL
DESCRIPTOR artifact-hipify.toml
COMPONENTS
run
dbg
SUBPROJECT_DEPS
hipify
)
endif(THEROCK_ENABLE_HIPIFY)