mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-11-10 00:08:43 -05:00
* chat: remove unused oscompat source files
These files are no longer needed now that the hnswlib index is gone.
This fixes an issue with the Windows build as there was a compilation
error in oscompat.cpp.
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
* llm: fix pragma to be recognized by MSVC
Replaces this MSVC warning:
C:\msys64\home\Jared\gpt4all\gpt4all-chat\llm.cpp(53,21): warning C4081: expected '('; found 'string'
With this:
C:\msys64\home\Jared\gpt4all\gpt4all-chat\llm.cpp : warning : offline installer build will not check for updates!
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
* usearch: fork usearch to fix `CreateFile` build error
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
* dlhandle: fix incorrect assertion on Windows
SetErrorMode returns the previous value of the error mode flags, not an
indicator of success.
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
* llamamodel: fix UB in LLamaModel::embedInternal
It is undefined behavior to increment an STL iterator past the end of
the container. Use offsets to do the math instead.
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
* cmake: install embedding model to bundle's Resources dir on macOS
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
* ci: fix macOS build by explicitly installing Rosetta
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
---------
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
74 lines
1.5 KiB
C++
74 lines
1.5 KiB
C++
#include "dlhandle.h"
|
|
|
|
#include <string>
|
|
|
|
#ifndef _WIN32
|
|
# include <dlfcn.h>
|
|
#else
|
|
# include <cassert>
|
|
# include <sstream>
|
|
# define WIN32_LEAN_AND_MEAN
|
|
# ifndef NOMINMAX
|
|
# define NOMINMAX
|
|
# endif
|
|
# include <windows.h>
|
|
#endif
|
|
|
|
using namespace std::string_literals;
|
|
namespace fs = std::filesystem;
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
Dlhandle::Dlhandle(const fs::path &fpath)
|
|
{
|
|
chandle = dlopen(fpath.c_str(), RTLD_LAZY | RTLD_LOCAL);
|
|
if (!chandle) {
|
|
throw Exception("dlopen: "s + dlerror());
|
|
}
|
|
}
|
|
|
|
Dlhandle::~Dlhandle()
|
|
{
|
|
if (chandle) dlclose(chandle);
|
|
}
|
|
|
|
void *Dlhandle::get_internal(const char *symbol) const
|
|
{
|
|
return dlsym(chandle, symbol);
|
|
}
|
|
|
|
#else // defined(_WIN32)
|
|
|
|
Dlhandle::Dlhandle(const fs::path &fpath)
|
|
{
|
|
fs::path afpath = fs::absolute(fpath);
|
|
|
|
// Suppress the "Entry Point Not Found" dialog, caused by outdated nvcuda.dll from the GPU driver
|
|
UINT lastErrorMode = GetErrorMode();
|
|
SetErrorMode(lastErrorMode | SEM_FAILCRITICALERRORS);
|
|
|
|
chandle = LoadLibraryExW(afpath.c_str(), NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
|
|
|
|
SetErrorMode(lastErrorMode);
|
|
|
|
if (!chandle) {
|
|
DWORD err = GetLastError();
|
|
std::ostringstream ss;
|
|
ss << "LoadLibraryExW failed with error 0x" << std::hex << err;
|
|
throw Exception(ss.str());
|
|
}
|
|
}
|
|
|
|
Dlhandle::~Dlhandle()
|
|
{
|
|
if (chandle) FreeLibrary(HMODULE(chandle));
|
|
}
|
|
|
|
void *Dlhandle::get_internal(const char *symbol) const
|
|
{
|
|
return GetProcAddress(HMODULE(chandle), symbol);
|
|
}
|
|
|
|
#endif // defined(_WIN32)
|