-
Notifications
You must be signed in to change notification settings - Fork 92
Fix compilation for wasm32-wasi #205
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
Conversation
@TerrorJack please target master branch instead. |
Thanks, I've retargetted the PR against |
@TerrorJack build fails with
|
Ah, thanks for pointing that out. I've fixed it and |
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.
Overall looks reasonable to me, but please add {-# WARNING #-}
similar to #178.
@TerrorJack and rebase again please. |
This looks reasonable to me, but I'm out of my depth, so it is up to @hs-viktor to review. |
I am reading this today, looks reasonable so far, will be done soon. |
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.
Overall the PR seems sound, but I have some concerns.
Perhaps "dummy" values could be returned in some cases rather than throwing an error. Errors might be deferred until these are used in some unsupported operation.
More fundamentally, I am concerned about the maintainability of this approach. As new functions are added or platforms evolve, it is not clear that we have adequate testing resources or platform knowledge of web assembly. This package is supposed to provide OS API bindings on POSIX systems, but clearly web assembly is not a POSIX platform.
Is liberally sprinkling "unix" with #ifdef
guards the best way to support this platform?
#else | ||
|
||
{-# WARNING packRTLDFlag | ||
"operation will throw 'IOError' \"unsupported operation\" (CPP guard: @#if HAVE_DLFCN_H@)" #-} | ||
packRTLDFlag _ = throw (ioeSetLocation unsupportedOperation "packRTLDFlag") | ||
|
||
#endif // HAVE_DLFCN_H |
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.
Another option is to simply return 0, presumably any meaningful operation on the returned flags will be unsupported, and fail, but I don't see a compelling reason to throw an error in this pure operation.
If there's consensus on this view, similar considerations might apply in a few other places in this PR...
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.
Only some of the functions can return dummy values. I believe the extra effort to defer the errors for a small part of unix
functions is not worth it, and adds a lot of cognitive overhead for reviewers.
@TerrorJack could you possibly give us more perspective on your Echoing Viktor's question, might it be better to have a separate library for WebAssembly platform, so that clients choose between I think that shifting |
It may be appropriate to solicit views from @bgamari and other |
Hi @hs-viktor @Bodigrim, thanks a lot for reviewing this patch and raising these questions! For a bit more context about wasm32-wasi work: we did announce in The maintainability of this approach is totally a valid concern, but not as serious as it sounds:
It also makes sense to ask, why not a |
That would be extremely useful. |
Cf. https://gitlab.haskell.org/ghc/ghc/-/issues/21426
I appreciate this, but it does not sound right to me. We might be making changes at the very last moment before release, and breaking one of deliverables would be most disappointing. @TerrorJack could you please create a CI job for wasm32-wasi build? Ideally on GHA infrastructure, feel free to smuggle a GHC bindist for wasm32-wasi branch from elsewhere. |
@Bodigrim Sure! Thanks for the kind words, I'm starting to work on the CI part. Side note: there's a legacy ad hoc check that sets |
@TerrorJack please raise a separate PR. |
Hi all, sorry for the delay; this PR now includes a new CI job dedicated to wasm32-wasi build, which uses a bindist tarball from ghc gitlab. You're welcome to take a look and ask questions :) |
@TerrorJack there are plenty of build warning at https://github.com/haskell/unix/runs/6358300515?check_suite_focus=true#step:7:287, could you please clean them up? Disabling |
@Bodigrim The wasm32-wasi job compilation warnings have all been cleaned up. The only warning option that I needed to turn off globally was |
Where are we with this PR? I'm done with the technical review, but I still don't know whether we've resolved the maintenance burden issue. P.S. I'm adding another test in #216 that expects |
As discussed above, there is no expectation for |
Please rebase, there are new conflicts with |
Note also that the new test may not be compatible with wasm. |
Thanks a lot for all the reviews; the PR has been rebased on recent BaudRate changes. |
Is there further action required to advance the state of this PR? |
Thanks @TerrorJack! |
This patch fixes compilation for wasm32-wasi. Much of the added CPP guards are not wasm-specific though, they merely check for headers and functions that exists on typical posix platforms, but not on wasm32-wasi.