Skip to content

Skip major/minor/makedev on WASM #16

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

Merged
merged 6 commits into from
Mar 27, 2025

Conversation

SquidDev
Copy link
Contributor

@SquidDev SquidDev commented Mar 21, 2025

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
Copy link

@amesgen amesgen left a comment

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
Copy link
Member

andreasabel commented Mar 26, 2025

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
Copy link
Contributor Author

SquidDev commented Mar 26, 2025

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:

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
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
Member

@SquidDev : Is it ok to squash the commits?

@SquidDev
Copy link
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
Member

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

@SquidDev
Copy link
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
36 checks passed
@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
Member

This will be released as v0.7.4.

@andreasabel
Copy link
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