From fd0da240c845996d9cc4d02ed25d4464823f4ec7 Mon Sep 17 00:00:00 2001 From: -k Date: Fri, 2 Jan 2026 13:48:58 -0500 Subject: [PATCH 1/2] build: fix fbsd imports --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8670013..11bf5c57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,6 +128,11 @@ if (DBUS) list(APPEND QT_FPDEPS DBus) endif() +if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + include_directories(SYSTEM /usr/local/include) + link_directories(/usr/local/lib) +endif() + find_package(Qt6 REQUIRED COMPONENTS ${QT_FPDEPS}) # In Qt 6.10, private dependencies are required to be explicit, From 8b25ac2c6c790679edbea26d2de1354acb931521 Mon Sep 17 00:00:00 2001 From: -k Date: Fri, 2 Jan 2026 13:52:43 -0500 Subject: [PATCH 2/2] core: fix `flock`/`sendfile()` on fbsd --- src/core/logging.cpp | 47 ++++++++++++++++++++++++++++------------ src/core/paths.cpp | 26 ++++++++++------------ src/core/toolsupport.cpp | 13 +++++------ 3 files changed, 51 insertions(+), 35 deletions(-) diff --git a/src/core/logging.cpp b/src/core/logging.cpp index 5c809f68..3e42a45f 100644 --- a/src/core/logging.cpp +++ b/src/core/logging.cpp @@ -27,7 +27,14 @@ #include #include #include + +#ifdef __FreeBSD__ +#include +#include +#include +#else #include +#endif #include "instanceinfo.hpp" #include "logcat.hpp" @@ -392,13 +399,12 @@ void ThreadLogging::initFs() { delete detailedFile; detailedFile = nullptr; } else { - auto lock = flock { - .l_type = F_WRLCK, - .l_whence = SEEK_SET, - .l_start = 0, - .l_len = 0, - .l_pid = 0, - }; + struct flock lock = {}; + lock.l_type = F_WRLCK; + lock.l_whence = SEEK_SET; + lock.l_start = 0; + lock.l_len = 0; + lock.l_pid = 0; if (fcntl(detailedFile->handle(), F_SETLK, &lock) != 0) { // NOLINT qCWarning(logLogging) << "Unable to set lock marker on detailed log file. --follow from " @@ -414,7 +420,14 @@ void ThreadLogging::initFs() { auto* oldFile = this->file; if (oldFile) { oldFile->seek(0); + // clang-format off + #ifdef __FreeBSD__ + off_t sent = 0; + sendfile(oldFile->handle(), file->handle(), 0, oldFile->size(), nullptr, &sent, 0); + #else sendfile(file->handle(), oldFile->handle(), nullptr, oldFile->size()); + #endif + // clang-format on } this->file = file; @@ -426,7 +439,14 @@ void ThreadLogging::initFs() { auto* oldFile = this->detailedFile; if (oldFile) { oldFile->seek(0); + // clang-format off + #ifdef __FreeBSD__ + off_t sent = 0; + sendfile(oldFile->handle(), detailedFile->handle(), 0, oldFile->size(), nullptr, &sent, 0); + #else sendfile(detailedFile->handle(), oldFile->handle(), nullptr, oldFile->size()); + #endif + // clang-format on } crash::CrashInfo::INSTANCE.logFd = detailedFile->handle(); @@ -889,13 +909,12 @@ bool LogReader::continueReading() { } void LogFollower::FcntlWaitThread::run() { - auto lock = flock { - .l_type = F_RDLCK, // won't block other read locks when we take it - .l_whence = SEEK_SET, - .l_start = 0, - .l_len = 0, - .l_pid = 0, - }; + struct flock lock = {}; + lock.l_type = F_RDLCK; // won't block other read locks when we take it + lock.l_whence = SEEK_SET; + lock.l_start = 0; + lock.l_len = 0; + lock.l_pid = 0; auto r = fcntl(this->follower->reader->file->handle(), F_SETLKW, &lock); // NOLINT diff --git a/src/core/paths.cpp b/src/core/paths.cpp index 55beb87c..e3e486d7 100644 --- a/src/core/paths.cpp +++ b/src/core/paths.cpp @@ -361,13 +361,12 @@ void QsPaths::createLock() { return; } - auto lock = flock { - .l_type = F_WRLCK, - .l_whence = SEEK_SET, - .l_start = 0, - .l_len = 0, - .l_pid = 0, - }; + struct flock lock = {}; + lock.l_type = F_WRLCK; + lock.l_whence = SEEK_SET; + lock.l_start = 0; + lock.l_len = 0; + lock.l_pid = 0; if (fcntl(file->handle(), F_SETLK, &lock) != 0) { // NOLINT qCCritical(logPaths).nospace() << "Could not lock instance lock at " << path @@ -389,13 +388,12 @@ bool QsPaths::checkLock(const QString& path, InstanceLockInfo* info, bool allowD auto file = QFile(QDir(path).filePath("instance.lock")); if (!file.open(QFile::ReadOnly)) return false; - auto lock = flock { - .l_type = F_WRLCK, - .l_whence = SEEK_SET, - .l_start = 0, - .l_len = 0, - .l_pid = 0, - }; + struct flock lock = {}; + lock.l_type = F_WRLCK; + lock.l_whence = SEEK_SET; + lock.l_start = 0; + lock.l_len = 0; + lock.l_pid = 0; fcntl(file.handle(), F_GETLK, &lock); // NOLINT auto isLocked = lock.l_type != F_UNLCK; diff --git a/src/core/toolsupport.cpp b/src/core/toolsupport.cpp index afce008b..1d445cf4 100644 --- a/src/core/toolsupport.cpp +++ b/src/core/toolsupport.cpp @@ -54,13 +54,12 @@ bool QmlToolingSupport::lockTooling() { return false; } - auto lock = flock { - .l_type = F_WRLCK, - .l_whence = SEEK_SET, // NOLINT (fcntl.h??) - .l_start = 0, - .l_len = 0, - .l_pid = 0, - }; + struct flock lock = {}; + lock.l_type = F_WRLCK; + lock.l_whence = SEEK_SET; // NOLINT (fcntl.h??) + lock.l_start = 0; + lock.l_len = 0; + lock.l_pid = 0; if (fcntl(file->handle(), F_SETLK, &lock) == 0) { qCInfo(logTooling) << "Acquired tooling support lock";