Makefile 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792
  1. # Define the default target now so that it is always the first target
  2. BUILD_TARGETS = \
  3. libllava.a \
  4. llama-batched \
  5. llama-batched-bench \
  6. llama-bench \
  7. llama-cli \
  8. llama-convert-llama2c-to-ggml \
  9. llama-embedding \
  10. llama-eval-callback \
  11. llama-export-lora \
  12. llama-gbnf-validator \
  13. llama-gguf \
  14. llama-gguf-hash \
  15. llama-gguf-split \
  16. llama-gritlm \
  17. llama-imatrix \
  18. llama-infill \
  19. llama-llava-cli \
  20. llama-minicpmv-cli\
  21. llama-lookahead \
  22. llama-lookup \
  23. llama-lookup-create \
  24. llama-lookup-merge \
  25. llama-lookup-stats \
  26. llama-parallel \
  27. llama-passkey \
  28. llama-perplexity \
  29. llama-q8dot \
  30. llama-quantize \
  31. llama-quantize-stats \
  32. llama-retrieval \
  33. llama-save-load-state \
  34. llama-server \
  35. llama-simple \
  36. llama-simple-chat \
  37. llama-speculative \
  38. llama-tokenize \
  39. llama-vdot \
  40. llama-cvector-generator \
  41. llama-gen-docs \
  42. tests/test-c.o
  43. # Binaries only useful for tests
  44. TEST_TARGETS = \
  45. tests/test-arg-parser \
  46. tests/test-autorelease \
  47. tests/test-backend-ops \
  48. tests/test-chat-template \
  49. tests/test-double-float \
  50. tests/test-grad0 \
  51. tests/test-grammar-integration \
  52. tests/test-grammar-parser \
  53. tests/test-json-schema-to-grammar \
  54. tests/test-llama-grammar \
  55. tests/test-log \
  56. tests/test-model-load-cancel \
  57. tests/test-quantize-fns \
  58. tests/test-quantize-perf \
  59. tests/test-rope \
  60. tests/test-sampling \
  61. tests/test-tokenizer-0 \
  62. tests/test-tokenizer-1-bpe \
  63. tests/test-tokenizer-1-spm
  64. # tests/test-opt \
  65. # Legacy build targets that were renamed in #7809, but should still be removed when the project is cleaned
  66. LEGACY_TARGETS_CLEAN = main quantize quantize-stats perplexity imatrix embedding vdot q8dot convert-llama2c-to-ggml \
  67. simple batched batched-bench save-load-state server gguf gguf-split eval-callback llama-bench libllava.a llava-cli baby-llama \
  68. retrieval speculative infill tokenize parallel export-lora lookahead lookup passkey gritlm
  69. # Legacy build targets that were renamed in #7809, but we want to build binaries that for them that output a deprecation warning if people try to use them.
  70. # We don't want to clutter things too much, so we only build replacements for the most commonly used binaries.
  71. LEGACY_TARGETS_BUILD = main quantize perplexity embedding server
  72. # Deprecation aliases
  73. ifdef LLAMA_CUBLAS
  74. $(error LLAMA_CUBLAS is removed. Use GGML_CUDA instead.)
  75. endif
  76. ifdef LLAMA_CUDA
  77. GGML_CUDA := 1
  78. DEPRECATE_WARNING := 1
  79. endif
  80. ifdef LLAMA_KOMPUTE
  81. GGML_KOMPUTE := 1
  82. DEPRECATE_WARNING := 1
  83. endif
  84. ifdef LLAMA_METAL
  85. GGML_METAL := 1
  86. DEPRECATE_WARNING := 1
  87. endif
  88. ifdef LLAMA_RPC
  89. GGML_RPC := 1
  90. DEPRECATE_WARNING := 1
  91. endif
  92. ifdef LLAMA_SYCL
  93. GGML_SYCL := 1
  94. DEPRECATE_WARNING := 1
  95. endif
  96. ifdef LLAMA_SYCL_F16
  97. GGML_SYCL_F16 := 1
  98. DEPRECATE_WARNING := 1
  99. endif
  100. ifdef LLAMA_OPENBLAS
  101. GGML_OPENBLAS := 1
  102. DEPRECATE_WARNING := 1
  103. endif
  104. ifdef LLAMA_OPENBLAS64
  105. GGML_OPENBLAS64 := 1
  106. DEPRECATE_WARNING := 1
  107. endif
  108. ifdef LLAMA_BLIS
  109. GGML_BLIS := 1
  110. DEPRECATE_WARNING := 1
  111. endif
  112. ifdef LLAMA_NO_LLAMAFILE
  113. GGML_NO_LLAMAFILE := 1
  114. DEPRECATE_WARNING := 1
  115. endif
  116. ifdef LLAMA_NO_ACCELERATE
  117. GGML_NO_ACCELERATE := 1
  118. DEPRECATE_WARNING := 1
  119. endif
  120. ifdef LLAMA_NO_OPENMP
  121. GGML_NO_OPENMP := 1
  122. DEPRECATE_WARNING := 1
  123. endif
  124. ifdef LLAMA_NO_METAL
  125. GGML_NO_METAL := 1
  126. DEPRECATE_WARNING := 1
  127. endif
  128. ifdef LLAMA_DISABLE_LOGS
  129. REMOVE_WARNING := 1
  130. endif
  131. ifdef LLAMA_SERVER_VERBOSE
  132. REMOVE_WARNING := 1
  133. endif
  134. ifndef UNAME_S
  135. UNAME_S := $(shell uname -s)
  136. endif
  137. ifndef UNAME_P
  138. UNAME_P := $(shell uname -p)
  139. endif
  140. ifndef UNAME_M
  141. UNAME_M := $(shell uname -m)
  142. endif
  143. # In GNU make default CXX is g++ instead of c++. Let's fix that so that users
  144. # of non-gcc compilers don't have to provide g++ alias or wrapper.
  145. DEFCC := cc
  146. DEFCXX := c++
  147. ifeq ($(origin CC),default)
  148. CC := $(DEFCC)
  149. endif
  150. ifeq ($(origin CXX),default)
  151. CXX := $(DEFCXX)
  152. endif
  153. # Mac OS + Arm can report x86_64
  154. # ref: https://github.com/ggerganov/whisper.cpp/issues/66#issuecomment-1282546789
  155. ifeq ($(UNAME_S),Darwin)
  156. ifndef GGML_NO_METAL
  157. GGML_METAL := 1
  158. endif
  159. GGML_NO_OPENMP := 1
  160. ifneq ($(UNAME_P),arm)
  161. SYSCTL_M := $(shell sysctl -n hw.optional.arm64 2>/dev/null)
  162. ifeq ($(SYSCTL_M),1)
  163. # UNAME_P := arm
  164. # UNAME_M := arm64
  165. warn := $(warning Your arch is announced as x86_64, but it seems to actually be ARM64. Not fixing that can lead to bad performance. For more info see: https://github.com/ggerganov/whisper.cpp/issues/66\#issuecomment-1282546789)
  166. endif
  167. endif
  168. endif
  169. ifdef GGML_METAL
  170. GGML_METAL_EMBED_LIBRARY := 1
  171. endif
  172. ifdef GGML_RPC
  173. BUILD_TARGETS += rpc-server
  174. endif
  175. ifdef GGML_VULKAN
  176. BUILD_TARGETS += vulkan-shaders-gen
  177. endif
  178. default: $(BUILD_TARGETS) $(LEGACY_TARGETS_BUILD)
  179. test: $(TEST_TARGETS)
  180. @failures=0; \
  181. for test_target in $(TEST_TARGETS); do \
  182. if [ "$$test_target" = "tests/test-tokenizer-0" ]; then \
  183. ./$$test_target $(CURDIR)/models/ggml-vocab-llama-spm.gguf; \
  184. ./$$test_target $(CURDIR)/models/ggml-vocab-llama-bpe.gguf; \
  185. ./$$test_target $(CURDIR)/models/ggml-vocab-phi-3.gguf; \
  186. ./$$test_target $(CURDIR)/models/ggml-vocab-falcon.gguf; \
  187. ./$$test_target $(CURDIR)/models/ggml-vocab-bert-bge.gguf; \
  188. ./$$test_target $(CURDIR)/models/ggml-vocab-starcoder.gguf; \
  189. ./$$test_target $(CURDIR)/models/ggml-vocab-gpt-2.gguf; \
  190. ./$$test_target $(CURDIR)/models/ggml-vocab-refact.gguf; \
  191. elif [ "$$test_target" = "tests/test-tokenizer-1-spm" ]; then \
  192. continue; \
  193. elif [ "$$test_target" = "tests/test-tokenizer-1-bpe" ]; then \
  194. continue; \
  195. else \
  196. echo "Running test $$test_target..."; \
  197. ./$$test_target; \
  198. fi; \
  199. if [ $$? -ne 0 ]; then \
  200. printf 'Test %s FAILED!\n\n' $$test_target; \
  201. failures=$$(( failures + 1 )); \
  202. else \
  203. printf 'Test %s passed.\n\n' $$test_target; \
  204. fi; \
  205. done; \
  206. if [ $$failures -gt 0 ]; then \
  207. printf '\n%s tests failed.\n' $$failures; \
  208. exit 1; \
  209. fi
  210. @echo 'All tests passed.'
  211. all: $(BUILD_TARGETS) $(TEST_TARGETS) $(LEGACY_TARGETS_BUILD)
  212. ifdef RISCV_CROSS_COMPILE
  213. CC := riscv64-unknown-linux-gnu-gcc
  214. CXX := riscv64-unknown-linux-gnu-g++
  215. endif
  216. #
  217. # Compile flags
  218. #
  219. # keep standard at C11 and C++11
  220. MK_CPPFLAGS = -Iggml/include -Iggml/src -Iinclude -Isrc -Icommon
  221. MK_CFLAGS = -std=c11 -fPIC
  222. MK_CXXFLAGS = -std=c++11 -fPIC
  223. MK_NVCCFLAGS = -std=c++11
  224. ifdef LLAMA_NO_CCACHE
  225. GGML_NO_CCACHE := 1
  226. DEPRECATE_WARNING := 1
  227. endif
  228. ifndef GGML_NO_CCACHE
  229. CCACHE := $(shell which ccache)
  230. ifdef CCACHE
  231. export CCACHE_SLOPPINESS = time_macros
  232. $(info I ccache found, compilation results will be cached. Disable with GGML_NO_CCACHE.)
  233. CC := $(CCACHE) $(CC)
  234. CXX := $(CCACHE) $(CXX)
  235. else
  236. $(info I ccache not found. Consider installing it for faster compilation.)
  237. endif # CCACHE
  238. endif # GGML_NO_CCACHE
  239. # clock_gettime came in POSIX.1b (1993)
  240. # CLOCK_MONOTONIC came in POSIX.1-2001 / SUSv3 as optional
  241. # posix_memalign came in POSIX.1-2001 / SUSv3
  242. # M_PI is an XSI extension since POSIX.1-2001 / SUSv3, came in XPG1 (1985)
  243. MK_CPPFLAGS += -D_XOPEN_SOURCE=600
  244. # Somehow in OpenBSD whenever POSIX conformance is specified
  245. # some string functions rely on locale_t availability,
  246. # which was introduced in POSIX.1-2008, forcing us to go higher
  247. ifeq ($(UNAME_S),OpenBSD)
  248. MK_CPPFLAGS += -U_XOPEN_SOURCE -D_XOPEN_SOURCE=700
  249. endif
  250. # Data types, macros and functions related to controlling CPU affinity and
  251. # some memory allocation are available on Linux through GNU extensions in libc
  252. ifeq ($(UNAME_S),Linux)
  253. MK_CPPFLAGS += -D_GNU_SOURCE
  254. endif
  255. # RLIMIT_MEMLOCK came in BSD, is not specified in POSIX.1,
  256. # and on macOS its availability depends on enabling Darwin extensions
  257. # similarly on DragonFly, enabling BSD extensions is necessary
  258. ifeq ($(UNAME_S),Darwin)
  259. MK_CPPFLAGS += -D_DARWIN_C_SOURCE
  260. endif
  261. ifeq ($(UNAME_S),DragonFly)
  262. MK_CPPFLAGS += -D__BSD_VISIBLE
  263. endif
  264. # alloca is a non-standard interface that is not visible on BSDs when
  265. # POSIX conformance is specified, but not all of them provide a clean way
  266. # to enable it in such cases
  267. ifeq ($(UNAME_S),FreeBSD)
  268. MK_CPPFLAGS += -D__BSD_VISIBLE
  269. endif
  270. ifeq ($(UNAME_S),NetBSD)
  271. MK_CPPFLAGS += -D_NETBSD_SOURCE
  272. endif
  273. ifeq ($(UNAME_S),OpenBSD)
  274. MK_CPPFLAGS += -D_BSD_SOURCE
  275. endif
  276. ifdef GGML_SCHED_MAX_COPIES
  277. MK_CPPFLAGS += -DGGML_SCHED_MAX_COPIES=$(GGML_SCHED_MAX_COPIES)
  278. endif
  279. ifdef LLAMA_DEBUG
  280. MK_CFLAGS += -O0 -g
  281. MK_CXXFLAGS += -O0 -g
  282. MK_LDFLAGS += -g
  283. MK_NVCCFLAGS += -O0 -g
  284. ifeq ($(UNAME_S),Linux)
  285. MK_CPPFLAGS += -D_GLIBCXX_ASSERTIONS
  286. endif
  287. else
  288. MK_CPPFLAGS += -DNDEBUG
  289. MK_CFLAGS += -O3 -g
  290. MK_CXXFLAGS += -O3 -g
  291. MK_NVCCFLAGS += -O3 -g
  292. endif
  293. ifdef LLAMA_SANITIZE_THREAD
  294. MK_CFLAGS += -fsanitize=thread -g
  295. MK_CXXFLAGS += -fsanitize=thread -g
  296. MK_LDFLAGS += -fsanitize=thread -g
  297. endif
  298. ifdef LLAMA_SANITIZE_ADDRESS
  299. MK_CFLAGS += -fsanitize=address -fno-omit-frame-pointer -g
  300. MK_CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -g
  301. MK_LDFLAGS += -fsanitize=address -fno-omit-frame-pointer -g
  302. endif
  303. ifdef LLAMA_SANITIZE_UNDEFINED
  304. MK_CFLAGS += -fsanitize=undefined -g
  305. MK_CXXFLAGS += -fsanitize=undefined -g
  306. MK_LDFLAGS += -fsanitize=undefined -g
  307. endif
  308. ifdef LLAMA_SERVER_SSL
  309. MK_CPPFLAGS += -DCPPHTTPLIB_OPENSSL_SUPPORT
  310. MK_LDFLAGS += -lssl -lcrypto
  311. endif
  312. ifndef GGML_NO_CPU_AARCH64
  313. MK_CPPFLAGS += -DGGML_USE_CPU_AARCH64
  314. endif
  315. # warnings
  316. WARN_FLAGS = \
  317. -Wall \
  318. -Wextra \
  319. -Wpedantic \
  320. -Wcast-qual \
  321. -Wno-unused-function
  322. MK_CFLAGS += \
  323. $(WARN_FLAGS) \
  324. -Wshadow \
  325. -Wstrict-prototypes \
  326. -Wpointer-arith \
  327. -Wmissing-prototypes \
  328. -Werror=implicit-int \
  329. -Werror=implicit-function-declaration
  330. MK_CXXFLAGS += \
  331. $(WARN_FLAGS) \
  332. -Wmissing-declarations \
  333. -Wmissing-noreturn
  334. ifeq ($(LLAMA_FATAL_WARNINGS),1)
  335. MK_CFLAGS += -Werror
  336. MK_CXXFLAGS += -Werror
  337. endif
  338. # this version of Apple ld64 is buggy
  339. ifneq '' '$(findstring dyld-1015.7,$(shell $(CC) $(LDFLAGS) -Wl,-v 2>&1))'
  340. MK_CPPFLAGS += -DHAVE_BUGGY_APPLE_LINKER
  341. endif
  342. # OS specific
  343. # TODO: support Windows
  344. ifneq '' '$(filter $(UNAME_S),Linux Darwin FreeBSD NetBSD OpenBSD Haiku)'
  345. MK_CFLAGS += -pthread
  346. MK_CXXFLAGS += -pthread
  347. endif
  348. # detect Windows
  349. ifneq ($(findstring _NT,$(UNAME_S)),)
  350. _WIN32 := 1
  351. endif
  352. # library name prefix
  353. ifneq ($(_WIN32),1)
  354. LIB_PRE := lib
  355. endif
  356. # Dynamic Shared Object extension
  357. ifneq ($(_WIN32),1)
  358. DSO_EXT := .so
  359. else
  360. DSO_EXT := .dll
  361. endif
  362. # Windows Sockets 2 (Winsock) for network-capable apps
  363. ifeq ($(_WIN32),1)
  364. LWINSOCK2 := -lws2_32
  365. endif
  366. ifdef LLAMA_GPROF
  367. MK_CFLAGS += -pg
  368. MK_CXXFLAGS += -pg
  369. endif
  370. # Architecture specific
  371. # TODO: probably these flags need to be tweaked on some architectures
  372. # feel free to update the Makefile for your architecture and send a pull request or issue
  373. ifndef RISCV_CROSS_COMPILE
  374. ifeq ($(UNAME_M),$(filter $(UNAME_M),x86_64 i686 amd64))
  375. # Use all CPU extensions that are available:
  376. MK_CFLAGS += -march=native -mtune=native
  377. HOST_CXXFLAGS += -march=native -mtune=native
  378. # Usage AVX-only
  379. #MK_CFLAGS += -mfma -mf16c -mavx
  380. #MK_CXXFLAGS += -mfma -mf16c -mavx
  381. # Usage SSSE3-only (Not is SSE3!)
  382. #MK_CFLAGS += -mssse3
  383. #MK_CXXFLAGS += -mssse3
  384. endif
  385. ifneq '' '$(findstring mingw,$(shell $(CC) -dumpmachine))'
  386. # The stack is only 16-byte aligned on Windows, so don't let gcc emit aligned moves.
  387. # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54412
  388. # https://github.com/ggerganov/llama.cpp/issues/2922
  389. MK_CFLAGS += -Xassembler -muse-unaligned-vector-move
  390. MK_CXXFLAGS += -Xassembler -muse-unaligned-vector-move
  391. # Target Windows 8 for PrefetchVirtualMemory
  392. MK_CPPFLAGS += -D_WIN32_WINNT=0x602
  393. endif
  394. ifneq ($(filter aarch64%,$(UNAME_M)),)
  395. # Apple M1, M2, etc.
  396. # Raspberry Pi 3, 4, Zero 2 (64-bit)
  397. # Nvidia Jetson
  398. MK_CFLAGS += -mcpu=native
  399. MK_CXXFLAGS += -mcpu=native
  400. JETSON_RELEASE_INFO = $(shell jetson_release)
  401. ifdef JETSON_RELEASE_INFO
  402. ifneq ($(filter TX2%,$(JETSON_RELEASE_INFO)),)
  403. JETSON_EOL_MODULE_DETECT = 1
  404. CC = aarch64-unknown-linux-gnu-gcc
  405. cxx = aarch64-unknown-linux-gnu-g++
  406. endif
  407. endif
  408. endif
  409. ifneq ($(filter armv6%,$(UNAME_M)),)
  410. # Raspberry Pi 1, Zero
  411. MK_CFLAGS += -mfpu=neon-fp-armv8 -mfp16-format=ieee -mno-unaligned-access
  412. MK_CXXFLAGS += -mfpu=neon-fp-armv8 -mfp16-format=ieee -mno-unaligned-access
  413. endif
  414. ifneq ($(filter armv7%,$(UNAME_M)),)
  415. # Raspberry Pi 2
  416. MK_CFLAGS += -mfpu=neon-fp-armv8 -mfp16-format=ieee -mno-unaligned-access -funsafe-math-optimizations
  417. MK_CXXFLAGS += -mfpu=neon-fp-armv8 -mfp16-format=ieee -mno-unaligned-access -funsafe-math-optimizations
  418. endif
  419. ifneq ($(filter armv8%,$(UNAME_M)),)
  420. # Raspberry Pi 3, 4, Zero 2 (32-bit)
  421. MK_CFLAGS += -mfp16-format=ieee -mno-unaligned-access
  422. MK_CXXFLAGS += -mfp16-format=ieee -mno-unaligned-access
  423. endif
  424. ifneq ($(filter ppc64%,$(UNAME_M)),)
  425. POWER9_M := $(shell grep "POWER9" /proc/cpuinfo)
  426. ifneq (,$(findstring POWER9,$(POWER9_M)))
  427. MK_CFLAGS += -mcpu=power9
  428. MK_CXXFLAGS += -mcpu=power9
  429. endif
  430. endif
  431. ifneq ($(filter ppc64le%,$(UNAME_M)),)
  432. MK_CFLAGS += -mcpu=powerpc64le
  433. MK_CXXFLAGS += -mcpu=powerpc64le
  434. CUDA_POWER_ARCH = 1
  435. endif
  436. ifneq ($(filter loongarch64%,$(UNAME_M)),)
  437. MK_CFLAGS += -mlasx
  438. MK_CXXFLAGS += -mlasx
  439. endif
  440. ifneq ($(filter riscv64%,$(UNAME_M)),)
  441. MK_CFLAGS += -march=rv64gcv -mabi=lp64d
  442. MK_CXXFLAGS += -march=rv64gcv -mabi=lp64d
  443. endif
  444. else # RISC-V CROSS COMPILATION
  445. MK_CFLAGS += -march=rv64gcv -mabi=lp64d
  446. MK_CXXFLAGS += -march=rv64gcv -mabi=lp64d
  447. endif
  448. ifndef GGML_NO_ACCELERATE
  449. # Mac OS - include Accelerate framework.
  450. # `-framework Accelerate` works both with Apple Silicon and Mac Intel
  451. ifeq ($(UNAME_S),Darwin)
  452. MK_CPPFLAGS += -DGGML_USE_ACCELERATE -DGGML_USE_BLAS -DGGML_BLAS_USE_ACCELERATE
  453. MK_CPPFLAGS += -DACCELERATE_NEW_LAPACK
  454. MK_CPPFLAGS += -DACCELERATE_LAPACK_ILP64
  455. MK_LDFLAGS += -framework Accelerate
  456. OBJ_GGML += ggml/src/ggml-blas/ggml-blas.o
  457. endif
  458. endif # GGML_NO_ACCELERATE
  459. ifndef GGML_NO_OPENMP
  460. MK_CPPFLAGS += -DGGML_USE_OPENMP
  461. MK_CFLAGS += -fopenmp
  462. MK_CXXFLAGS += -fopenmp
  463. endif # GGML_NO_OPENMP
  464. ifdef GGML_OPENBLAS
  465. MK_CPPFLAGS += -DGGML_USE_BLAS $(shell pkg-config --cflags-only-I openblas)
  466. MK_CFLAGS += $(shell pkg-config --cflags-only-other openblas)
  467. MK_LDFLAGS += $(shell pkg-config --libs openblas)
  468. OBJ_GGML += ggml/src/ggml-blas/ggml-blas.o
  469. endif # GGML_OPENBLAS
  470. ifdef GGML_OPENBLAS64
  471. MK_CPPFLAGS += -DGGML_USE_BLAS $(shell pkg-config --cflags-only-I openblas64)
  472. MK_CFLAGS += $(shell pkg-config --cflags-only-other openblas64)
  473. MK_LDFLAGS += $(shell pkg-config --libs openblas64)
  474. OBJ_GGML += ggml/src/ggml-blas/ggml-blas.o
  475. endif # GGML_OPENBLAS64
  476. ifdef GGML_BLIS
  477. MK_CPPFLAGS += -DGGML_USE_BLAS -DGGML_BLAS_USE_BLIS -I/usr/local/include/blis -I/usr/include/blis
  478. MK_LDFLAGS += -lblis -L/usr/local/lib
  479. OBJ_GGML += ggml/src/ggml-blas/ggml-blas.o
  480. endif # GGML_BLIS
  481. ifdef GGML_NVPL
  482. MK_CPPFLAGS += -DGGML_USE_BLAS -DGGML_BLAS_USE_NVPL -DNVPL_ILP64 -I/usr/local/include/nvpl_blas -I/usr/include/nvpl_blas
  483. MK_LDFLAGS += -L/usr/local/lib -lnvpl_blas_core -lnvpl_blas_ilp64_gomp
  484. OBJ_GGML += ggml/src/ggml-blas/ggml-blas.o
  485. endif # GGML_NVPL
  486. ifndef GGML_NO_LLAMAFILE
  487. MK_CPPFLAGS += -DGGML_USE_LLAMAFILE
  488. OBJ_GGML += ggml/src/ggml-cpu/llamafile/sgemm.o
  489. endif
  490. ifndef GGML_NO_AMX
  491. MK_CPPFLAGS += -DGGML_USE_AMX
  492. OBJ_GGML += ggml/src/ggml-amx/ggml-amx.o ggml/src/ggml-amx/mmq.o
  493. endif
  494. ifdef GGML_RPC
  495. MK_CPPFLAGS += -DGGML_USE_RPC
  496. OBJ_GGML += ggml/src/ggml-rpc.o
  497. endif # GGML_RPC
  498. OBJ_CUDA_TMPL = $(patsubst %.cu,%.o,$(wildcard ggml/src/ggml-cuda/template-instances/fattn-wmma*.cu))
  499. OBJ_CUDA_TMPL += $(patsubst %.cu,%.o,$(wildcard ggml/src/ggml-cuda/template-instances/mmq*.cu))
  500. ifdef GGML_CUDA_FA_ALL_QUANTS
  501. OBJ_CUDA_TMPL += $(patsubst %.cu,%.o,$(wildcard ggml/src/ggml-cuda/template-instances/fattn-vec*.cu))
  502. else
  503. OBJ_CUDA_TMPL += $(patsubst %.cu,%.o,$(wildcard ggml/src/ggml-cuda/template-instances/fattn-vec*q4_0-q4_0.cu))
  504. OBJ_CUDA_TMPL += $(patsubst %.cu,%.o,$(wildcard ggml/src/ggml-cuda/template-instances/fattn-vec*q8_0-q8_0.cu))
  505. OBJ_CUDA_TMPL += $(patsubst %.cu,%.o,$(wildcard ggml/src/ggml-cuda/template-instances/fattn-vec*f16-f16.cu))
  506. endif # GGML_CUDA_FA_ALL_QUANTS
  507. ifdef GGML_CUDA
  508. ifneq ('', '$(wildcard /opt/cuda)')
  509. CUDA_PATH ?= /opt/cuda
  510. else
  511. CUDA_PATH ?= /usr/local/cuda
  512. endif
  513. MK_CPPFLAGS += -DGGML_USE_CUDA -DGGML_CUDA_USE_GRAPHS -I$(CUDA_PATH)/include -I$(CUDA_PATH)/targets/$(UNAME_M)-linux/include
  514. MK_LDFLAGS += -lcuda -lcublas -lculibos -lcudart -lcublasLt -lpthread -ldl -lrt -L$(CUDA_PATH)/lib64 -L/usr/lib64 -L$(CUDA_PATH)/targets/$(UNAME_M)-linux/lib -L$(CUDA_PATH)/lib64/stubs -L/usr/lib/wsl/lib
  515. MK_NVCCFLAGS += -use_fast_math
  516. OBJ_GGML += ggml/src/ggml-cuda/ggml-cuda.o
  517. OBJ_GGML += $(patsubst %.cu,%.o,$(wildcard ggml/src/ggml-cuda/*.cu))
  518. OBJ_GGML += $(OBJ_CUDA_TMPL)
  519. ifdef LLAMA_FATAL_WARNINGS
  520. MK_NVCCFLAGS += -Werror all-warnings
  521. endif # LLAMA_FATAL_WARNINGS
  522. ifndef JETSON_EOL_MODULE_DETECT
  523. MK_NVCCFLAGS += --forward-unknown-to-host-compiler
  524. endif # JETSON_EOL_MODULE_DETECT
  525. ifdef LLAMA_DEBUG
  526. MK_NVCCFLAGS += -lineinfo
  527. endif # LLAMA_DEBUG
  528. ifdef GGML_CUDA_DEBUG
  529. MK_NVCCFLAGS += --device-debug
  530. endif # GGML_CUDA_DEBUG
  531. ifdef GGML_CUDA_NVCC
  532. NVCC = $(CCACHE) $(GGML_CUDA_NVCC)
  533. else
  534. NVCC = $(CCACHE) nvcc
  535. endif # GGML_CUDA_NVCC
  536. ifdef CUDA_DOCKER_ARCH
  537. MK_NVCCFLAGS += -Wno-deprecated-gpu-targets -arch=$(CUDA_DOCKER_ARCH)
  538. else ifndef CUDA_POWER_ARCH
  539. MK_NVCCFLAGS += -arch=native
  540. endif # CUDA_DOCKER_ARCH
  541. ifdef GGML_CUDA_FORCE_DMMV
  542. MK_NVCCFLAGS += -DGGML_CUDA_FORCE_DMMV
  543. endif # GGML_CUDA_FORCE_DMMV
  544. ifdef GGML_CUDA_FORCE_MMQ
  545. MK_NVCCFLAGS += -DGGML_CUDA_FORCE_MMQ
  546. endif # GGML_CUDA_FORCE_MMQ
  547. ifdef GGML_CUDA_FORCE_CUBLAS
  548. MK_NVCCFLAGS += -DGGML_CUDA_FORCE_CUBLAS
  549. endif # GGML_CUDA_FORCE_CUBLAS
  550. ifdef GGML_CUDA_DMMV_X
  551. MK_NVCCFLAGS += -DGGML_CUDA_DMMV_X=$(GGML_CUDA_DMMV_X)
  552. else
  553. MK_NVCCFLAGS += -DGGML_CUDA_DMMV_X=32
  554. endif # GGML_CUDA_DMMV_X
  555. ifdef GGML_CUDA_MMV_Y
  556. MK_NVCCFLAGS += -DGGML_CUDA_MMV_Y=$(GGML_CUDA_MMV_Y)
  557. else ifdef GGML_CUDA_DMMV_Y
  558. MK_NVCCFLAGS += -DGGML_CUDA_MMV_Y=$(GGML_CUDA_DMMV_Y) # for backwards compatibility
  559. else
  560. MK_NVCCFLAGS += -DGGML_CUDA_MMV_Y=1
  561. endif # GGML_CUDA_MMV_Y
  562. ifdef GGML_CUDA_F16
  563. MK_NVCCFLAGS += -DGGML_CUDA_F16
  564. endif # GGML_CUDA_F16
  565. ifdef GGML_CUDA_DMMV_F16
  566. MK_NVCCFLAGS += -DGGML_CUDA_F16
  567. endif # GGML_CUDA_DMMV_F16
  568. ifdef GGML_CUDA_KQUANTS_ITER
  569. MK_NVCCFLAGS += -DK_QUANTS_PER_ITERATION=$(GGML_CUDA_KQUANTS_ITER)
  570. else
  571. MK_NVCCFLAGS += -DK_QUANTS_PER_ITERATION=2
  572. endif
  573. ifdef GGML_CUDA_PEER_MAX_BATCH_SIZE
  574. MK_NVCCFLAGS += -DGGML_CUDA_PEER_MAX_BATCH_SIZE=$(GGML_CUDA_PEER_MAX_BATCH_SIZE)
  575. else
  576. MK_NVCCFLAGS += -DGGML_CUDA_PEER_MAX_BATCH_SIZE=128
  577. endif # GGML_CUDA_PEER_MAX_BATCH_SIZE
  578. ifdef GGML_CUDA_NO_PEER_COPY
  579. MK_NVCCFLAGS += -DGGML_CUDA_NO_PEER_COPY
  580. endif # GGML_CUDA_NO_PEER_COPY
  581. ifdef GGML_CUDA_CCBIN
  582. MK_NVCCFLAGS += -ccbin $(GGML_CUDA_CCBIN)
  583. endif # GGML_CUDA_CCBIN
  584. ifdef GGML_CUDA_FA_ALL_QUANTS
  585. MK_NVCCFLAGS += -DGGML_CUDA_FA_ALL_QUANTS
  586. endif # GGML_CUDA_FA_ALL_QUANTS
  587. ifdef JETSON_EOL_MODULE_DETECT
  588. define NVCC_COMPILE
  589. $(NVCC) -I. -Icommon -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DNDEBUG -DGGML_USE_CUDA -I/usr/local/cuda/include -I/opt/cuda/include -I/usr/local/cuda/targets/aarch64-linux/include -std=c++11 -O3 $(NVCCFLAGS) $(CPPFLAGS) -Xcompiler "$(CUDA_CXXFLAGS)" -c $< -o $@
  590. endef # NVCC_COMPILE
  591. else
  592. define NVCC_COMPILE
  593. $(NVCC) $(NVCCFLAGS) $(CPPFLAGS) -Xcompiler "$(CUDA_CXXFLAGS)" -c $< -o $@
  594. endef # NVCC_COMPILE
  595. endif # JETSON_EOL_MODULE_DETECT
  596. ggml/src/ggml-cuda/%.o: \
  597. ggml/src/ggml-cuda/%.cu \
  598. ggml/include/ggml.h \
  599. ggml/src/ggml-common.h \
  600. ggml/src/ggml-cuda/common.cuh
  601. $(NVCC_COMPILE)
  602. ggml/src/ggml-cuda/ggml-cuda.o: \
  603. ggml/src/ggml-cuda/ggml-cuda.cu \
  604. ggml/include/ggml-cuda.h \
  605. ggml/include/ggml.h \
  606. ggml/include/ggml-backend.h \
  607. ggml/src/ggml-backend-impl.h \
  608. ggml/src/ggml-common.h \
  609. $(wildcard ggml/src/ggml-cuda/*.cuh)
  610. $(NVCC_COMPILE)
  611. endif # GGML_CUDA
  612. ifdef GGML_VULKAN
  613. MK_CPPFLAGS += -DGGML_USE_VULKAN
  614. MK_LDFLAGS += $(shell pkg-config --libs vulkan)
  615. OBJ_GGML += ggml/src/ggml-vulkan.o ggml/src/ggml-vulkan-shaders.o
  616. ifdef GGML_VULKAN_CHECK_RESULTS
  617. MK_CPPFLAGS += -DGGML_VULKAN_CHECK_RESULTS
  618. endif
  619. ifdef GGML_VULKAN_DEBUG
  620. MK_CPPFLAGS += -DGGML_VULKAN_DEBUG
  621. endif
  622. ifdef GGML_VULKAN_MEMORY_DEBUG
  623. MK_CPPFLAGS += -DGGML_VULKAN_MEMORY_DEBUG
  624. endif
  625. ifdef GGML_VULKAN_PERF
  626. MK_CPPFLAGS += -DGGML_VULKAN_PERF
  627. endif
  628. ifdef GGML_VULKAN_VALIDATE
  629. MK_CPPFLAGS += -DGGML_VULKAN_VALIDATE
  630. endif
  631. ifdef GGML_VULKAN_RUN_TESTS
  632. MK_CPPFLAGS += -DGGML_VULKAN_RUN_TESTS
  633. endif
  634. GLSLC_CMD = glslc
  635. _ggml_vk_genshaders_cmd = $(shell pwd)/vulkan-shaders-gen
  636. _ggml_vk_header = ggml/src/ggml-vulkan-shaders.hpp
  637. _ggml_vk_source = ggml/src/ggml-vulkan-shaders.cpp
  638. _ggml_vk_input_dir = ggml/src/vulkan-shaders
  639. _ggml_vk_shader_deps = $(echo $(_ggml_vk_input_dir)/*.comp)
  640. ggml/src/ggml-vulkan.o: ggml/src/ggml-vulkan.cpp ggml/include/ggml-vulkan.h $(_ggml_vk_header) $(_ggml_vk_source)
  641. $(CXX) $(CXXFLAGS) $(shell pkg-config --cflags vulkan) -c $< -o $@
  642. $(_ggml_vk_header): $(_ggml_vk_source)
  643. $(_ggml_vk_source): $(_ggml_vk_shader_deps) vulkan-shaders-gen
  644. $(_ggml_vk_genshaders_cmd) \
  645. --glslc $(GLSLC_CMD) \
  646. --input-dir $(_ggml_vk_input_dir) \
  647. --target-hpp $(_ggml_vk_header) \
  648. --target-cpp $(_ggml_vk_source)
  649. vulkan-shaders-gen: ggml/src/vulkan-shaders/vulkan-shaders-gen.cpp
  650. $(CXX) $(CXXFLAGS) -o $@ $(LDFLAGS) ggml/src/vulkan-shaders/vulkan-shaders-gen.cpp
  651. endif # GGML_VULKAN
  652. ifdef GGML_HIPBLAS
  653. ifeq ($(wildcard /opt/rocm),)
  654. ROCM_PATH ?= /usr
  655. AMDGPU_TARGETS ?= $(shell $(shell which amdgpu-arch))
  656. else
  657. ROCM_PATH ?= /opt/rocm
  658. AMDGPU_TARGETS ?= $(shell $(ROCM_PATH)/llvm/bin/amdgpu-arch)
  659. endif
  660. GGML_CUDA_DMMV_X ?= 32
  661. GGML_CUDA_MMV_Y ?= 1
  662. GGML_CUDA_KQUANTS_ITER ?= 2
  663. MK_CPPFLAGS += -DGGML_USE_HIP -DGGML_USE_CUDA
  664. ifdef GGML_HIP_UMA
  665. MK_CPPFLAGS += -DGGML_HIP_UMA
  666. endif # GGML_HIP_UMA
  667. MK_LDFLAGS += -L$(ROCM_PATH)/lib -Wl,-rpath=$(ROCM_PATH)/lib
  668. MK_LDFLAGS += -L$(ROCM_PATH)/lib64 -Wl,-rpath=$(ROCM_PATH)/lib64
  669. MK_LDFLAGS += -lhipblas -lamdhip64 -lrocblas
  670. HIPCC ?= $(CCACHE) $(ROCM_PATH)/bin/hipcc
  671. HIPFLAGS += $(addprefix --offload-arch=,$(AMDGPU_TARGETS))
  672. HIPFLAGS += -DGGML_CUDA_DMMV_X=$(GGML_CUDA_DMMV_X)
  673. HIPFLAGS += -DGGML_CUDA_MMV_Y=$(GGML_CUDA_MMV_Y)
  674. HIPFLAGS += -DK_QUANTS_PER_ITERATION=$(GGML_CUDA_KQUANTS_ITER)
  675. ifdef GGML_CUDA_FORCE_DMMV
  676. HIPFLAGS += -DGGML_CUDA_FORCE_DMMV
  677. endif # GGML_CUDA_FORCE_DMMV
  678. ifdef GGML_CUDA_FORCE_MMQ
  679. HIPFLAGS += -DGGML_CUDA_FORCE_MMQ
  680. endif # GGML_CUDA_FORCE_MMQ
  681. ifdef GGML_CUDA_FORCE_CUBLAS
  682. HIPFLAGS += -DGGML_CUDA_FORCE_CUBLAS
  683. endif # GGML_CUDA_FORCE_CUBLAS
  684. ifdef GGML_CUDA_NO_PEER_COPY
  685. HIPFLAGS += -DGGML_CUDA_NO_PEER_COPY
  686. endif # GGML_CUDA_NO_PEER_COPY
  687. OBJ_GGML += ggml/src/ggml-cuda/ggml-cuda.o
  688. OBJ_GGML += $(patsubst %.cu,%.o,$(wildcard ggml/src/ggml-cuda/*.cu))
  689. OBJ_GGML += $(OBJ_CUDA_TMPL)
  690. ggml/src/ggml-cuda/ggml-cuda.o: \
  691. ggml/src/ggml-cuda/ggml-cuda.cu \
  692. ggml/include/ggml-cuda.h \
  693. ggml/include/ggml.h \
  694. ggml/include/ggml-backend.h \
  695. ggml/src/ggml-backend-impl.h \
  696. ggml/src/ggml-common.h \
  697. $(wildcard ggml/src/ggml-cuda/*.cuh)
  698. $(HIPCC) $(CXXFLAGS) $(HIPFLAGS) -x hip -c -o $@ $<
  699. ggml/src/ggml-cuda/%.o: \
  700. ggml/src/ggml-cuda/%.cu \
  701. ggml/include/ggml.h \
  702. ggml/src/ggml-common.h \
  703. ggml/src/ggml-cuda/common.cuh
  704. $(HIPCC) $(CXXFLAGS) $(HIPFLAGS) -x hip -c -o $@ $<
  705. endif # GGML_HIPBLAS
  706. ifdef GGML_MUSA
  707. ifeq ($(wildcard /opt/musa),)
  708. MUSA_PATH ?= /usr/local/musa
  709. else
  710. MUSA_PATH ?= /opt/musa
  711. endif
  712. MTGPU_TARGETS ?= mp_21 mp_22
  713. MK_CPPFLAGS += -DGGML_USE_MUSA -DGGML_USE_CUDA
  714. MK_LDFLAGS += -L$(MUSA_PATH)/lib -Wl,-rpath=$(MUSA_PATH)/lib
  715. MK_LDFLAGS += -lmusa -lmusart -lmublas
  716. ifndef GGML_NO_OPENMP
  717. # For Ubuntu Focal
  718. MK_CPPFLAGS += -I/usr/lib/llvm-10/include/openmp
  719. MK_LDFLAGS += -L/usr/lib/llvm-10/lib
  720. # For Ubuntu Jammy
  721. MK_CPPFLAGS += -I/usr/lib/llvm-14/lib/clang/14.0.0/include
  722. MK_LDFLAGS += -L/usr/lib/llvm-14/lib
  723. endif # GGML_NO_OPENMP
  724. CC := $(MUSA_PATH)/bin/clang
  725. CXX := $(MUSA_PATH)/bin/clang++
  726. MCC := $(CCACHE) $(MUSA_PATH)/bin/mcc
  727. MUSAFLAGS += $(addprefix --cuda-gpu-arch=, $(MTGPU_TARGETS))
  728. ifdef GGML_CUDA_FORCE_DMMV
  729. MUSAFLAGS += -DGGML_CUDA_FORCE_DMMV
  730. endif # GGML_CUDA_FORCE_DMMV
  731. ifdef GGML_CUDA_FORCE_MMQ
  732. MUSAFLAGS += -DGGML_CUDA_FORCE_MMQ
  733. endif # GGML_CUDA_FORCE_MMQ
  734. ifdef GGML_CUDA_FORCE_CUBLAS
  735. MUSAFLAGS += -DGGML_CUDA_FORCE_CUBLAS
  736. endif # GGML_CUDA_FORCE_CUBLAS
  737. ifdef GGML_CUDA_DMMV_X
  738. MUSAFLAGS += -DGGML_CUDA_DMMV_X=$(GGML_CUDA_DMMV_X)
  739. else
  740. MUSAFLAGS += -DGGML_CUDA_DMMV_X=32
  741. endif # GGML_CUDA_DMMV_X
  742. ifdef GGML_CUDA_MMV_Y
  743. MUSAFLAGS += -DGGML_CUDA_MMV_Y=$(GGML_CUDA_MMV_Y)
  744. else
  745. MUSAFLAGS += -DGGML_CUDA_MMV_Y=1
  746. endif # GGML_CUDA_MMV_Y
  747. ifdef GGML_CUDA_F16
  748. MUSAFLAGS += -DGGML_CUDA_F16
  749. endif # GGML_CUDA_F16
  750. ifdef GGML_CUDA_DMMV_F16
  751. MUSAFLAGS += -DGGML_CUDA_F16
  752. endif # GGML_CUDA_DMMV_F16
  753. ifdef GGML_CUDA_KQUANTS_ITER
  754. MUSAFLAGS += -DK_QUANTS_PER_ITERATION=$(GGML_CUDA_KQUANTS_ITER)
  755. else
  756. MUSAFLAGS += -DK_QUANTS_PER_ITERATION=2
  757. endif
  758. ifdef GGML_CUDA_PEER_MAX_BATCH_SIZE
  759. MUSAFLAGS += -DGGML_CUDA_PEER_MAX_BATCH_SIZE=$(GGML_CUDA_PEER_MAX_BATCH_SIZE)
  760. else
  761. MUSAFLAGS += -DGGML_CUDA_PEER_MAX_BATCH_SIZE=128
  762. endif # GGML_CUDA_PEER_MAX_BATCH_SIZE
  763. ifdef GGML_CUDA_NO_PEER_COPY
  764. MUSAFLAGS += -DGGML_CUDA_NO_PEER_COPY
  765. endif # GGML_CUDA_NO_PEER_COPY
  766. ifdef GGML_CUDA_FA_ALL_QUANTS
  767. MUSAFLAGS += -DGGML_CUDA_FA_ALL_QUANTS
  768. endif # GGML_CUDA_FA_ALL_QUANTS
  769. OBJ_GGML += ggml/src/ggml-cuda/ggml-cuda.o
  770. OBJ_GGML += $(patsubst %.cu,%.o,$(wildcard ggml/src/ggml-cuda/*.cu))
  771. OBJ_GGML += $(OBJ_CUDA_TMPL)
  772. ggml/src/ggml-cuda/ggml-cuda.o: \
  773. ggml/src/ggml-cuda/ggml-cuda.cu \
  774. ggml/include/ggml-cuda.h \
  775. ggml/include/ggml.h \
  776. ggml/include/ggml-backend.h \
  777. ggml/src/ggml-backend-impl.h \
  778. ggml/src/ggml-common.h \
  779. $(wildcard ggml/src/ggml-cuda/*.cuh)
  780. $(MCC) $(CXXFLAGS) $(MUSAFLAGS) -x musa -mtgpu -c -o $@ $<
  781. ggml/src/ggml-cuda/%.o: \
  782. ggml/src/ggml-cuda/%.cu \
  783. ggml/include/ggml.h \
  784. ggml/src/ggml-common.h \
  785. ggml/src/ggml-cuda/common.cuh
  786. $(MCC) $(CXXFLAGS) $(MUSAFLAGS) -x musa -mtgpu -c -o $@ $<
  787. endif # GGML_MUSA
  788. ifdef GGML_METAL
  789. MK_CPPFLAGS += -DGGML_USE_METAL
  790. MK_LDFLAGS += -framework Foundation -framework Metal -framework MetalKit
  791. OBJ_GGML += ggml/src/ggml-metal/ggml-metal.o
  792. ifdef GGML_METAL_USE_BF16
  793. MK_CPPFLAGS += -DGGML_METAL_USE_BF16
  794. endif # GGML_METAL_USE_BF16
  795. ifdef GGML_METAL_NDEBUG
  796. MK_CPPFLAGS += -DGGML_METAL_NDEBUG
  797. endif
  798. ifdef GGML_METAL_EMBED_LIBRARY
  799. MK_CPPFLAGS += -DGGML_METAL_EMBED_LIBRARY
  800. OBJ_GGML += ggml/src/ggml-metal-embed.o
  801. endif
  802. endif # GGML_METAL
  803. ifdef GGML_METAL
  804. ggml/src/ggml-metal/ggml-metal.o: \
  805. ggml/src/ggml-metal/ggml-metal.m \
  806. ggml/include/ggml-metal.h \
  807. ggml/include/ggml.h
  808. $(CC) $(CFLAGS) -c $< -o $@
  809. ifdef GGML_METAL_EMBED_LIBRARY
  810. ggml/src/ggml-metal-embed.o: \
  811. ggml/src/ggml-metal/ggml-metal.metal \
  812. ggml/src/ggml-common.h
  813. @echo "Embedding Metal library"
  814. @sed -e '/__embed_ggml-common.h__/r ggml/src/ggml-common.h' -e '/__embed_ggml-common.h__/d' < ggml/src/ggml-metal/ggml-metal.metal > ggml/src/ggml-metal/ggml-metal-embed.metal
  815. $(eval TEMP_ASSEMBLY=$(shell mktemp -d))
  816. @echo ".section __DATA, __ggml_metallib" > $(TEMP_ASSEMBLY)/ggml-metal-embed.s
  817. @echo ".globl _ggml_metallib_start" >> $(TEMP_ASSEMBLY)/ggml-metal-embed.s
  818. @echo "_ggml_metallib_start:" >> $(TEMP_ASSEMBLY)/ggml-metal-embed.s
  819. @echo ".incbin \"ggml/src/ggml-metal/ggml-metal-embed.metal\"" >> $(TEMP_ASSEMBLY)/ggml-metal-embed.s
  820. @echo ".globl _ggml_metallib_end" >> $(TEMP_ASSEMBLY)/ggml-metal-embed.s
  821. @echo "_ggml_metallib_end:" >> $(TEMP_ASSEMBLY)/ggml-metal-embed.s
  822. $(CC) $(CFLAGS) -c $(TEMP_ASSEMBLY)/ggml-metal-embed.s -o $@
  823. @rm -f ${TEMP_ASSEMBLY}/ggml-metal-embed.s
  824. @rmdir ${TEMP_ASSEMBLY}
  825. endif
  826. endif # GGML_METAL
  827. OBJ_GGML += \
  828. ggml/src/ggml.o \
  829. ggml/src/ggml-aarch64.o \
  830. ggml/src/ggml-alloc.o \
  831. ggml/src/ggml-backend.o \
  832. ggml/src/ggml-backend-reg.o \
  833. ggml/src/ggml-quants.o \
  834. ggml/src/ggml-threading.o \
  835. ggml/src/ggml-cpu/ggml-cpu.o \
  836. ggml/src/ggml-cpu/ggml-cpu-cpp.o \
  837. ggml/src/ggml-cpu/ggml-cpu-aarch64.o \
  838. ggml/src/ggml-cpu/ggml-cpu-quants.o
  839. OBJ_LLAMA = \
  840. src/llama.o \
  841. src/llama-vocab.o \
  842. src/llama-grammar.o \
  843. src/llama-sampling.o \
  844. src/unicode.o \
  845. src/unicode-data.o
  846. OBJ_COMMON = \
  847. common/common.o \
  848. common/arg.o \
  849. common/log.o \
  850. common/console.o \
  851. common/ngram-cache.o \
  852. common/sampling.o \
  853. common/build-info.o \
  854. common/json-schema-to-grammar.o
  855. OBJ_ALL = $(OBJ_GGML) $(OBJ_LLAMA) $(OBJ_COMMON)
  856. LIB_GGML = $(LIB_PRE)ggml$(DSO_EXT)
  857. LIB_GGML_S = $(LIB_PRE)ggml.a
  858. LIB_LLAMA = $(LIB_PRE)llama$(DSO_EXT)
  859. LIB_LLAMA_S = $(LIB_PRE)llama.a
  860. LIB_COMMON = $(LIB_PRE)common$(DSO_EXT)
  861. LIB_COMMON_S = $(LIB_PRE)common.a
  862. LIB_ALL = $(LIB_GGML) $(LIB_LLAMA) $(LIB_COMMON)
  863. LIB_ALL_S = $(LIB_GGML_S) $(LIB_LLAMA_S) $(LIB_COMMON_S)
  864. GF_CC := $(CC)
  865. include scripts/get-flags.mk
  866. # combine build flags with cmdline overrides
  867. override CPPFLAGS := $(MK_CPPFLAGS) $(CPPFLAGS)
  868. override CFLAGS := $(CPPFLAGS) $(MK_CFLAGS) $(GF_CFLAGS) $(CFLAGS)
  869. BASE_CXXFLAGS := $(MK_CXXFLAGS) $(CXXFLAGS)
  870. override CXXFLAGS := $(BASE_CXXFLAGS) $(HOST_CXXFLAGS) $(GF_CXXFLAGS) $(CPPFLAGS)
  871. override NVCCFLAGS := $(MK_NVCCFLAGS) $(NVCCFLAGS)
  872. override LDFLAGS := $(MK_LDFLAGS) $(LDFLAGS)
  873. # identify CUDA host compiler
  874. ifdef GGML_CUDA
  875. GF_CC := $(NVCC) $(NVCCFLAGS) 2>/dev/null .c -Xcompiler
  876. include scripts/get-flags.mk
  877. CUDA_CXXFLAGS := $(BASE_CXXFLAGS) $(GF_CXXFLAGS) -Wno-pedantic
  878. endif
  879. ifdef LLAMA_CURL
  880. override CXXFLAGS := $(CXXFLAGS) -DLLAMA_USE_CURL
  881. override LDFLAGS := $(LDFLAGS) -lcurl
  882. endif
  883. #
  884. # Print build information
  885. #
  886. $(info I llama.cpp build info: )
  887. $(info I UNAME_S: $(UNAME_S))
  888. $(info I UNAME_P: $(UNAME_P))
  889. $(info I UNAME_M: $(UNAME_M))
  890. $(info I CFLAGS: $(CFLAGS))
  891. $(info I CXXFLAGS: $(CXXFLAGS))
  892. $(info I NVCCFLAGS: $(NVCCFLAGS))
  893. $(info I LDFLAGS: $(LDFLAGS))
  894. $(info I CC: $(shell $(CC) --version | head -n 1))
  895. $(info I CXX: $(shell $(CXX) --version | head -n 1))
  896. ifdef GGML_CUDA
  897. $(info I NVCC: $(shell $(NVCC) --version | tail -n 1))
  898. CUDA_VERSION := $(shell $(NVCC) --version | grep -oP 'release (\K[0-9]+\.[0-9])')
  899. ifeq ($(shell awk -v "v=$(CUDA_VERSION)" 'BEGIN { print (v < 11.7) }'),1)
  900. ifndef CUDA_DOCKER_ARCH
  901. ifndef CUDA_POWER_ARCH
  902. $(error I ERROR: For CUDA versions < 11.7 a target CUDA architecture must be explicitly provided via environment variable CUDA_DOCKER_ARCH, e.g. by running "export CUDA_DOCKER_ARCH=compute_XX" on Unix-like systems, where XX is the minimum compute capability that the code needs to run on. A list with compute capabilities can be found here: https://developer.nvidia.com/cuda-gpus )
  903. endif # CUDA_POWER_ARCH
  904. endif # CUDA_DOCKER_ARCH
  905. endif # eq ($(shell echo "$(CUDA_VERSION) < 11.7" | bc),1)
  906. endif # GGML_CUDA
  907. $(info )
  908. ifdef DEPRECATE_WARNING
  909. $(info !!! DEPRECATION WARNING !!!)
  910. $(info The following LLAMA_ options are deprecated and will be removed in the future. Use the GGML_ prefix instead)
  911. $(info - LLAMA_CUDA)
  912. $(info - LLAMA_METAL)
  913. $(info - LLAMA_METAL_EMBED_LIBRARY)
  914. $(info - LLAMA_OPENMP)
  915. $(info - LLAMA_RPC)
  916. $(info - LLAMA_SYCL)
  917. $(info - LLAMA_SYCL_F16)
  918. $(info - LLAMA_OPENBLAS)
  919. $(info - LLAMA_OPENBLAS64)
  920. $(info - LLAMA_BLIS)
  921. $(info - LLAMA_NO_LLAMAFILE)
  922. $(info - LLAMA_NO_ACCELERATE)
  923. $(info - LLAMA_NO_OPENMP)
  924. $(info - LLAMA_NO_METAL)
  925. $(info - LLAMA_NO_CCACHE)
  926. $(info )
  927. endif
  928. ifdef REMOVE_WARNING
  929. $(info !!! REMOVAL WARNING !!!)
  930. $(info The following LLAMA_ options have been removed and are no longer supported)
  931. $(info - LLAMA_DISABLE_LOGS (https://github.com/ggerganov/llama.cpp/pull/9418))
  932. $(info - LLAMA_SERVER_VERBOSE (https://github.com/ggerganov/llama.cpp/pull/9418))
  933. $(info )
  934. endif
  935. #
  936. # Build libraries
  937. #
  938. # ggml
  939. ggml/src/ggml.o: \
  940. ggml/src/ggml.c \
  941. ggml/include/ggml.h
  942. $(CC) $(CFLAGS) -c $< -o $@
  943. ggml/src/ggml-threading.o: \
  944. ggml/src/ggml-threading.cpp \
  945. ggml/include/ggml.h
  946. $(CXX) $(XXCFLAGS) -c $< -o $@
  947. ggml/src/ggml-cpu/ggml-cpu.o: \
  948. ggml/src/ggml-cpu/ggml-cpu.c \
  949. ggml/include/ggml.h \
  950. ggml/src/ggml-common.h
  951. $(CC) $(CFLAGS) -c $< -o $@
  952. ggml/src/ggml-cpu/ggml-cpu-cpp.o: \
  953. ggml/src/ggml-cpu/ggml-cpu.cpp \
  954. ggml/include/ggml.h \
  955. ggml/src/ggml-common.h
  956. $(CXX) $(CXXFLAGS) -c $< -o $@
  957. ggml/src/ggml-alloc.o: \
  958. ggml/src/ggml-alloc.c \
  959. ggml/include/ggml.h \
  960. ggml/include/ggml-alloc.h
  961. $(CC) $(CFLAGS) -c $< -o $@
  962. ggml/src/ggml-backend.o: \
  963. ggml/src/ggml-backend.cpp \
  964. ggml/src/ggml-backend-impl.h \
  965. ggml/include/ggml.h \
  966. ggml/include/ggml-backend.h
  967. $(CXX) $(CXXFLAGS) -c $< -o $@
  968. ggml/src/ggml-quants.o: \
  969. ggml/src/ggml-quants.c \
  970. ggml/include/ggml.h \
  971. ggml/src/ggml-quants.h \
  972. ggml/src/ggml-common.h
  973. $(CC) $(CFLAGS) -c $< -o $@
  974. ggml/src/ggml-aarch64.o: \
  975. ggml/src/ggml-aarch64.c \
  976. ggml/include/ggml.h \
  977. ggml/src/ggml-aarch64.h \
  978. ggml/src/ggml-common.h
  979. $(CC) $(CFLAGS) -c $< -o $@
  980. ggml/src/ggml-blas/ggml-blas.o: \
  981. ggml/src/ggml-blas/ggml-blas.cpp \
  982. ggml/include/ggml-blas.h
  983. $(CXX) $(CXXFLAGS) -c $< -o $@
  984. ifndef GGML_NO_LLAMAFILE
  985. ggml/src/ggml-cpu/llamafile/sgemm.o: \
  986. ggml/src/ggml-cpu/llamafile/sgemm.cpp \
  987. ggml/src/ggml-cpu/llamafile/sgemm.h \
  988. ggml/include/ggml.h
  989. $(CXX) $(CXXFLAGS) -c $< -o $@ -I ggml/src -I ggml/src/ggml-cpu
  990. endif # GGML_NO_LLAMAFILE
  991. ifndef GGML_NO_AMX
  992. ggml/src/ggml-amx/ggml-amx.o: \
  993. ggml/src/ggml-amx/ggml-amx.cpp \
  994. ggml/include/ggml-amx.h
  995. $(CXX) $(CXXFLAGS) -c $< -o $@
  996. ggml/src/ggml-amx/mmq.o: \
  997. ggml/src/ggml-amx/mmq.cpp \
  998. ggml/src/ggml-amx/mmq.h \
  999. ggml/include/ggml.h
  1000. $(CXX) $(CXXFLAGS) -c $< -o $@
  1001. endif
  1002. ifdef GGML_RPC
  1003. ggml/src/ggml-rpc.o: \
  1004. ggml/src/ggml-rpc.cpp \
  1005. ggml/include/ggml-rpc.h
  1006. $(CXX) $(CXXFLAGS) -c $< -o $@
  1007. endif # GGML_RPC
  1008. $(LIB_GGML): \
  1009. $(OBJ_GGML)
  1010. $(CXX) $(CXXFLAGS) -shared -fPIC -o $@ $^ $(LDFLAGS)
  1011. $(LIB_GGML_S): \
  1012. $(OBJ_GGML)
  1013. ar rcs $(LIB_GGML_S) $^
  1014. # llama
  1015. src/unicode.o: \
  1016. src/unicode.cpp \
  1017. src/unicode.h
  1018. $(CXX) $(CXXFLAGS) -c $< -o $@
  1019. src/unicode-data.o: \
  1020. src/unicode-data.cpp \
  1021. src/unicode-data.h
  1022. $(CXX) $(CXXFLAGS) -c $< -o $@
  1023. src/llama.o: \
  1024. src/llama.cpp \
  1025. src/llama-impl.h \
  1026. src/llama-vocab.h \
  1027. src/llama-grammar.h \
  1028. src/llama-sampling.h \
  1029. src/unicode.h \
  1030. include/llama.h \
  1031. ggml/include/ggml-cuda.h \
  1032. ggml/include/ggml-metal.h \
  1033. ggml/include/ggml.h \
  1034. ggml/include/ggml-alloc.h \
  1035. ggml/include/ggml-backend.h
  1036. $(CXX) $(CXXFLAGS) -c $< -o $@
  1037. src/llama-vocab.o: \
  1038. src/llama-vocab.cpp \
  1039. src/llama-vocab.h \
  1040. src/llama-impl.h \
  1041. include/llama.h
  1042. $(CXX) $(CXXFLAGS) -c $< -o $@
  1043. src/llama-grammar.o: \
  1044. src/llama-grammar.cpp \
  1045. src/llama-grammar.h \
  1046. src/llama-impl.h \
  1047. src/llama-vocab.h \
  1048. src/llama-sampling.h \
  1049. include/llama.h
  1050. $(CXX) $(CXXFLAGS) -c $< -o $@
  1051. src/llama-sampling.o: \
  1052. src/llama-sampling.cpp \
  1053. src/llama-sampling.h \
  1054. src/llama-impl.h \
  1055. include/llama.h
  1056. $(CXX) $(CXXFLAGS) -c $< -o $@
  1057. $(LIB_LLAMA): \
  1058. $(OBJ_LLAMA) \
  1059. $(LIB_GGML)
  1060. $(CXX) $(CXXFLAGS) -shared -fPIC -o $@ $^ $(LDFLAGS)
  1061. $(LIB_LLAMA_S): \
  1062. $(OBJ_LLAMA)
  1063. ar rcs $(LIB_LLAMA_S) $^
  1064. # common
  1065. common/common.o: \
  1066. common/common.cpp \
  1067. common/common.h \
  1068. common/console.h \
  1069. common/sampling.h \
  1070. common/json.hpp \
  1071. common/json-schema-to-grammar.h \
  1072. include/llama.h
  1073. $(CXX) $(CXXFLAGS) -c $< -o $@
  1074. common/arg.o: \
  1075. common/arg.cpp \
  1076. common/arg.h
  1077. $(CXX) $(CXXFLAGS) -c $< -o $@
  1078. common/log.o: \
  1079. common/log.cpp \
  1080. common/log.h
  1081. $(CXX) $(CXXFLAGS) -c $< -o $@
  1082. common/sampling.o: \
  1083. common/sampling.cpp \
  1084. common/sampling.h \
  1085. include/llama.h
  1086. $(CXX) $(CXXFLAGS) -c $< -o $@
  1087. common/console.o: \
  1088. common/console.cpp \
  1089. common/console.h
  1090. $(CXX) $(CXXFLAGS) -c $< -o $@
  1091. common/json-schema-to-grammar.o: \
  1092. common/json-schema-to-grammar.cpp \
  1093. common/json-schema-to-grammar.h
  1094. $(CXX) $(CXXFLAGS) -c $< -o $@
  1095. common/ngram-cache.o: \
  1096. common/ngram-cache.cpp \
  1097. common/ngram-cache.h
  1098. $(CXX) $(CXXFLAGS) -c $< -o $@
  1099. $(LIB_COMMON): \
  1100. $(OBJ_COMMON) \
  1101. $(LIB_LLAMA) \
  1102. $(LIB_GGML)
  1103. $(CXX) $(CXXFLAGS) -shared -fPIC -o $@ $^ $(LDFLAGS)
  1104. $(LIB_COMMON_S): \
  1105. $(OBJ_COMMON)
  1106. ar rcs $(LIB_COMMON_S) $^
  1107. clean:
  1108. rm -vrf *.dot $(BUILD_TARGETS) $(TEST_TARGETS)
  1109. rm -rvf src/*.o
  1110. rm -rvf tests/*.o
  1111. rm -rvf examples/*.o
  1112. rm -rvf common/*.o
  1113. rm -rvf *.a
  1114. rm -rvf *.dll
  1115. rm -rvf *.so
  1116. rm -rvf *.dot
  1117. rm -rvf ggml/*.a
  1118. rm -rvf ggml/*.dll
  1119. rm -rvf ggml/*.so
  1120. rm -rvf ggml/src/*.o
  1121. rm -rvf common/build-info.cpp
  1122. rm -rvf ggml/src/ggml-cpu/*.o
  1123. rm -rvf ggml/src/ggml-cpu/llamafile/*.o
  1124. rm -vrf ggml/src/ggml-amx/*.o
  1125. rm -vrf ggml/src/ggml-blas/*.o
  1126. rm -vrf ggml/src/ggml-cann/*.o
  1127. rm -vrf ggml/src/ggml-cpu/*.o
  1128. rm -vrf ggml/src/ggml-cuda/*.o
  1129. rm -vrf ggml/src/ggml-cuda/template-instances/*.o
  1130. rm -vrf ggml/src/ggml-hip/*.o
  1131. rm -vrf ggml/src/ggml-kompute/*.o
  1132. rm -vrf ggml/src/ggml-metal/*.o
  1133. rm -vrf ggml/src/ggml-metal/ggml-metal-embed.metal
  1134. rm -vrf ggml/src/ggml-rpc/*.o
  1135. rm -vrf ggml/src/ggml-sycl/*.o
  1136. rm -vrf ggml/src/ggml-vulkan/*.o
  1137. rm -vrf ggml/src/ggml-musa/*.o
  1138. rm -rvf $(BUILD_TARGETS)
  1139. rm -rvf $(TEST_TARGETS)
  1140. rm -f vulkan-shaders-gen ggml/src/ggml-vulkan-shaders.hpp ggml/src/ggml-vulkan-shaders.cpp
  1141. rm -rvf $(LEGACY_TARGETS_CLEAN)
  1142. find examples pocs -type f -name "*.o" -delete
  1143. #
  1144. # Examples
  1145. #
  1146. # $< is the first prerequisite, i.e. the source file.
  1147. # Explicitly compile this to an object file so that it can be cached with ccache.
  1148. # The source file is then filtered out from $^ (the list of all prerequisites) and the object file is added instead.
  1149. # Helper function that replaces .c, .cpp, and .cu file endings with .o:
  1150. GET_OBJ_FILE = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(patsubst %.cu,%.o,$(1))))
  1151. llama-cli: examples/main/main.cpp \
  1152. $(OBJ_ALL)
  1153. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1154. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1155. @echo
  1156. @echo '==== Run ./llama-cli -h for help. ===='
  1157. @echo
  1158. llama-infill: examples/infill/infill.cpp \
  1159. $(OBJ_ALL)
  1160. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1161. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1162. llama-simple: examples/simple/simple.cpp \
  1163. $(OBJ_ALL)
  1164. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1165. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1166. llama-simple-chat: examples/simple-chat/simple-chat.cpp \
  1167. $(OBJ_ALL)
  1168. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1169. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1170. llama-tokenize: examples/tokenize/tokenize.cpp \
  1171. $(OBJ_ALL)
  1172. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1173. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1174. llama-batched: examples/batched/batched.cpp \
  1175. $(OBJ_ALL)
  1176. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1177. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1178. llama-batched-bench: examples/batched-bench/batched-bench.cpp \
  1179. $(OBJ_ALL)
  1180. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1181. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1182. llama-quantize: examples/quantize/quantize.cpp \
  1183. $(OBJ_ALL)
  1184. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1185. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1186. llama-quantize-stats: examples/quantize-stats/quantize-stats.cpp \
  1187. $(OBJ_ALL)
  1188. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1189. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1190. llama-perplexity: examples/perplexity/perplexity.cpp \
  1191. $(OBJ_ALL)
  1192. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1193. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1194. llama-imatrix: examples/imatrix/imatrix.cpp \
  1195. $(OBJ_ALL)
  1196. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1197. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1198. llama-embedding: examples/embedding/embedding.cpp \
  1199. $(OBJ_ALL)
  1200. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1201. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1202. llama-gritlm: examples/gritlm/gritlm.cpp \
  1203. $(OBJ_ALL)
  1204. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1205. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1206. llama-save-load-state: examples/save-load-state/save-load-state.cpp \
  1207. $(OBJ_ALL)
  1208. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1209. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1210. llama-gguf: examples/gguf/gguf.cpp \
  1211. $(OBJ_GGML)
  1212. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1213. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1214. examples/gguf-hash/deps/sha1/sha1.o: \
  1215. examples/gguf-hash/deps/sha1/sha1.c
  1216. $(CC) $(CFLAGS) -Iexamples/gguf-hash/deps -c $< -o $@
  1217. examples/gguf-hash/deps/xxhash/xxhash.o: \
  1218. examples/gguf-hash/deps/xxhash/xxhash.c
  1219. $(CC) $(CFLAGS) -Iexamples/gguf-hash/deps -c $< -o $@
  1220. examples/gguf-hash/deps/sha256/sha256.o: \
  1221. examples/gguf-hash/deps/sha256/sha256.c
  1222. $(CC) $(CFLAGS) -Iexamples/gguf-hash/deps -c $< -o $@
  1223. llama-gguf-hash: examples/gguf-hash/gguf-hash.cpp examples/gguf-hash/deps/sha1/sha1.o examples/gguf-hash/deps/xxhash/xxhash.o examples/gguf-hash/deps/sha256/sha256.o\
  1224. $(OBJ_ALL)
  1225. $(CXX) $(CXXFLAGS) -Iexamples/gguf-hash/deps -c $< -o $(call GET_OBJ_FILE, $<)
  1226. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1227. llama-gguf-split: examples/gguf-split/gguf-split.cpp \
  1228. $(OBJ_ALL)
  1229. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1230. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1231. llama-eval-callback: examples/eval-callback/eval-callback.cpp \
  1232. $(OBJ_ALL)
  1233. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1234. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1235. llama-cvector-generator: examples/cvector-generator/cvector-generator.cpp \
  1236. $(OBJ_ALL)
  1237. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1238. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1239. llama-convert-llama2c-to-ggml: examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp \
  1240. $(OBJ_ALL)
  1241. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1242. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1243. llama-bench: examples/llama-bench/llama-bench.cpp \
  1244. $(OBJ_ALL)
  1245. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1246. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1247. llama-export-lora: examples/export-lora/export-lora.cpp \
  1248. $(OBJ_ALL)
  1249. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1250. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1251. llama-retrieval: examples/retrieval/retrieval.cpp \
  1252. $(OBJ_ALL)
  1253. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1254. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1255. llama-speculative: examples/speculative/speculative.cpp \
  1256. $(OBJ_ALL)
  1257. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1258. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1259. llama-parallel: examples/parallel/parallel.cpp \
  1260. $(OBJ_ALL)
  1261. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1262. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1263. llama-lookahead: examples/lookahead/lookahead.cpp \
  1264. $(OBJ_ALL)
  1265. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1266. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1267. llama-lookup: examples/lookup/lookup.cpp \
  1268. $(OBJ_ALL)
  1269. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1270. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1271. llama-lookup-create: examples/lookup/lookup-create.cpp \
  1272. $(OBJ_ALL)
  1273. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1274. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1275. llama-lookup-merge: examples/lookup/lookup-merge.cpp \
  1276. $(OBJ_ALL)
  1277. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1278. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1279. llama-lookup-stats: examples/lookup/lookup-stats.cpp \
  1280. $(OBJ_ALL)
  1281. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1282. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1283. llama-passkey: examples/passkey/passkey.cpp \
  1284. $(OBJ_ALL)
  1285. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1286. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1287. llama-gbnf-validator: examples/gbnf-validator/gbnf-validator.cpp \
  1288. $(OBJ_ALL)
  1289. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1290. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1291. ifdef GGML_RPC
  1292. rpc-server: examples/rpc/rpc-server.cpp \
  1293. $(OBJ_GGML)
  1294. $(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS)
  1295. endif # GGML_RPC
  1296. llama-server: \
  1297. examples/server/server.cpp \
  1298. examples/server/utils.hpp \
  1299. examples/server/httplib.h \
  1300. examples/server/index.html.hpp \
  1301. examples/server/completion.js.hpp \
  1302. examples/server/loading.html.hpp \
  1303. examples/server/deps_daisyui.min.css.hpp \
  1304. examples/server/deps_markdown-it.js.hpp \
  1305. examples/server/deps_tailwindcss.js.hpp \
  1306. examples/server/deps_vue.esm-browser.js.hpp \
  1307. common/json.hpp \
  1308. common/stb_image.h \
  1309. $(OBJ_ALL)
  1310. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1311. $(CXX) $(CXXFLAGS) $(filter-out %.h %.hpp $<,$^) -Iexamples/server $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS) $(LWINSOCK2)
  1312. # Portable equivalent of `cd examples/server/public && xxd -i $(notdir $<) ../$(notdir $<).hpp`:
  1313. examples/server/%.hpp: examples/server/public/% Makefile
  1314. @( export NAME=$(subst .,_,$(subst -,_,$(notdir $<))) && \
  1315. echo "unsigned char $${NAME}[] = {" && \
  1316. cat $< | od -v -t x1 -An | sed -E 's/([0-9a-fA-F]+)/0x\1, /g' && \
  1317. echo "};" && \
  1318. echo "unsigned int $${NAME}_len = $(shell cat $< | wc -c );" \
  1319. ) > $@
  1320. llama-gen-docs: examples/gen-docs/gen-docs.cpp \
  1321. $(OBJ_ALL)
  1322. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1323. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1324. libllava.a: examples/llava/llava.cpp \
  1325. examples/llava/llava.h \
  1326. examples/llava/clip.cpp \
  1327. examples/llava/clip.h \
  1328. common/stb_image.h \
  1329. common/base64.hpp \
  1330. $(OBJ_ALL)
  1331. $(CXX) $(CXXFLAGS) -static -fPIC -c $< -o $@ -Wno-cast-qual
  1332. llama-llava-cli: examples/llava/llava-cli.cpp \
  1333. examples/llava/llava.cpp \
  1334. examples/llava/llava.h \
  1335. examples/llava/clip.cpp \
  1336. examples/llava/clip.h \
  1337. $(OBJ_ALL)
  1338. $(CXX) $(CXXFLAGS) $< $(filter-out %.h $<,$^) -o $@ $(LDFLAGS) -Wno-cast-qual
  1339. llama-minicpmv-cli: examples/llava/minicpmv-cli.cpp \
  1340. examples/llava/llava.cpp \
  1341. examples/llava/llava.h \
  1342. examples/llava/clip.cpp \
  1343. examples/llava/clip.h \
  1344. $(OBJ_ALL)
  1345. $(CXX) $(CXXFLAGS) $< $(filter-out %.h $<,$^) -o $@ $(LDFLAGS) -Wno-cast-qual
  1346. ifeq ($(UNAME_S),Darwin)
  1347. swift: examples/batched.swift
  1348. (cd examples/batched.swift; make build)
  1349. endif
  1350. common/build-info.cpp: $(wildcard .git/index) scripts/build-info.sh
  1351. @sh scripts/build-info.sh "$(CC)" > $@.tmp
  1352. @if ! cmp -s $@.tmp $@; then \
  1353. mv $@.tmp $@; \
  1354. else \
  1355. rm $@.tmp; \
  1356. fi
  1357. common/build-info.o: common/build-info.cpp
  1358. $(CXX) $(CXXFLAGS) -c $(filter-out %.h,$^) -o $@
  1359. #
  1360. # Tests
  1361. #
  1362. tests: $(TEST_TARGETS)
  1363. tests/test-arg-parser: tests/test-arg-parser.cpp \
  1364. $(OBJ_ALL)
  1365. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1366. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1367. tests/test-llama-grammar: tests/test-llama-grammar.cpp \
  1368. $(OBJ_ALL)
  1369. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1370. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1371. tests/test-log: tests/test-log.cpp \
  1372. $(OBJ_ALL)
  1373. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1374. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1375. tests/test-grammar-parser: tests/test-grammar-parser.cpp \
  1376. $(OBJ_ALL)
  1377. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1378. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1379. tests/test-grammar-integration: tests/test-grammar-integration.cpp \
  1380. $(OBJ_ALL)
  1381. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1382. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1383. tests/test-double-float: tests/test-double-float.cpp
  1384. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1385. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1386. tests/test-json-schema-to-grammar: tests/test-json-schema-to-grammar.cpp \
  1387. $(OBJ_ALL)
  1388. $(CXX) $(CXXFLAGS) -Iexamples/server -c $< -o $(call GET_OBJ_FILE, $<)
  1389. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1390. tests/test-grad0: tests/test-grad0.cpp \
  1391. $(OBJ_GGML)
  1392. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1393. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1394. tests/test-opt: tests/test-opt.cpp \
  1395. $(OBJ_GGML)
  1396. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1397. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1398. tests/test-quantize-fns: tests/test-quantize-fns.cpp \
  1399. $(OBJ_GGML)
  1400. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1401. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1402. tests/test-quantize-perf: tests/test-quantize-perf.cpp \
  1403. $(OBJ_GGML)
  1404. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1405. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1406. tests/test-sampling: tests/test-sampling.cpp \
  1407. $(OBJ_ALL)
  1408. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1409. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1410. tests/test-tokenizer-0: tests/test-tokenizer-0.cpp \
  1411. $(OBJ_ALL)
  1412. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1413. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1414. tests/test-tokenizer-1-bpe: tests/test-tokenizer-1-bpe.cpp \
  1415. $(OBJ_ALL)
  1416. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1417. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1418. tests/test-tokenizer-1-spm: tests/test-tokenizer-1-spm.cpp \
  1419. $(OBJ_ALL)
  1420. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1421. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1422. tests/test-rope: tests/test-rope.cpp ggml/src/ggml.o \
  1423. $(OBJ_GGML)
  1424. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1425. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1426. tests/test-c.o: tests/test-c.c include/llama.h
  1427. $(CC) $(CFLAGS) -c $(filter-out %.h,$^) -o $@
  1428. tests/test-backend-ops: tests/test-backend-ops.cpp \
  1429. $(OBJ_GGML)
  1430. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1431. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1432. tests/test-model-load-cancel: tests/test-model-load-cancel.cpp tests/get-model.cpp \
  1433. $(OBJ_ALL)
  1434. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1435. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1436. tests/test-autorelease: tests/test-autorelease.cpp tests/get-model.cpp \
  1437. $(OBJ_ALL)
  1438. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1439. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1440. tests/test-chat-template: tests/test-chat-template.cpp \
  1441. $(OBJ_ALL)
  1442. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1443. $(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1444. #
  1445. # PoCs
  1446. #
  1447. llama-vdot: pocs/vdot/vdot.cpp ggml/src/ggml.o \
  1448. $(OBJ_GGML)
  1449. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1450. $(CXX) $(CXXFLAGS) $(filter-out $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1451. llama-q8dot: pocs/vdot/q8dot.cpp ggml/src/ggml.o \
  1452. $(OBJ_GGML)
  1453. $(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
  1454. $(CXX) $(CXXFLAGS) $(filter-out $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
  1455. #
  1456. # Deprecated binaries that we want to keep around long enough for people to migrate to the new filenames, then these can be removed.
  1457. #
  1458. # Mark legacy binary targets as .PHONY so that they are always checked.
  1459. .PHONY: main quantize perplexity embedding server
  1460. # Define the object file target
  1461. examples/deprecation-warning/deprecation-warning.o: examples/deprecation-warning/deprecation-warning.cpp
  1462. $(CXX) $(CXXFLAGS) -c $< -o $@
  1463. # NOTE: We currently will always build the deprecation-warning `main` and `server` binaries to help users migrate.
  1464. # Eventually we will want to remove these target from building all the time.
  1465. main: examples/deprecation-warning/deprecation-warning.o
  1466. $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS)
  1467. @echo "NOTICE: The 'main' binary is deprecated. Please use 'llama-cli' instead."
  1468. server: examples/deprecation-warning/deprecation-warning.o
  1469. $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS)
  1470. @echo "NOTICE: The 'server' binary is deprecated. Please use 'llama-server' instead."
  1471. quantize: examples/deprecation-warning/deprecation-warning.o
  1472. ifneq (,$(wildcard quantize))
  1473. $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS)
  1474. @echo "#########"
  1475. @echo "WARNING: The 'quantize' binary is deprecated. Please use 'llama-quantize' instead."
  1476. @echo " Remove the 'quantize' binary to remove this warning."
  1477. @echo "#########"
  1478. endif
  1479. perplexity: examples/deprecation-warning/deprecation-warning.o
  1480. ifneq (,$(wildcard perplexity))
  1481. $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS)
  1482. @echo "#########"
  1483. @echo "WARNING: The 'perplexity' binary is deprecated. Please use 'llama-perplexity' instead."
  1484. @echo " Remove the 'perplexity' binary to remove this warning."
  1485. @echo "#########"
  1486. endif
  1487. embedding: examples/deprecation-warning/deprecation-warning.o
  1488. ifneq (,$(wildcard embedding))
  1489. $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS)
  1490. @echo "#########"
  1491. @echo "WARNING: The 'embedding' binary is deprecated. Please use 'llama-embedding' instead."
  1492. @echo " Remove the 'embedding' binary to remove this warning."
  1493. @echo "#########"
  1494. endif