From 44892f44dd05808c0c12d622ca2e723aba363b7d Mon Sep 17 00:00:00 2001 From: Kunwar Grover Date: Mon, 27 Jul 2026 01:03:26 +0100 Subject: [PATCH 1/6] feat(rocjitsu): package HSA hotswap hook with runtime Publish libhsa_hotswap_rocjitsu.so as a dedicated rocjitsu artifact component. ROCr's HSA_HOTSWAP_ENABLE=2 mode requires this library, so the HSA hotswap hook must be included in runtime distributions. Keeping it as an independently selectable component lets runtime packages ship the HSA hotswap hook without pulling in the general librocjitsu shared library or introducing a ROCr build or link dependency. The currently validated unstripped shared library is 5,996,136 bytes (approximately 5.72 MiB). Include the component in the rocm-sdk-core wheel, the amdrocm-runtime native package, and base artifact installations. Validate the staged shared library and add focused coverage for wheel selection and base artifact retrieval. --- build_tools/build_python_packages.py | 3 ++- build_tools/install_rocm_from_artifacts.py | 1 + build_tools/packaging/linux/package.json | 11 +++++++++++ .../tests/install_rocm_from_artifacts_test.py | 4 ++++ build_tools/tests/py_packaging_test.py | 17 +++++++++++++++++ emulation/CMakeLists.txt | 7 +++++++ emulation/artifact-rocjitsu.toml | 7 +++++++ 7 files changed, 49 insertions(+), 1 deletion(-) diff --git a/build_tools/build_python_packages.py b/build_tools/build_python_packages.py index 5f9738e6953..c633d2adb5c 100755 --- a/build_tools/build_python_packages.py +++ b/build_tools/build_python_packages.py @@ -520,12 +520,13 @@ def core_artifact_filter(an: ArtifactName) -> bool: "lib", "run", ] + hotswap = an.name == "rocjitsu" and an.component == "hotswap" # hiprtc needs to be able to find HIP headers in its same tree. hip_dev = an.name in [ "core-hip", "core-ocl", ] and an.component in ["dev"] - return core or hip_dev + return core or hotswap or hip_dev def libraries_artifact_filter(target_family: str, an: ArtifactName) -> bool: diff --git a/build_tools/install_rocm_from_artifacts.py b/build_tools/install_rocm_from_artifacts.py index 965ff7dce2c..02b5e1f87c2 100644 --- a/build_tools/install_rocm_from_artifacts.py +++ b/build_tools/install_rocm_from_artifacts.py @@ -350,6 +350,7 @@ def retrieve_artifacts_by_run_id(args): "core-hipinfo_run", "core-runtime_run", "core-runtime_lib", + "rocjitsu_hotswap", "sysdeps_lib", "base_run", "base_lib", diff --git a/build_tools/packaging/linux/package.json b/build_tools/packaging/linux/package.json index 3106b41436c..ed44fd19cc7 100644 --- a/build_tools/packaging/linux/package.json +++ b/build_tools/packaging/linux/package.json @@ -214,6 +214,17 @@ } ] }, + { + "Artifact": "rocjitsu", + "Artifact_Subdir": [ + { + "Name": "rocjitsu", + "Components": [ + "hotswap" + ] + } + ] + }, { "Artifact": "core-hip", "Artifact_Subdir": [ diff --git a/build_tools/tests/install_rocm_from_artifacts_test.py b/build_tools/tests/install_rocm_from_artifacts_test.py index 301fc5a06d8..d95337b7b69 100644 --- a/build_tools/tests/install_rocm_from_artifacts_test.py +++ b/build_tools/tests/install_rocm_from_artifacts_test.py @@ -68,6 +68,10 @@ def test_mirage_flag_includes_mirage_run(self): argv = self._run_main(["--mirage"]) self.assertIn("mirage_run", argv) + def test_base_only_includes_rocjitsu_hotswap(self): + argv = self._run_main(["--base-only"]) + self.assertIn("rocjitsu_hotswap", argv) + class TestReleaseDiscovery(unittest.TestCase): def test_extract_version_ignores_test_tarball(self) -> None: diff --git a/build_tools/tests/py_packaging_test.py b/build_tools/tests/py_packaging_test.py index fbaf5a7825b..6d1251274df 100644 --- a/build_tools/tests/py_packaging_test.py +++ b/build_tools/tests/py_packaging_test.py @@ -657,6 +657,23 @@ def test_device_artifact_filter(self): an_core = ArtifactName("core-hip", "lib", "gfx942") self.assertFalse(device_artifact_filter("gfx942", an_core)) + def test_core_artifact_filter_includes_only_rocjitsu_hotswap(self): + """The core wheel ships the HSA hotswap hook without the rocjitsu library.""" + sys.path.insert(0, os.fspath(Path(__file__).parent.parent)) + from build_python_packages import core_artifact_filter + + from _therock_utils.artifacts import ArtifactName + + self.assertTrue( + core_artifact_filter(ArtifactName("rocjitsu", "hotswap", "generic")) + ) + self.assertFalse( + core_artifact_filter(ArtifactName("rocjitsu", "lib", "generic")) + ) + self.assertFalse( + core_artifact_filter(ArtifactName("rocjitsu", "run", "generic")) + ) + def test_device_dist_info_has_libraries_py_package_name(self): """Device package _dist_info.py must contain LIBRARIES_PY_PACKAGE_NAME.""" artifact_dir = self._setup_kpack_split_artifacts() diff --git a/emulation/CMakeLists.txt b/emulation/CMakeLists.txt index f228a97c7f7..cb5bbbf1243 100644 --- a/emulation/CMakeLists.txt +++ b/emulation/CMakeLists.txt @@ -40,6 +40,12 @@ if(THEROCK_ENABLE_ROCJITSU) LIB_NAMES librocjitsu.so ) + if(NOT WIN32) + therock_test_validate_shared_lib(PATH rocjitsu/dist/lib + LIB_NAMES + libhsa_hotswap_rocjitsu.so + ) + endif() therock_provide_artifact(rocjitsu TARGET_NEUTRAL @@ -47,6 +53,7 @@ if(THEROCK_ENABLE_ROCJITSU) COMPONENTS dbg dev + hotswap lib run SUBPROJECT_DEPS diff --git a/emulation/artifact-rocjitsu.toml b/emulation/artifact-rocjitsu.toml index f7f4ea9e53f..7f80126a8bf 100644 --- a/emulation/artifact-rocjitsu.toml +++ b/emulation/artifact-rocjitsu.toml @@ -4,6 +4,13 @@ default_patterns = false include = [ "lib/librocjitsu.so", ] +# Keep the HSA hotswap hook independently selectable so runtime packages can +# ship it without also shipping the general rocjitsu shared library. +[components.hotswap."emulation/rocjitsu/stage"] +default_patterns = false +include = [ + "lib/libhsa_hotswap_rocjitsu.so", +] [components.dbg."emulation/rocjitsu/stage"] [components.dev."emulation/rocjitsu/stage"] [components.run."emulation/rocjitsu/stage"] From 32ef0f3f3d3b56db5c16eeceb0f717cdd0f75c7e Mon Sep 17 00:00:00 2001 From: "Rosa, Ada" Date: Mon, 27 Jul 2026 16:49:58 +0000 Subject: [PATCH 2/6] feat(rocjitsu): made rocjitsu-hotswap it's own artifact --- BUILD_TOPOLOGY.toml | 7 +++++ build_tools/build_python_packages.py | 2 +- build_tools/install_rocm_from_artifacts.py | 2 +- build_tools/packaging/linux/package.json | 6 ++--- .../tests/install_rocm_from_artifacts_test.py | 2 +- build_tools/tests/py_packaging_test.py | 2 +- emulation/CMakeLists.txt | 27 +++++++++++++++++-- emulation/artifact-rocjitsu-hotswap.toml | 6 +++++ emulation/artifact-rocjitsu.toml | 7 ----- emulation/rocjitsu-hotswap/CMakeLists.txt | 19 +++++++++++++ 10 files changed, 64 insertions(+), 16 deletions(-) create mode 100644 emulation/artifact-rocjitsu-hotswap.toml create mode 100644 emulation/rocjitsu-hotswap/CMakeLists.txt diff --git a/BUILD_TOPOLOGY.toml b/BUILD_TOPOLOGY.toml index 620f2afd558..dc403882ace 100644 --- a/BUILD_TOPOLOGY.toml +++ b/BUILD_TOPOLOGY.toml @@ -819,6 +819,13 @@ artifact_deps = [] feature_group = "EMULATION" disable_platforms = ["windows"] +[artifacts.rocjitsu-hotswap] +artifact_group = "rocjitsu" +type = "target-neutral" +artifact_deps = ["rocjitsu"] +feature_group = "EMULATION" +disable_platforms = ["windows"] + [artifacts.mirage] artifact_group = "rocjitsu" type = "target-neutral" diff --git a/build_tools/build_python_packages.py b/build_tools/build_python_packages.py index c633d2adb5c..ed6b4c94a87 100755 --- a/build_tools/build_python_packages.py +++ b/build_tools/build_python_packages.py @@ -520,7 +520,7 @@ def core_artifact_filter(an: ArtifactName) -> bool: "lib", "run", ] - hotswap = an.name == "rocjitsu" and an.component == "hotswap" + hotswap = an.name == "rocjitsu-hotswap" and an.component == "lib" # hiprtc needs to be able to find HIP headers in its same tree. hip_dev = an.name in [ "core-hip", diff --git a/build_tools/install_rocm_from_artifacts.py b/build_tools/install_rocm_from_artifacts.py index 02b5e1f87c2..b2d8794bde0 100644 --- a/build_tools/install_rocm_from_artifacts.py +++ b/build_tools/install_rocm_from_artifacts.py @@ -350,7 +350,7 @@ def retrieve_artifacts_by_run_id(args): "core-hipinfo_run", "core-runtime_run", "core-runtime_lib", - "rocjitsu_hotswap", + "rocjitsu-hotswap_lib", "sysdeps_lib", "base_run", "base_lib", diff --git a/build_tools/packaging/linux/package.json b/build_tools/packaging/linux/package.json index ed44fd19cc7..b8ce4982038 100644 --- a/build_tools/packaging/linux/package.json +++ b/build_tools/packaging/linux/package.json @@ -215,12 +215,12 @@ ] }, { - "Artifact": "rocjitsu", + "Artifact": "rocjitsu-hotswap", "Artifact_Subdir": [ { - "Name": "rocjitsu", + "Name": "rocjitsu-hotswap", "Components": [ - "hotswap" + "lib" ] } ] diff --git a/build_tools/tests/install_rocm_from_artifacts_test.py b/build_tools/tests/install_rocm_from_artifacts_test.py index d95337b7b69..67e153ecfc2 100644 --- a/build_tools/tests/install_rocm_from_artifacts_test.py +++ b/build_tools/tests/install_rocm_from_artifacts_test.py @@ -70,7 +70,7 @@ def test_mirage_flag_includes_mirage_run(self): def test_base_only_includes_rocjitsu_hotswap(self): argv = self._run_main(["--base-only"]) - self.assertIn("rocjitsu_hotswap", argv) + self.assertIn("rocjitsu-hotswap_lib", argv) class TestReleaseDiscovery(unittest.TestCase): diff --git a/build_tools/tests/py_packaging_test.py b/build_tools/tests/py_packaging_test.py index 6d1251274df..0744ae6ff6c 100644 --- a/build_tools/tests/py_packaging_test.py +++ b/build_tools/tests/py_packaging_test.py @@ -665,7 +665,7 @@ def test_core_artifact_filter_includes_only_rocjitsu_hotswap(self): from _therock_utils.artifacts import ArtifactName self.assertTrue( - core_artifact_filter(ArtifactName("rocjitsu", "hotswap", "generic")) + core_artifact_filter(ArtifactName("rocjitsu-hotswap", "lib", "generic")) ) self.assertFalse( core_artifact_filter(ArtifactName("rocjitsu", "lib", "generic")) diff --git a/emulation/CMakeLists.txt b/emulation/CMakeLists.txt index cb5bbbf1243..3de2a811bf0 100644 --- a/emulation/CMakeLists.txt +++ b/emulation/CMakeLists.txt @@ -43,7 +43,7 @@ if(THEROCK_ENABLE_ROCJITSU) if(NOT WIN32) therock_test_validate_shared_lib(PATH rocjitsu/dist/lib LIB_NAMES - libhsa_hotswap_rocjitsu.so + librocjitsu_hooks.so ) endif() @@ -53,12 +53,35 @@ if(THEROCK_ENABLE_ROCJITSU) COMPONENTS dbg dev - hotswap lib run SUBPROJECT_DEPS rocjitsu ) + + if(THEROCK_ENABLE_ROCJITSU_HOTSWAP) + therock_cmake_subproject_declare(rocjitsu-hotswap + DISABLE_AMDGPU_TARGETS + NO_MERGE_COMPILE_COMMANDS + EXTERNAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/rocjitsu-hotswap" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/rocjitsu-hotswap" + CMAKE_ARGS + -DROCJITSU_HOTSWAP_LIBRARY=${CMAKE_CURRENT_BINARY_DIR}/rocjitsu/stage/lib/librocjitsu_hooks.so + BUILD_DEPS + rocjitsu + ) + + therock_cmake_subproject_activate(rocjitsu-hotswap) + + therock_provide_artifact(rocjitsu-hotswap + TARGET_NEUTRAL + DESCRIPTOR artifact-rocjitsu-hotswap.toml + COMPONENTS + lib + SUBPROJECT_DEPS + rocjitsu-hotswap + ) + endif() endif() if(THEROCK_ENABLE_MIRAGE) diff --git a/emulation/artifact-rocjitsu-hotswap.toml b/emulation/artifact-rocjitsu-hotswap.toml new file mode 100644 index 00000000000..840eaebb9cb --- /dev/null +++ b/emulation/artifact-rocjitsu-hotswap.toml @@ -0,0 +1,6 @@ +# rocjitsu HSA hotswap hook +[components.lib."emulation/rocjitsu-hotswap/stage"] +default_patterns = false +include = [ + "lib/librocjitsu_hooks.so", +] diff --git a/emulation/artifact-rocjitsu.toml b/emulation/artifact-rocjitsu.toml index 7f80126a8bf..f7f4ea9e53f 100644 --- a/emulation/artifact-rocjitsu.toml +++ b/emulation/artifact-rocjitsu.toml @@ -4,13 +4,6 @@ default_patterns = false include = [ "lib/librocjitsu.so", ] -# Keep the HSA hotswap hook independently selectable so runtime packages can -# ship it without also shipping the general rocjitsu shared library. -[components.hotswap."emulation/rocjitsu/stage"] -default_patterns = false -include = [ - "lib/libhsa_hotswap_rocjitsu.so", -] [components.dbg."emulation/rocjitsu/stage"] [components.dev."emulation/rocjitsu/stage"] [components.run."emulation/rocjitsu/stage"] diff --git a/emulation/rocjitsu-hotswap/CMakeLists.txt b/emulation/rocjitsu-hotswap/CMakeLists.txt new file mode 100644 index 00000000000..734f5aa474b --- /dev/null +++ b/emulation/rocjitsu-hotswap/CMakeLists.txt @@ -0,0 +1,19 @@ +# Copyright Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT + +# Artifact descriptors cannot share a stage directory. This packaging-only +# subproject gives the hotswap hook its own stage without rebuilding rocjitsu. +cmake_minimum_required(VERSION 3.25) +project(rocjitsu_hotswap_package LANGUAGES NONE) + +if(NOT THEROCK_STAGE_INSTALL_ROOT) + message(FATAL_ERROR "THEROCK_STAGE_INSTALL_ROOT is required") +endif() + +if(NOT EXISTS "${ROCJITSU_HOTSWAP_LIBRARY}") + message(FATAL_ERROR + "ROCJITSU_HOTSWAP_LIBRARY does not exist: ${ROCJITSU_HOTSWAP_LIBRARY}" + ) +endif() + +install(FILES "${ROCJITSU_HOTSWAP_LIBRARY}" DESTINATION lib) From 31d1d90097be61affe00c8e4bc4bd6d94c57f354 Mon Sep 17 00:00:00 2001 From: "Rosa, Ada" Date: Mon, 27 Jul 2026 17:38:17 +0000 Subject: [PATCH 3/6] rocjitsu-hotswap_hook to remove ugly dedicated sub project --- build_tools/build_python_packages.py | 2 +- build_tools/install_rocm_from_artifacts.py | 2 +- build_tools/packaging/linux/package.json | 2 +- .../tests/install_rocm_from_artifacts_test.py | 2 +- build_tools/tests/py_packaging_test.py | 2 +- emulation/CMakeLists.txt | 21 ++++--------------- emulation/artifact-rocjitsu-hotswap.toml | 6 ------ emulation/artifact-rocjitsu.toml | 5 +++++ emulation/rocjitsu-hotswap/CMakeLists.txt | 19 ----------------- 9 files changed, 14 insertions(+), 47 deletions(-) delete mode 100644 emulation/artifact-rocjitsu-hotswap.toml delete mode 100644 emulation/rocjitsu-hotswap/CMakeLists.txt diff --git a/build_tools/build_python_packages.py b/build_tools/build_python_packages.py index ed6b4c94a87..b2a592d6063 100755 --- a/build_tools/build_python_packages.py +++ b/build_tools/build_python_packages.py @@ -520,7 +520,7 @@ def core_artifact_filter(an: ArtifactName) -> bool: "lib", "run", ] - hotswap = an.name == "rocjitsu-hotswap" and an.component == "lib" + hotswap = an.name == "rocjitsu-hotswap" and an.component == "hook" # hiprtc needs to be able to find HIP headers in its same tree. hip_dev = an.name in [ "core-hip", diff --git a/build_tools/install_rocm_from_artifacts.py b/build_tools/install_rocm_from_artifacts.py index b2d8794bde0..60933a0cdce 100644 --- a/build_tools/install_rocm_from_artifacts.py +++ b/build_tools/install_rocm_from_artifacts.py @@ -350,7 +350,7 @@ def retrieve_artifacts_by_run_id(args): "core-hipinfo_run", "core-runtime_run", "core-runtime_lib", - "rocjitsu-hotswap_lib", + "rocjitsu-hotswap_hook", "sysdeps_lib", "base_run", "base_lib", diff --git a/build_tools/packaging/linux/package.json b/build_tools/packaging/linux/package.json index b8ce4982038..f01457eeab5 100644 --- a/build_tools/packaging/linux/package.json +++ b/build_tools/packaging/linux/package.json @@ -220,7 +220,7 @@ { "Name": "rocjitsu-hotswap", "Components": [ - "lib" + "hook" ] } ] diff --git a/build_tools/tests/install_rocm_from_artifacts_test.py b/build_tools/tests/install_rocm_from_artifacts_test.py index 67e153ecfc2..555a3969d4e 100644 --- a/build_tools/tests/install_rocm_from_artifacts_test.py +++ b/build_tools/tests/install_rocm_from_artifacts_test.py @@ -70,7 +70,7 @@ def test_mirage_flag_includes_mirage_run(self): def test_base_only_includes_rocjitsu_hotswap(self): argv = self._run_main(["--base-only"]) - self.assertIn("rocjitsu-hotswap_lib", argv) + self.assertIn("rocjitsu-hotswap_hook", argv) class TestReleaseDiscovery(unittest.TestCase): diff --git a/build_tools/tests/py_packaging_test.py b/build_tools/tests/py_packaging_test.py index 0744ae6ff6c..a52236bbab8 100644 --- a/build_tools/tests/py_packaging_test.py +++ b/build_tools/tests/py_packaging_test.py @@ -665,7 +665,7 @@ def test_core_artifact_filter_includes_only_rocjitsu_hotswap(self): from _therock_utils.artifacts import ArtifactName self.assertTrue( - core_artifact_filter(ArtifactName("rocjitsu-hotswap", "lib", "generic")) + core_artifact_filter(ArtifactName("rocjitsu-hotswap", "hook", "generic")) ) self.assertFalse( core_artifact_filter(ArtifactName("rocjitsu", "lib", "generic")) diff --git a/emulation/CMakeLists.txt b/emulation/CMakeLists.txt index 3de2a811bf0..1a206a09b57 100644 --- a/emulation/CMakeLists.txt +++ b/emulation/CMakeLists.txt @@ -43,7 +43,7 @@ if(THEROCK_ENABLE_ROCJITSU) if(NOT WIN32) therock_test_validate_shared_lib(PATH rocjitsu/dist/lib LIB_NAMES - librocjitsu_hooks.so + libhsa_hotswap_rocjitsu.so ) endif() @@ -60,26 +60,13 @@ if(THEROCK_ENABLE_ROCJITSU) ) if(THEROCK_ENABLE_ROCJITSU_HOTSWAP) - therock_cmake_subproject_declare(rocjitsu-hotswap - DISABLE_AMDGPU_TARGETS - NO_MERGE_COMPILE_COMMANDS - EXTERNAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/rocjitsu-hotswap" - BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/rocjitsu-hotswap" - CMAKE_ARGS - -DROCJITSU_HOTSWAP_LIBRARY=${CMAKE_CURRENT_BINARY_DIR}/rocjitsu/stage/lib/librocjitsu_hooks.so - BUILD_DEPS - rocjitsu - ) - - therock_cmake_subproject_activate(rocjitsu-hotswap) - therock_provide_artifact(rocjitsu-hotswap TARGET_NEUTRAL - DESCRIPTOR artifact-rocjitsu-hotswap.toml + DESCRIPTOR artifact-rocjitsu.toml COMPONENTS - lib + hook SUBPROJECT_DEPS - rocjitsu-hotswap + rocjitsu ) endif() endif() diff --git a/emulation/artifact-rocjitsu-hotswap.toml b/emulation/artifact-rocjitsu-hotswap.toml deleted file mode 100644 index 840eaebb9cb..00000000000 --- a/emulation/artifact-rocjitsu-hotswap.toml +++ /dev/null @@ -1,6 +0,0 @@ -# rocjitsu HSA hotswap hook -[components.lib."emulation/rocjitsu-hotswap/stage"] -default_patterns = false -include = [ - "lib/librocjitsu_hooks.so", -] diff --git a/emulation/artifact-rocjitsu.toml b/emulation/artifact-rocjitsu.toml index f7f4ea9e53f..0b191db1898 100644 --- a/emulation/artifact-rocjitsu.toml +++ b/emulation/artifact-rocjitsu.toml @@ -4,6 +4,11 @@ default_patterns = false include = [ "lib/librocjitsu.so", ] +[components.hook."emulation/rocjitsu/stage"] +default_patterns = false +include = [ + "lib/libhsa_hotswap_rocjitsu.so", +] [components.dbg."emulation/rocjitsu/stage"] [components.dev."emulation/rocjitsu/stage"] [components.run."emulation/rocjitsu/stage"] diff --git a/emulation/rocjitsu-hotswap/CMakeLists.txt b/emulation/rocjitsu-hotswap/CMakeLists.txt deleted file mode 100644 index 734f5aa474b..00000000000 --- a/emulation/rocjitsu-hotswap/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright Advanced Micro Devices, Inc. -# SPDX-License-Identifier: MIT - -# Artifact descriptors cannot share a stage directory. This packaging-only -# subproject gives the hotswap hook its own stage without rebuilding rocjitsu. -cmake_minimum_required(VERSION 3.25) -project(rocjitsu_hotswap_package LANGUAGES NONE) - -if(NOT THEROCK_STAGE_INSTALL_ROOT) - message(FATAL_ERROR "THEROCK_STAGE_INSTALL_ROOT is required") -endif() - -if(NOT EXISTS "${ROCJITSU_HOTSWAP_LIBRARY}") - message(FATAL_ERROR - "ROCJITSU_HOTSWAP_LIBRARY does not exist: ${ROCJITSU_HOTSWAP_LIBRARY}" - ) -endif() - -install(FILES "${ROCJITSU_HOTSWAP_LIBRARY}" DESTINATION lib) From ca31c3db5e72460e038c8aceec90abaf17a3ab2b Mon Sep 17 00:00:00 2001 From: Kunwar Grover Date: Tue, 28 Jul 2026 14:46:53 +0100 Subject: [PATCH 4/6] refactor(rocjitsu): use lib component for hotswap artifact --- build_tools/build_python_packages.py | 2 +- build_tools/install_rocm_from_artifacts.py | 2 +- build_tools/packaging/linux/package.json | 2 +- build_tools/tests/install_rocm_from_artifacts_test.py | 2 +- build_tools/tests/py_packaging_test.py | 2 +- emulation/CMakeLists.txt | 4 ++-- emulation/artifact-rocjitsu-hotswap.toml | 6 ++++++ emulation/artifact-rocjitsu.toml | 5 ----- 8 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 emulation/artifact-rocjitsu-hotswap.toml diff --git a/build_tools/build_python_packages.py b/build_tools/build_python_packages.py index b2a592d6063..ed6b4c94a87 100755 --- a/build_tools/build_python_packages.py +++ b/build_tools/build_python_packages.py @@ -520,7 +520,7 @@ def core_artifact_filter(an: ArtifactName) -> bool: "lib", "run", ] - hotswap = an.name == "rocjitsu-hotswap" and an.component == "hook" + hotswap = an.name == "rocjitsu-hotswap" and an.component == "lib" # hiprtc needs to be able to find HIP headers in its same tree. hip_dev = an.name in [ "core-hip", diff --git a/build_tools/install_rocm_from_artifacts.py b/build_tools/install_rocm_from_artifacts.py index 60933a0cdce..b2d8794bde0 100644 --- a/build_tools/install_rocm_from_artifacts.py +++ b/build_tools/install_rocm_from_artifacts.py @@ -350,7 +350,7 @@ def retrieve_artifacts_by_run_id(args): "core-hipinfo_run", "core-runtime_run", "core-runtime_lib", - "rocjitsu-hotswap_hook", + "rocjitsu-hotswap_lib", "sysdeps_lib", "base_run", "base_lib", diff --git a/build_tools/packaging/linux/package.json b/build_tools/packaging/linux/package.json index f01457eeab5..b8ce4982038 100644 --- a/build_tools/packaging/linux/package.json +++ b/build_tools/packaging/linux/package.json @@ -220,7 +220,7 @@ { "Name": "rocjitsu-hotswap", "Components": [ - "hook" + "lib" ] } ] diff --git a/build_tools/tests/install_rocm_from_artifacts_test.py b/build_tools/tests/install_rocm_from_artifacts_test.py index 555a3969d4e..67e153ecfc2 100644 --- a/build_tools/tests/install_rocm_from_artifacts_test.py +++ b/build_tools/tests/install_rocm_from_artifacts_test.py @@ -70,7 +70,7 @@ def test_mirage_flag_includes_mirage_run(self): def test_base_only_includes_rocjitsu_hotswap(self): argv = self._run_main(["--base-only"]) - self.assertIn("rocjitsu-hotswap_hook", argv) + self.assertIn("rocjitsu-hotswap_lib", argv) class TestReleaseDiscovery(unittest.TestCase): diff --git a/build_tools/tests/py_packaging_test.py b/build_tools/tests/py_packaging_test.py index a52236bbab8..0744ae6ff6c 100644 --- a/build_tools/tests/py_packaging_test.py +++ b/build_tools/tests/py_packaging_test.py @@ -665,7 +665,7 @@ def test_core_artifact_filter_includes_only_rocjitsu_hotswap(self): from _therock_utils.artifacts import ArtifactName self.assertTrue( - core_artifact_filter(ArtifactName("rocjitsu-hotswap", "hook", "generic")) + core_artifact_filter(ArtifactName("rocjitsu-hotswap", "lib", "generic")) ) self.assertFalse( core_artifact_filter(ArtifactName("rocjitsu", "lib", "generic")) diff --git a/emulation/CMakeLists.txt b/emulation/CMakeLists.txt index 1a206a09b57..8bd1803d693 100644 --- a/emulation/CMakeLists.txt +++ b/emulation/CMakeLists.txt @@ -62,9 +62,9 @@ if(THEROCK_ENABLE_ROCJITSU) if(THEROCK_ENABLE_ROCJITSU_HOTSWAP) therock_provide_artifact(rocjitsu-hotswap TARGET_NEUTRAL - DESCRIPTOR artifact-rocjitsu.toml + DESCRIPTOR artifact-rocjitsu-hotswap.toml COMPONENTS - hook + lib SUBPROJECT_DEPS rocjitsu ) diff --git a/emulation/artifact-rocjitsu-hotswap.toml b/emulation/artifact-rocjitsu-hotswap.toml new file mode 100644 index 00000000000..fecc46b806e --- /dev/null +++ b/emulation/artifact-rocjitsu-hotswap.toml @@ -0,0 +1,6 @@ +# rocjitsu HSA hotswap hook +[components.lib."emulation/rocjitsu/stage"] +default_patterns = false +include = [ + "lib/libhsa_hotswap_rocjitsu.so", +] diff --git a/emulation/artifact-rocjitsu.toml b/emulation/artifact-rocjitsu.toml index 0b191db1898..f7f4ea9e53f 100644 --- a/emulation/artifact-rocjitsu.toml +++ b/emulation/artifact-rocjitsu.toml @@ -4,11 +4,6 @@ default_patterns = false include = [ "lib/librocjitsu.so", ] -[components.hook."emulation/rocjitsu/stage"] -default_patterns = false -include = [ - "lib/libhsa_hotswap_rocjitsu.so", -] [components.dbg."emulation/rocjitsu/stage"] [components.dev."emulation/rocjitsu/stage"] [components.run."emulation/rocjitsu/stage"] From bae5dda37f697da954e29e0c4b569cfc8186326d Mon Sep 17 00:00:00 2001 From: Kunwar Grover Date: Tue, 28 Jul 2026 15:02:17 +0100 Subject: [PATCH 5/6] fix(rocjitsu): restage hotswap artifact separately --- emulation/CMakeLists.txt | 18 +++++++++++++++++- emulation/artifact-rocjitsu-hotswap.toml | 2 +- emulation/rocjitsu-hotswap/CMakeLists.txt | 15 +++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 emulation/rocjitsu-hotswap/CMakeLists.txt diff --git a/emulation/CMakeLists.txt b/emulation/CMakeLists.txt index 8bd1803d693..9e6b9868962 100644 --- a/emulation/CMakeLists.txt +++ b/emulation/CMakeLists.txt @@ -60,13 +60,29 @@ if(THEROCK_ENABLE_ROCJITSU) ) if(THEROCK_ENABLE_ROCJITSU_HOTSWAP) + # Artifact descriptors must own distinct stage directories. Re-stage the + # already-built hook without rebuilding rocjitsu so it can remain a + # separately selectable artifact. + therock_cmake_subproject_declare(rocjitsu-hotswap + DISABLE_AMDGPU_TARGETS + NO_MERGE_COMPILE_COMMANDS + EXTERNAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/rocjitsu-hotswap" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/rocjitsu-hotswap" + CMAKE_ARGS + -DROCJITSU_HOTSWAP_LIBRARY=${CMAKE_CURRENT_BINARY_DIR}/rocjitsu/stage/lib/libhsa_hotswap_rocjitsu.so + BUILD_DEPS + rocjitsu + ) + + therock_cmake_subproject_activate(rocjitsu-hotswap) + therock_provide_artifact(rocjitsu-hotswap TARGET_NEUTRAL DESCRIPTOR artifact-rocjitsu-hotswap.toml COMPONENTS lib SUBPROJECT_DEPS - rocjitsu + rocjitsu-hotswap ) endif() endif() diff --git a/emulation/artifact-rocjitsu-hotswap.toml b/emulation/artifact-rocjitsu-hotswap.toml index fecc46b806e..68691ba011e 100644 --- a/emulation/artifact-rocjitsu-hotswap.toml +++ b/emulation/artifact-rocjitsu-hotswap.toml @@ -1,5 +1,5 @@ # rocjitsu HSA hotswap hook -[components.lib."emulation/rocjitsu/stage"] +[components.lib."emulation/rocjitsu-hotswap/stage"] default_patterns = false include = [ "lib/libhsa_hotswap_rocjitsu.so", diff --git a/emulation/rocjitsu-hotswap/CMakeLists.txt b/emulation/rocjitsu-hotswap/CMakeLists.txt new file mode 100644 index 00000000000..b0da59a0972 --- /dev/null +++ b/emulation/rocjitsu-hotswap/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT + +# Artifact descriptors cannot share a stage directory. This packaging-only +# subproject gives the hotswap hook its own stage without rebuilding rocjitsu. +cmake_minimum_required(VERSION 3.25) +project(rocjitsu_hotswap_package LANGUAGES NONE) + +if(NOT EXISTS "${ROCJITSU_HOTSWAP_LIBRARY}") + message(FATAL_ERROR + "ROCJITSU_HOTSWAP_LIBRARY does not exist: ${ROCJITSU_HOTSWAP_LIBRARY}" + ) +endif() + +install(FILES "${ROCJITSU_HOTSWAP_LIBRARY}" DESTINATION lib) From 17abd6579f655be8b45982a9bea747a011940c4f Mon Sep 17 00:00:00 2001 From: Kunwar Grover Date: Tue, 28 Jul 2026 16:55:05 +0100 Subject: [PATCH 6/6] refactor(rocjitsu): clean up hotswap artifact wiring --- emulation/CMakeLists.txt | 62 +++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/emulation/CMakeLists.txt b/emulation/CMakeLists.txt index 9e6b9868962..8f5b7ed089f 100644 --- a/emulation/CMakeLists.txt +++ b/emulation/CMakeLists.txt @@ -40,12 +40,10 @@ if(THEROCK_ENABLE_ROCJITSU) LIB_NAMES librocjitsu.so ) - if(NOT WIN32) - therock_test_validate_shared_lib(PATH rocjitsu/dist/lib - LIB_NAMES - libhsa_hotswap_rocjitsu.so - ) - endif() + therock_test_validate_shared_lib(PATH rocjitsu/dist/lib + LIB_NAMES + libhsa_hotswap_rocjitsu.so + ) therock_provide_artifact(rocjitsu TARGET_NEUTRAL @@ -58,33 +56,33 @@ if(THEROCK_ENABLE_ROCJITSU) SUBPROJECT_DEPS rocjitsu ) +endif() + +if(THEROCK_ENABLE_ROCJITSU_HOTSWAP) + # Artifact descriptors must own distinct stage directories. Re-stage the + # already-built hook without rebuilding rocjitsu so it can remain a + # separately selectable artifact. + therock_cmake_subproject_declare(rocjitsu-hotswap + DISABLE_AMDGPU_TARGETS + NO_MERGE_COMPILE_COMMANDS + EXTERNAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/rocjitsu-hotswap" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/rocjitsu-hotswap" + CMAKE_ARGS + -DROCJITSU_HOTSWAP_LIBRARY=${CMAKE_CURRENT_BINARY_DIR}/rocjitsu/dist/lib/libhsa_hotswap_rocjitsu.so + BUILD_DEPS + rocjitsu + ) - if(THEROCK_ENABLE_ROCJITSU_HOTSWAP) - # Artifact descriptors must own distinct stage directories. Re-stage the - # already-built hook without rebuilding rocjitsu so it can remain a - # separately selectable artifact. - therock_cmake_subproject_declare(rocjitsu-hotswap - DISABLE_AMDGPU_TARGETS - NO_MERGE_COMPILE_COMMANDS - EXTERNAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/rocjitsu-hotswap" - BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/rocjitsu-hotswap" - CMAKE_ARGS - -DROCJITSU_HOTSWAP_LIBRARY=${CMAKE_CURRENT_BINARY_DIR}/rocjitsu/stage/lib/libhsa_hotswap_rocjitsu.so - BUILD_DEPS - rocjitsu - ) - - therock_cmake_subproject_activate(rocjitsu-hotswap) - - therock_provide_artifact(rocjitsu-hotswap - TARGET_NEUTRAL - DESCRIPTOR artifact-rocjitsu-hotswap.toml - COMPONENTS - lib - SUBPROJECT_DEPS - rocjitsu-hotswap - ) - endif() + therock_cmake_subproject_activate(rocjitsu-hotswap) + + therock_provide_artifact(rocjitsu-hotswap + TARGET_NEUTRAL + DESCRIPTOR artifact-rocjitsu-hotswap.toml + COMPONENTS + lib + SUBPROJECT_DEPS + rocjitsu-hotswap + ) endif() if(THEROCK_ENABLE_MIRAGE)