-
-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support extensions on i686-unknown-linux-gnu #1014
Support extensions on i686-unknown-linux-gnu #1014
Conversation
3c511db
to
c33cd5a
Compare
Do tests pass? We definitely want @workingjubilee to review this and think about it. I'm concerned about future maintainability. I feel like we probably have other hidden assumptions in the code that the compiler won't pickup. Where did the desire for 32bit support come from? |
@eeeebbbbrrrr I'm trying to run a pgx extension on v86, an in-browser virtualized CPU (mostly for demonstration purposes). I just ran the tests on a 32-bit Docker image and most of them passed, but the datetime tests failed, probably because there's an assumption that It might be possible to an i386 Docker image to the will-it-blend nightly tests. |
At the end of the day I think'll merge this. I don't really see any reason not to. I just have some concern right now that if we say "pgx also runs in 32bit!" and we missed a few things that'd be embarrassing. Also, because I just don't know any better, is there a better type than |
Like, is |
I used So for all platforms pgx supports, |
Also: I've done some more experimenting, and while you can get pgx extensions to compile and run with this, they are very prone to crashing and producing incorrect results. It's only really useful for further improving pgx's 32-bit support right now. |
That's kinda why I asked what prompted this. How invested are you (y'all) in the idea of pgx supporting 32bit? We're not opposed to it, by any means, but I don't see us doing much heavy lifting ourselves. We'll definitely help out where we can and merge and add things to CI and whatever. |
I'm just doing some experimenting at this point - I'm not super invested in 32-bit support at this point. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also review the implementations in pgx-pg-sys/src/submodules/datum.rs
for 32-bit correctness. I'm not too concerned if some of the conversions are actually secretly lossy so much as they should be checked for correctness due to sign-extension or zero-extension and then truncation that may happen differently.
let secs_per_day: libc::time_t = | ||
pg_sys::SECS_PER_DAY.try_into().expect("couldn't fit time into time_t"); | ||
libc::time_t::from(self.to_unix_epoch_days()) * secs_per_day |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, whether a system uses a 32-bit or 64-bit value for time_t
is actually only incidentally historically related. Sometimes a 32-bit system will use a 64-bit time_t
. Sometimes a 64-bit system will use a 32-bit time_t
. Sometimes time_t
is an unsigned integer. Sometimes it is a signed integer.
I don't think this actually affects this code's current correctness, it just felt worthy of note.
We may pick up some side benefits like supporting virtual Sometime in the next 20 years, if Postgres and |
I added a test to Trying to stick a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If your experiments with this bear more fruit (i.e. we get past "extensions mostly just crash on 32-bit") and we get some interesting results with them, or something like a wasm32-wasi
Postgres or whatever, we might consider something like that, but I don't think that's something we currently want to do right now. It's just way too convenient to be able to shove u64
into a pg_sys::Datum
since that's usually legal, and for many integers, it's not the end of the world if it truncates.
This PR looks good as-is, and since Eric also approves, I'm gonna merge this.
* Support pgx extensions on i386 processors * Add test for roundtripping datum
Support extensions on i686-unknown-linux-gnu (#1014)
pgx assumes it's running on a 64-bit processor in a few places:
long
andtime_t
are always ani64
double
s always have a different alignment thanint
sThis PR fixes pgx to work on 32-bit systems. I've verified that pgx successfully compiles on
i686-unknown-linux-gnu
with this.