mirror of https://github.com/nomic-ai/gpt4all
chat: fix build on Windows and Nomic Embed path on macOS (#2467)
* 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>macos/cloud-signing-workflow v3.0.0-rc1
parent
bbf0c2f246
commit
88d85be0f9
@ -1,70 +0,0 @@
|
||||
#include "oscompat.h"
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# ifndef NOMINMAX
|
||||
# define NOMINMAX
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# include <errno.h>
|
||||
#else
|
||||
# include <fcntl.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
bool gpt4all_fsync(int fd)
|
||||
{
|
||||
#if defined(Q_OS_WIN32)
|
||||
HANDLE handle = HANDLE(_get_osfhandle(fd));
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
errno = EBADF;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FlushFileBuffers(handle))
|
||||
return true;
|
||||
|
||||
DWORD error = GetLastError();
|
||||
switch (error) {
|
||||
case ERROR_ACCESS_DENIED: // read-only file
|
||||
return true;
|
||||
case ERROR_INVALID_HANDLE: // not a regular file
|
||||
errno = EINVAL;
|
||||
default:
|
||||
errno = EIO;
|
||||
}
|
||||
|
||||
return false;
|
||||
#elif defined(Q_OS_DARWIN)
|
||||
return fcntl(fd, F_FULLFSYNC, 0) == 0;
|
||||
#else
|
||||
return fsync(fd) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool gpt4all_fdatasync(int fd)
|
||||
{
|
||||
#if defined(Q_OS_WIN32) || defined(Q_OS_DARWIN)
|
||||
return gpt4all_fsync(fd);
|
||||
#else
|
||||
return fdatasync(fd) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool gpt4all_syncdir(const QString &path)
|
||||
{
|
||||
#if defined(Q_OS_WIN32)
|
||||
(void)path; // cannot sync a directory on Windows
|
||||
return true;
|
||||
#else
|
||||
int fd = open(path.toLocal8Bit().constData(), O_RDONLY | O_DIRECTORY);
|
||||
if (fd == -1) return false;
|
||||
bool ok = gpt4all_fdatasync(fd);
|
||||
close(fd);
|
||||
return ok;
|
||||
#endif
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
class QString;
|
||||
|
||||
bool gpt4all_fsync(int fd);
|
||||
bool gpt4all_fdatasync(int fd);
|
||||
bool gpt4all_syncdir(const QString &path);
|
@ -1 +1 @@
|
||||
Subproject commit 5ea48c87c56a25ab57634a8f207f80ae675ed58e
|
||||
Subproject commit 22cfa3bd00ea542132ee826cdb220f9d6434bd43
|
Loading…
Reference in New Issue