(see also Startup issue on recent macOS on M3 · Issue #29 · felipenoris/Oracle.jl · GitHub)
We’d like to use Oracle.jl for a project and the initial port went fine, until someone wanted to run things on their macbook. There the Oracle driver bails out because a structure does not match its C-side equivalent.
In a nutshell, Oracle.jl defines C functions that essentially return sizeof
of each relevant struct, and on loading the library, it will start by verifying that these functions return the same as Julia-side sizeof
on the equivalent structs. Works swell on x64.
On M-series macs, however, these definitions give an issue:
# 40 bytes -> sizeof dpiDataBuffer on 64bit arch
primitive type OraDataBuffer 40 * 8 end
struct OraData
is_null::Int32 # Specifies if the value refers to a null value (1) or not (0).
value::OraDataBuffer
end
the equivalent C structure in the Oracle library that Oracle.jl uses has a C definition that is equivalent:
// structure used for transferring data to/from ODPI-C
struct dpiData {
int isNull;
dpiDataBuffer value;
};
but where dpiDataBuffer
is a union of a whole list of things.
In any case, both on x64 and aarch64, the size of this C struct is 48 bytes - 4 bytes for the isNull
, alignment bytes, then 40 bytes for the dpiDataBuffer
. So while the primitive type
definition above is a bit of a hack/shortcut, the 40 bytes looks correct here.
On x64, sizeof(OraDataBuffer)
returns the same value, 48. On macOS, however, it gets - apparently - rounded up to 64 bytes. I have no clue why, the closest I’ve come to grokking this is the definition for MAX_ALIGN in julia_internals.h which sets 4 bytes on Intel, 16 bytes on Apple M series, and that matches what I seem to be observing somewhat.
Anyway, sorry for all the context, my question is: how can I convince Julia that this struct is, in fact, just 48 bytes? Or is the only solution that I need to somehow figure out how to make the struct larger/“more aligned” C-side? That might be doable using a vendored version of the Oracle library, but… well, needless to say, not really a preferred direction
(the version of macOS I tested on has clang 16 and I used multiple recent versions of Julia 1.11 to exclude our choice of using a Nix-managed version of Julia)