Skip to content

Commit cc14ed1

Browse files
committed
compat : rebase and build for windows xp.
1 parent b8fe4b5 commit cc14ed1

File tree

33 files changed

+92
-40
lines changed

33 files changed

+92
-40
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "compat/mingw"]
2+
path = compat/mingw
3+
url = https://github.com/meganz/mingw-std-threads

CMakeLists.txt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
cmake_minimum_required(VERSION 3.13) # for add_link_options
2+
23
project("llama.cpp" C CXX)
34

45
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@@ -80,7 +81,7 @@ option(LLAMA_ACCELERATE "llama: enable Accelerate framework
8081
option(LLAMA_BLAS "llama: use BLAS" OFF)
8182
set(LLAMA_BLAS_VENDOR "Generic" CACHE STRING "llama: BLAS library vendor")
8283
option(LLAMA_CUBLAS "llama: use CUDA" OFF)
83-
#option(LLAMA_CUDA_CUBLAS "llama: use cuBLAS for prompt processing" OFF)
84+
#option(LLAMA_CUDA_CUBLAS "llama: use cuBLAS for prompt processing" OFF)
8485
option(LLAMA_CUDA_FORCE_DMMV "llama: use dmmv instead of mmvq CUDA kernels" OFF)
8586
set(LLAMA_CUDA_DMMV_X "32" CACHE STRING "llama: x stride for dmmv CUDA kernels")
8687
set(LLAMA_CUDA_MMV_Y "1" CACHE STRING "llama: y block size for mmv CUDA kernels")
@@ -89,16 +90,17 @@ set(LLAMA_CUDA_KQUANTS_ITER "2" CACHE STRING "llama: iters./thread per block for
8990
set(LLAMA_CUDA_PEER_MAX_BATCH_SIZE "128" CACHE STRING
9091
"llama: max. batch size for using peer access")
9192
option(LLAMA_HIPBLAS "llama: use hipBLAS" OFF)
93+
option(LLAMA_MINGW_COMPAT "llama: use MinGW compatibility headers" OFF)
9294
option(LLAMA_CLBLAST "llama: use CLBlast" OFF)
9395
option(LLAMA_METAL "llama: use Metal" ${LLAMA_METAL_DEFAULT})
9496
option(LLAMA_METAL_NDEBUG "llama: disable Metal debugging" OFF)
9597
option(LLAMA_MPI "llama: use MPI" OFF)
9698
option(LLAMA_K_QUANTS "llama: use k-quants" ON)
9799
option(LLAMA_QKK_64 "llama: use super-block size of 64 for k-quants" OFF)
98100

99-
option(LLAMA_BUILD_TESTS "llama: build tests" ${LLAMA_STANDALONE})
100-
option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
101-
option(LLAMA_BUILD_SERVER "llama: build server example" ON)
101+
option(LLAMA_BUILD_TESTS "llama: build tests" ${LLAMA_STANDALONE})
102+
option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
103+
option(LLAMA_BUILD_SERVER "llama: build server example" ON)
102104

103105
#
104106
# Build info header
@@ -646,6 +648,9 @@ endif()
646648
if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
647649
add_compile_definitions(_BSD_SOURCE)
648650
endif()
651+
if ((MINGW) AND (LLAMA_MINGW_COMPAT))
652+
add_compile_definitions(_USE_MINGW_COMPAT)
653+
endif()
649654

650655
#
651656
# libraries
@@ -695,6 +700,10 @@ add_library(llama
695700
)
696701

697702
target_include_directories(llama PUBLIC .)
703+
if (MINGW AND LLAMA_MINGW_COMPAT)
704+
include_directories(PRIVATE ${CMAKE_SOURCE_DIR}/compat/mingw)
705+
endif()
706+
698707
target_compile_features(llama PUBLIC cxx_std_11) # don't bump
699708
target_link_libraries(llama PRIVATE
700709
ggml
@@ -750,10 +759,10 @@ set(GGML_PUBLIC_HEADERS "ggml.h"
750759
"${GGML_HEADERS_METAL}" "${GGML_HEADERS_MPI}" "${GGML_HEADERS_EXTRA}")
751760

752761
set_target_properties(ggml PROPERTIES PUBLIC_HEADER "${GGML_PUBLIC_HEADERS}")
753-
install(TARGETS ggml PUBLIC_HEADER)
762+
install(TARGETS ggml PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
754763

755764
set_target_properties(llama PROPERTIES PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/llama.h)
756-
install(TARGETS llama LIBRARY PUBLIC_HEADER)
765+
install(TARGETS llama PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
757766

758767
install(
759768
FILES convert.py

common/common.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@
1212
#include <string>
1313
#include <vector>
1414
#include <random>
15-
#include <thread>
1615
#include <unordered_map>
1716
#include <tuple>
1817

18+
#if defined(__MINGW32__) && defined(_USE_MINGW_COMPAT)
19+
#include <mingw.thread.h>
20+
#else
21+
#include <thread>
22+
#endif
23+
1924
#ifdef _WIN32
2025
#define DIRECTORY_SEPARATOR '\\'
2126
#else

common/log.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44
#include <cstring>
55
#include <sstream>
66
#include <iostream>
7-
#include <thread>
87
#include <vector>
98
#include <algorithm>
109
#include <cinttypes>
1110

11+
#if defined(__MINGW32__) && defined(_USE_MINGW_COMPAT)
12+
#include <mingw.thread.h>
13+
#else
14+
#include <thread>
15+
#endif
16+
1217
// --------------------------------
1318
//
1419
// Basic usage:

compat/mingw

Submodule mingw added at c931bac

examples/baby-llama/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set(TARGET baby-llama)
22
add_executable(${TARGET} baby-llama.cpp)
3-
install(TARGETS ${TARGET} RUNTIME)
3+
install(TARGETS ${TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
44
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
55
target_compile_features(${TARGET} PRIVATE cxx_std_11)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set(TARGET batched-bench)
22
add_executable(${TARGET} batched-bench.cpp)
3-
install(TARGETS ${TARGET} RUNTIME)
3+
install(TARGETS ${TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
44
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
55
target_compile_features(${TARGET} PRIVATE cxx_std_11)

examples/batched/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set(TARGET batched)
22
add_executable(${TARGET} batched.cpp)
3-
install(TARGETS ${TARGET} RUNTIME)
3+
install(TARGETS ${TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
44
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
55
target_compile_features(${TARGET} PRIVATE cxx_std_11)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set(TARGET beam-search)
22
add_executable(${TARGET} beam-search.cpp)
3-
install(TARGETS ${TARGET} RUNTIME)
3+
install(TARGETS ${TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
44
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
55
target_compile_features(${TARGET} PRIVATE cxx_std_11)

examples/benchmark/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
set(TARGET benchmark)
22
add_executable(${TARGET} benchmark-matmult.cpp)
3-
install(TARGETS ${TARGET} RUNTIME)
3+
install(TARGETS ${TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
44
target_link_libraries(${TARGET} PRIVATE llama ${CMAKE_THREAD_LIBS_INIT})
55
target_include_directories(${TARGET} PRIVATE ../../common)
66
target_compile_features(${TARGET} PRIVATE cxx_std_11)

0 commit comments

Comments
 (0)