yesodweb / wai

Haskell Web Application Interface
MIT License
834 stars 263 forks source link

warp-3.4.0 failed to build with Cabal on macOS #982

Closed SpeedyOrc-C closed 6 months ago

SpeedyOrc-C commented 7 months ago

This project failed to build warp-3.4.0 as a dependency when building with Cabal.

Environment

macOS: 14.4.1 (23E224) GHC: 9.8.2 Cabal: 3.10.3.0 Kernel:

Darwin DESKTOP-CHENZHANMING-OSX.local 23.4.0
Darwin Kernel Version 23.4.0: Fri Mar 15 00:11:05 PDT 2024;
root:xnu-10063.101.17~1/RELEASE_X86_64 x86_64

Error message

Network/Wai/Handler/Warp/Settings.hs:307:20: error: [GHC-83865]
    • Couldn't match expected type: GHC.Prim.State# GHC.Prim.RealWorld
                                    -> (# GHC.Prim.State# GHC.Prim.RealWorld, a0 #)
                  with actual type: IO ()
    • In the first argument of ‘fork#’, namely ‘(io unsafeUnmask)’
      In the expression: fork# (io unsafeUnmask) s0
      In the expression:
        case fork# (io unsafeUnmask) s0 of (# s1, _tid #) -> (# s1, () #)
    |
307 |         case fork# (io unsafeUnmask) s0 of
    |                    ^^^^^^^^^^^^^^^^^
Error: cabal: Failed to build warp-3.4.0 (which is required by
exe:irminsul-api from irminsul-api-0.1.0.0). See the build log above for
details.

It seems that the condition __GLASGOW_HASKELL__ >= 904 of the #if macro wasn't working.

kazu-yamamoto commented 7 months ago

I tries to reproduce this with GHC 9.8.2 on macOS 14.4.1 on my M2 mac. But I could not reproduce this. The build successes.

SpeedyOrc-C commented 7 months ago

My Mac is Intel-based :(

kazu-yamamoto commented 7 months ago

I don't understand why intel-based mac gets the wrong macro.

gfarrell commented 7 months ago

I get the same error on GHC 9.4.8 (archlinux x86_64) but it builds fine on 9.4.7:

Network/Wai/Handler/Warp/Settings.hs:307:20: error:
    • Couldn't match expected type: GHC.Prim.State# GHC.Prim.RealWorld
                                    -> (# GHC.Prim.State# GHC.Prim.RealWorld, a0 #)
                  with actual type: IO ()
    • In the first argument of ‘fork#’, namely ‘(io unsafeUnmask)’
      In the expression: fork# (io unsafeUnmask) s0
      In the expression:
        case fork# (io unsafeUnmask) s0 of (# s1, _tid #) -> (# s1, () #)
    |
307 |         case fork# (io unsafeUnmask) s0 of
    |                    ^^^^^^^^^^^^^^^^^
Error: cabal: Failed to build warp-3.4.0 (which is required by
exe:gtf-website-server from gtf-website-0.1.0.0). See the build log above for
details.
georgefst commented 7 months ago

I'm seeing this on GHC 9.6.4, also on x86_64 Arch Linux.

kazu-yamamoto commented 7 months ago

No problem with GHC 9.6.4 on x86_64 CentOS.

georgefst commented 6 months ago

Well, I've run out of time for investigating this right now, but it's pretty bizarre. The macros seem to pick up the GHC version installed from the Arch repos rather than the GHCup-installed version (9.2 vs 9.6 in my case), despite the latter having precedence in my PATH and clearly being used (log shows Build profile: -w ghc-9.6.4 -O1). This issue isn't actually specific to warp. It occurs for any project which depends on streaming-commons...

kazu-yamamoto commented 6 months ago

Please bring this to streaming-commons. Let's close.

Iizuki commented 1 month ago

Well, I've run out of time for investigating this right now, but it's pretty bizarre. The macros seem to pick up the GHC version installed from the Arch repos rather than the GHCup-installed version (9.2 vs 9.6 in my case), despite the latter having precedence in my PATH and clearly being used (log shows Build profile: -w ghc-9.6.4 -O1). This issue isn't actually specific to warp. It occurs for any project which depends on streaming-commons...

I don't really understand what's going on here, but based on this uninstalling the system ghc solved the issue for me.

Did someone open up an issue at the correct place?

georgefst commented 1 month ago

I've got my findings half written up. Will post to Cabal in the next few days.

Basically it's interference from the system GHC. Quick fix is pacman -R ghc. EDIT: just noticed you've already mentioned this!