Problem
On macOS (Homebrew llvm@19, x86_64), the vendored ThirdParty/openzgy
library fails to compile with two errors:
open-zgy/native/src/exception.cpp:60 — the #else branch assumes the
glibc signature for strerror_r (returns char*), but Apple's libc
returns int:
char *e = strerror_r(system_errno, buf, sizeof(buf)-1);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
open-zgy/native/src/impl/bulk.cpp:149 — #include <omp.h> fails
because Homebrew llvm@19 doesn't ship libomp and
ThirdParty/openzgy/CMakeLists.txt calls find_package(OpenMP) only as
optional, so no include path is added. The same unconditional include
appears in 5 more files (file_sd.cpp, mtguard.cpp, workorder.cpp,
zgycopyc.cpp, wrappermodule.cpp).
The upstream open-zgy README documents Linux and Windows as the only
supported platforms.
Proposed fix
Adopt the brute-force patch maintained by the cssr-tools/homebrew-opm
tap, vendored as ThirdParty/openzgy/patches/macos-disable-openmp.patch
and applied automatically from ThirdParty/openzgy/CMakeLists.txt when
APPLE is true. The patch:
- Replaces
#include <omp.h> with three inline omp_get_*() stubs
returning 1/0 in 6 files. Remaining #pragma omp directives become
no-ops because clang is invoked without -fopenmp on macOS.
- Rewrites the
strerror_r fallback in exception.cpp to use a plain
\"Unknown errno N\" string.
- Comments out a
BrickIterator bounds-check in edgebrick.h and the
exception-capture blocks in MTGuard::fail() / WorkOrderTP::fail();
these depend on OpenMP-driven parallel regions and are unreachable
with threading disabled.
ThirdParty/openzgy/CMakeLists.txt is updated to:
- Skip
find_package(OpenMP) on APPLE.
- Apply the patch idempotently via
git apply with
--reverse --check as the "already applied" probe; emit
FATAL_ERROR with a pointer to the patch file when the source has
drifted and the patch needs refreshing.
All edits are inside if(APPLE) guards — Linux and Windows configure
paths are byte-identical.
Trade-offs
- OpenZGY operations on macOS run single-threaded (acceptable functional
trade-off; performance regression on large ZGY ingest).
- The disabled bounds-check and
fail() blocks should be revisited if
OpenMP is ever re-enabled on macOS.
Alternative considered
SoilRos/homebrew-OPM ships a minimal patch that only fixes the
preprocessor branch in exception.cpp and relies on Homebrew libomp
being wired into the CMake invocation. Rejected in favour of the
self-contained brute-force approach so the build works without
brew install libomp.
Sources
Verification
git apply --check succeeds against the current vendored open-zgy tree
(commit ea9a1b7d8 Update to latest open-zgy).
- After applying the patch,
exception.cpp, bulk.cpp, mtguard.cpp
and workorder.cpp compile cleanly with clang++ -std=c++20 -arch x86_64 from Homebrew llvm@19 — no strerror_r or omp.h errors.
if(APPLE) guards leave Linux/Windows configure paths unchanged.
Problem
On macOS (Homebrew
llvm@19, x86_64), the vendoredThirdParty/openzgylibrary fails to compile with two errors:
open-zgy/native/src/exception.cpp:60— the#elsebranch assumes theglibc signature for
strerror_r(returnschar*), but Apple's libcreturns
int:open-zgy/native/src/impl/bulk.cpp:149—#include <omp.h>failsbecause Homebrew
llvm@19doesn't shiplibompandThirdParty/openzgy/CMakeLists.txtcallsfind_package(OpenMP)only asoptional, so no include path is added. The same unconditional include
appears in 5 more files (
file_sd.cpp,mtguard.cpp,workorder.cpp,zgycopyc.cpp,wrappermodule.cpp).The upstream open-zgy README documents Linux and Windows as the only
supported platforms.
Proposed fix
Adopt the brute-force patch maintained by the
cssr-tools/homebrew-opmtap, vendored as
ThirdParty/openzgy/patches/macos-disable-openmp.patchand applied automatically from
ThirdParty/openzgy/CMakeLists.txtwhenAPPLEis true. The patch:#include <omp.h>with three inlineomp_get_*()stubsreturning 1/0 in 6 files. Remaining
#pragma ompdirectives becomeno-ops because clang is invoked without
-fopenmpon macOS.strerror_rfallback inexception.cppto use a plain\"Unknown errno N\"string.BrickIteratorbounds-check inedgebrick.hand theexception-capture blocks in
MTGuard::fail()/WorkOrderTP::fail();these depend on OpenMP-driven parallel regions and are unreachable
with threading disabled.
ThirdParty/openzgy/CMakeLists.txtis updated to:find_package(OpenMP)onAPPLE.git applywith--reverse --checkas the "already applied" probe; emitFATAL_ERRORwith a pointer to the patch file when the source hasdrifted and the patch needs refreshing.
All edits are inside
if(APPLE)guards — Linux and Windows configurepaths are byte-identical.
Trade-offs
trade-off; performance regression on large ZGY ingest).
fail()blocks should be revisited ifOpenMP is ever re-enabled on macOS.
Alternative considered
SoilRos/homebrew-OPMships a minimal patch that only fixes thepreprocessor branch in
exception.cppand relies on Homebrewlibompbeing wired into the CMake invocation. Rejected in favour of the
self-contained brute-force approach so the build works without
brew install libomp.Sources
Verification
git apply --checksucceeds against the current vendored open-zgy tree(commit
ea9a1b7d8 Update to latest open-zgy).exception.cpp,bulk.cpp,mtguard.cppand
workorder.cppcompile cleanly withclang++ -std=c++20 -arch x86_64from Homebrewllvm@19— nostrerror_roromp.herrors.if(APPLE)guards leave Linux/Windows configure paths unchanged.