HEAD: HSinteger-gmp-0.2.0.2.o: unknown symbol `base_ControlziExceptionziBase_patError_info'

Edward Z. Yang ezyang at MIT.EDU
Sat Dec 4 02:40:44 CET 2010


I did some digging on this issue, and it seems that the culprits
are andInteger, orInteger and xorInteger, each of which generate a C--
stanza that looks something like

    sMK_ret()
            { has static closure: False update_frame: <none>
              type: 0
              desc: 0
              tag: 32
              stack: [Nothing, Nothing]
              srt: (GHCziInteger_andInteger_srt,0,1)
            }
        c1IZ:
            I32[Sp + 8] = c1IX_str;
            Sp = Sp + 8;
            jump base_ControlziExceptionziBase_patError_info ();
    }

Which is dead code and would be optimized out.  This is a bit fiddly,
because the pattern matching /is/ complete and -Wall won't complain
about it, but we generate patErrors in our core anyway...

GHC.Integer.andInteger =
  \ (ds_dqi :: GHC.Integer.Type.Integer)
    (ds1_dqj :: GHC.Integer.Type.Integer) ->
    let {
      fail_dql
        :: GHC.Prim.State# GHC.Prim.RealWorld -> GHC.Integer.Type.Integer
      [LclId, Arity=1]
      fail_dql =
        \ _ ->
          Control.Exception.Base.patError
            @ GHC.Integer.Type.Integer
            "GHC/Integer.lhs:(499,1)-(504,27)|function GHC.Integer.andInteger" } in
    case ds_dqi of wild_X1g {
      GHC.Integer.Type.S# x_al0 -> [snip]
      GHC.Integer.Type.J# ipv_ssW ipv1_ssX ->
        case ds1_dqj of wild1_X1l {
          GHC.Integer.Type.S# ds2_dqk -> [snip]
          GHC.Integer.Type.J# ipv2_st0 ipv3_st1 ->
            case wild_X1g of _ {
              GHC.Integer.Type.S# _ -> fail_dql GHC.Prim.realWorld#;
              GHC.Integer.Type.J# s1_al6 d1_al7 ->
                case wild1_X1l of _ {
                  GHC.Integer.Type.S# _ -> fail_dql GHC.Prim.realWorld#;
                  GHC.Integer.Type.J# s2_al8 d2_al9 -> [snip]
                }
            }
        }
    }
end Rec }

I think explicitly spelling out the constructors being matched against
will prevent this double nested case on wild_X1g:

    andInteger :: Integer -> Integer -> Integer
    (S# x) `andInteger` (S# y) = S# (word2Int# (int2Word# x `and#` int2Word# y))
    x@(S# _) `andInteger` y = toBig x `andInteger` y
    x `andInteger` y@(S# _) = x `andInteger` toBig y
    (J# s1 d1) `andInteger` (J# s2 d2) =
         case andInteger# s1 d1 s2 d2 of
           (# s, d #) -> J# s d

to

    andInteger :: Integer -> Integer -> Integer
    (S# x) `andInteger` (S# y) = S# (word2Int# (int2Word# x `and#` int2Word# y))
    x@(S# _) `andInteger` y@(J# _ _) = toBig x `andInteger` y
    x@(J# _ _) `andInteger` y@(S# _) = x `andInteger` toBig y
    (J# s1 d1) `andInteger` (J# s2 d2) =
         case andInteger# s1 d1 s2 d2 of
           (# s, d #) -> J# s d

I've posted a patch, and it appears to fix builds on quickest.  Let me know
if it works for you guys too.

Cheers,
Edward



More information about the Cvs-ghc mailing list