Skip to content

wasi32 cross target GHC failure #2435

@dhess

Description

@dhess

Hi! Immense thanks for making the wasi32 cross-target available in haskell.nix!

We've been building our application using the ghc-meta-wasm flake for about a year, and are now trying to get a working build with the haskell.nix wasi32 target, but we're encountering what looks like an internal GHC bug when compiling generics-sop:

Running phase: unpackPhase
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking source archive /nix/store/2smbbljgf6max5nk6zvjml826dmmbf5p-generics-sop-0.5.1.4.tar.gz
source root is generics-sop-0.5.1.4
setting SOURCE_DATE_EPOCH to timestamp 1000000000 of file "generics-sop-0.5.1.4/test/HTransExample.hs"
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "patchPhase" }
'/tmp/nix-build-generics-sop-lib-generics-sop-static-wasm32-unknown-wasi-0.5.1.4.drv-0/.attr-0h9ydb7s8pfhl5kfs3rmmwnmpi49yyiw7jgr5dpw9rmvv8sy0f2b' -> 'generics-sop.cabal'
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: configurePhase
@nix { "action": "setPhase", "phase": "configurePhase" }
Configure flags:
--prefix=/nix/store/95sha6bw7h8h7lczgvdrmh678s4x44dv-generics-sop-lib-generics-sop-static-wasm32-unknown-wasi-0.5.1.4 --ghc-option=-fwrite-ide-info --ghc-option=-hiedir/nix/store/6b2kszwfqywz55n9ncz0j358gg7yjn9m-generics-sop-lib-generics-sop-static-wasm32-unknown-wasi-0.5.1.4-hie lib:generics-sop --package-db=clear --package-db=/tmp/nix-build-generics-sop-lib-generics-sop-static-wasm32-unknown-wasi-0.5.1.4.drv-0/tmp.CFCdoAk>
Configuring library for generics-sop-0.5.1.4...
Running phase: buildPhase
@nix { "action": "setPhase", "phase": "buildPhase" }
Preprocessing library for generics-sop-0.5.1.4...
Building library for generics-sop-0.5.1.4...
[ 1 of 14] Compiling Generics.SOP.BasicFunctors ( src/Generics/SOP/BasicFunctors.hs, dist/build/Generics/SOP/BasicFunctors.o, dist/build/Generics/SOP/BasicFunctors.dyn_o )
[ 2 of 14] Compiling Generics.SOP.Classes ( src/Generics/SOP/Classes.hs, dist/build/Generics/SOP/Classes.o, dist/build/Generics/SOP/Classes.dyn_o )
[ 3 of 14] Compiling Generics.SOP.Constraint ( src/Generics/SOP/Constraint.hs, dist/build/Generics/SOP/Constraint.o, dist/build/Generics/SOP/Constraint.dyn_o )
[ 4 of 14] Compiling Generics.SOP.Dict ( src/Generics/SOP/Dict.hs, dist/build/Generics/SOP/Dict.o, dist/build/Generics/SOP/Dict.dyn_o )
[ 5 of 14] Compiling Generics.SOP.NP  ( src/Generics/SOP/NP.hs, dist/build/Generics/SOP/NP.o, dist/build/Generics/SOP/NP.dyn_o )
[ 6 of 14] Compiling Generics.SOP.Metadata ( src/Generics/SOP/Metadata.hs, dist/build/Generics/SOP/Metadata.o, dist/build/Generics/SOP/Metadata.dyn_o )
[ 7 of 14] Compiling Generics.SOP.NS  ( src/Generics/SOP/NS.hs, dist/build/Generics/SOP/NS.o, dist/build/Generics/SOP/NS.dyn_o )
[ 8 of 14] Compiling Generics.SOP.Sing ( src/Generics/SOP/Sing.hs, dist/build/Generics/SOP/Sing.o, dist/build/Generics/SOP/Sing.dyn_o )
[ 9 of 14] Compiling Generics.SOP.Type.Metadata ( src/Generics/SOP/Type/Metadata.hs, dist/build/Generics/SOP/Type/Metadata.o, dist/build/Generics/SOP/Type/Metadata.dyn_o )
[10 of 14] Compiling Generics.SOP.GGP ( src/Generics/SOP/GGP.hs, dist/build/Generics/SOP/GGP.o, dist/build/Generics/SOP/GGP.dyn_o )
[11 of 14] Compiling Generics.SOP.Universe ( src/Generics/SOP/Universe.hs, dist/build/Generics/SOP/Universe.o, dist/build/Generics/SOP/Universe.dyn_o )
[12 of 14] Compiling Generics.SOP.TH  ( src/Generics/SOP/TH.hs, dist/build/Generics/SOP/TH.o, dist/build/Generics/SOP/TH.dyn_o )
src/Generics/SOP/TH.hs:15:1: warning: [GHC-66111] [-Wunused-imports]
    The import of ‘Data.List’ is redundant
      except perhaps to import instances from ‘Data.List’
    To import instances alone, use: import Data.List()
   |
15 | import Data.List (foldl')
   | ^^^^^^^^^^^^^^^^^^^^^^^^^

src/Generics/SOP/TH.hs:23:1: warning: [GHC-66111] [-Wunused-imports]
    The import of ‘Language.Haskell.TH.Datatype.TyVarBndr’ is redundant
      except perhaps to import instances from ‘Language.Haskell.TH.Datatype.TyVarBndr’
    To import instances alone, use: import Language.Haskell.TH.Datatype.TyVarBndr()
   |
23 | import Language.Haskell.TH.Datatype.TyVarBndr
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Generics/SOP/TH.hs:319:34: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Prelude, but defined in GHC.Internal.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching, 'Data.List.uncons' or 'Data.Maybe.listToMaybe' instead. Consider refactoring to use "Data.List.NonEmpty"."
    |
319 |                         $(mdCon (head cs))
    |                                  ^^^^

src/Generics/SOP/TH.hs:393:38: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Prelude, but defined in GHC.Internal.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching, 'Data.List.uncons' or 'Data.Maybe.listToMaybe' instead. Consider refactoring to use "Data.List.NonEmpty"."
    |
393 |                             $(mdCon (head cs))
    |                                      ^^^^

[13 of 14] Compiling Generics.SOP.Instances ( src/Generics/SOP/Instances.hs, dist/build/Generics/SOP/Instances.o, dist/build/Generics/SOP/Instances.dyn_o )
<no location info>: error:
    compiler/GHC/Runtime/Interpreter/Wasm.hs:(36,7)-(39,38): Non-exhaustive patterns in Just ghci_unit_id

This error does not occur with the ghc-meta-wasm version of GHC 9.12.2 (specifically, 9.12.2.20250828 from the ghc-meta-wasm flake).

Build details:

  • Build system (eg. x86_64-linux or aarch64-darwin): both x86_64-linux and aarch64-darwin
  • GHC version: ghc9122
  • Haskell.nix version (or commit) used: f104621

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions