composewell / unicode-transforms

Fast Unicode normalization in Haskell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

build failure "couldn't match expected type GHC.Prim.Word##..."

simonmichael opened this issue · comments

Building unicode-transforms 0.3.7 with ghc 8.8.4:

$ stack build unicode-transforms
unicode-transforms> configure
unicode-transforms> Configuring unicode-transforms-0.3.7...
unicode-transforms> build
unicode-transforms> Preprocessing library for unicode-transforms-0.3.7..
unicode-transforms> Building library for unicode-transforms-0.3.7..
unicode-transforms> [ 1 of 15] Compiling Data.Unicode.Internal.Bits
unicode-transforms>
unicode-transforms> /tmp/stack-9a08d602/unicode-transforms-0.3.7/Data/Unicode/Internal/Bits.hs:30:37: error:
unicode-transforms>     • Couldn't match expected type ‘GHC.Prim.Word#’
unicode-transforms>                   with actual type ‘GHC.Prim.Word64#’
unicode-transforms>     • In the first argument of ‘and#’, namely ‘word##’
unicode-transforms>       In the first argument of ‘W#’, namely ‘(word## `and#` bitMask##)’
unicode-transforms>       In the first argument of ‘(/=)’, namely
unicode-transforms>         ‘W# (word## `and#` bitMask##)’
unicode-transforms>    |
unicode-transforms> 30 | lookupBit64 addr# (I# index#) = W# (word## `and#` bitMask##) /= 0
unicode-transforms>    |                                     ^^^^^^
unicode-transforms>

--  While building package unicode-transforms-0.3.7 using:
      /home/simon/.stack/setup-exe-cache/i386-linux/Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.4 --builddir=.stack-work/dist/i386-linux/Cabal-3.0.1.0 build --ghc-options " -fdiagnostics$
    Process exited with code: ExitFailure 1

We do have a GHC-8.8 CI in place, and it is passing. I tried cabal build unicode-transforms as well as stack build unicode-transforms manually using ghc-8.8.4 and both succeeded. I am wondering what could be wrong. Can you do a bit more investigation if there is some issue in your setup? Which version of ghc-prim is being picked up? Maybe we need to fix the bounds?

Anyway ghc-prim is dictated by the ghc version. so that should not be an issue.

Are you compiling on a 32-bit machine?

@simonmichael can you try PR #54 and see if that fixes your build?

As discussed in #54 the bug manifests on 32 bit platforms. I ran into it on i386-openbsd.

@harendra-kumar #54 seems not to help, however I remember this is a weird 32-bit VPS that was upgraded to 64-bit software over time, I believe it is still 32 bit "hardware" so this may be confusing the issue:

$ git checkout word64
Branch 'word64' set up to track remote branch 'word64' from 'origin'.
Switched to a new branch 'word64'
$ git l
2020-09-04 0a03754 Use Word64 type instead of Word (HEAD -> word64, origin/word64, master)
2020-08-17 19aec48 Use cabal build for ghc-7.10.3 (tag: v0.3.7, origin/metadata, origin/master, origin/HEAD)
...
$ stack build
unicode-transforms> configure (lib)
Configuring unicode-transforms-0.3.7...
unicode-transforms> build (lib)
Preprocessing library for unicode-transforms-0.3.7..
Building library for unicode-transforms-0.3.7..
[ 1 of 15] Compiling Data.Unicode.Internal.Bits

/home/simon/src/hledger/unicode-transforms/Data/Unicode/Internal/Bits.hs:31:39: error:
    • Couldn't match expected type ‘GHC.Prim.Word#’
                  with actual type ‘GHC.Prim.Word64#’
    • In the first argument of ‘and#’, namely ‘word##’
      In the first argument of ‘W64#’, namely ‘(word## `and#` bitMask##)’
      In the first argument of ‘(/=)’, namely
        ‘W64# (word## `and#` bitMask##)’
   |
31 | lookupBit64 addr# (I# index#) = W64# (word## `and#` bitMask##) /= 0
   |                                       ^^^^^^

/home/simon/src/hledger/unicode-transforms/Data/Unicode/Internal/Bits.hs:31:39: error:
    • Couldn't match expected type ‘GHC.Prim.Word64#’
                  with actual type ‘GHC.Prim.Word#’
    • In the first argument of ‘W64#’, namely
        ‘(word## `and#` bitMask##)’
      In the first argument of ‘(/=)’, namely
        ‘W64# (word## `and#` bitMask##)’
      In the expression: W64# (word## `and#` bitMask##) /= 0
   |
31 | lookupBit64 addr# (I# index#) = W64# (word## `and#` bitMask##) /= 0
   |                                       ^^^^^^^^^^^^^^^^^^^^^^^


--  While building package unicode-transforms-0.3.7 using:
      /home/simon/.stack/setup-exe-cache/i386-linux/Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.3 --builddir=.stack-work/dist/i386-linux/Cabal-3.0.1.0 build lib:unicode-transforms --ghc-$
    Process exited with code: ExitFailure 1
$ arch -a
Linux somehost.com 5.1.17-x86_64-linode128 #1 SMP PREEMPT Wed Jul 10 17:11:49 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
$ file `/usr/bin/which stack`
/home/simon/.local/bin/stack: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib, for GNU/Linux 3.2.0, BuildID[sha1]=a27e394924ed6aa26a7$

I confirm that #55 fixes the build on this machine.

I released #55 as unicode-transforms-0.3.7.1. Does it work for you, @simonmichael?

Test suite passes! I only get the warning

Data/Unicode/Internal/Division.hs:58:26: warning: [-Woverflowed-literals]
    Literal 14054662151397753613 is out of the Word range 0..4294967295
   |
58 |         high = highMul w 14054662151397753613 -- (2^68+17)/21
   |                          ^^^^^^^^^^^^^^^^^^^^

Data/Unicode/Internal/Division.hs:76:26: warning: [-Woverflowed-literals]
    Literal 5270498306774157605 is out of the Word range 0..4294967295
   |
76 |         high = highMul w 5270498306774157605 -- (2^65+3)/7
   |                          ^^^^^^^^^^^^^^^^^^^

This warning is alright, the code path is disabled on x32 arch anyways.

Fixed by #55