haskell / unix

POSIX functionality
https://hackage.haskell.org/package/unix
Other
107 stars 92 forks source link

JS: add support for utimes/lutimes/futimes #285

Closed hsyl20 closed 1 year ago

hsyl20 commented 1 year ago

In particular, add support for touchFd required here: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9237

Cc @bgamari

hasufell commented 1 year ago

How can we test this in CI?

hsyl20 commented 1 year ago

You need to build GHC with the JS backend enabled. Apparently CI is using ghcup so it would be good to fix https://github.com/haskell/ghcup-hs/issues/838 first

Bodigrim commented 1 year ago

@hsyl20 it's fine to add a custom CI job, which manually grabs GHC JS from elsewhere, without ghcup, if it's easier. But I'm reluctant to merge without one.

hsyl20 commented 1 year ago

it's fine to add a custom CI job, which manually grabs GHC JS from elsewhere, without ghcup, if it's easier. But I'm reluctant to merge without one.

We're in the process of fixing GHCup to build cross-compilers. Moritz, however, suggested that we use the haskell.nix infrastructure to avoid the build times. I'll try this.

hasufell commented 1 year ago

Moritz, however, suggested that we use the haskell.nix infrastructure to avoid the build times. I'll try this.

I personally don't want to maintain nix code in CI.

GHCup should be fixed to be able to install cross toolchain from bindist as well.

hsyl20 commented 1 year ago

I personally don't want to maintain nix code in CI.

Nix would only be used to provide the environment with the appropriate ghc (nix shell some_url). Does that count as nix code? :)

GHCup should be fixed to be able to install cross toolchain from bindist as well.

Sadly upstream doesn't provide JS bindists. Does ghcup already provide custom bindists (and where are they hosted)?

hasufell commented 1 year ago

Nix would only be used to provide the environment with the appropriate ghc (nix shell some_url). Does that count as nix code? :)

Yes, my experience with nix has been rather negative and I want to avoid pinging other people whenever there's a problem with it (and IME, there are a lot).

Sadly upstream doesn't provide JS bindists.

We can just build our own.

bgamari commented 1 year ago

I have incorporated this change into ghc!9237 which passed CI.

Bodigrim commented 1 year ago

@bgamari the reason we insist on GitHub CI job is so that the feature does not get accidentally broken in the very next commit. We cannot really tell all future contributors "go bump a submodule in GHC source tree and check that it works, then report back".

hasufell commented 1 year ago

ghcup is very close to being able to install ghc JS cross from bindist. I already built one: https://downloads.haskell.org/~ghcup/unofficial-bindists/ghc/javascript-unknown-ghcjs-9.6.2/

It'll require another ghcup release first. Then we'll maintain a separate ghcup metadata for JS.

hsyl20 commented 1 year ago

I've opened https://github.com/haskell/unix/pull/290 to make the testsuite runnable with GHC head+!10900 built with the JS backend. I just have to rebase and to add a test for this PR.

CI will be more difficult because we need to use GHC 9.8 at least. But releasing 9.8 might be blocked on this...

hasufell commented 1 year ago

Can't we just build a bindist from the current 9.8 branch?

I already have ghcup CI that tests ghcup compile ghc against JS cross: https://github.com/haskell/ghcup-hs/actions/runs/5593656559

I don't think CI is prerequisite to get this merged, but it needs to remain a TODO list, so that we don't regress.

hsyl20 commented 1 year ago

Can't we just build a bindist from the current 9.8 branch?

After https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10900 is backported, we can.

I don't think CI is prerequisite to get this merged, but it needs to remain a TODO list, so that we don't regress.

I've opened https://github.com/haskell/unix/issues/291 to track this.

hsyl20 commented 1 year ago

I'm working on a test for this PR but I need https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10909 to fix createFile and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10912 to fix getFileStatus...

Bodigrim commented 1 year ago

@hsyl20 could you please rebase? How can I test this patch manually?

hsyl20 commented 1 year ago

@Bodigrim I'm on vacation this week but next week sure. I have a wip test but it isn't complete yet. There is also a test for touchFd in the ghc MR.

hsyl20 commented 1 year ago

I've rebased. Test is stil wip and depends on (at least) https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10909 (currently being merged).