haskell / time

A time library
http://hackage.haskell.org/package/time
Other
118 stars 78 forks source link

Fix wasm32-wasi build support #205

Closed TerrorJack closed 2 years ago

TerrorJack commented 2 years ago

CLOCK_REALTIME is not always a literal integer. One counter-example is wasi-libc, where it aliases an internal symbol and therefore is a pointer type. This makes it incompatible with hsc2hs #const, therefore we better use capi import here, which is guaranteed to work uniformly and fixes wasm32-wasi support.

AshleyYakeley commented 2 years ago

GHC doesn't support WebAssembly, does it? Is this a new effort for GHC, or some other Haskell compiler? I'd like to be able to test this if possible.

TerrorJack commented 2 years ago

It's a part of the work in adding WebAssembly support to GHC: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7632

There aren't instructions to build that branch yet, but the change included here can be validated on CI for normal architecture.

AshleyYakeley commented 2 years ago

Could you point me to the headers that define clockid_t and CLOCK_REALTIME in wasi-libc? I'd like to have a better idea of what's going on.

TerrorJack commented 2 years ago

Of course:

Overall, clockid_t can't be an integer literal that can be detected as hsc2hs #const, at least in the case of wasm32-wasi.

AshleyYakeley commented 2 years ago

Merged, thanks.