PKGNAME=rocm-llama-cpp
PKGDES="HIP/C++ implementation of LLM inference"
PKGSEC=devel
PKGDEP="rocm-llvm rocm-clr rocm-cmake rocm-roctracer rocm-smi-lib rocm-hipify rocm-rccl rocm-rocsolver rocm-hipblas"
BUILDDEP="cmake"

# FIXME LTO BFD without gold, HIP compiler unsupport LTO LLD
#   Check for working C compiler: /usr/lib/rocm/lib/llvm/bin/clang - broken
# LTO Detecting HIP compiler ABI info
#   LINKER_TYPE 'LLD' is unknown or not supported by this toolchain.
NOLTO=1

USECLANG=1

ABTYPE=cmakeninja
CMAKE_AFTER=(
    '-DCMAKE_INSTALL_PREFIX=/usr/lib/rocm/llama-cpp'
    '-DCMAKE_CXX_COMPILER=/usr/lib/rocm/lib/llvm/bin/clang++'
    '-DCMAKE_SKIP_INSTALL_RPATH=OFF'
    '-DCMAKE_PREFIX_PATH=/usr/lib/rocm'
    '-DROCM_PATH=/usr/lib/rocm'
    '-DAMDGPU_TARGETS=gfx900;gfx906:xnack-;gfx908:xnack-;gfx90a;gfx942;gfx950;gfx1010;gfx1012;gfx1030;gfx1100;gfx1101;gfx1102;gfx1151;gfx1200;gfx1201'
    '-DGGML_HIP=ON'
    '-DGGML_NATIVE=OFF'
    '-DCMAKE_FIND_ROOT_PATH=/usr/lib/rocm/;/usr/lib/rocm/lib/llvm/'
    '-DCMAKE_INSTALL_RPATH=/usr/lib/rocm/lib/llvm/lib;/usr/lib/rocm/lib;/usr/lib/rocm/llama-cpp/lib'
    '-DCMAKE_BUILD_TYPE=Release'
)

FAIL_ARCH="!(amd64|arm64|loongarch64)"
