diff --git a/add-loongarch64-support.patch b/add-loongarch64-support.patch deleted file mode 100644 index c9ec16211ae15b970f4348751185bdf1f704fd06..0000000000000000000000000000000000000000 --- a/add-loongarch64-support.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/ggml.c b/ggml.c -index beb7f46..2374287 100644 ---- a/ggml.c -+++ b/ggml.c -@@ -299,7 +299,7 @@ typedef double ggml_float; - #if defined(_MSC_VER) || defined(__MINGW32__) - #include - #else --#if !defined(__riscv) -+#if !defined(__riscv) && !defined(__loongarch64) - #include - #endif - #endif -diff --git a/k_quants.c b/k_quants.c -index 6348fce..6816121 100644 ---- a/k_quants.c -+++ b/k_quants.c -@@ -26,7 +26,7 @@ - #if defined(_MSC_VER) || defined(__MINGW32__) - #include - #else --#if !defined(__riscv) -+#if !defined(__riscv) && !defined(__loongarch64) - #include - #endif - #endif diff --git a/b6602.tar.gz b/b6602.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..c5d6f5c51506c521251f92e936574977c9aa5987 Binary files /dev/null and b/b6602.tar.gz differ diff --git a/backport-CVE-2025-52566.patch b/backport-CVE-2025-52566.patch deleted file mode 100644 index d3cc419ad6f167f309793dc9acf02bebb9319e06..0000000000000000000000000000000000000000 --- a/backport-CVE-2025-52566.patch +++ /dev/null @@ -1,51 +0,0 @@ -From e4e28809e4b48d41e380ee326474f56819855021 Mon Sep 17 00:00:00 2001 -From: Ruikai Peng -Date: Fri, 20 Jun 2025 22:13:06 +0800 -Subject: [PATCH] vocab : prevent tokenizer overflow (#14301) - -* vocab : prevent stack overflow in tokenize - -* vocab : return error instead of aborting on oversized token count - -* vocab : INT32_MIN from llama_tokenize on overflow ---- - examples/train-text-from-scratch/train-text-from-scratch.cpp | 5 +++++ - llama.cpp | 5 +++++ - 2 files changed, 10 insertions(+) - -diff --git a/examples/train-text-from-scratch/train-text-from-scratch.cpp b/examples/train-text-from-scratch/train-text-from-scratch.cpp -index 54dc2be..f1867ea 100644 ---- a/examples/train-text-from-scratch/train-text-from-scratch.cpp -+++ b/examples/train-text-from-scratch/train-text-from-scratch.cpp -@@ -2191,6 +2191,11 @@ int tokenize_file(struct llama_context * lctx, const char * filename, std::vecto - out.resize(buf.size()); - - int n_tokens = llama_tokenize(lctx, buf.data(), out.data(), buf.size(), false); -+ -+ if (n_tokens == std::numeric_limits::min()) { -+ throw std::runtime_error("Tokenization failed: input text too large, tokenization result exceeds int32_t limit"); -+ } -+ - if (n_tokens >= 0) { - out.resize(n_tokens); - } -diff --git a/llama.cpp b/llama.cpp -index c8ab313..cfa908f 100644 ---- a/llama.cpp -+++ b/llama.cpp -@@ -4134,6 +4134,11 @@ int llama_tokenize_with_model( - bool add_bos) { - auto res = llama_tokenize(model->vocab, text, add_bos); - -+ if (res.size() >= static_cast(std::numeric_limits::max())) { -+ LLAMA_LOG_ERROR("%s: tokenization result size %zu exceeds int32_t limit\n", __func__, res.size()); -+ return std::numeric_limits::min(); -+ } -+ - if (n_max_tokens < (int) res.size()) { - LLAMA_LOG_ERROR("%s: too many tokens\n", __func__); - return -((int) res.size()); --- -2.33.0 - - diff --git a/llama.cpp.spec b/llama.cpp.spec index c057fc2423e9e60e6659e782b775b31beb9bc8cc..ff634264a91f207f0a6e2dec6fe0f629ad556b14 100644 --- a/llama.cpp.spec +++ b/llama.cpp.spec @@ -1,46 +1,63 @@ %define debug_package %{nil} -%global llama_commitid master-3ebb009 +%global llama_commitid b6602 -Name: llama.cpp -Version: 20230815 -Release: 5 -License: MIT -Summary: Port of English lagre model LLaMA implemented based on C/C++ +Name: llama.cpp +Version: 20251009 +Release: 6 +License: MIT +Summary: Port of English large model LLaMA implemented in C/C++ -URL: https://github.com/ggerganov/llama.cpp +URL: https://github.com/ggerganov/llama.cpp Source0: https://github.com/ggerganov/llama.cpp/archive/refs/tags/%{llama_commitid}.tar.gz -Patch0: add-loongarch64-support.patch -Patch1: backport-CVE-2025-52566.patch -BuildRequires: gcc,gcc-c++,cmake +BuildRequires: gcc +BuildRequires: gcc-c++ +BuildRequires: cmake %description -Port of English lagre model LLaMA implemented based on C/C++, -it can be used for model dialogue based on local laptops. +Port of English large model LLaMA implemented in C/C++, +can be used for local inference on laptops. + +%package devel +Summary: Development headers and libraries for %{name} +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description devel +This package contains the header files, CMake config files and pkg-config +files needed to develop against %{name}. %prep -%autosetup -b 0 -n %{name}-%{llama_commitid} -p1 +%autosetup -n %{name}-%{llama_commitid} %build -mkdir llama_builddir -pushd llama_builddir -cmake .. +mkdir -p build +cd build +cmake .. \ + -DCMAKE_INSTALL_PREFIX=%{_prefix} \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_LIBDIR=%{_libdir} %make_build -popd %install -pushd llama_builddir +cd build %make_install -mv %{buildroot}%{_prefix}/local/bin/main %{buildroot}%{_prefix}/local/bin/llama_cpp_main -mv %{buildroot}%{_prefix}/local/bin/convert.py %{buildroot}%{_prefix}/local/bin/llama_convert.py -mv %{buildroot}%{_prefix}/local/* %{buildroot}%{_prefix} -popd +# 清理空目录 +find %{buildroot} -type d -empty -delete %files %{_bindir}/* -%{_libdir}/libembdinput.a +%{_libdir}/*.so + +%files devel +%{_includedir}/*.h +%{_libdir}/cmake/ +%{_libdir}/pkgconfig/ +%{_libdir}/*.so %changelog +* Thu Oct 9 2025 Stephen Curry - 20251009-6 +- Upgrade to b6602 + * Thu Jul 10 2025 PshySimon - 20230815-5 - fix CVE-2025-52566 diff --git a/master-3ebb009.tar.gz b/master-3ebb009.tar.gz deleted file mode 100644 index 356831c48e7b03dea92a6d97b2f5c5b9d5d1c257..0000000000000000000000000000000000000000 Binary files a/master-3ebb009.tar.gz and /dev/null differ