From b4ac6f0820fa65ed19dc493e3500eeaf54953a24 Mon Sep 17 00:00:00 2001 From: hutli Date: Thu, 15 Feb 2024 14:25:04 +0100 Subject: [PATCH 01/11] merge --- .devops/nix/package.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.devops/nix/package.nix b/.devops/nix/package.nix index 815db6a2d8c20..289db78ac0553 100644 --- a/.devops/nix/package.nix +++ b/.devops/nix/package.nix @@ -1,4 +1,5 @@ { + pkgs, lib, config, stdenv, @@ -160,6 +161,7 @@ effectiveStdenv.mkDerivation ( ninja pkg-config git + pkgs.glibc.static ] ++ optionals useCuda [ cudaPackages.cuda_nvcc From 51ec91b93a21d7dd4b1539d583624b5e9e45dc01 Mon Sep 17 00:00:00 2001 From: hutli Date: Fri, 23 Feb 2024 15:09:38 +0100 Subject: [PATCH 02/11] using default LLAMA_STATIC cmake skipping build of shared libs and using pkgs.glibc.static --- .devops/nix/package.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devops/nix/package.nix b/.devops/nix/package.nix index 289db78ac0553..e039f6aa1e9e4 100644 --- a/.devops/nix/package.nix +++ b/.devops/nix/package.nix @@ -183,7 +183,7 @@ effectiveStdenv.mkDerivation ( [ (cmakeBool "LLAMA_NATIVE" false) (cmakeBool "LLAMA_BUILD_SERVER" true) - (cmakeBool "BUILD_SHARED_LIBS" true) + (cmakeBool "BUILD_SHARED_LIBS" false) (cmakeBool "CMAKE_SKIP_BUILD_RPATH" true) (cmakeBool "LLAMA_BLAS" useBlas) (cmakeBool "LLAMA_CLBLAST" useOpenCL) @@ -192,6 +192,7 @@ effectiveStdenv.mkDerivation ( (cmakeBool "LLAMA_METAL" useMetalKit) (cmakeBool "LLAMA_MPI" useMpi) (cmakeBool "LLAMA_VULKAN" useVulkan) + (cmakeBool "LLAMA_STATIC" true) ] ++ optionals useCuda [ ( From 498e998cd769c46b45f92df1b397fd472c6708b8 Mon Sep 17 00:00:00 2001 From: hutli Date: Fri, 1 Mar 2024 14:29:03 +0100 Subject: [PATCH 03/11] buildStatic variable to toggle static builds --- .devops/nix/package.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.devops/nix/package.nix b/.devops/nix/package.nix index e039f6aa1e9e4..10dbd1e637b20 100644 --- a/.devops/nix/package.nix +++ b/.devops/nix/package.nix @@ -1,6 +1,6 @@ { - pkgs, lib, + glibc, config, stdenv, mkShell, @@ -31,6 +31,7 @@ useRocm ? config.rocmSupport, useVulkan ? false, llamaVersion ? "0.0.0", # Arbitrary version, substituted by the flake + buildStatic ? false, }@inputs: let @@ -161,7 +162,6 @@ effectiveStdenv.mkDerivation ( ninja pkg-config git - pkgs.glibc.static ] ++ optionals useCuda [ cudaPackages.cuda_nvcc @@ -169,6 +169,9 @@ effectiveStdenv.mkDerivation ( # TODO: Replace with autoAddDriverRunpath # once https://github.com/NixOS/nixpkgs/pull/275241 has been merged cudaPackages.autoAddOpenGLRunpathHook + ] + ++ optionals buildStatic [ + glibc.static ]; buildInputs = @@ -183,7 +186,7 @@ effectiveStdenv.mkDerivation ( [ (cmakeBool "LLAMA_NATIVE" false) (cmakeBool "LLAMA_BUILD_SERVER" true) - (cmakeBool "BUILD_SHARED_LIBS" false) + (cmakeBool "BUILD_SHARED_LIBS" !buildStatic) (cmakeBool "CMAKE_SKIP_BUILD_RPATH" true) (cmakeBool "LLAMA_BLAS" useBlas) (cmakeBool "LLAMA_CLBLAST" useOpenCL) @@ -192,7 +195,7 @@ effectiveStdenv.mkDerivation ( (cmakeBool "LLAMA_METAL" useMetalKit) (cmakeBool "LLAMA_MPI" useMpi) (cmakeBool "LLAMA_VULKAN" useVulkan) - (cmakeBool "LLAMA_STATIC" true) + (cmakeBool "LLAMA_STATIC" buildStatic) ] ++ optionals useCuda [ ( From bf11052b9fd20454a5fed45ecf9275c364bfd347 Mon Sep 17 00:00:00 2001 From: hutli Date: Fri, 1 Mar 2024 14:35:12 +0100 Subject: [PATCH 04/11] buildStatic variable to toggle static builds --- .devops/nix/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devops/nix/package.nix b/.devops/nix/package.nix index 10dbd1e637b20..027921ac48c7c 100644 --- a/.devops/nix/package.nix +++ b/.devops/nix/package.nix @@ -186,7 +186,7 @@ effectiveStdenv.mkDerivation ( [ (cmakeBool "LLAMA_NATIVE" false) (cmakeBool "LLAMA_BUILD_SERVER" true) - (cmakeBool "BUILD_SHARED_LIBS" !buildStatic) + (cmakeBool "BUILD_SHARED_LIBS" (!buildStatic)) (cmakeBool "CMAKE_SKIP_BUILD_RPATH" true) (cmakeBool "LLAMA_BLAS" useBlas) (cmakeBool "LLAMA_CLBLAST" useOpenCL) From db22ce347febbe54a3c730ab7136efdcf752edb4 Mon Sep 17 00:00:00 2001 From: hutli <6594598+hutli@users.noreply.github.com> Date: Sat, 2 Mar 2024 02:42:22 +0100 Subject: [PATCH 05/11] using host platform isStatic as default value for "enableStatic" Co-authored-by: Philip Taron --- .devops/nix/package.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devops/nix/package.nix b/.devops/nix/package.nix index 027921ac48c7c..cd5e820d544c2 100644 --- a/.devops/nix/package.nix +++ b/.devops/nix/package.nix @@ -31,7 +31,8 @@ useRocm ? config.rocmSupport, useVulkan ? false, llamaVersion ? "0.0.0", # Arbitrary version, substituted by the flake - buildStatic ? false, + effectiveStdenv = if useCuda then cudaPackages.backendStdenv else stdenv, + enableStatic ? effectiveStdenv.hostPlatform.isStatic }@inputs: let From 48830d706cbdd16d83faf4bac351ce1c45adfb19 Mon Sep 17 00:00:00 2001 From: hutli <6594598+hutli@users.noreply.github.com> Date: Sat, 2 Mar 2024 02:44:22 +0100 Subject: [PATCH 06/11] "buildStatic" -> "enableStatic" Co-authored-by: Philip Taron --- .devops/nix/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devops/nix/package.nix b/.devops/nix/package.nix index cd5e820d544c2..eb7c1c82e29ce 100644 --- a/.devops/nix/package.nix +++ b/.devops/nix/package.nix @@ -187,7 +187,7 @@ effectiveStdenv.mkDerivation ( [ (cmakeBool "LLAMA_NATIVE" false) (cmakeBool "LLAMA_BUILD_SERVER" true) - (cmakeBool "BUILD_SHARED_LIBS" (!buildStatic)) + (cmakeBool "BUILD_SHARED_LIBS" (!enableStatic)) (cmakeBool "CMAKE_SKIP_BUILD_RPATH" true) (cmakeBool "LLAMA_BLAS" useBlas) (cmakeBool "LLAMA_CLBLAST" useOpenCL) From 3cfb0f01c8e7aacd31ea4a4492e35c7605ace831 Mon Sep 17 00:00:00 2001 From: hutli <6594598+hutli@users.noreply.github.com> Date: Sat, 2 Mar 2024 02:44:55 +0100 Subject: [PATCH 07/11] "buildStatic" -> "enableStatic" Co-authored-by: Philip Taron --- .devops/nix/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devops/nix/package.nix b/.devops/nix/package.nix index eb7c1c82e29ce..093d22ba7fa6b 100644 --- a/.devops/nix/package.nix +++ b/.devops/nix/package.nix @@ -196,7 +196,7 @@ effectiveStdenv.mkDerivation ( (cmakeBool "LLAMA_METAL" useMetalKit) (cmakeBool "LLAMA_MPI" useMpi) (cmakeBool "LLAMA_VULKAN" useVulkan) - (cmakeBool "LLAMA_STATIC" buildStatic) + (cmakeBool "LLAMA_STATIC" enableStatic) ] ++ optionals useCuda [ ( From d12f2399ac993a611884896c58b41db1cc5b88d3 Mon Sep 17 00:00:00 2001 From: hutli Date: Mon, 4 Mar 2024 12:45:03 +0100 Subject: [PATCH 08/11] using enableStatic to determine glibc dependency --- .devops/nix/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devops/nix/package.nix b/.devops/nix/package.nix index 093d22ba7fa6b..598f880d9ae90 100644 --- a/.devops/nix/package.nix +++ b/.devops/nix/package.nix @@ -171,7 +171,7 @@ effectiveStdenv.mkDerivation ( # once https://github.com/NixOS/nixpkgs/pull/275241 has been merged cudaPackages.autoAddOpenGLRunpathHook ] - ++ optionals buildStatic [ + ++ optionals (effectiveStdenv.hostPlatform.isGnu && enableStatic) [ glibc.static ]; From bc51e28cf4aa5cd3a25ce1050d7b6c240df9c0a1 Mon Sep 17 00:00:00 2001 From: hutli Date: Mon, 4 Mar 2024 12:53:18 +0100 Subject: [PATCH 09/11] using correct syntax for effectiveStdenv default --- .devops/nix/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devops/nix/package.nix b/.devops/nix/package.nix index 598f880d9ae90..065aad2c983e8 100644 --- a/.devops/nix/package.nix +++ b/.devops/nix/package.nix @@ -31,7 +31,7 @@ useRocm ? config.rocmSupport, useVulkan ? false, llamaVersion ? "0.0.0", # Arbitrary version, substituted by the flake - effectiveStdenv = if useCuda then cudaPackages.backendStdenv else stdenv, + effectiveStdenv ? if useCuda then cudaPackages.backendStdenv else stdenv, enableStatic ? effectiveStdenv.hostPlatform.isStatic }@inputs: From 7a2ca8bde89077729efa5a4be0505e92b31ff21c Mon Sep 17 00:00:00 2001 From: hutli Date: Mon, 4 Mar 2024 14:02:58 +0100 Subject: [PATCH 10/11] removed dupulicate declaration of effectiveStdenv --- .devops/nix/package.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.devops/nix/package.nix b/.devops/nix/package.nix index 065aad2c983e8..73e8e1897e8a3 100644 --- a/.devops/nix/package.nix +++ b/.devops/nix/package.nix @@ -31,6 +31,9 @@ useRocm ? config.rocmSupport, useVulkan ? false, llamaVersion ? "0.0.0", # Arbitrary version, substituted by the flake + + # It's necessary to consistently use backendStdenv when building with CUDA support, + # otherwise we get libstdc++ errors downstream.1 effectiveStdenv ? if useCuda then cudaPackages.backendStdenv else stdenv, enableStatic ? effectiveStdenv.hostPlatform.isStatic }@inputs: @@ -43,11 +46,8 @@ let strings versionOlder ; - - # It's necessary to consistently use backendStdenv when building with CUDA support, - # otherwise we get libstdc++ errors downstream. + stdenv = throw "Use effectiveStdenv instead"; - effectiveStdenv = if useCuda then cudaPackages.backendStdenv else inputs.stdenv; suffices = lib.optionals useBlas [ "BLAS" ] From 4aa00f48d6d9fb77def9785edb3c4b507abdc156 Mon Sep 17 00:00:00 2001 From: Philip Taron Date: Mon, 4 Mar 2024 07:29:03 -0800 Subject: [PATCH 11/11] nix: update comment on effectiveStdenv I suspect an editor typo. --- .devops/nix/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devops/nix/package.nix b/.devops/nix/package.nix index 73e8e1897e8a3..01c99185b86ac 100644 --- a/.devops/nix/package.nix +++ b/.devops/nix/package.nix @@ -33,7 +33,7 @@ llamaVersion ? "0.0.0", # Arbitrary version, substituted by the flake # It's necessary to consistently use backendStdenv when building with CUDA support, - # otherwise we get libstdc++ errors downstream.1 + # otherwise we get libstdc++ errors downstream. effectiveStdenv ? if useCuda then cudaPackages.backendStdenv else stdenv, enableStatic ? effectiveStdenv.hostPlatform.isStatic }@inputs: