setup: compile the HIP engine against the chosen ROCm's own headers

Ubuntu's libamdhip64-dev puts HIP headers in /usr/include, which clang
searches before the include folder of a --rocm-path. With a newer system
ROCm in /opt/rocm, hipblaslt.h then picks up the distro's older headers:
their __ocml_exp10/log/log10/log2 calls are not declared by ROCm 10's
clang-24, and src/prefill/gemm.cu fails to compile (4 errors). Name the
chosen root's include folder first with -isystem, in build_engine_hip,
build_vision_hip and the image tool's HIP defs.
This commit is contained in:
iMil committed 2026-11-19 06:50:10 +00:00
1 parent 58ee322772
commit 722f4a6cb8
2 files changed
+5 -3

No files matched your search

+4 -2
View File
@@ -5277,12 +5277,14 @@ def build_engine_hip(gpu, llama, vision="none") -> Path:
if meta.get("backend") == "hip" and (eng / EXE).exists() and has_archs
else f" Compiling the Strata engine for your AMD GPU{'s' if len(archs) > 1 else ''} ({', '.join(archs)}; "
"10-20 minutes, once) ...")
# Ubuntu's libamdhip64-dev puts other HIP headers in /usr/include, which clang searches before the ones of a
# --rocm-path: name the chosen root's include folder first, so the headers match the compiler that is used.
cmake_build(engine_src(), ROOT / "build-hip", "strata",
["-DSTRATA_ENABLE_HIP=ON", "-DSTRATA_ENABLE_CUDA=OFF", "-DSTRATA_BUILD_TESTS=OFF",
"-DSTRATA_Q6K_EXPERTS=ON", "-DCMAKE_HIP_ARCHITECTURES=" + ";".join(archs),
f"-DCMAKE_HIP_COMPILER={rocm_clang(root)}", f"-DCMAKE_HIP_COMPILER_ROCM_ROOT={root}",
"-DCMAKE_PREFIX_PATH=" + ";".join([str(root), *libs]),
f"-DCMAKE_HIP_FLAGS=--rocm-path={root} --rocm-device-lib-path={bitcode}",
f"-DCMAKE_HIP_FLAGS=-isystem {root}/include --rocm-path={root} --rocm-device-lib-path={bitcode}",
*ggml_defs(llama), *isa_floor_defs(floor, ROOT / "build-hip", meta)], None, "")
if stale_binary(ROOT / "build-hip" / EXE): # #2054: no stamp for a binary of another version
fail(f"the engine build finished without a new engine ({EXE} is version "
@@ -5356,7 +5358,7 @@ def build_vision_hip(eng: Path, stamp: Path, meta: dict, llama, vsrc, archs: lis
["-DSTRATA_VISION_HIP=ON", "-DSTRATA_VISION_HIP_ARCHS=" + ";".join(archs),
"-DSTRATA_PORTABLE=OFF", f"-DCMAKE_HIP_COMPILER={rocm_clang(root)}",
f"-DCMAKE_HIP_COMPILER_ROCM_ROOT={root}", "-DCMAKE_PREFIX_PATH=" + ";".join([str(root), *libs]),
f"-DCMAKE_HIP_FLAGS=--rocm-path={root} --rocm-device-lib-path={bitcode}"], None, "")
f"-DCMAKE_HIP_FLAGS=-isystem {root}/include --rocm-path={root} --rocm-device-lib-path={bitcode}"], None, "")
shutil.copy2(ROOT / "build-vision-hip" / "bin" / HVEXE, eng / HVEXE)
except SystemExit:
raise
+1 -1
View File
@@ -132,7 +132,7 @@ def cmake_defs(backend: str, arch=None, rocm: Path | None = None, cuda_root: Pat
f"-DCMAKE_C_COMPILER={llvm / 'bin' / 'clang'}", f"-DCMAKE_CXX_COMPILER={llvm / 'bin' / 'clang++'}",
f"-DCMAKE_HIP_COMPILER={llvm / 'bin' / 'clang++'}",
f"-DCMAKE_PREFIX_PATH={rocm};{rocm / 'lib' / 'rocm_sysdeps'};{llvm}",
f"-DCMAKE_HIP_FLAGS=--rocm-path={rocm} --rocm-device-lib-path={bitcode}"]
f"-DCMAKE_HIP_FLAGS=-isystem {rocm}/include --rocm-path={rocm} --rocm-device-lib-path={bitcode}"]
elif backend == "vulkan":
defs += ["-DSD_VULKAN=ON"]
elif backend != "cpu":