kubkon opened PR #1269 from wasi-common-armv7 to master:
This commit enables
target_pointer_width = 32compatibility forwasi-common(and by transitivity, any crate found inside, e.g.,yanix). I've also added a simplistic (bare minimum) check to our CI to ensure thatwasi-commoncross-compiles toarmv7-unknown-gnueabihffine. While here, I've done the same forwasm32-unknown-emscripten.To avoid code duplication, I've added a custom ext trait
FileTimeExtwhich implements seconds and nanoseconds accessors for with different impls for different pointer widths. I'm not sure whether that's the cleanest approach but definitely seemed like it at the time. Lemme know what you reckon!Fixes #1219
cc @stefson hopefully this fixes it for you :-)
kubkon requested alexcrichton, and sunfishcode for a review on PR #1269.
kubkon requested alexcrichton, and sunfishcode for a review on PR #1269.
sunfishcode submitted PR Review.
sunfishcode submitted PR Review.
sunfishcode created PR Review Comment:
Actually, seeing this written out reminds me that some 32-bit targets are transitioning to a 64-bit
time_tand making theirtv_secatime_tto fix the 2038 bug. So what we could do instead here would be to change theResult<i32>here to aResult<libc::time_t>, and that should work for both 32-bit and 64-bit targets. It can still usetry_into, but it should get optimized away in the case wheretime_tis 64-bit.
sunfishcode created PR Review Comment:
We should use
libc::c_longhere. Or even better, can we uselibc::UTIME_NOWandlibc::UTIME_OMITinstead of defining our own copies?
sunfishcode created PR Review Comment:
For nanoseconds, the
filetimelibrary documents that the nanoseconds value is always less than 1 billion, so any value it returns should be convertible toi32, so we can just.try_into().unwrap().
kubkon submitted PR Review.
kubkon created PR Review Comment:
That's a good point actually. As far as I can remember, the main reason why we'd define them ourselves was to support older
libccrates where those constants were incorrectly defined for some targets (netbsd and macos are the awkward ones among others). Given that they are now fixed inlibc, I'm happy to reuse their definitions instead :+1:
kubkon submitted PR Review.
kubkon created PR Review Comment:
Good catch, thanks!
kubkon submitted PR Review.
kubkon created PR Review Comment:
Excellent!
kubkon updated PR #1269 from wasi-common-armv7 to master:
This commit enables
target_pointer_width = 32compatibility forwasi-common(and by transitivity, any crate found inside, e.g.,yanix). I've also added a simplistic (bare minimum) check to our CI to ensure thatwasi-commoncross-compiles toarmv7-unknown-gnueabihffine. While here, I've done the same forwasm32-unknown-emscripten.To avoid code duplication, I've added a custom ext trait
FileTimeExtwhich implements seconds and nanoseconds accessors for with different impls for different pointer widths. I'm not sure whether that's the cleanest approach but definitely seemed like it at the time. Lemme know what you reckon!Fixes #1219
cc @stefson hopefully this fixes it for you :-)
kubkon requested alexcrichton, and sunfishcode for a review on PR #1269.
alexcrichton submitted PR Review.
alexcrichton submitted PR Review.
alexcrichton created PR Review Comment:
Could we avoid having this
#[cfg]? It seems like it'd be best to just always have thetry_into().unwrap(), and that I think means we could also remove the_checkedfrom the name, right?
alexcrichton created PR Review Comment:
Is the
#[cfg]here necessary?I'd love to have as few
#[cfg]as necessary and it seems like we'd want this logic on all platforms?
alexcrichton created PR Review Comment:
Since this likely executes pretty quickly I don't think we necessarily need to have two whole builders for this, could these be collapsed perhaps into a single "check all the targets" builder?
kubkon submitted PR Review.
kubkon created PR Review Comment:
Agreed! You beat me to it actually! I was just reworking this bit as it seems silly to have
unwrapwrapped inResult:-D
kubkon submitted PR Review.
kubkon created PR Review Comment:
Agreed about
#[cfg]s.Hmm, do you reckon we could collapse both
from_rawversions into one withtry_into?
sunfishcode submitted PR Review.
sunfishcode submitted PR Review.
sunfishcode created PR Review Comment:
We can take this even further:
tv_nsecis always alibc::c_long, so we can return that for both 32-bit and 64-bit platforms and avoid thetarget_pointer_widthchecks, and since the check always succeeds, we can just return the value instead of aResult.
sunfishcode created PR Review Comment:
And now that I think about it, we can do a similar thing here -- just have one version for both 32-bit and 64-bit platforms, which returns a
Result<libc::c_long>, and we can rely on the compiler to optimize away themap_errin the case wherec_longis 64-bit.
alexcrichton created PR Review Comment:
Ah yeah @sunfishcode put it well here
alexcrichton submitted PR Review.
kubkon updated PR #1269 from wasi-common-armv7 to master:
This commit enables
target_pointer_width = 32compatibility forwasi-common(and by transitivity, any crate found inside, e.g.,yanix). I've also added a simplistic (bare minimum) check to our CI to ensure thatwasi-commoncross-compiles toarmv7-unknown-gnueabihffine. While here, I've done the same forwasm32-unknown-emscripten.To avoid code duplication, I've added a custom ext trait
FileTimeExtwhich implements seconds and nanoseconds accessors for with different impls for different pointer widths. I'm not sure whether that's the cleanest approach but definitely seemed like it at the time. Lemme know what you reckon!Fixes #1219
cc @stefson hopefully this fixes it for you :-)
kubkon updated PR #1269 from wasi-common-armv7 to master:
This commit enables
target_pointer_width = 32compatibility forwasi-common(and by transitivity, any crate found inside, e.g.,yanix). I've also added a simplistic (bare minimum) check to our CI to ensure thatwasi-commoncross-compiles toarmv7-unknown-gnueabihffine. While here, I've done the same forwasm32-unknown-emscripten.To avoid code duplication, I've added a custom ext trait
FileTimeExtwhich implements seconds and nanoseconds accessors for with different impls for different pointer widths. I'm not sure whether that's the cleanest approach but definitely seemed like it at the time. Lemme know what you reckon!Fixes #1219
cc @stefson hopefully this fixes it for you :-)
kubkon requested alexcrichton for a review on PR #1269.
kubkon requested alexcrichton, and sunfishcode for a review on PR #1269.
alexcrichton submitted PR Review.
kubkon merged PR #1269.
Last updated: Dec 06 2025 at 06:05 UTC