This commit is contained in:
LIU Xiao 2024-11-14 14:03:00 +08:00 committed by GitHub
commit f263838447
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 481 additions and 110 deletions

View file

@ -46,6 +46,11 @@ if (WIN32)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS) add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
endif() endif()
if(MSVC)
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
endif()
# #
# option list # option list
# #

View file

@ -452,8 +452,7 @@ ifneq '' '$(findstring mingw,$(shell $(CC) -dumpmachine))'
MK_CFLAGS += -Xassembler -muse-unaligned-vector-move MK_CFLAGS += -Xassembler -muse-unaligned-vector-move
MK_CXXFLAGS += -Xassembler -muse-unaligned-vector-move MK_CXXFLAGS += -Xassembler -muse-unaligned-vector-move
# Target Windows 8 for PrefetchVirtualMemory MK_CPPFLAGS += -D_WIN32_WINNT=_WIN32_WINNT_WIN7 -DWINVER=_WIN32_WINNT_WIN7
MK_CPPFLAGS += -D_WIN32_WINNT=0x602
endif endif
ifneq ($(filter aarch64%,$(UNAME_M)),) ifneq ($(filter aarch64%,$(UNAME_M)),)

View file

@ -4,11 +4,6 @@ option(LLAMA_SERVER_SSL "Build SSL support for the server" OFF)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
if (MINGW)
# fix: https://github.com/ggerganov/llama.cpp/actions/runs/9651004652/job/26617901362?pr=8006
add_compile_definitions(_WIN32_WINNT=${GGML_WIN_VER})
endif()
set(TARGET_SRCS set(TARGET_SRCS
server.cpp server.cpp
utils.hpp utils.hpp
@ -48,6 +43,7 @@ endif()
if (WIN32) if (WIN32)
TARGET_LINK_LIBRARIES(${TARGET} PRIVATE ws2_32) TARGET_LINK_LIBRARIES(${TARGET} PRIVATE ws2_32)
target_compile_definitions(${TARGET} PRIVATE _WIN32_WINNT=${GGML_WIN_VER} WINVER=${GGML_WIN_VER})
endif() endif()
target_compile_features(${TARGET} PRIVATE cxx_std_11) target_compile_features(${TARGET} PRIVATE cxx_std_11)

File diff suppressed because it is too large Load diff

View file

@ -111,7 +111,7 @@ option(GGML_LSX "ggml: enable lsx" ON)
option(GGML_SVE "ggml: enable SVE" OFF) option(GGML_SVE "ggml: enable SVE" OFF)
if (WIN32) if (WIN32)
set(GGML_WIN_VER "0x602" CACHE STRING "ggml: Windows Version") set(GGML_WIN_VER "_WIN32_WINNT_WIN7" CACHE STRING "ggml: Windows Version")
endif() endif()
# ggml core # ggml core

View file

@ -1304,9 +1304,8 @@ if (GGML_CUDA)
add_compile_options("$<$<COMPILE_LANGUAGE:CUDA>:${CUDA_FLAGS}>") add_compile_options("$<$<COMPILE_LANGUAGE:CUDA>:${CUDA_FLAGS}>")
endif() endif()
if (MINGW) if (WIN32)
# Target Windows 8 for PrefetchVirtualMemory add_compile_definitions(_WIN32_WINNT=${GGML_WIN_VER} WINVER=${GGML_WIN_VER})
add_compile_definitions(_WIN32_WINNT=${GGML_WIN_VER})
endif() endif()
# #

View file

@ -2041,8 +2041,14 @@ struct llama_mmap {
} }
if (prefetch > 0) { if (prefetch > 0) {
#if _WIN32_WINNT >= 0x602
// PrefetchVirtualMemory is only present on Windows 8 and above, so we dynamically load it // PrefetchVirtualMemory is only present on Windows 8 and above, so we dynamically load it
#if (_WIN32_WINNT < _WIN32_WINNT_WIN8)
typedef struct _WIN32_MEMORY_RANGE_ENTRY {
PVOID VirtualAddress;
SIZE_T NumberOfBytes;
} WIN32_MEMORY_RANGE_ENTRY, *PWIN32_MEMORY_RANGE_ENTRY;
#endif // (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
BOOL (WINAPI *pPrefetchVirtualMemory) (HANDLE, ULONG_PTR, PWIN32_MEMORY_RANGE_ENTRY, ULONG); BOOL (WINAPI *pPrefetchVirtualMemory) (HANDLE, ULONG_PTR, PWIN32_MEMORY_RANGE_ENTRY, ULONG);
HMODULE hKernel32 = GetModuleHandleW(L"kernel32.dll"); HMODULE hKernel32 = GetModuleHandleW(L"kernel32.dll");
@ -2059,9 +2065,6 @@ struct llama_mmap {
llama_format_win_err(GetLastError()).c_str()); llama_format_win_err(GetLastError()).c_str());
} }
} }
#else
throw std::runtime_error("PrefetchVirtualMemory unavailable");
#endif
} }
} }