From: Mathieu Baudier Date: Mon, 4 May 2026 13:25:22 +0000 (+0200) Subject: Build with clang X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=1319b67d04c7b041f09a8b752f6663a3de2b9998;p=pkg%2Fggml%2Fsources%2Fggml Build with clang --- diff --git a/debian/argeo-libggml-base0.lintian-overrides b/debian/argeo-libggml-base0.lintian-overrides index 8f2c09e3..317dfc2d 100644 --- a/debian/argeo-libggml-base0.lintian-overrides +++ b/debian/argeo-libggml-base0.lintian-overrides @@ -1,3 +1,3 @@ # According to https://wiki.debian.org/UsingSymbolsFiles # "For C++ libraries it is often better not to ship symbols files." -libggml-base0: no-symbols-control-file +argeo-libggml-base0: no-symbols-control-file diff --git a/debian/argeo-libggml0.lintian-overrides b/debian/argeo-libggml0.lintian-overrides index c83a4baf..bb0aa3d8 100644 --- a/debian/argeo-libggml0.lintian-overrides +++ b/debian/argeo-libggml0.lintian-overrides @@ -1,7 +1,7 @@ # Debian hardening flags are applied, # so it seems a false positive -libggml0: hardening-no-fortify-functions +argeo-libggml0: hardening-no-fortify-functions # According to https://wiki.debian.org/UsingSymbolsFiles # "For C++ libraries it is often better not to ship symbols files." -libggml0: no-symbols-control-file +argeo-libggml0: no-symbols-control-file diff --git a/debian/control b/debian/control index 7123ef38..7fa28f8b 100644 --- a/debian/control +++ b/debian/control @@ -6,10 +6,15 @@ Standards-Version: 4.7.2 Vcs-Browser: https://git.djapps.eu/?p=pkg/ggml/sources/ggml;a=summary Vcs-Git: https://git.djapps.eu/pkg/ggml/sources/ggml Homepage: https://github.com/ggml-org/ggml -Build-Depends: cmake, +Build-Depends: debhelper-compat (= 13), lsb-release, - debhelper-compat (= 13), + cmake, pkgconf, + clang, + lld, + llvm, + libc++-dev, + libomp-dev, libvulkan-dev , glslc , cuda-nvcc-13-2 , @@ -44,8 +49,8 @@ Conflicts: libggml-dev Section: libdevel Architecture: any Multi-Arch: same -Depends: libggml0 (= ${binary:Version}), - libggml-base0 (= ${binary:Version}), +Depends: argeo-libggml0 (= ${binary:Version}), + argeo-libggml-base0 (= ${binary:Version}), ${misc:Depends}, Description: Tensor library for machine learning (development files) This developments package provides the files required to build diff --git a/debian/rules b/debian/rules index 8542bb5c..631c954b 100755 --- a/debian/rules +++ b/debian/rules @@ -1,6 +1,11 @@ #!/usr/bin/make -f #export DH_VERBOSE = 1 +# clang build +export CC = clang +export CXX = clang++ +export LD = ld.lld + export DEB_BUILD_MAINT_OPTIONS = hardening=-all # Derivative @@ -27,6 +32,15 @@ CMAKE_OPTS = -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DGGML_BACKEND_DL=ON \ -DGGML_BACKEND_DIR=/usr/lib/${DEB_HOST_MULTIARCH}/ggml/backends0 \ +# clang build +CMAKE_OPTS += -DCMAKE_C_COMPILER=clang \ + -DCMAKE_CXX_COMPILER=clang++ \ + -DCMAKE_CXX_FLAGS=-stdlib=libc++ \ + -DCMAKE_LINKER_TYPE=LLD \ + +# OpenMP seems to work better with clang than with gcc +CMAKE_OPTS += -DGGML_OPENMP=ON + # Common backends CMAKE_OPTS += -DGGML_RPC=ON \ @@ -34,8 +48,8 @@ FLAGS_ARGEO=-O3 -g -DNDEBUG ifeq ($(DEB_TARGET_ARCH),arm64) -CMAKE_OPTS += -DGGML_CPU_ALL_VARIANTS=OFF -CMAKE_OPTS += -DGGML_CPU_ARM_ARCH=armv8.4-a +CMAKE_OPTS += -DGGML_CPU_ALL_VARIANTS=ON +#CMAKE_OPTS += -DGGML_CPU_ARM_ARCH=armv8.4-a else # amd64 @@ -43,16 +57,28 @@ CMAKE_OPTS += -DGGML_CPU_ALL_VARIANTS=ON endif # arm64 +## +## VULKAN +## ifeq ($(filter pkg.ggml.novulkan,$(DEB_BUILD_PROFILES)),) CMAKE_OPTS += -DGGML_VULKAN=ON endif +## +## CUDA +## ifeq ($(filter pkg.ggml.nocuda,$(DEB_BUILD_PROFILES)),) CMAKE_OPTS += -DGGML_CUDA=ON \ -DCMAKE_CUDA_FLAGS_RELWITHDEBINFO="$(FLAGS_ARGEO)" \ -DCMAKE_CUDA_COMPILER=/usr/local/cuda-13/bin/nvcc +# Compute capabilities supported by Argeo +# cf. https://developer.nvidia.com/cuda/gpus +CMAKE_OPTS += -DCMAKE_CUDA_ARCHITECTURES="121;120;89;86" +# All K/V cache combinations +CMAKE_OPTS += -DGGML_CUDA_FA_ALL_QUANTS=ON endif +# Add Argeo optimization flags CMAKE_OPTS += -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(FLAGS_ARGEO)" \ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(FLAGS_ARGEO)" \ @@ -66,3 +92,7 @@ override_dh_auto_configure: override_dh_installexamples: dh_installexamples --exclude=.gitignore + +override_dh_dwz: + # Skip dwz optimization when using clang + \ No newline at end of file