Skip to content

Commit ac32902

Browse files
authored
llama : support WinXP build with MinGW 8.1.0 (#3419)
1 parent 147b17a commit ac32902

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

CMakeLists.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.13) # for add_link_options
1+
cmake_minimum_required(VERSION 3.14) # for add_link_options and implicit target directories.
22
project("llama.cpp" C CXX)
33

44
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@@ -76,6 +76,10 @@ if (NOT MSVC)
7676
option(LLAMA_F16C "llama: enable F16C" ${INS_ENB})
7777
endif()
7878

79+
if (WIN32)
80+
option(LLAMA_WIN_VER "llama: Windows Version" 0x602)
81+
endif()
82+
7983
# 3rd party libs
8084
option(LLAMA_ACCELERATE "llama: enable Accelerate framework" ON)
8185
option(LLAMA_BLAS "llama: use BLAS" OFF)
@@ -686,7 +690,7 @@ endif()
686690

687691
if (MINGW)
688692
# Target Windows 8 for PrefetchVirtualMemory
689-
add_compile_definitions(_WIN32_WINNT=0x602)
693+
add_compile_definitions(_WIN32_WINNT=${LLAMA_WIN_VER})
690694
endif()
691695

692696
#

llama.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,7 @@ struct llama_mmap {
987987
}
988988

989989
if (prefetch > 0) {
990+
#if _WIN32_WINNT >= 0x602
990991
// PrefetchVirtualMemory is only present on Windows 8 and above, so we dynamically load it
991992
BOOL (WINAPI *pPrefetchVirtualMemory) (HANDLE, ULONG_PTR, PWIN32_MEMORY_RANGE_ENTRY, ULONG);
992993
HMODULE hKernel32 = GetModuleHandleW(L"kernel32.dll");
@@ -1004,6 +1005,9 @@ struct llama_mmap {
10041005
llama_format_win_err(GetLastError()).c_str());
10051006
}
10061007
}
1008+
#else
1009+
throw std::runtime_error("PrefetchVirtualMemory unavailable");
1010+
#endif
10071011
}
10081012
}
10091013

0 commit comments

Comments
 (0)