From 14a4fc874b0c0363c73136311cb36677f321cfd1 Mon Sep 17 00:00:00 2001 From: Corbin Date: Wed, 19 Apr 2023 10:23:47 -0700 Subject: [PATCH 1/2] Nix flake: Use Makefile instead of CMake I can't test whether this works on Darwin, but it can build libllama.so. I did try building via CMake with -DBUILD_SHARED_LIBS=ON, but it did not work and I could not make it work. --- flake.nix | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index 5363052b1058a..6d108d7c573c8 100644 --- a/flake.nix +++ b/flake.nix @@ -18,17 +18,21 @@ packages.default = pkgs.stdenv.mkDerivation { name = "llama.cpp"; src = ./.; - nativeBuildInputs = with pkgs; [ cmake ]; buildInputs = with pkgs; lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Accelerate ]; - cmakeFlags = with pkgs; lib.optionals (system == "aarch64-darwin") [ - "-DCMAKE_C_FLAGS=-D__ARM_FEATURE_DOTPROD=1" - ]; + buildPhase = '' + make main quantize quantize-stats perplexity embedding vdot libllama.so + ''; installPhase = '' - mkdir -p $out/bin - mv bin/* $out/bin/ - mv $out/bin/main $out/bin/llama + mkdir -p $out/lib/ + cp libllama.so $out/lib/ + + mkdir -p $out/bin/ + mv main $out/bin/llama + for exe in quantize quantize-stats perplexity embedding vdot; do + mv $exe $out/bin/ + done echo "#!${llama-python}/bin/python" > $out/bin/convert-pth-to-ggml cat ${./convert-pth-to-ggml.py} >> $out/bin/convert-pth-to-ggml From fe14e7c522bb2f01c9d948072e15377403bfc270 Mon Sep 17 00:00:00 2001 From: Corbin Date: Wed, 19 Apr 2023 10:53:42 -0700 Subject: [PATCH 2/2] Re-add dropped Darwin-only flag. Whoops! I didn't notice this at first because I'm not on Darwin. Can somebody test this, please? --- flake.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/flake.nix b/flake.nix index 6d108d7c573c8..a353b8c3b4c8f 100644 --- a/flake.nix +++ b/flake.nix @@ -21,6 +21,9 @@ buildInputs = with pkgs; lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Accelerate ]; + makeFlags = with pkgs; lib.optionals (system == "aarch64-darwin") [ + "CFLAGS=-D__ARM_FEATURE_DOTPROD=1" + ]; buildPhase = '' make main quantize quantize-stats perplexity embedding vdot libllama.so '';