]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
Patch CMake build in order to add shared library versions
authorMathieu Baudier <redacted>
Sat, 22 Feb 2025 06:53:15 +0000 (07:53 +0100)
committerMathieu Baudier <redacted>
Sat, 22 Feb 2025 08:13:36 +0000 (09:13 +0100)
15 files changed:
debian/cmake/debian-ggml.cpp.cmake [new file with mode: 0644]
debian/control
debian/ggml-dev.install
debian/libggml-base.install [deleted file]
debian/libggml-base.triggers [deleted file]
debian/libggml-base0.install [new file with mode: 0644]
debian/libggml-base0.lintian-overrides [new file with mode: 0644]
debian/libggml-cpu.install
debian/libggml.install [deleted file]
debian/libggml.triggers [deleted file]
debian/libggml0.install [new file with mode: 0644]
debian/libggml0.lintian-overrides [new file with mode: 0644]
debian/patches/0001-improve-cmake-build.patch [new file with mode: 0644]
debian/patches/series [new file with mode: 0644]
debian/rules

diff --git a/debian/cmake/debian-ggml.cpp.cmake b/debian/cmake/debian-ggml.cpp.cmake
new file mode 100644 (file)
index 0000000..431e5c6
--- /dev/null
@@ -0,0 +1,2 @@
+set(GGML_BUILD_NUMBER 1722)
+
index 6a94060499c2812803426c003faab3d5b2757cb7..fd43c7e13bf07e9c35e7cb5bc67ce8b90f5dfbaa 100644 (file)
@@ -12,7 +12,7 @@ Rules-Requires-Root: binary-targets
 Package: ggml
 Architecture: any
 Depends: ${misc:Depends},
- libggml, libggml-cpu
+ libggml0, libggml-cpu
 Description: Tensor library for machine learning (metapackage)
  ggml is a pure C/C++ library implementing tensor computations
  used by neural networks. It is the basis for llama.cpp (large language models)
@@ -23,7 +23,8 @@ Description: Tensor library for machine learning (metapackage)
  installed additionally, typically to support specific computing hardware
  such as GPUs.
 
-Package: libggml-base
+Package: libggml-base0
+Section: libs
 Architecture: any
 Multi-Arch: same
 Pre-Depends: ${misc:Pre-Depends}
@@ -32,12 +33,13 @@ Description: Tensor library for machine learning (base)
  The ggml base library provides the backend-independent API
  upon which specialized libraries or applications can be built.
 
-Package: libggml
+Package: libggml0
+Section: libs
 Architecture: any
 Multi-Arch: same
 Pre-Depends: ${misc:Pre-Depends}
 Depends: ${misc:Depends}, ${shlibs:Depends},
- libggml-base
+ libggml-base0
 Description: Tensor library for machine learning (loader)
  The ggml library is a thin high-level layer mostly
  responsible for loading the various ggml backends,
@@ -48,7 +50,7 @@ Architecture: any
 Multi-Arch: same
 Pre-Depends: ${misc:Pre-Depends}
 Depends: ${misc:Depends}, ${shlibs:Depends},
- libggml
+ libggml0
 Description: Tensor library for machine learning (CPU backend)
  The ggml CPU backend provides computations based solely
  on plain CPU, without software or hardware acceleration.
@@ -63,7 +65,7 @@ Architecture: any
 Multi-Arch: same
 Pre-Depends: ${misc:Pre-Depends}
 Depends: ${misc:Depends}, ${shlibs:Depends},
- libggml,
+ libggml0,
 # GGML shows warning that it uses OpenMP if default OpenBLAS (pthread) is used.
  libopenblas0-openmp, libopenblas64-0-openmp [amd64 arm64],
 Description: Tensor library for machine learning (OpenBLAS backend)
@@ -75,7 +77,7 @@ Architecture: any
 Multi-Arch: same
 Pre-Depends: ${misc:Depends}, ${misc:Pre-Depends}
 Depends: ${shlibs:Depends},
- libggml
+ libggml0
 Description: Tensor library for machine learning (RPC backend)
  The ggml RPC backend allows one to distribute computations over
  the network on remote ggml backends.
@@ -85,7 +87,7 @@ Architecture: any
 Multi-Arch: same
 Pre-Depends: ${misc:Pre-Depends}
 Depends: ${misc:Depends}, ${shlibs:Depends},
- libggml,
+ libggml0,
  libvulkan1
 Description: Tensor library for machine learning (Vulkan backend)
  The ggml Vulkan backend provides hardware acceleration of the
@@ -95,7 +97,7 @@ Description: Tensor library for machine learning (Vulkan backend)
 Package: ggml-dev
 Architecture: any
 Depends: ${misc:Depends},
- libggml (= ${binary:Version})
+ libggml0 (= ${binary:Version}), libggml-base0 (= ${binary:Version})
 Description: Tensor library for machine learning (development files)
  This developments package provides the files required to build
  software based on ggml.
index 62164bb28d8a39d638cc62c90c4c572e4d6364fd..8c3bfceb1c67fba681cb51bf8b7f7f84f6cdd7d2 100644 (file)
@@ -2,4 +2,10 @@
 /usr/share/pkgconfig/*.pc
 /usr/lib/*/cmake/ggml/*.cmake
 
+# Symbolic links
+/usr/lib/*/libggml.so
+/usr/lib/*/libggml-base.so
+# portable CPU backend
+/usr/libexec/*/ggml/libggml-cpu.so
+
 include/ggml-cpp.h usr/include/
diff --git a/debian/libggml-base.install b/debian/libggml-base.install
deleted file mode 100644 (file)
index f8e6dee..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/usr/lib/*/libggml-base.so
diff --git a/debian/libggml-base.triggers b/debian/libggml-base.triggers
deleted file mode 100644 (file)
index dd86603..0000000
+++ /dev/null
@@ -1 +0,0 @@
-activate-noawait ldconfig
diff --git a/debian/libggml-base0.install b/debian/libggml-base0.install
new file mode 100644 (file)
index 0000000..880c76b
--- /dev/null
@@ -0,0 +1 @@
+/usr/lib/*/libggml-base.so.*
diff --git a/debian/libggml-base0.lintian-overrides b/debian/libggml-base0.lintian-overrides
new file mode 100644 (file)
index 0000000..a4115c1
--- /dev/null
@@ -0,0 +1 @@
+libggml-base0: no-symbols-control-file
index 927fa70e7718c9a494449c8a6aeb0ce4eb1d699b..572be906016d49e71c0cffa9639275fb60d17a73 100644 (file)
@@ -1,4 +1 @@
-/usr/libexec/*/ggml/libggml-cpu*.so
-
-# portable CPU backend
-/usr/lib/*/libggml-cpu.so
+/usr/libexec/*/ggml/libggml-cpu-*.so
diff --git a/debian/libggml.install b/debian/libggml.install
deleted file mode 100644 (file)
index 5f30d79..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/usr/lib/*/libggml.so
diff --git a/debian/libggml.triggers b/debian/libggml.triggers
deleted file mode 100644 (file)
index dd86603..0000000
+++ /dev/null
@@ -1 +0,0 @@
-activate-noawait ldconfig
diff --git a/debian/libggml0.install b/debian/libggml0.install
new file mode 100644 (file)
index 0000000..fbfd644
--- /dev/null
@@ -0,0 +1 @@
+/usr/lib/*/libggml.so.*
diff --git a/debian/libggml0.lintian-overrides b/debian/libggml0.lintian-overrides
new file mode 100644 (file)
index 0000000..d106b34
--- /dev/null
@@ -0,0 +1,2 @@
+libggml0: hardening-no-fortify-functions
+libggml0: no-symbols-control-file
diff --git a/debian/patches/0001-improve-cmake-build.patch b/debian/patches/0001-improve-cmake-build.patch
new file mode 100644 (file)
index 0000000..f3eb25b
--- /dev/null
@@ -0,0 +1,22 @@
+From: Mathieu Baudier <mbaudier@argeo.org>
+Date: Sat, 22 Feb 2025 07:52:42 +0100
+Subject: improve-cmake-build
+
+---
+ src/CMakeLists.txt | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 0002ac1..48687f0 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -353,5 +353,9 @@ if (BUILD_SHARED_LIBS)
+         set_target_properties(${target} PROPERTIES POSITION_INDEPENDENT_CODE ON)
+         target_compile_definitions(${target} PRIVATE GGML_BUILD)
+         target_compile_definitions(${target} PUBLIC  GGML_SHARED)
++              if(DEFINED GGML_BUILD_NUMBER)
++              message(STATUS "Set ${target} shared library version to 0.0.${GGML_BUILD_NUMBER}")
++              set_target_properties(${target} PROPERTIES VERSION 0.0.${GGML_BUILD_NUMBER} SOVERSION 0)
++        endif()
+     endforeach()
+ endif()
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644 (file)
index 0000000..b9192bb
--- /dev/null
@@ -0,0 +1 @@
+0001-improve-cmake-build.patch
index e38fd4c38a4609d7be5e17f1970d45c35ce913a4..5baebd01c23cde5aa279e545f7981dbbed761ebb 100755 (executable)
@@ -15,6 +15,9 @@ install_libexec_multiarch=debian/tmp/usr/libexec/$(DEB_HOST_MULTIARCH)
 # parallelism
 DEB_BUILD_OPTIONS ?= parallel=8
 
+# hardening
+export DEB_BUILD_MAINT_OPTIONS = hardening=+all
+
 # ggml specific
 ifeq ($(DEB_HOST_ARCH),aarch64)
        GGML_CPU_AARCH64 ?= ON
@@ -35,7 +38,9 @@ endif
 override_dh_auto_configure:
        dh_auto_configure -- \
        -DCMAKE_SKIP_BUILD_RPATH=ON \
+       -DGGML_ALL_WARNINGS=OFF \
        -DCMAKE_LIBRARY_ARCHITECTURE="$(DEB_HOST_MULTIARCH)" \
+       -DCMAKE_PROJECT_ggml_INCLUDE=debian/cmake/debian-ggml.cpp.cmake \
        -DCMAKE_BUILD_TYPE=Release \
        -DBUILD_SHARED_LIBS=ON \
        -DGGML_CCACHE=OFF \
@@ -65,7 +70,6 @@ override_dh_auto_install:
                install -t $(install_libexec_multiarch)/ggml $$file; \
        done
        
-       # whisper.cpp currently requires linking to a CPU backend
-       # we therefore provide a link in /usr/lib/*/
-       # TODO use alternative
-       ln -s --relative $(install_libexec_multiarch)/ggml/libggml-cpu-sandybridge.so $(install_lib_multiarch)/libggml-cpu.so
+       # Provide a symbolic link to the most portable CPU backend
+       # so that it can be used for builds (e.g. whisper.cpp build requires a CPU backend)
+       ln -s --relative $(install_libexec_multiarch)/ggml/libggml-cpu-sandybridge.so $(install_libexec_multiarch)/ggml/libggml-cpu.so