1
1
{
2
2
lib ,
3
+ glibc ,
3
4
config ,
4
5
stdenv ,
5
6
mkShell ,
30
31
useRocm ? config . rocmSupport ,
31
32
useVulkan ? false ,
32
33
llamaVersion ? "0.0.0" , # Arbitrary version, substituted by the flake
34
+
35
+ # It's necessary to consistently use backendStdenv when building with CUDA support,
36
+ # otherwise we get libstdc++ errors downstream.
37
+ effectiveStdenv ? if useCuda then cudaPackages . backendStdenv else stdenv ,
38
+ enableStatic ? effectiveStdenv . hostPlatform . isStatic
33
39
} @inputs :
34
40
35
41
let
40
46
strings
41
47
versionOlder
42
48
;
43
-
44
- # It's necessary to consistently use backendStdenv when building with CUDA support,
45
- # otherwise we get libstdc++ errors downstream.
49
+
46
50
stdenv = throw "Use effectiveStdenv instead" ;
47
- effectiveStdenv = if useCuda then cudaPackages . backendStdenv else inputs . stdenv ;
48
51
49
52
suffices =
50
53
lib . optionals useBlas [ "BLAS" ]
@@ -167,6 +170,9 @@ effectiveStdenv.mkDerivation (
167
170
# TODO: Replace with autoAddDriverRunpath
168
171
# once https://github.com/NixOS/nixpkgs/pull/275241 has been merged
169
172
cudaPackages . autoAddOpenGLRunpathHook
173
+ ]
174
+ ++ optionals ( effectiveStdenv . hostPlatform . isGnu && enableStatic ) [
175
+ glibc . static
170
176
] ;
171
177
172
178
buildInputs =
@@ -181,7 +187,7 @@ effectiveStdenv.mkDerivation (
181
187
[
182
188
( cmakeBool "LLAMA_NATIVE" false )
183
189
( cmakeBool "LLAMA_BUILD_SERVER" true )
184
- ( cmakeBool "BUILD_SHARED_LIBS" true )
190
+ ( cmakeBool "BUILD_SHARED_LIBS" ( ! enableStatic ) )
185
191
( cmakeBool "CMAKE_SKIP_BUILD_RPATH" true )
186
192
( cmakeBool "LLAMA_BLAS" useBlas )
187
193
( cmakeBool "LLAMA_CLBLAST" useOpenCL )
@@ -190,6 +196,7 @@ effectiveStdenv.mkDerivation (
190
196
( cmakeBool "LLAMA_METAL" useMetalKit )
191
197
( cmakeBool "LLAMA_MPI" useMpi )
192
198
( cmakeBool "LLAMA_VULKAN" useVulkan )
199
+ ( cmakeBool "LLAMA_STATIC" enableStatic )
193
200
]
194
201
++ optionals useCuda [
195
202
(
0 commit comments