Skip to content

Fix installation of precompiled kernels and bitcode files for multi-cononfig generators#61

Open
jpola-amd wants to merge 1 commit intoGPUOpen-LibrariesAndSDKs:mainfrom
jpola-amd:jpola/dev/cmake-install-fix
Open

Fix installation of precompiled kernels and bitcode files for multi-cononfig generators#61
jpola-amd wants to merge 1 commit intoGPUOpen-LibrariesAndSDKs:mainfrom
jpola-amd:jpola/dev/cmake-install-fix

Conversation

@jpola-amd
Copy link
Contributor

In case of relying on CMake to generate the HIPRT project the installation step fails when trying to populate the precompiled device codes. In example:

cmake -B build -S . -DCMAKE_INSTALL_PREFIX="./install" -DPRECOMPILE=ON -DBITCODE=ON -DCOMPILED_COMPRESSION=OFF -DFORCE_DISABLE_CUDA=ON -DNO_UNITTEST=OFF

cmake --build .\build\ --config Release --target install

You will get an error:

  CMake Error at cmake_install.cmake:138 (file):
    file INSTALL cannot find
    "E:/sandbox/HIPRT/dist/bin//hiprt03001_7.1_amd.hipfb": No error.

This pr is fixing this case and correctly populates the *.hipfb and *.bc files to bin folder.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes installation of precompiled HIPRT kernel artifacts when using multi-config CMake generators (e.g., Visual Studio), where install() previously referenced paths containing an empty ${CMAKE_BUILD_TYPE} segment.

Changes:

  • Adjust install() logic for precompiled kernels to select config-specific output folders under dist/bin/<config>/.
  • Add installation of the generated HIPRT bitcode (*_amd_lib_<os>.bc) alongside the .hipfb artifacts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +635 to +645
if(CMAKE_CONFIGURATION_TYPES)
# Multi-config generators (e.g. Visual Studio): install from the selected config output folder.
get_filename_component(KERNEL_OROCHI_COMP_NAME "${KERNEL_OROCHI_COMP}" NAME)

install(FILES "${BASE_OUTPUT_DIR}/Debug/${KERNEL_HIPRT_COMP_NAME}" "${BASE_OUTPUT_DIR}/Debug/${KERNEL_OROCHI_COMP_NAME}" "${BASE_OUTPUT_DIR}/Debug/${KERNEL_HIPRT_BC_NAME}"
DESTINATION bin
CONFIGURATIONS Debug)
install(FILES "${BASE_OUTPUT_DIR}/Release/${KERNEL_HIPRT_COMP_NAME}" "${BASE_OUTPUT_DIR}/Release/${KERNEL_OROCHI_COMP_NAME}" "${BASE_OUTPUT_DIR}/Release/${KERNEL_HIPRT_BC_NAME}"
DESTINATION bin
CONFIGURATIONS Release RelWithDebInfo MinSizeRel)
else()
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMAKE_CONFIGURATION_TYPES is set to include DebugGpu earlier in this file, but the multi-config install rules here only cover Debug and Release/RelWithDebInfo/MinSizeRel. As a result, cmake --build ... --config DebugGpu --target install would skip installing the precompiled .hipfb/.bc artifacts. Add an install(... CONFIGURATIONS DebugGpu ...) rule (mapping to the correct output folder) or remove/rename the unused configuration to avoid a broken install for that config.

Copilot uses AI. Check for mistakes.
CONFIGURATIONS Debug)
install(FILES "${BASE_OUTPUT_DIR}/Release/${KERNEL_HIPRT_COMP_NAME}" "${BASE_OUTPUT_DIR}/Release/${KERNEL_OROCHI_COMP_NAME}" "${BASE_OUTPUT_DIR}/Release/${KERNEL_HIPRT_BC_NAME}"
DESTINATION bin
CONFIGURATIONS Release RelWithDebInfo MinSizeRel)
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says this installs “from the selected config output folder”, but the Release folder is used for RelWithDebInfo and MinSizeRel as well. Either adjust the logic to install from ${BASE_OUTPUT_DIR}/RelWithDebInfo and ${BASE_OUTPUT_DIR}/MinSizeRel (consistent with the output-dir setup earlier), or update the comment to explain why those configs intentionally reuse the Release artifacts (e.g., because compile.py only emits into Debug/Release).

Suggested change
CONFIGURATIONS Release RelWithDebInfo MinSizeRel)
CONFIGURATIONS Release)
install(FILES "${BASE_OUTPUT_DIR}/RelWithDebInfo/${KERNEL_HIPRT_COMP_NAME}" "${BASE_OUTPUT_DIR}/RelWithDebInfo/${KERNEL_OROCHI_COMP_NAME}" "${BASE_OUTPUT_DIR}/RelWithDebInfo/${KERNEL_HIPRT_BC_NAME}"
DESTINATION bin
CONFIGURATIONS RelWithDebInfo)
install(FILES "${BASE_OUTPUT_DIR}/MinSizeRel/${KERNEL_HIPRT_COMP_NAME}" "${BASE_OUTPUT_DIR}/MinSizeRel/${KERNEL_OROCHI_COMP_NAME}" "${BASE_OUTPUT_DIR}/MinSizeRel/${KERNEL_HIPRT_BC_NAME}"
DESTINATION bin
CONFIGURATIONS MinSizeRel)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants