From: Mathieu Baudier Date: Sat, 22 Feb 2025 06:53:15 +0000 (+0100) Subject: Patch CMake build in order to add shared library versions X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=62c316fd861c41a467dae818c5fb2f97ba177ed0;p=pkg%2Fggml%2Fsources%2Fggml Patch CMake build in order to add shared library versions --- diff --git a/debian/cmake/debian-ggml.cpp.cmake b/debian/cmake/debian-ggml.cpp.cmake new file mode 100644 index 00000000..431e5c6b --- /dev/null +++ b/debian/cmake/debian-ggml.cpp.cmake @@ -0,0 +1,2 @@ +set(GGML_BUILD_NUMBER 1722) + diff --git a/debian/control b/debian/control index 6a940604..fd43c7e1 100644 --- a/debian/control +++ b/debian/control @@ -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. diff --git a/debian/ggml-dev.install b/debian/ggml-dev.install index 62164bb2..8c3bfceb 100644 --- a/debian/ggml-dev.install +++ b/debian/ggml-dev.install @@ -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 index f8e6dee9..00000000 --- a/debian/libggml-base.install +++ /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 index dd866036..00000000 --- a/debian/libggml-base.triggers +++ /dev/null @@ -1 +0,0 @@ -activate-noawait ldconfig diff --git a/debian/libggml-base0.install b/debian/libggml-base0.install new file mode 100644 index 00000000..880c76b7 --- /dev/null +++ b/debian/libggml-base0.install @@ -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 index 00000000..a4115c1f --- /dev/null +++ b/debian/libggml-base0.lintian-overrides @@ -0,0 +1 @@ +libggml-base0: no-symbols-control-file diff --git a/debian/libggml-cpu.install b/debian/libggml-cpu.install index 927fa70e..572be906 100644 --- a/debian/libggml-cpu.install +++ b/debian/libggml-cpu.install @@ -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 index 5f30d798..00000000 --- a/debian/libggml.install +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/*/libggml.so diff --git a/debian/libggml.triggers b/debian/libggml.triggers deleted file mode 100644 index dd866036..00000000 --- a/debian/libggml.triggers +++ /dev/null @@ -1 +0,0 @@ -activate-noawait ldconfig diff --git a/debian/libggml0.install b/debian/libggml0.install new file mode 100644 index 00000000..fbfd6448 --- /dev/null +++ b/debian/libggml0.install @@ -0,0 +1 @@ +/usr/lib/*/libggml.so.* diff --git a/debian/libggml0.lintian-overrides b/debian/libggml0.lintian-overrides new file mode 100644 index 00000000..d106b346 --- /dev/null +++ b/debian/libggml0.lintian-overrides @@ -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 index 00000000..f3eb25b1 --- /dev/null +++ b/debian/patches/0001-improve-cmake-build.patch @@ -0,0 +1,22 @@ +From: Mathieu Baudier +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 index 00000000..b9192bb5 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +0001-improve-cmake-build.patch diff --git a/debian/rules b/debian/rules index e38fd4c3..5baebd01 100755 --- a/debian/rules +++ b/debian/rules @@ -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