1PORTNAME=	llama-cpp
2DISTVERSIONPREFIX=	b
3DISTVERSION=	7134
4CATEGORIES=	misc # machine-learning
5
6MAINTAINER=	ports@MidnightBSD.org
7COMMENT=	Facebook's LLaMA model in C/C++ # '
8WWW=		https://github.com/ggerganov/llama.cpp
9
10LICENSE=	mit
11LICENSE_FILE=	${WRKSRC}/LICENSE
12
13BROKEN_armv7=	clang crashes, see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278810
14BROKEN_i386=	compilation fails, see https://github.com/ggerganov/llama.cpp/issues/9545
15
16USES=		cmake:testing compiler:c++11-lang python:run shebangfix
17USE_LDCONFIG=	yes
18
19USE_GITHUB=	yes
20GH_ACCOUNT=	ggerganov
21GH_PROJECT=	llama.cpp
22GH_TUPLE=	nomic-ai:kompute:4565194:kompute/kompute
23
24SHEBANG_GLOB=	*.py
25
26CMAKE_ON=	BUILD_SHARED_LIBS
27CMAKE_OFF=	GGML_NATIVE \
28		FREEBSD_ALLOW_ADVANCED_CPU_FEATURES \
29		LLAMA_BUILD_TESTS
30CMAKE_TESTING_ON=	LLAMA_BUILD_TESTS
31
32# user for llama-server, only used when EXAMPLES=ON
33USER=		nobody
34SUB_LIST=	USER=${USER}
35
36OPTIONS_DEFINE=		CURL EXAMPLES VULKAN
37OPTIONS_DEFAULT=	CURL VULKAN
38OPTIONS_SUB=		yes
39
40CURL_DESCR=		Use libcurl to download model from an URL
41CURL_CMAKE_BOOL=	LLAMA_CURL
42CURL_USES=		localbase
43CURL_LIB_DEPENDS=	libcurl.so:ftp/curl
44
45EXAMPLES_CMAKE_BOOL=	LLAMA_BUILD_EXAMPLES
46
47VULKAN_DESC=		Vulkan GPU offload support
48VULKAN_CMAKE_BOOL=	GGML_VULKAN
49VULKAN_BUILD_DEPENDS=	glslc:graphics/shaderc \
50			vulkan-headers>0:graphics/vulkan-headers
51VULKAN_LIB_DEPENDS=	libvulkan.so:graphics/vulkan-loader
52
53BINARY_ALIAS=	git=false \
54		python=${PYTHON_CMD} # for tests
55
56post-patch: # set version in the code
57	@${REINPLACE_CMD} \
58		-e "s|set(BUILD_NUMBER 0)|set(BUILD_NUMBER ${DISTVERSION})|" \
59		${WRKSRC}/cmake/build-info.cmake
60
61do-test-ci: # build of tests fails, see https://github.com/ggerganov/llama.cpp/issues/10955
62	@cd ${WRKSRC} && \
63		${SETENV} ${MAKE_ENV} bash ci/run.sh ./tmp/results ./tmp/mnt
64
65.include <bsd.mport.options.mk>
66
67.if ${PORT_OPTIONS:MEXAMPLES}
68USE_RC_SUBR=	llama-server
69.endif
70
71# tests as of 4458: 97% tests passed, 1 tests failed out of 31, see https://github.com/ggerganov/llama.cpp/issues/11036
72
73# tests as of 4649:
74# 88% tests passed, 4 tests failed out of 32
75# The following tests FAILED:
76#         18 - test-chat (Subprocess aborted)                    main   # see https://github.com/ggerganov/llama.cpp/issues/11705
77#         24 - test-gguf (SEGFAULT)                              main
78#         25 - test-backend-ops (SEGFAULT)                       main
79#         32 - test-eval-callback (SEGFAULT)                     curl eval-callback
80
81.include <bsd.port.mk>
82