karlseguin / pg.zig

Native PostgreSQL driver / client for Zig
MIT License
214 stars 16 forks source link

Cross compile to 32bit - error in counter.zig - expected 32-bit integer type or smaller; found 64-bit integer type. #17

Closed zigster64 closed 4 months ago

zigster64 commented 4 months ago

Situation:

I have a small util that uses pg.zig. I dev and test this util locally on Apple M silicon / arm64 mac To deploy - I normally compile this for linux/x86 (32bit), scp the binary to the target machine, and run it there

Workaround - I just cross compile for x86_64 linux musl, and that works fine, but seems like a regression

Currently using zig 0.12-release version

Not sure if this is a Zig comptime bug with @atomicRmw() or a pg.zig bug (or a metrics bug) ?

In metrics.zig, the Counters for alloc_params, etc are defined as Counter(u64), but the alloc_params, etc functions assume its incrementing the counters by usize. For 64bit platforms, this of course works fine :)

Have played with changing metrics.zig to use u16 or u32 for those counters, but its not as simple as that ... which makes me think it might be a newish Zig comptime bug.

Not sure

--------------------------------------------s

To easily duplicate the error

Fails with the same error Im seeing