Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sci-misc/llama-cpp/Manifest
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ DIST llama-cpp-0_pre7924.tar.gz 28899921 BLAKE2B b89c8c170d1c2d52390dfef35a4e085
DIST llama-cpp-0_pre8198.tar.gz 29091642 BLAKE2B b5d02310a7e71fec88e29094aa7936cb520530fb9f81cef58f87c97948e6116734f9a19da5ad8daba1027f8e26308e5fa1f3e91e33a49539929f6e3475b08429 SHA512 bc8aef7cb29a32e0acf90d50cbf426c1a42d99659747203449ebf85f0c9c2fed98fd23b7e50b963dd537d3d6edecf17936d0cf7ae04266df4723e2d4a5c7ecfa
DIST llama-cpp-0_pre8628.tar.gz 29611654 BLAKE2B 5efeb855b5833ca7a0ba552a142e9fac08773e0f0f31d9d3188c03840d91c91aa22edaf310a6472c9077cd4fb2a48c82371887374fb6d417dd022a18c51ff9e2 SHA512 7b86c37b3f926a0983fe6648629019e9f32001dbf474de9278d94d5e1a9e4c37dfaa9832557555724941c32c437efcbf2e91b0b0ad558936657e14ec5e52f8f0
DIST llama-cpp-0_pre8838.tar.gz 33811834 BLAKE2B 1223a15237186dc8e11c454d76adfd875a9d6b3ee56c046fc0cf63415c7ebbb4b0dc2da49b7e697ecd9908dad6adcb4f2a5bd4665b7118d2c2508e3b215c1f39 SHA512 d345a2645dcad2564f94efdef45a7681b85f4079d30e68297b42a529ccfe4f50429067dce8685791c914cd59d00843c8e5d02c6ef7ce2d97bb990d6c896f5e9f
DIST llama-cpp-0_pre9219-uiasset-bundle.css 505965 BLAKE2B cb09d237e482b0b9474b27adf89a2129a6543c9c8b47beb7b5e77d3f4632f866cb0996e19bca0938394bb3a16d63dca716788dd24c3f7389d4545425e1441330 SHA512 8ddda7222c376dff3a2930452d0e86cda39b4047ee2aeb094da5ea98d83ec3bc8a490b8b0e110560bd5802454d965d403a7b6f2c07aa4a02b21c6504aaf1ded2
DIST llama-cpp-0_pre9219-uiasset-bundle.js 5279222 BLAKE2B b4f31e74787ffb233b0e6772c05202eacaf79af2faf07a24a199f92e5d9eb0e786e94bd8c23e346ec7f6dcb0fb8a594d5de144a3c2079ced05397466d7f256ee SHA512 076d09f41cbbfc1a8fed044802bf4b6b47d1c0b26abecf5958845ab3e99db1aa5d7d5096bfdb1c34a98a5be3ea0cd974c3af3aa13226cf0659b68b08ad86edca
DIST llama-cpp-0_pre9219-uiasset-index.html 6917 BLAKE2B 4c81aa40f5ab4618e9b1f14d1ac2eaf062d7fd4b11c309c9027432b5e0e9b4bf92dc6555b1a5ca81359beac884ea39c1cd074170e2be4407315fb170ca1c35db SHA512 d48aae733cb64b2fa2893e64fcea68da284e13923572efb174619f85c507825def0757093e8eb54f7bd7cdcb31b63e5a6854daef6e6e25ee0eb7284bb8cc8432
DIST llama-cpp-0_pre9219-uiasset-loading.html 268 BLAKE2B 4b8339b8b3a52bb151f3ab9eabc4d3187aeea312da255d4f55a80839f8145258ee1cf9ea594abe5aa2b49731fe55716870312095fd6a10df42b6cfa4f120ac70 SHA512 d045fac9f2cf87aa5756f27ef0760df494399de6df40ca0a06387685eb69150053a1204b8b17d2d8a8166279081c01f7fbbba10645510309e9debe18cdc20f0c
DIST llama-cpp-0_pre9219.tar.gz 33881298 BLAKE2B 27f66cea2798f151bfc9a648fa4197e65dc8e0969e7793416b10bce6659f46e54c8d80e4d951f3ea4081df23909bd9616740cc506401ef32f4e8ccf1a21a26b8 SHA512 e8ec0330802533f6c60c42eca67d3db99d6310d9b3b37c5b7b05cb9dd451c3372e2eb25d9c655e3e396e1f472042401bf3f1b431c24995b32b8c320b4aa3297a
187 changes: 187 additions & 0 deletions sci-misc/llama-cpp/llama-cpp-0_pre9219.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

ROCM_VERSION="6.3"

inherit cmake cuda rocm linux-info

TINY_LLAMAS_COMMIT="99dd1a73db5a37100bd4ae633f4cfce6560e1567"

DESCRIPTION="Port of Facebook's LLaMA model in C/C++"
HOMEPAGE="https://github.com/ggml-org/llama.cpp"

UI_ASSETS=( index.html bundle.js bundle.css loading.html )
UI_ASSET_BUCKET="https://huggingface.co/buckets/ggml-org/llama-ui"

if [[ ${PV} == *9999* ]]; then
inherit git-r3
EGIT_REPO_URI="https://github.com/ggml-org/llama.cpp.git"
else
MY_PV="b${PV#0_pre}"
SRC_URI="https://github.com/ggml-org/llama.cpp/archive/refs/tags/${MY_PV}.tar.gz -> ${P}.tar.gz"
for asset in "${UI_ASSETS[@]}"; do
SRC_URI+="
webui? ( ${UI_ASSET_BUCKET}/resolve/${MY_PV}/${asset}?download=true -> ${P}-uiasset-${asset} )
"
done
S="${WORKDIR}/llama.cpp-${MY_PV}"
KEYWORDS="~amd64"
fi

SRC_URI+="
examples? (
https://huggingface.co/ggml-org/tiny-llamas/resolve/${TINY_LLAMAS_COMMIT}/stories15M-q4_0.gguf
-> ggml-org_models_tinyllamas_stories15M-q4_0-${TINY_LLAMAS_COMMIT}.gguf
)
"

LICENSE="MIT"
SLOT="0"
CPU_FLAGS_X86=( avx avx2 f16c )

# wwma USE explained here: https://github.com/ggml-org/llama.cpp/blob/master/docs/build.md#hip
IUSE="curl openblas +openmp blis rocm cuda opencl openssl vulkan flexiblas wmma examples webui"

REQUIRED_USE="
?? (
openblas
blis
flexiblas
)
wmma? (
rocm
)
"
if [[ ${PV} == *9999* ]]; then
# Webui assets are only published for tagged releases and
# building them locally would require fetching npm dependencies
REQUIRED_USE+="!webui"
fi

# curl is needed for pulling models from huggingface
# numpy is used by convert_hf_to_gguf.py
CDEPEND="
curl? ( net-misc/curl:= )
openblas? ( sci-libs/openblas:= )
openmp? ( llvm-runtimes/openmp:= )
blis? ( sci-libs/blis:= )
flexiblas? ( sci-libs/flexiblas:= )
rocm? (
>=dev-util/hip-${ROCM_VERSION}:=
>=sci-libs/hipBLAS-${ROCM_VERSION}:=
wmma? (
>=sci-libs/rocWMMA-${ROCM_VERSION}:=
)
)
cuda? ( dev-util/nvidia-cuda-toolkit:= )
openssl? ( dev-libs/openssl:= )
"
DEPEND="${CDEPEND}
opencl? ( dev-util/opencl-headers )
vulkan? (
dev-util/spirv-headers
dev-util/vulkan-headers
)
"
RDEPEND="${CDEPEND}
dev-python/numpy
opencl? ( dev-libs/opencl-icd-loader )
vulkan? ( media-libs/vulkan-loader )
"
BDEPEND="media-libs/shaderc"

pkg_setup() {
if use rocm; then
linux-info_pkg_setup
if linux-info_get_any_version && linux_config_exists; then
if ! linux_chkconfig_present HSA_AMD_SVM; then
ewarn "To use ROCm/HIP, you need to have HSA_AMD_SVM option enabled in your kernel."
fi
fi
fi
}

src_prepare() {
use cuda && cuda_src_prepare
cmake_src_prepare
if use examples; then
mkdir -p "${BUILD_DIR}/tinyllamas" || die
cp "${DISTDIR}/ggml-org_models_tinyllamas_stories15M-q4_0-${TINY_LLAMAS_COMMIT}.gguf" \
"${BUILD_DIR}/tinyllamas/stories15M-q4_0.gguf" || die
fi
if use webui; then
mkdir -p "${S}/build/tools/ui/dist" || die
for asset in "${UI_ASSETS[@]}"; do
ln -s "${DISTDIR}/${P}-uiasset-${asset}" "${S}/build/tools/ui/dist/${asset}" || die
done
fi
}

src_configure() {
local mycmakeargs=(
-DLLAMA_BUILD_WEBUI=$(usex webui)
-DLLAMA_BUILD_TESTS=OFF
-DLLAMA_BUILD_EXAMPLES=$(usex examples)
-DLLAMA_BUILD_SERVER=ON
-DCMAKE_SKIP_BUILD_RPATH=ON
-DGGML_NATIVE=0 # don't set march
-DGGML_RPC=ON
-DLLAMA_CURL=$(usex curl)
-DLLAMA_OPENSSL=$(usex openssl)
-DBUILD_NUMBER="1"
-DGENTOO_REMOVE_CMAKE_BLAS_HACK=ON
-DGGML_CUDA=$(usex cuda)
-DGGML_OPENCL=$(usex opencl)
-DGGML_OPENMP=$(usex openmp)
-DGGML_VULKAN=$(usex vulkan)

# avoid clashing with whisper.cpp
-DCMAKE_INSTALL_LIBDIR="${EPREFIX}/usr/$(get_libdir)/llama.cpp"
-DCMAKE_INSTALL_RPATH="${EPREFIX}/usr/$(get_libdir)/llama.cpp"
)

if use openblas ; then
mycmakeargs+=(
-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS
)
fi

if use blis ; then
mycmakeargs+=(
-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=FLAME
)
fi

if use flexiblas; then
mycmakeargs+=(
-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=FlexiBLAS
)
fi

if use cuda; then
local -x CUDAHOSTCXX="$(cuda_gccdir)"
# tries to recreate dev symlinks
cuda_add_sandbox
addpredict "/dev/char/"
fi

if use rocm; then
rocm_use_hipcc
mycmakeargs+=(
-DGGML_HIP=ON -DAMDGPU_TARGETS=$(get_amdgpu_flags)
-DGGML_HIP_ROCWMMA_FATTN=$(usex wmma)
)
fi

cmake_src_configure
}

src_install() {
cmake_src_install
dobin "${BUILD_DIR}/bin/rpc-server"

# avoid clashing with whisper.cpp
rm -rf "${ED}/usr/include"
}
1 change: 1 addition & 0 deletions sci-misc/llama-cpp/metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<flag name="openblas">Build an OpenBLAS backend</flag>
<flag name="opencl">Build an OpenCL backend, so far only works on Adreno and Intel GPUs</flag>
<flag name="openssl">Use openssl to support HTTPS</flag>
<flag name="webui">Build llama-server with the webui (not supported in live ebuilds)</flag>
</use>
<maintainer type="person">
<email>zl29ah@gmail.com</email>
Expand Down