GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:01:59Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/16020Hadrian: correctly Install libffi shared object files2019-07-07T18:01:59ZdavideHadrian: correctly Install libffi shared object filesIn [D5423](https://phabricator.haskell.org/D5423) a hack to correctly install the libffi .so files is implemented. This is a quick and dirty solution to fix the hadrian build. Note \[Hadrian: install libffi hack\] from that patch and als...In [D5423](https://phabricator.haskell.org/D5423) a hack to correctly install the libffi .so files is implemented. This is a quick and dirty solution to fix the hadrian build. Note \[Hadrian: install libffi hack\] from that patch and also issue #15837 have more details, but ultimately hadrian should not have a special case for libffi.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ---------------------- |
| Version | 8.6.2 |
| Type | Task |
| TypeOfFailure | OtherFailure |
| Priority | high |
| Resolution | Unresolved |
| Component | Build System (Hadrian) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Hadrian: correctly Install libffi shared object files","status":"New","operating_system":"","component":"Build System (Hadrian)","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Task","description":"In Phab:D5423 a hack to correctly install the libffi .so files is implemented. This is a quick and dirty solution to fix the hadrian build. Note [Hadrian: install libffi hack] from that patch and also issue #15837 have more details, but ultimately hadrian should not have a special case for libffi.","type_of_failure":"OtherFailure","blocking":[]} -->8.6.3davidedavidehttps://gitlab.haskell.org/ghc/ghc/-/issues/16024Kind Signatures on data instances2019-07-07T18:01:59ZAndrew MartinKind Signatures on data instancesThere's a comment in `compiler/typecheck/TcInstDcls.hs` that reads:
> The "header" is the part other than the data constructors themselves
> e.g. `data instance D [a] :: * -> * = ...`
> Here the "header" is the bit before the "=" sign...There's a comment in `compiler/typecheck/TcInstDcls.hs` that reads:
> The "header" is the part other than the data constructors themselves
> e.g. `data instance D [a] :: * -> * = ...`
> Here the "header" is the bit before the "=" sign
What's weird is that you cannot actually compile code that this example suggests is valid. Consider this:
```
{-# language TypeFamilies #-}
module BadSig where
data family Bar a :: *
data instance Bar Int :: * = Bool
```
It fails on GHC 8.6.2 with:
```
bad_sig.hs:6:28: error:
parse error on input ‘=’
Perhaps you need a 'let' in a 'do' block?
e.g. 'let x = 5' instead of 'x = 5'
|
6 | data instance Bar Int :: * = Bool
| ^
```
Oddly, GHC will accept the instance if the body is missing:
```
{-# language TypeFamilies #-}
module BadSig where
data family Bar a :: *
data instance Bar Int :: *
```
It is not clear to me whether or not this one should be accepted, but that is beside the point. The first example should certainly be accepted. It should also be accepted with `TYPE 'LiftedRep` instead of `*`, but it fails with the same parser error when given that kind signature as well.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Kind Signatures on data instances","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"There's a comment in `compiler/typecheck/TcInstDcls.hs` that reads:\r\n\r\n> The \"header\" is the part other than the data constructors themselves\r\n\r\n> e.g. `data instance D [a] :: * -> * = ...`\r\n\r\n> Here the \"header\" is the bit before the \"=\" sign\r\n\r\nWhat's weird is that you cannot actually compile code that this example suggests is valid. Consider this:\r\n\r\n{{{\r\n{-# language TypeFamilies #-}\r\n \r\nmodule BadSig where\r\n\r\ndata family Bar a :: *\r\ndata instance Bar Int :: * = Bool\r\n}}}\r\n\r\nIt fails on GHC 8.6.2 with:\r\n\r\n{{{\r\nbad_sig.hs:6:28: error:\r\n parse error on input ‘=’\r\n Perhaps you need a 'let' in a 'do' block?\r\n e.g. 'let x = 5' instead of 'x = 5'\r\n |\r\n6 | data instance Bar Int :: * = Bool\r\n | ^\r\n}}}\r\n\r\nOddly, GHC will accept the instance if the body is missing:\r\n\r\n{{{\r\n{-# language TypeFamilies #-}\r\n \r\nmodule BadSig where\r\n\r\ndata family Bar a :: *\r\ndata instance Bar Int :: *\r\n}}}\r\n\r\nIt is not clear to me whether or not this one should be accepted, but that is beside the point. The first example should certainly be accepted. It should also be accepted with `TYPE 'LiftedRep` instead of `*`, but it fails with the same parser error when given that kind signature as well.","type_of_failure":"OtherFailure","blocking":[]} -->8.6.3https://gitlab.haskell.org/ghc/ghc/-/issues/16029Inadequate absence analysis2019-07-07T18:01:57ZSimon Peyton JonesInadequate absence analysisConsider
```
data S = MkS Int Int
g1 :: S -> Int -> Int
g1 (MkS x y) 0 = 0
g1 (MkS x y) n = g1 (MkS y x) (n-1)
```
With GHC 8.6 we get
```
$wg1 :: S -> GHC.Prim.Int# -> GHC.Prim.Int#
[Str=<S,1*H><S,1*U>]
$wg1 = \ (w_s2oH :: S)
...Consider
```
data S = MkS Int Int
g1 :: S -> Int -> Int
g1 (MkS x y) 0 = 0
g1 (MkS x y) n = g1 (MkS y x) (n-1)
```
With GHC 8.6 we get
```
$wg1 :: S -> GHC.Prim.Int# -> GHC.Prim.Int#
[Str=<S,1*H><S,1*U>]
$wg1 = \ (w_s2oH :: S)
(ww_s2oL :: GHC.Prim.Int#) ->
case w_s2oH of { MkS x_s2pz y_s2pA ->
case ww_s2oL of ds_X2nb {
__DEFAULT ->
Foo.$wg1 (Foo.MkS y_s2pA x_s2pz) (GHC.Prim.-# ds_X2nb 1#);
0# -> 0# }}
g1 :: S -> Int -> Int
[Str=<S,1*H><S(S),1*U(1*U)>m]
g1 = \ (w_s2oH :: S) (w1_s2oI :: Int) ->
case w_s2oH of w2_X2pG { MkS ipv_s2p2 ipv1_s2p3 ->
case w1_s2oI of { GHC.Types.I# ww1_s2oL ->
case Foo.$wg1 w2_X2pG ww1_s2oL of ww2_s2oP { __DEFAULT ->
GHC.Types.I# ww2_s2oP }}}
```
What terrible code! We evaluate the S argument in the wrapper,
and box and unbox it every time around the loop, even though it is never ultimately used.
Here's what happens if the arguments are banged:
```
data T = MkT !Int !Int
g2 :: T -> Int -> Int
g2 (MkT x y) 0 = 0
g2 (MkT x y) n = g2 (MkT y x) (n-1)
```
We get
```
$wg2 GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int#
[Str=<L,1*U><L,1*U><S,1*U>]
Foo.$wg2 = \ (ww_s2ow :: GHC.Prim.Int#)
(ww1_s2ox :: GHC.Prim.Int#)
(ww2_s2oB :: GHC.Prim.Int#) ->
case ww2_s2oB of ds_X2n0 {
__DEFAULT -> Foo.$wg2 ww1_s2ox ww_s2ow (GHC.Prim.-# ds_X2n0 1#);
0# -> 0# }
g2 :: T -> Int -> Int
[Str=<S(SS),1*U(1*U,1*U)><S(S),1*U(1*U)>m ]
g2 = \ (w_s2os :: T) (w1_s2ot :: Int) ->
case w_s2os of { MkT ww1_s2ow ww2_s2ox ->
case w1_s2ot of { GHC.Types.I# ww4_s2oB ->
case Foo.$wg2 ww1_s2ow ww2_s2ox ww4_s2oB of ww5_s2oF {
__DEFAULT -> GHC.Types.I# ww5_s2oF }}}
```
Still terrible. We pass the two components around the loop before discarding them
at the end.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.6.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Inadequate absence analysis","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"8.6.3","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.6.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Consider\r\n{{{\r\ndata S = MkS Int Int\r\ng1 :: S -> Int -> Int\r\ng1 (MkS x y) 0 = 0\r\ng1 (MkS x y) n = g1 (MkS y x) (n-1)\r\n}}}\r\nWith GHC 8.6 we get\r\n{{{\r\n$wg1 :: S -> GHC.Prim.Int# -> GHC.Prim.Int#\r\n[Str=<S,1*H><S,1*U>]\r\n$wg1 = \\ (w_s2oH :: S)\r\n (ww_s2oL :: GHC.Prim.Int#) ->\r\n case w_s2oH of { MkS x_s2pz y_s2pA ->\r\n case ww_s2oL of ds_X2nb {\r\n __DEFAULT ->\r\n Foo.$wg1 (Foo.MkS y_s2pA x_s2pz) (GHC.Prim.-# ds_X2nb 1#);\r\n 0# -> 0# }}\r\n\r\ng1 :: S -> Int -> Int\r\n[Str=<S,1*H><S(S),1*U(1*U)>m]\r\ng1 = \\ (w_s2oH :: S) (w1_s2oI :: Int) ->\r\n case w_s2oH of w2_X2pG { MkS ipv_s2p2 ipv1_s2p3 ->\r\n case w1_s2oI of { GHC.Types.I# ww1_s2oL ->\r\n case Foo.$wg1 w2_X2pG ww1_s2oL of ww2_s2oP { __DEFAULT ->\r\n GHC.Types.I# ww2_s2oP }}}\r\n}}}\r\nWhat terrible code! We evaluate the S argument in the wrapper,\r\nand box and unbox it every time around the loop, even though it is never ultimately used.\r\n\r\nHere's what happens if the arguments are banged:\r\n{{{\r\ndata T = MkT !Int !Int\r\ng2 :: T -> Int -> Int\r\ng2 (MkT x y) 0 = 0\r\ng2 (MkT x y) n = g2 (MkT y x) (n-1)\r\n}}}\r\nWe get\r\n{{{\r\n$wg2 GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int#\r\n[Str=<L,1*U><L,1*U><S,1*U>]\r\nFoo.$wg2 = \\ (ww_s2ow :: GHC.Prim.Int#)\r\n (ww1_s2ox :: GHC.Prim.Int#)\r\n (ww2_s2oB :: GHC.Prim.Int#) ->\r\n case ww2_s2oB of ds_X2n0 {\r\n __DEFAULT -> Foo.$wg2 ww1_s2ox ww_s2ow (GHC.Prim.-# ds_X2n0 1#);\r\n 0# -> 0# }\r\n\r\ng2 :: T -> Int -> Int\r\n[Str=<S(SS),1*U(1*U,1*U)><S(S),1*U(1*U)>m ]\r\ng2 = \\ (w_s2os :: T) (w1_s2ot :: Int) ->\r\n case w_s2os of { MkT ww1_s2ow ww2_s2ox ->\r\n case w1_s2ot of { GHC.Types.I# ww4_s2oB ->\r\n case Foo.$wg2 ww1_s2ow ww2_s2ox ww4_s2oB of ww5_s2oF {\r\n __DEFAULT -> GHC.Types.I# ww5_s2oF }}}\r\n}}}\r\nStill terrible. We pass the two components around the loop before discarding them\r\nat the end.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.6.3https://gitlab.haskell.org/ghc/ghc/-/issues/17766got an error when profile memory using -hr2020-01-31T00:04:41ZXiaoninggot an error when profile memory using -hr# compile
```
ghc -O2 -w -rtsopts -prof Main
```
# run
```
./Main -tcount w45.log -identity 45 -order wire ./$1 +RTS -A4M -H1G -s -p -hr
```
# error
```
Main: internal error: Invalid object in isRetainer(): 64
(GHC version 8.0.2 fo...# compile
```
ghc -O2 -w -rtsopts -prof Main
```
# run
```
./Main -tcount w45.log -identity 45 -order wire ./$1 +RTS -A4M -H1G -s -p -hr
```
# error
```
Main: internal error: Invalid object in isRetainer(): 64
(GHC version 8.0.2 for x86_64_unknown_linux)
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
# this run works (-hr => -h)
```
./Main -tcount w45.log -identity 45 -order wire ./$1 +RTS -A4M -H1G -s -p -h
```8.6.3