Skip to content

WinIO work#612

Open
thomasjm wants to merge 7 commits intohaskell:masterfrom
thomasjm:win-io-squashed
Open

WinIO work#612
thomasjm wants to merge 7 commits intohaskell:masterfrom
thomasjm:win-io-squashed

Conversation

@thomasjm
Copy link
Copy Markdown
Contributor

@thomasjm thomasjm commented Apr 6, 2026

This contains all the work we've been doing in #602.

CC @kazu-yamamoto

@Mistuke
Copy link
Copy Markdown
Collaborator

Mistuke commented Apr 7, 2026

Right, had a quick look and so far looks good. I'll have a deeper review thursday morning.

I do like this approach because it also fixes the type error on the POSIX path on Windows that's been long standing.

@Mistuke
Copy link
Copy Markdown
Collaborator

Mistuke commented Apr 12, 2026

This looks really good! I have some nits and the build errors need to be fixed.

Copy link
Copy Markdown
Collaborator

@Mistuke Mistuke left a comment

Choose a reason for hiding this comment

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

Oops forgot to publish the review comments

Comment thread Network/Socket/Buffer.hsc Outdated
Comment thread Network/Socket/Buffer.hsc Outdated
Comment thread Network/Socket/Buffer.hsc Outdated
Comment thread Network/Socket/Syscall.hs Outdated
Comment thread Network/Socket/Handle.hs Outdated
Comment thread Network/Socket/Fcntl.hs
-- Since 2.7.0.0.
getNonBlock :: CInt -> IO Bool
getNonBlock :: CSocket -> IO Bool
#if defined(mingw32_HOST_OS)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

think this can be dropped.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You mean remove the #if defined(mingw32_HOST_OS) ?

I don't think we can, since there are separate code paths here for Windows with WinIO, Windows without WinIO, and non-Windows. The first two are different because we always conditionally import <!> gated on HAS_WINIO. But maybe I'm misunderstanding you?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hmm I see. I asked because this macro is being defined in the cabal file just based on windows. If the macro is intended to check if the compiler supports WINIO then GHC already sets __IO_MANAGER_WINIO__ so perhaps that's better to use rather than a custom macro?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Other than that the rest look good

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, do you want to get rid of HAS_WINIO throughout and replace with __IO_MANAGER_WINIO__? That sounds like a good idea.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah, that's the recommended macro, because it let's the compiler stay in control!

We might be able to leverage this macro to tell which compilers have a "fixed" winio for network, if we eg make the macro a version. So like with your ghc patch (I gave some comments btw) we can change the macro to be, say version 2 and check for that instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

All right, I made this change in the latest commit and also pushed a corresponding change to https://gitlab.haskell.org/ghc/ghc/-/merge_requests/15887, what do you think?

@thomasjm thomasjm requested a review from Mistuke April 24, 2026 23:43
@Mistuke
Copy link
Copy Markdown
Collaborator

Mistuke commented Apr 26, 2026

Thanks! This looks good. The hangs are due to patched compiler right? Let me accept this and do the upstream one too.

@thomasjm
Copy link
Copy Markdown
Contributor Author

I had a question on the upstream one about your comment btw @Mistuke.

@kazu-yamamoto
Copy link
Copy Markdown
Collaborator

@Mistuke May I merge this PR?

@Mistuke
Copy link
Copy Markdown
Collaborator

Mistuke commented Apr 27, 2026

I had a question on the upstream one about your comment btw @Mistuke.

Yeah, I saw. I'll answer it there (once I wake up fully) but let's leave it and make the change to backport as small as possible.

@Mistuke
Copy link
Copy Markdown
Collaborator

Mistuke commented Apr 27, 2026

@Mistuke May I merge this PR?

Not yet, I think the CI is hanging because the cabal file turns on winio but the code disables it until it knows it's using a fixed version with __IO_MANAGER_WINIO__ >= 2 so I was gonna see first if we can do a cpp check in a cabal file..

But if you want to merge it I'd turn it off in the cabal file for now.

@kazu-yamamoto
Copy link
Copy Markdown
Collaborator

I will merge this PR because another PR, which would conflict with this PR, is waiting.
So, please send necessary PRs after that.

kazu-yamamoto added a commit to kazu-yamamoto/network that referenced this pull request Apr 27, 2026
@kazu-yamamoto
Copy link
Copy Markdown
Collaborator

Two PRs have been merged.
Please update your master branch by git pull and continue your work.

@thomasjm
Copy link
Copy Markdown
Contributor Author

Hi @Mistuke, just wanted to ping you here just in case. I left another comment on the GHC MR, about an unexpected failure caused by rethrowing the exceptions like we did. Somehow it breaks cross-compiling TH code that performs IO.

That MR won't be ready to ship until we figure this out, so I'd greatly appreciate any advice.

@Mistuke
Copy link
Copy Markdown
Collaborator

Mistuke commented Apr 30, 2026 via email

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants