Fix installation of precompiled kernels and bitcode files for multi-cononfig generators#61
Conversation
There was a problem hiding this comment.
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 underdist/bin/<config>/. - Add installation of the generated HIPRT bitcode (
*_amd_lib_<os>.bc) alongside the.hipfbartifacts.
💡 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.
| 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() |
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
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).
| 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) |
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=OFFcmake --build .\build\ --config Release --target installYou will get an error:
This pr is fixing this case and correctly populates the *.hipfb and *.bc files to bin folder.