From 733940b771e9acb5fb1ec59f6e7b8aab0d7d04d9 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Sun, 8 Nov 2026 18:42:23 -0400 Subject: [PATCH] hrx: the device library goes to the HIP kernel compile only, not the host C/C++ flags (Refs #1539) cmake/hrx.cmake appended --rocm-device-lib-path to ONEBIT_HRX_EXTRA_FLAGS, which becomes llama_hrx's CMAKE_C_FLAGS and CMAKE_CXX_FLAGS and so reaches every host object of the hrx-system deps build. That build compiles with -Werror, and on a host C file clang rejects the flag as unused (-Wunused-command-line-argument), so a cold HRX build of main fails in iree_async_async, and so does hrx-build whenever the deps rebuild (runs 42524820160, 42526921955). The HIP kernels are compiled by their own amdclang++ step and already get the device library from GGML_HRX_HIP_FLAGS (#771's review), so the host copy is dropped. tests/hrx_toolchain_pin.sh gains a row that fails if the flag returns to the host flags; docs/hrx.md says where it goes. Co-Authored-By: Claude Opus 5.5 --- cmake/hrx.cmake | 5 ++++- docs/hrx.md | 4 +++- tests/hrx_toolchain_pin.sh | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cmake/hrx.cmake b/cmake/hrx.cmake index 6d3bd2690..bc7a6e4b6 100644 --- a/cmake/hrx.cmake +++ b/cmake/hrx.cmake @@ -158,8 +158,11 @@ if(NOT ONEBIT_HRX_DEVICE_LIB) endif() endif() endif() +# It goes to the HIP kernel compile only (ONEBIT_HRX_HIP_FLAGS below), never into CMAKE_C/CXX_FLAGS: +# those reach every host object of the hrx-system deps build, which compiles with -Werror, and a host C +# file has no device code to link, so clang rejects the flag as unused (-Wunused-command-line-argument). +# A cold HRX build failed on it here, and so did hrx-build whenever the deps rebuilt (runs 42524820160, 42526921955). if(ONEBIT_HRX_DEVICE_LIB) - string(APPEND ONEBIT_HRX_EXTRA_FLAGS " --rocm-device-lib-path=${ONEBIT_HRX_DEVICE_LIB}") message(STATUS "ONEBIT_HRX: device library ${ONEBIT_HRX_DEVICE_LIB}") else() message(STATUS "ONEBIT_HRX: no device library under ${ONEBIT_HRX_TOOLCHAIN}; hipcc's default is used") diff --git a/docs/hrx.md b/docs/hrx.md index 0dd2f8a38..9056bdd1e 100644 --- a/docs/hrx.md +++ b/docs/hrx.md @@ -1044,7 +1044,9 @@ cmake --build build --target onebit a fresh box needs only this repository. `-DONEBIT_HRX_TOOLCHAIN` / `ROCM_PATH` still override it, and an existing `/opt/rocm-therock` is used when the tree copy is absent. The device library (the `amdgcn` bitcode) is read from the toolchain itself, so no `HIP_DEVICE_LIB_PATH`, - `ROCM_PATH` or `HIP_PATH` is needed in the environment. + `ROCM_PATH` or `HIP_PATH` is needed in the environment. It is passed to the HIP kernel compile only + (`GGML_HRX_HIP_FLAGS`), not to the host C/C++ flags: the hrx-system build uses `-Werror`, and + clang rejects the flag as unused on a host object. - **One external project.** llama.cpp's ggml-hrx builds hrx-system itself (`HRX_SOURCE_DIR`) with TheRock's `amdclang`. diff --git a/tests/hrx_toolchain_pin.sh b/tests/hrx_toolchain_pin.sh index 95d047673..6aefeb4ec 100755 --- a/tests/hrx_toolchain_pin.sh +++ b/tests/hrx_toolchain_pin.sh @@ -86,6 +86,11 @@ grep -q "removing stale toolchain" "$root/scripts/fetch-rocm-sdk.sh" && ok "the # environment and takes the compiler from /opt (the gap pi-prs found in review) grep -q "GGML_HRX_HIP_FLAGS" "$root/cmake/hrx.cmake" && ok "the HIP kernel flags are passed (GGML_HRX_HIP_FLAGS)" || bad "cmake/hrx.cmake does not pass GGML_HRX_HIP_FLAGS: the HIP kernel compile needs the device library in the environment" +# the device library must not reach the host C/C++ flags: the hrx-system deps build compiles with -Werror, +# and on a host object clang rejects the flag as unused, so every cold HRX build failed on it +grep -Eq 'APPEND ONEBIT_HRX_EXTRA_FLAGS[^)]*rocm-device-lib-path' "$root/cmake/hrx.cmake" && + bad "cmake/hrx.cmake puts --rocm-device-lib-path into the host C/C++ flags (-Werror fails host objects on it)" || + ok "the device library goes to the HIP kernel compile only, not the host C/C++ flags" grep -q "GGML_HRX_HIP_COMPILER" "$root/cmake/hrx.cmake" && ok "the HIP kernel compiler comes from the toolchain" || bad "cmake/hrx.cmake does not set GGML_HRX_HIP_COMPILER: ggml-hrx-hip.cmake would find /opt/rocm-therock first" grep -q "config/hrx-toolchain.config" "$root/cmake/hrx.cmake" "$root/scripts/fetch-rocm-sdk.sh" "$root/scripts/weekly.sh" &&