Skip to content

Skip major/minor/makedev on WASM - #16

Merged
andreasabel merged 6 commits into
haskell-pkg-janitors:mainfrom
SquidDev:wasm
Mar 27, 2025
Merged

Skip major/minor/makedev on WASM#16
andreasabel merged 6 commits into
haskell-pkg-janitors:mainfrom
SquidDev:wasm

Conversation

@SquidDev

@SquidDev SquidDev commented Mar 21, 2025

Copy link
Copy Markdown
Contributor

WebAssembly/WASI does not have makedev and friends. When targetting WASI, we skip building HsUnixCompat.c and (like with Windows) just provide dummy implementations instead.

This removes the NEED_setSymbolicLinkOwnerAndGroup macro from HsUnixCompat.h as we can no longer rely on that file existing, and so inline the definition directly into Files.hsc. I do not believe any other packages rely on this macro existing, so this should not cause any breakage.

However, if preferred, I'm happy to revert this, and instead put the definitions of unix_makedev inside a #ifndef wasm32_HOST_ARCH.

@SquidDev
SquidDev marked this pull request as draft March 21, 2025 21:50
We just skip compiling it. Yes, this is horrible, but what can you do.
Alternative solution to building. This allows us to remove the include
of HsUnixCompat.
@SquidDev
SquidDev marked this pull request as ready for review March 21, 2025 22:06

@amesgen amesgen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been using a very ad-hoc version of this patch (amesgen@50f40ea) in the past, this PR seems like a proper way to integrate it, LGTM 👍

@andreasabel

andreasabel commented Mar 26, 2025

Copy link
Copy Markdown
Member

We talked about this during the Agda dev call today (2025-03-26) @L-TChen @wenkokke

Would be nice to have a CI for WASM, maybe along the lines of: https://github.com/haskell/unix/blob/master/.github/workflows/ci-wasm32-wasi.yml

Also @SquidDev would it be possible to write a https://github.com/haskell-pkg-janitors/unix-compat/blob/main/CHANGELOG.md entry?

@SquidDev

SquidDev commented Mar 26, 2025

Copy link
Copy Markdown
Contributor Author

Would be nice to have a CI for WASM, maybe along the lines of: https://github.com/haskell/unix/blob/master/.github/workflows/ci-wasm32-wasi.yml

Yep, of course!

Running tests is a bit of a pain here, as splitmix does not support targetting WASM. There is a PR for this (haskellari/splitmix#73), but sadly it doesn't look like the maintainer is going to merge it.

If we switch to that commit, there's two tests which fail with UnsupportedOperation. Will have a look at fixing those:

Comment thread cabal.project.wasm32-wasi Outdated
We need to use a fork of splitmix here. We /should/ be able to still
point to the original repo, but Cabal doesn't run a "git fetch" to
download the ref, so you can't point to a commit not on a branch.
This is fixed in latest, but that won't be released for a while.
GHCUp doesn't appear to have GHC 9.12. While we don't strictly speaking
need it here (it would be sufficient to test with GHC 9.10), it feels
easier to just rely on the Nix flake.
@SquidDev

Copy link
Copy Markdown
Contributor Author

Sorry for the commit spam, took a while to get CI working. I did try to test locally, I swear! I think this is there now. I'm not thrilled about how the workflow looks (bit of a misuse of Nix), but a) ghcup doesn't appear to have the WASM version of GHC 9.12 and b) honestly, the Nix version is easier (probably)?) to run locally.

@andreasabel

Copy link
Copy Markdown
Member

@SquidDev : Is it ok to squash the commits?

@SquidDev

Copy link
Copy Markdown
Contributor Author

Yes! Left them separate as it felt easier to review, but happy for you to squash when merging, or for me to squash now.

@andreasabel andreasabel added the pr: squash Squash the commits in this PR label Mar 27, 2025
@andreasabel andreasabel self-assigned this Mar 27, 2025
@andreasabel

Copy link
Copy Markdown
Member

Ok, I put up the "squash" banner, let me know when this PR is ready to merge and release.

@SquidDev

Copy link
Copy Markdown
Contributor Author

I think this is good to go whenever! It's not pretty, but I think it does what it needs to do for now :).

@andreasabel
andreasabel merged commit 0fb4f1c into haskell-pkg-janitors:main Mar 27, 2025
@SquidDev
SquidDev deleted the wasm branch March 27, 2025 14:02
@andreasabel andreasabel added this to the 0.7.4 milestone Mar 27, 2025
@andreasabel

Copy link
Copy Markdown
Member

This will be released as v0.7.4.

@andreasabel

Copy link
Copy Markdown
Member

Published: https://hackage.haskell.org/package/unix-compat-0.7.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: squash Squash the commits in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants