From 7948df8ac1070f5f6881b8d34675821893eb97d6 Mon Sep 17 00:00:00 2001 From: RapidMark <32768622+RapidMark@users.noreply.github.com> Date: Mon, 1 Jun 2026 09:07:48 -0700 Subject: [PATCH] fix(cmake): build HIP backend with PIC so the static-lib PIE link succeeds (#1593) --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d6c03da..2804bad4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,6 +125,12 @@ endif () if (SD_HIPBLAS) message("-- Use HIPBLAS as backend stable-diffusion") set(GGML_HIP ON) + # ggml-hip's device-stub objects must be position-independent, or the + # default-PIE sd-cli link fails with `relocation R_X86_64_32 ... cannot be + # used when making a PIE object` on distros that default to PIE + # (Ubuntu 24.04, Fedora 40+, Debian 12+). The shared-library branch below + # already sets this; the static build (the HIP default) did not. + set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif () if(SD_MUSA)