Skip to content

Commit 45bbf99

Browse files
committed
Add ggml-backend-meta.cpp to GPU runtime build scripts
Upstream's ggml-backend.cpp now references ggml_backend_buffer_is_meta (line 133, 2006) and ggml-alloc.c references ggml_backend_buft_is_meta (line 1240). Both functions are defined in the new ggml-backend-meta.cpp which upstream made part of ggml-base. Without this, the runtime-built GPU DSOs (ggml-cuda.so/.dll, ggml-rocm.dll, ggml-vulkan.dll) and the on-the-fly Metal dylib build would link with undefined references. Updated: - llamafile/build-functions.sh (Linux CUDA + ROCm via cuda.sh / rocm.sh) - llamafile/cuda.bat, llamafile/cuda_parallel.bat - llamafile/rocm.bat, llamafile/rocm_parallel.bat - llamafile/vulkan.bat - llamafile/metal.c (yoink + extracted-files map + compile list) - llamafile/BUILD.mk (add ggml-backend-meta.cpp.zip.o to LLAMAFILE_METAL_SOURCES)
1 parent 7a5f2e8 commit 45bbf99

8 files changed

Lines changed: 10 additions & 5 deletions

File tree

llamafile/BUILD.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ LLAMAFILE_METAL_SOURCES := \
234234
o/$(MODE)/llama.cpp/ggml/src/ggml.c.zip.o \
235235
o/$(MODE)/llama.cpp/ggml/src/ggml-alloc.c.zip.o \
236236
o/$(MODE)/llama.cpp/ggml/src/ggml-backend.cpp.zip.o \
237+
o/$(MODE)/llama.cpp/ggml/src/ggml-backend-meta.cpp.zip.o \
237238
o/$(MODE)/llama.cpp/ggml/src/ggml-quants.c.zip.o \
238239
o/$(MODE)/llama.cpp/ggml/src/ggml-threading.cpp.zip.o \
239240
o/$(MODE)/llama.cpp/ggml/include/ggml.h.zip.o \

llamafile/build-functions.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ compile_ggml_core() {
175175
$llama_cpp_dir/ggml/src/ggml.c \
176176
$llama_cpp_dir/ggml/src/ggml-alloc.c \
177177
$llama_cpp_dir/ggml/src/ggml-backend.cpp \
178+
$llama_cpp_dir/ggml/src/ggml-backend-meta.cpp \
178179
$llama_cpp_dir/ggml/src/ggml-quants.c \
179180
$llama_cpp_dir/ggml/src/ggml-threading.cpp"
180181

llamafile/cuda.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ for %%f in (ggml.c ggml-alloc.c ggml-quants.c) do (
249249
)
250250

251251
:: C++ sources
252-
for %%f in (ggml-backend.cpp ggml-threading.cpp) do (
252+
for %%f in (ggml-backend.cpp ggml-backend-meta.cpp ggml-threading.cpp) do (
253253
set "SRC=%GGML_SRC_DIR%\%%f"
254254
set "BASE=%%~nf"
255255
set "OBJ=%BUILD_DIR%\ggml-core-!BASE!.obj"

llamafile/cuda_parallel.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ for %%f in (ggml.c ggml-alloc.c ggml-quants.c) do (
268268
)
269269

270270
:: C++ sources
271-
for %%f in (ggml-backend.cpp ggml-threading.cpp) do (
271+
for %%f in (ggml-backend.cpp ggml-backend-meta.cpp ggml-threading.cpp) do (
272272
set "SRC=%GGML_SRC_DIR%\%%f"
273273
set "BASE=%%~nf"
274274
set "OBJ=%BUILD_DIR%\ggml-core-!BASE!.obj"

llamafile/metal.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ extern char **environ;
5454
__static_yoink("llama.cpp/ggml/src/ggml.c");
5555
__static_yoink("llama.cpp/ggml/src/ggml-alloc.c");
5656
__static_yoink("llama.cpp/ggml/src/ggml-backend.cpp");
57+
__static_yoink("llama.cpp/ggml/src/ggml-backend-meta.cpp");
5758
__static_yoink("llama.cpp/ggml/src/ggml-quants.c");
5859
__static_yoink("llama.cpp/ggml/src/ggml-threading.cpp");
5960

@@ -108,6 +109,7 @@ static const struct MetalSource {
108109
{"/zip/llama.cpp/ggml/src/ggml.c", "ggml.c"},
109110
{"/zip/llama.cpp/ggml/src/ggml-alloc.c", "ggml-alloc.c"},
110111
{"/zip/llama.cpp/ggml/src/ggml-backend.cpp", "ggml-backend.cpp"},
112+
{"/zip/llama.cpp/ggml/src/ggml-backend-meta.cpp", "ggml-backend-meta.cpp"},
111113
{"/zip/llama.cpp/ggml/src/ggml-quants.c", "ggml-quants.c"},
112114
{"/zip/llama.cpp/ggml/src/ggml-threading.cpp", "ggml-threading.cpp"},
113115

@@ -379,6 +381,7 @@ static bool BuildMetal(const char *dso) {
379381
"ggml-alloc.c",
380382
"ggml-quants.c",
381383
"ggml-backend.cpp",
384+
"ggml-backend-meta.cpp",
382385
"ggml-threading.cpp",
383386
"ggml-metal.cpp",
384387
"ggml-metal-device.cpp",

llamafile/rocm.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ for %%f in (ggml.c ggml-alloc.c ggml-quants.c) do (
235235
)
236236

237237
:: C++ sources
238-
for %%f in (ggml-backend.cpp ggml-threading.cpp) do (
238+
for %%f in (ggml-backend.cpp ggml-backend-meta.cpp ggml-threading.cpp) do (
239239
set "SRC=%GGML_SRC_DIR%\%%f"
240240
set "BASE=%%~nf"
241241
set "OBJ=%BUILD_DIR%\ggml-core-!BASE!.obj"

llamafile/rocm_parallel.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ for %%f in (ggml.c ggml-alloc.c ggml-quants.c) do (
254254
)
255255

256256
:: C++ sources
257-
for %%f in (ggml-backend.cpp ggml-threading.cpp) do (
257+
for %%f in (ggml-backend.cpp ggml-backend-meta.cpp ggml-threading.cpp) do (
258258
set "SRC=%GGML_SRC_DIR%\%%f"
259259
set "BASE=%%~nf"
260260
set "OBJ=%BUILD_DIR%\ggml-core-!BASE!.obj"

llamafile/vulkan.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ for %%f in (ggml.c ggml-alloc.c ggml-quants.c) do (
292292
)
293293

294294
:: C++ sources
295-
for %%f in (ggml-backend.cpp ggml-threading.cpp) do (
295+
for %%f in (ggml-backend.cpp ggml-backend-meta.cpp ggml-threading.cpp) do (
296296
set "SRC=%GGML_SRC_DIR%\%%f"
297297
set "BASE=%%~nf"
298298
set "OBJ=%BUILD_DIR%\ggml-core-!BASE!.obj"

0 commit comments

Comments
 (0)