Skip to content

Commit 4ae3f88

Browse files
luisleo526claude
andauthored
Build on macOS: fdatasync via F_FULLFSYNC, mkdtemp via <unistd.h> (1.7.0 tag blocker) (#501)
Build on macOS: fdatasync via F_FULLFSYNC, mkdtemp via <unistd.h> main stopped compiling on macOS (Apple clang 17, macOS 26 SDK). A full keep-going build of every target the default configuration contains (both libraries, 673 tests, the tutorial strategies and the native examples; 859 translation units) found exactly two compile errors in three translation units. Both are fixed here. * src/command_scratch_production.cpp, CommandScratchFile::do_sync(): macOS has no ::fdatasync ("no member named 'fdatasync' in the global namespace"). The file is compiled into both pineforge_kernel and pineforge, so this one error failed both archives and blocked every other target. On __APPLE__ the ScratchDurability::data case now calls fcntl(fd_, F_FULLFSYNC) and falls back to ::fsync(fd_) when that fcntl fails; ScratchDurability::full still calls ::fsync(fd_) and the EINTR retry loop is unchanged. Every other platform keeps the exact existing ::fdatasync(fd_) call behind the #else, so Linux behaviour does not change. * tests/test_report_mode_v1_summary_with_observer.cpp, sink_directory(): ::mkdtemp is declared in <unistd.h> on macOS (in <stdlib.h> on glibc) and the file did not include it, so it failed with "no member named 'mkdtemp' in the global namespace". Add #include <unistd.h>. No call and no test expectation changes, and the header is harmless on Linux. Line counts: src/command_scratch_production.cpp +6 (inserted after line 331); tests/test_report_mode_v1_summary_with_observer.cpp +1 (inserted after line 19). Build on macOS: ScratchDurability::full also uses F_FULLFSYNC On macOS fsync does not reach stable storage, so the previous commit gave the stronger ScratchDurability::full mode a weaker flush than data. On __APPLE__ both modes now call fcntl(fd_, F_FULLFSYNC) and fall back to ::fsync(fd_) when it fails. The EINTR loop is unchanged; every other platform keeps the exact ::fdatasync / ::fsync line. Line counts unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent b250ceb commit 4ae3f88

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎src/command_scratch_production.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,13 @@ class CommandScratchFile final : public ScratchBacking {
329329
if (durability == ScratchDurability::buffered) return ScratchStatus::ok;
330330
int result;
331331
do {
332+
#if defined(__APPLE__)
333+
// macOS has no fdatasync and its fsync stops short of stable storage: both modes use F_FULLFSYNC, fsync if it fails.
334+
result = ::fcntl(fd_, F_FULLFSYNC) != -1
335+
? 0 : ::fsync(fd_);
336+
#else
332337
result = durability == ScratchDurability::data ? ::fdatasync(fd_) : ::fsync(fd_);
338+
#endif
333339
} while (result < 0 && errno == EINTR);
334340
return result == 0 ? ScratchStatus::ok : command_scratch_io_status(errno);
335341
}

‎tests/test_report_mode_v1_summary_with_observer.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <filesystem>
1818
#include <stdexcept>
1919
#include <string>
20+
#include <unistd.h>
2021
#include <vector>
2122

2223
namespace {

0 commit comments

Comments
 (0)