GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2022-08-19T04:14:30Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/22044ghc `-E -cpp` doesn't behave the same for GHC 9.4 as GHC 9.22022-08-19T04:14:30ZVanessa McHaleghc `-E -cpp` doesn't behave the same for GHC 9.4 as GHC 9.2## Summary
Building with GHC 9.4 gives:
```
Error: cabal-3.8.1.0: Spec.hs doesn't exist
```
even though things were fine with GHC 9.2
## Steps to reproduce
```
darcs clone https://hub.darcs.net/vmchale/apple
cabal build apple-test -...## Summary
Building with GHC 9.4 gives:
```
Error: cabal-3.8.1.0: Spec.hs doesn't exist
```
even though things were fine with GHC 9.2
## Steps to reproduce
```
darcs clone https://hub.darcs.net/vmchale/apple
cabal build apple-test -w ghc-9.4
```
I ran `cabal` with `-v3` to see that GHC is invoked like so:
```
/home/vanessa/.ghcup/bin/ghc-9.4 -E -cpp -x hs -optP-include -optP/development/haskell/apple/dist-newstyle/build/x86_64-linux/ghc-9.4.1/apple-0.1.0.0/t/apple-test/build/apple-test/autogen/cabal_macros.h -o /development/haskell/apple/dist-newstyle/build/x86_64-linux/ghc-9.4.1/apple-0.1.0.0/t/apple-test/build/apple-test/apple-test-tmp/Spec.hs test/Spec.cpphs '-D__GLASGOW_HASKELL__=904' '-Dlinux_BUILD_OS=1' '-Dx86_64_BUILD_ARCH=1' '-Dlinux_HOST_OS=1' '-Dx86_64_HOST_ARCH=1' -hide-all-packages
```
which is basically the same as GHC 9.2:
```
/home/vanessa/.ghcup/bin/ghc-9.2 -E -cpp -x hs -optP-include -optP/development/haskell/apple/dist-newstyle/build/x86_64-linux/ghc-9.2.4/apple-0.1.0.0/t/apple-test/build/apple-test/autogen/cabal_macros.h -o /development/haskell/apple/dist-newstyle/build/x86_64-linux/ghc-9.2.4/apple-0.1.0.0/t/apple-test/build/apple-test/apple-test-tmp/Spec.hs test/Spec.cpphs '-D__GLASGOW_HASKELL__=902' '-Dlinux_BUILD_OS=1' '-Dx86_64_BUILD_ARCH=1' '-Dlinux_HOST_OS=1' '-Dx86_64_HOST_ARCH=1' -hide-all-packages
```
However, the former fails while the latter works!
## Expected behavior
It should work as it does with
```
cabal build apple-test -w ghc-9.2
```
## Environment
* GHC version used: 9.4, 9.2
Optional:
* Operating System: Ubuntu 20.04
* System Architecture: x86_649.4.2Matthew PickeringMatthew Pickeringhttps://gitlab.haskell.org/ghc/ghc/-/issues/22026slow validate failure: unboxedsum3 stg lint failure2022-12-13T09:31:01ZMatthew Pickeringslow validate failure: unboxedsum3 stg lint failureReproduce with
```
hadrian/build test --freeze1 --docs=none --flavour=slow-validate --test-speed=slow --only="unboxedsums3"
```
```
Compile failed (exit code 1) errors were:
[1 of 2] Compiling Main ( unboxedsums3.hs, unbo...Reproduce with
```
hadrian/build test --freeze1 --docs=none --flavour=slow-validate --test-speed=slow --only="unboxedsums3"
```
```
Compile failed (exit code 1) errors were:
[1 of 2] Compiling Main ( unboxedsums3.hs, unboxedsums3.o )
unboxedsums3.hs:11:16: warning: [-Wdeprecations (in -Wdefault)]
In the use of type constructor or class ‘Void#’
(imported from GHC.Types):
Deprecated: "Void# is now an alias for the unboxed tuple (# #)."
unboxedsums3.hs:19:23: warning: [-Wdeprecations (in -Wdefault)]
In the use of type constructor or class ‘Void#’
(imported from GHC.Types):
Deprecated: "Void# is now an alias for the unboxed tuple (# #)."
*** Stg Lint ErrMsgs: in Unarise ***
<no location info>: warning:
[in body of lambda with binders ds_s2Ji :: D]
Function type reps and function argument reps missmatched
In application $wshowD [us_g2Ka, us_g2Kb, us_g2Kc, us_g2Kd,
us_g2Ke]
argument rep:[LiftedRep]
expected rep:[WordRep, LiftedRep, FloatRep]
unarised?:True
*** Offending Program ***
f2 :: D -> (# Void | Float# #)
[GblId[[RecSel]], Arity=1, Str=<1!P(A,1L)>, Unf=OtherCon []] =
\r [ds_s2IO]
case ds_s2IO of {
D us_g2JN us_g2JO us_g2JP us_g2JQ us_g2JR ->
(#,,#) [us_g2JP us_g2JQ us_g2JR];
};
f1 :: D -> (# Void# | (# #) | () #)
[GblId[[RecSel]], Arity=1, Str=<1!P(1L,A)>, Unf=OtherCon []] =
\r [ds_s2IS]
case ds_s2IS of {
D us_g2JS us_g2JT us_g2JU us_g2JV us_g2JW ->
(#,#) [us_g2JS us_g2JT];
};
lvl_r2Ge :: Addr#
[GblId, Unf=OtherCon []] =
"unboxedsums3.hs:(12,1)-(13,38)|function showAlt0"#;
showAlt2 :: ()
[GblId, Str=b, Cpr=b] =
\u [] patError lvl_r2Ge;
main14 :: Addr#
[GblId, Unf=OtherCon []] =
"(# | (# #) | #)"#;
main13 :: [Char]
[GblId] =
\u [] unpackCString# main14;
main12 :: Addr#
[GblId, Unf=OtherCon []] =
"(# | | () #)"#;
main11 :: [Char]
[GblId] =
\u [] unpackCString# main12;
showAlt0 :: (# Void# | (# #) | () #) -> String
[GblId, Arity=1, Str=<1L>, Unf=OtherCon []] =
\r [us_g2JX us_g2JY]
case us_g2JX of tag_g2JZ {
__DEFAULT -> showAlt2;
2# -> main13;
3# -> case us_g2JY of { () -> main11; };
};
$trModule4 :: Addr#
[GblId, Unf=OtherCon []] =
"main"#;
$trModule3 :: TrName
[GblId, Unf=OtherCon []] =
TrNameS! [$trModule4];
$trModule2 :: Addr#
[GblId, Unf=OtherCon []] =
"Main"#;
$trModule1 :: TrName
[GblId, Unf=OtherCon []] =
TrNameS! [$trModule2];
$trModule :: Module
[GblId, Unf=OtherCon []] =
Module! [$trModule3 $trModule1];
$tcD2 :: Addr#
[GblId, Unf=OtherCon []] =
"D"#;
$tcD1 :: TrName
[GblId, Unf=OtherCon []] =
TrNameS! [$tcD2];
$tcD :: TyCon
[GblId, Unf=OtherCon []] =
TyCon! [2478211139812765157##64
8067119037829273873##64
$trModule
$tcD1
0#
krep$*];
main10 :: Addr#
[GblId, Unf=OtherCon []] =
"(# Void | #)"#;
main9 :: [Char]
[GblId] =
\u [] unpackCString# main10;
main6 :: Addr#
[GblId, Unf=OtherCon []] =
"(# | "#;
main5 :: Addr#
[GblId, Unf=OtherCon []] =
"# #)"#;
main4 :: [Char]
[GblId] =
\u [] unpackCString# main5;
showAlt1 :: (# Void | Float# #) -> String
[GblId, Arity=1, Str=<1L>, Unf=OtherCon []] =
\r [us_g2K0 us_g2K1 us_g2K2]
case us_g2K0 of tag_g2K3 {
__DEFAULT -> main9;
2# ->
let {
sat_s2J8 [Occ=Once1, Dmd=ML] :: [Char]
[LclId] =
\s []
let {
sat_s2J6 [Occ=Once1] :: Float
[LclId] =
F#! [us_g2K2];
} in
case
$fShowFloat_$sshowSignedFloat $fShowFloat2 minExpt sat_s2J6 []
of
sat_s2J7 [Occ=Once1]
{
__DEFAULT -> ++ sat_s2J7 main4;
};
} in unpackAppendCString# main6 sat_s2J8;
};
main7 :: Addr#
[GblId, Unf=OtherCon []] =
"(# | (# #) | #)\n"#;
showD1 :: Addr#
[GblId, Unf=OtherCon []] =
"(# | | () #)\n"#;
$wshowD [InlPrag=[2]]
:: (# Void# | (# #) | () #) -> (# Void | Float# #) -> String
[GblId[StrictWorker([])], Arity=2, Str=<1L><ML>, Unf=OtherCon []] =
\r [us_g2K4 us_g2K5 us_g2K6 us_g2K7 us_g2K8]
case us_g2K4 of tag_g2K9 {
__DEFAULT -> showAlt2;
2# ->
let {
sat_s2Je [Occ=Once1, Dmd=ML] :: String
[LclId] =
\s [] showAlt1 us_g2K6 us_g2K7 us_g2K8;
} in unpackAppendCString# main7 sat_s2Je;
3# ->
case us_g2K5 of {
() ->
let {
sat_s2Jh [Occ=Once1, Dmd=ML] :: String
[LclId] =
\s [] showAlt1 us_g2K6 us_g2K7 us_g2K8;
} in unpackAppendCString# showD1 sat_s2Jh;
};
};
showD [InlPrag=[2]] :: D -> String
[GblId, Arity=1, Str=<1!P(1L,ML)>, Unf=OtherCon []] =
\r [ds_s2Ji]
case ds_s2Ji of {
D us_g2Ka us_g2Kb us_g2Kc us_g2Kd us_g2Ke ->
$wshowD us_g2Ka us_g2Kb us_g2Kc us_g2Kd us_g2Ke;
};
sat_s2Jo [Dmd=ML] :: [Char]
[LclId] =
\s []
let {
sat_s2Jm [Occ=Once1] :: Float
[LclId] =
F#! [1.2#];
} in
case
$fShowFloat_$sshowSignedFloat $fShowFloat2 minExpt sat_s2Jm []
of
sat_s2Jn [Occ=Once1]
{
__DEFAULT -> ++ sat_s2Jn main4;
};
main3 :: String
[GblId] =
\u [] unpackAppendCString# main6 sat_s2Jo;
main2 :: [Char]
[GblId] =
\u [] unpackAppendCString# main7 main3;
sat_s2Jr [Dmd=ML] :: [Char]
[LclId] =
\s []
let {
sat_s2Jp [Occ=Once1] :: Float
[LclId] =
F#! [8.1#];
} in
case
$fShowFloat_$sshowSignedFloat $fShowFloat2 minExpt sat_s2Jp []
of
sat_s2Jq [Occ=Once1]
{
__DEFAULT -> ++ sat_s2Jq main4;
};
main8 :: String
[GblId] =
\u [] unpackAppendCString# main6 sat_s2Jr;
$wmain [InlPrag=[2]] :: State# RealWorld -> State# RealWorld
[GblId, Arity=1, Str=<L>, Unf=OtherCon []] =
\r [void_0E]
case hPutStr2 stdout main13 True void# of {
Solo# _ [Occ=Dead] ->
case hPutStr2 stdout main11 True void# of {
Solo# _ [Occ=Dead] ->
case hPutStr2 stdout main9 True void# of {
Solo# _ [Occ=Dead] ->
case hPutStr2 stdout main8 True void# of {
Solo# _ [Occ=Dead] ->
case hPutStr2 stdout main2 True void# of {
Solo# _ [Occ=Dead] ->
case __ffi_static_ccall_safe base:performMajorGC :: [void#] of {
(##) -> (##) [];
};
};
};
};
};
};
main1 [InlPrag=[2]]
:: State# RealWorld -> (# State# RealWorld, () #)
[GblId, Arity=1, Str=<L>, Cpr=1(, 1), Unf=OtherCon []] =
\r [void_0E]
case $wmain void# of ww_s2JM [Occ=Once1] { (##) -> Solo# [()]; };
main :: IO ()
[GblId, Arity=1, Str=<L>, Cpr=1(, 1), Unf=OtherCon []] =
\r [void_0E] main1 void#;
main15 :: State# RealWorld -> (# State# RealWorld, () #)
[GblId, Arity=1, Str=<L>, Unf=OtherCon []] =
\r [void_0E] runMainIO1 main1 void#;
main :: IO ()
[GblId, Arity=1, Str=<L>, Unf=OtherCon []] =
\r [void_0E] main15 void#;
D [InlPrag=CONLIKE]
:: (# Void# | (# #) | () #) %1 -> (# Void | Float# #) %1 -> D
[GblId[DataCon], Arity=2, Caf=NoCafRefs, Unf=OtherCon []] =
\r [us_g2Kf us_g2Kg us_g2Kh us_g2Ki us_g2Kj]
D [us_g2Kf us_g2Kg us_g2Kh us_g2Ki us_g2Kj];
*** End of Offense ***
<no location info>: error:
Compilation had errors
<no location info>: error: ExitFailure 1
```9.6.1Andreas KlebingerAndreas Klebingerhttps://gitlab.haskell.org/ghc/ghc/-/issues/21981ghc 9.4.1 fails to compile head2022-08-22T16:14:08ZCheng Shaoghc 9.4.1 fails to compile headRun the below repro script in a clean `ubuntu:22.04` docker container:
```sh
#!/usr/bin/env bash
set -euo pipefail
export PATH=~/.cabal/bin:~/.ghcup/bin:$PATH
apt update
apt full-upgrade -y
apt install -y \
automake \
build-essen...Run the below repro script in a clean `ubuntu:22.04` docker container:
```sh
#!/usr/bin/env bash
set -euo pipefail
export PATH=~/.cabal/bin:~/.ghcup/bin:$PATH
apt update
apt full-upgrade -y
apt install -y \
automake \
build-essential \
curl \
git \
libgmp-dev \
libncurses-dev \
python3
mkdir -p ~/.ghcup/bin
curl -f -L --retry 5 https://downloads.haskell.org/~ghcup/x86_64-linux-ghcup -o ~/.ghcup/bin/ghcup
chmod +x ~/.ghcup/bin/ghcup
ghcup install ghc 9.2.4
ghcup install ghc 9.4.1 -u https://downloads.haskell.org/~ghc/9.4.1/ghc-9.4.1-x86_64-fedora33-linux.tar.xz
ghcup set ghc 9.4.1
ghcup install cabal
cabal update
cabal install \
alex \
happy
git clone --recurse-submodules https://gitlab.haskell.org/ghc/ghc.git /tmp/ghc
cd /tmp/ghc
./boot --hadrian
./configure
GHC=ghc-9.2.4 hadrian/build -j
```
It'll fail with linker error:
```
Command line: /root/.ghcup/bin/ghc -Wall -Wcompat -hisuf hi -osuf o -hcsuf hc -static -hide-all-packages -no-user-package-db '-package-env -' '-package-db _build/stage0/lib/package.conf.d' '-package-id array-0.5.4.0' '-package-id base-4.17.0.0' '-package-id containers-0.6.6' '-package-id directory-1.3.7.1' '-package-id filepath-1.4.2.2' '-package-id hpc-0.6.1.0' -i -i/tmp/ghc/_build/stage0/utils/hpc/build -i/tmp/ghc/_build/stage0/utils/hpc/build/hpc/autogen -i/tmp/ghc/utils/hpc -I_build/stage0/utils/hpc/build -I/tmp/ghc/_build/stage0/lib/x86_64-linux-ghc-9.4.1/unix-2.7.2.2/include -I/tmp/ghc/_build/stage0/lib/x86_64-linux-ghc-9.4.1/time-1.12.2/include -I/tmp/ghc/_build/stage0/lib/x86_64-linux-ghc-9.4.1/bytestring-0.11.3.0/include -I/root/.ghcup/ghc/9.4.1/lib/ghc-9.4.1/lib/x86_64-linux-ghc-9.4.1/base-4.17.0.0/include -I/root/.ghcup/ghc/9.4.1/lib/ghc-9.4.1/lib/x86_64-linux-ghc-9.4.1/ghc-bignum-1.3/include -I/root/.ghcup/ghc/9.4.1/lib/ghc-9.4.1/lib/x86_64-linux-ghc-9.4.1/rts-1.0.2/include -optP-include -optP_build/stage0/utils/hpc/build/hpc/autogen/cabal_macros.h -outputdir _build/stage0/utils/hpc/build -fdiagnostics-color=always -no-auto-link-packages -rtsopts -optc-Wno-error=inline -optP-Wno-nonportable-include-path _build/stage0/utils/hpc/build/Main.o _build/stage0/utils/hpc/build/HpcParser.o _build/stage0/utils/hpc/build/HpcCombine.o _build/stage0/utils/hpc/build/HpcDraft.o _build/stage0/utils/hpc/build/HpcFlags.o _build/stage0/utils/hpc/build/HpcLexer.o _build/stage0/utils/hpc/build/HpcMarkup.o _build/stage0/utils/hpc/build/HpcOverlay.o _build/stage0/utils/hpc/build/HpcReport.o _build/stage0/utils/hpc/build/HpcShowTix.o _build/stage0/utils/hpc/build/HpcUtils.o _build/stage0/utils/hpc/build/Paths_hpc_bin.o -o _build/stage0/bin/hpc -O -H32m -XHaskell2010
===> Command failed with error code: 1
/root/.ghcup/ghc/9.4.1/lib/ghc-9.4.1/lib/../lib/x86_64-linux-ghc-9.4.1/containers-0.6.6/libHScontainers-0.6.6.a(Tree.o)(.text+0x2d96): error: undefined reference to 'templatezmhaskell_LanguageziHaskellziTHziSyntax_zdwzdclift11_info'
/root/.ghcup/ghc/9.4.1/lib/ghc-9.4.1/lib/../lib/x86_64-linux-ghc-9.4.1/containers-0.6.6/libHScontainers-0.6.6.a(Tree.o)(.text+0x3426): error: undefined reference to 'templatezmhaskell_LanguageziHaskellziTHziSyntax_zdwzdclift11_info'
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
Command failed
Build failed.
```9.4.2Ben GamariMatthew PickeringBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21974GHC 9.4.1 binary distribution wrapper installation broken on BSDs including m...2022-10-14T17:50:40ZBen GamariGHC 9.4.1 binary distribution wrapper installation broken on BSDs including macOSIt turns out that a seemingly harmless change made in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8763 broken installation of the wrapper scripts installed by the bindist Makefile. Specifically, changing `cp -RP` to `cp -P` broke...It turns out that a seemingly harmless change made in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8763 broken installation of the wrapper scripts installed by the bindist Makefile. Specifically, changing `cp -RP` to `cp -P` broke on BSDs, which differ subtly in semantics from `coreutils`'s `cp` when copying symbolic links. This wasn't caught by CI since the only BSD which we test is Darwin, where we use `coreutils` in our testing environment.9.4.2Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21956Deb11 built against liffi8 but should be built against libffi72022-08-09T14:29:31ZMatthew PickeringDeb11 built against liffi8 but should be built against libffi7Henning Thielemann reports:
> I try
>
> https://downloads.haskell.org/ghc/9.4.1-rc1/ghc-9.4.0.20220721-x86_64-deb11-linux.tar.lz
>
> on Debian 11.
>
> $ /usr/local/ghc-9.4.0/bin/ghc --version
> /usr/local/ghc-9.4.0/lib/ghc-9.4.0.20...Henning Thielemann reports:
> I try
>
> https://downloads.haskell.org/ghc/9.4.1-rc1/ghc-9.4.0.20220721-x86_64-deb11-linux.tar.lz
>
> on Debian 11.
>
> $ /usr/local/ghc-9.4.0/bin/ghc --version
> /usr/local/ghc-9.4.0/lib/ghc-9.4.0.20220721/bin/ghc-9.4.0.20220721: error
> while loading shared libraries: libffi.so.8: cannot open shared object
> file: No such file or directory
>
>
> Debian 11 seems to support only libffi7:
>
> $ dpkg --list "*libffi*"
>
> ii libffi-dev:amd64 3.3-6 amd64 Foreign Function Interface library (development files)
> un libffi4-dev <keine> <keine> (keine Beschreibung vorhanden)
> ii libffi7:amd64 3.3-6 amd64 Foreign Function Interface library runtime
> ii libffi7:i386 3.3-6 i386 Foreign Function Interface library runtime
>
>
> I think this dependency is new and was not present in the Alpha releases.
>
>
>
> Also many directories have no read and cd permissions for 'other' users.9.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/21888HEAD fails to compile MemoTrie-0.6.10 due to stack space overflow2022-07-25T16:06:02ZRyan ScottHEAD fails to compile MemoTrie-0.6.10 due to stack space overflow_(Originally noticed in a `head.hackage` job [here](https://gitlab.haskell.org/ghc/head.hackage/-/jobs/1117128#L3125).)_
The `MemoTrie-0.6.10` library on Hackage fails to compile on GHC HEAD (at commit e2f0094c315746ff15b8d9650cf318f81d..._(Originally noticed in a `head.hackage` job [here](https://gitlab.haskell.org/ghc/head.hackage/-/jobs/1117128#L3125).)_
The `MemoTrie-0.6.10` library on Hackage fails to compile on GHC HEAD (at commit e2f0094c315746ff15b8d9650cf318f81d8416d7). Here is a minimized example:
```hs
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module Data.MemoTrie (HasTrie(..)) where
import Control.Arrow (Arrow(first))
import Data.Bits (Bits((.|.), shiftL))
import Data.Kind (Type)
infixr 0 :->:
class HasTrie a where
data (:->:) a :: Type -> Type
enumerate :: (a :->: b) -> [(a,b)]
instance HasTrie () where
newtype () :->: a = UnitTrie a
enumerate (UnitTrie a) = [((),a)]
instance HasTrie Bool where
data Bool :->: x = BoolTrie x x
enumerate (BoolTrie f t) = [(False,f),(True,t)]
instance (HasTrie a, HasTrie b) => HasTrie (Either a b) where
data (Either a b) :->: x = EitherTrie (a :->: x) (b :->: x)
enumerate (EitherTrie s t) = enum' Left s `weave` enum' Right t
enum' :: (HasTrie a) => (a -> a') -> (a :->: b) -> [(a', b)]
enum' f = (fmap.first) f . enumerate
weave :: [a] -> [a] -> [a]
[] `weave` as = as
as `weave` [] = as
(a:as) `weave` bs = a : (bs `weave` as)
instance (HasTrie a, HasTrie b) => HasTrie (a,b) where
newtype (a,b) :->: x = PairTrie (a :->: (b :->: x))
enumerate (PairTrie tt) =
[ ((a,b),x) | (a,t) <- enumerate tt , (b,x) <- enumerate t ]
instance HasTrie x => HasTrie [x] where
newtype [x] :->: a = ListTrie (Either () (x,[x]) :->: a)
enumerate (ListTrie t) = enum' list t
list :: Either () (x,[x]) -> [x]
list = either (const []) (uncurry (:))
unbit :: Num t => Bool -> t
unbit False = 0
unbit True = 1
unbits :: (Num t, Bits t) => [Bool] -> t
unbits [] = 0
unbits (x:xs) = unbit x .|. shiftL (unbits xs) 1
instance HasTrie Integer where
newtype Integer :->: a = IntegerTrie ((Bool,[Bool]) :->: a)
enumerate (IntegerTrie t) = enum' unbitsZ t
unbitsZ :: (Num n, Bits n) => (Bool,[Bool]) -> n
unbitsZ (positive,bs) = sig (unbits bs)
where
sig | positive = id
| otherwise = negate
```
If you compile this with optimizations with GHC 9.2 and earlier, it succeeds:
```
$ ghc-9.2.3 MemoTrie.hs -fforce-recomp -O
[1 of 1] Compiling Data.MemoTrie ( MemoTrie.hs, MemoTrie.o )
```
If you compile with HEAD, however, it fails with:
```
$ ~/Software/ghc-9.5.20220719/bin/ghc MemoTrie.hs -fforce-recomp -O
[1 of 1] Compiling Data.MemoTrie ( MemoTrie.hs, MemoTrie.o )
ghc-9.5.20220719: Stack space overflow: current size 33624 bytes.
ghc-9.5.20220719: Use `+RTS -Ksize -RTS' to increase it.
```9.6.1https://gitlab.haskell.org/ghc/ghc/-/issues/21838AdjustorPool Bitmap implementation is wrong2023-03-14T05:32:39ZBen GamariAdjustorPool Bitmap implementation is wrongIt turns out that `bitmap_first_unset` used by `AdjustorPool` is incorrect due to the fact that `__builtin_clz` silently widens its argument to `unsigned int`. This results in assertion failures when building with the debug RTS and may r...It turns out that `bitmap_first_unset` used by `AdjustorPool` is incorrect due to the fact that `__builtin_clz` silently widens its argument to `unsigned int`. This results in assertion failures when building with the debug RTS and may result in double-allocation of adjustor slots.9.4.1Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21787Statically linked 9.4.1 alpha 3 GHC is unable to do linking for TH2023-09-28T06:23:35ZZubinStatically linked 9.4.1 alpha 3 GHC is unable to do linking for TH# Steps to reproduce
1. Compile a statically linked GHC executable with 9.4.1-alpha3 and create a wrapper for it
2. `cabal get lsp-types-1.4.0.1 `
3. `cabal build -w ghc-static --allow-newer`
This results in the following linker failur...# Steps to reproduce
1. Compile a statically linked GHC executable with 9.4.1-alpha3 and create a wrapper for it
2. `cabal get lsp-types-1.4.0.1 `
3. `cabal build -w ghc-static --allow-newer`
This results in the following linker failures:
```
[ 5 of 52] Compiling Language.LSP.Types.StaticRegistrationOptions ( src/Language/LSP/Types/StaticRegistrationOptions.hs, /home/zubin/ghcs/unicode-lex/lsp-types-1.4.0.1/dist-newstyle/build/x86_64-linux/ghc-9.4.0.20220623/lsp-types-1.4.0.1/build/Language/LSP/Types/StaticRegistrationOptions.o )
ghc: /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a: unknown symbol `__popcountdi2'
ghc: /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a: unknown symbol `_hs_text_measure_off'
ghc: /home/zubin/.cabal/store/ghc-9.4.0.20220623/aeson-2.0.3.0-840985ab1cda79d2b376fa876992cb056ebfc140ab0b12a711a908a2accfc0ce/lib/libHSaeson-2.0.3.0-840985ab1cda79d2b376fa876992cb056ebfc140ab0b12a711a908a2accfc0ce.a: unknown symbol `textzm2zi0_DataziText_zdwzdclift_closure'
ghc: /home/zubin/.cabal/store/ghc-9.4.0.20220623/aeson-2.0.3.0-840985ab1cda79d2b376fa876992cb056ebfc140ab0b12a711a908a2accfc0ce/lib/libHSaeson-2.0.3.0-840985ab1cda79d2b376fa876992cb056ebfc140ab0b12a711a908a2accfc0ce.a: unknown symbol `aesonzm2zi0zi3zi0zm840985ab1cda79d2b376fa876992cb056ebfc140ab0b12a711a908a2accfc0ce_DataziAesonziKey_zdfCoArbitraryKey1_closure'
ghc: /home/zubin/ghcs/unicode-lex/lsp-types-1.4.0.1/dist-newstyle/build/x86_64-linux/ghc-9.4.0.20220623/lsp-types-1.4.0.1/build/Language/LSP/Types/Utils.o: unknown symbol `aesonzm2zi0zi3zi0zm840985ab1cda79d2b376fa876992cb056ebfc140ab0b12a711a908a2accfc0ce_DataziAesonziTypesziInternal_Options_con_info'
ghc: Could not load Object Code /home/zubin/ghcs/unicode-lex/lsp-types-1.4.0.1/dist-newstyle/build/x86_64-linux/ghc-9.4.0.20220623/lsp-types-1.4.0.1/build/Language/LSP/Types/Utils.o.
<no location info>: error:
[ 6 of 52] Compiling Language.LSP.Types.Progress ( src/Language/LSP/Types/Progress.hs, /home/zubin/ghcs/unicode-lex/lsp-types-1.4.0.1/dist-newstyle/build/x86_64-linux/ghc-9.4.0.20220623/lsp-types-1.4.0.1/build/Language/LSP/Types/Progress.o )
ghc: /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a: unknown symbol `__popcountdi2'
ghc: Could not load Object Code /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a(#3:measure_off.o).
<no location info>: error:
[ 7 of 52] Compiling Language.LSP.Types.Method ( src/Language/LSP/Types/Method.hs, /home/zubin/ghcs/unicode-lex/lsp-types-1.4.0.1/dist-newstyle/build/x86_64-linux/ghc-9.4.0.20220623/lsp-types-1.4.0.1/build/Language/LSP/Types/Method.o )
ghc: /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a: unknown symbol `__popcountdi2'
ghc: Could not load Object Code /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a(#3:measure_off.o).
<no location info>: error:
[10 of 52] Compiling Language.LSP.Types.MarkupContent ( src/Language/LSP/Types/MarkupContent.hs, /home/zubin/ghcs/unicode-lex/lsp-types-1.4.0.1/dist-newstyle/build/x86_64-linux/ghc-9.4.0.20220623/lsp-types-1.4.0.1/build/Language/LSP/Types/MarkupContent.o )
ghc: /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a: unknown symbol `__popcountdi2'
ghc: Could not load Object Code /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a(#3:measure_off.o).
<no location info>: error:
[11 of 52] Compiling Language.LSP.Types.Location ( src/Language/LSP/Types/Location.hs, /home/zubin/ghcs/unicode-lex/lsp-types-1.4.0.1/dist-newstyle/build/x86_64-linux/ghc-9.4.0.20220623/lsp-types-1.4.0.1/build/Language/LSP/Types/Location.o )
ghc: /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a: unknown symbol `__popcountdi2'
ghc: Could not load Object Code /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a(#3:measure_off.o).
<no location info>: error:
[12 of 52] Compiling Language.LSP.Types.DocumentFilter ( src/Language/LSP/Types/DocumentFilter.hs, /home/zubin/ghcs/unicode-lex/lsp-types-1.4.0.1/dist-newstyle/build/x86_64-linux/ghc-9.4.0.20220623/lsp-types-1.4.0.1/build/Language/LSP/Types/DocumentFilter.o )
ghc: /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a: unknown symbol `__popcountdi2'
ghc: Could not load Object Code /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a(#3:measure_off.o).
<no location info>: error:
[30 of 52] Compiling Language.LSP.Types.Configuration ( src/Language/LSP/Types/Configuration.hs, /home/zubin/ghcs/unicode-lex/lsp-types-1.4.0.1/dist-newstyle/build/x86_64-linux/ghc-9.4.0.20220623/lsp-types-1.4.0.1/build/Language/LSP/Types/Configuration.o )
ghc: /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a: unknown symbol `__popcountdi2'
ghc: Could not load Object Code /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a(#3:measure_off.o).
<no location info>: error:
[35 of 52] Compiling Language.LSP.Types.WatchedFiles ( src/Language/LSP/Types/WatchedFiles.hs, /home/zubin/ghcs/unicode-lex/lsp-types-1.4.0.1/dist-newstyle/build/x86_64-linux/ghc-9.4.0.20220623/lsp-types-1.4.0.1/build/Language/LSP/Types/WatchedFiles.o )
ghc: /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a: unknown symbol `__popcountdi2'
ghc: Could not load Object Code /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a(#3:measure_off.o).
<no location info>: error:
[42 of 52] Compiling Language.LSP.Types.WorkspaceFolders ( src/Language/LSP/Types/WorkspaceFolders.hs, /home/zubin/ghcs/unicode-lex/lsp-types-1.4.0.1/dist-newstyle/build/x86_64-linux/ghc-9.4.0.20220623/lsp-types-1.4.0.1/build/Language/LSP/Types/WorkspaceFolders.o )
ghc: /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a: unknown symbol `__popcountdi2'
ghc: Could not load Object Code /home/zubin/.ghcup/ghc/9.4.1/lib/ghc-9.4.0.20220623/lib/x86_64-linux-ghc-9.4.0.20220623/text-2.0/libHStext-2.0.a(#3:measure_off.o).
````9.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/21778Debian 10 linker used in armv7l image affected by binutils #161772023-08-21T09:00:25ZBen GamariDebian 10 linker used in armv7l image affected by binutils #16177The ARMv7 Debian 10 9.4.1-alpha3 release build failed with https://gitlab.haskell.org/ghc/ghc/-/jobs/1092655. This is the result of a bfd ld linker bug (see #9673). We need to ensure that we use another non-buggy linker.The ARMv7 Debian 10 9.4.1-alpha3 release build failed with https://gitlab.haskell.org/ghc/ghc/-/jobs/1092655. This is the result of a bfd ld linker bug (see #9673). We need to ensure that we use another non-buggy linker.9.4.1Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21717Demand analysis can produce unsound signatures2022-09-27T18:11:24ZSebastian GrafDemand analysis can produce unsound signaturesConsider
```hs
f :: Bool -> (Int, Int)
f True = (n,error "m")
f False = (error "m",n)
g :: (Bool -> (Int, Int)) -> Int
-- Inferred strictness <SCS(P(1L,1L))>
g h = fst (h True) + snd (h False)
{-# NOINLINE g #-}
```
The idea here is ...Consider
```hs
f :: Bool -> (Int, Int)
f True = (n,error "m")
f False = (error "m",n)
g :: (Bool -> (Int, Int)) -> Int
-- Inferred strictness <SCS(P(1L,1L))>
g h = fst (h True) + snd (h False)
{-# NOINLINE g #-}
```
The idea here is to call `g` with `f` at the top-level. We can see that it just barely plays out and we don't evaluate any of the `error`s, because `g` switches from `fst` to `snd` at the same time as it flips the boolean flag.
This is the signature we infer for `g`:
```
<SCS(P(1L,1L))>
```
Note the `P(1L,1L)`. This is wrong, because it says that `g` calls its argment (more than once), and that `g` evaluates *both* components of the result of *each call*.
The whole demand says "g's arg is called multiple times and we'll evalauate both components of the result". That is unfortunately unsound! Not every call evaluates both components and as `f` shows, what is stored in the components may vary from call to call.
Fortunately, I can't find a way to make GHC exploit the unsoundness. But one idea for the future (!5349) is to analyse `f`'s RHS assuming the demand it is put on in its body. If `g f` is the only use of `f`, we may put `P(1L,1L)` on `(n,error "m")` and crash on *every* call to `f`. Urgh!
The fix is to Lub `sd1` and `sd2` when we have `plusSubDmd C(n1:*sd1) C(n2:*sd2)`. Currently, we Plus them if `n1` and `n2` are strict.9.6.1Sebastian GrafSebastian Grafhttps://gitlab.haskell.org/ghc/ghc/-/issues/21708Compiled program with GHC9.2.2 often causes "internal error: evacuate: strang...2022-11-07T15:55:40ZJH LeCompiled program with GHC9.2.2 often causes "internal error: evacuate: strange closure type xxx"## Summary
I cannot come up with a good title, so please bear with me with the title.
I've been using XMonad with GHC 9.0.2 fine,
but when I updated it to GHC9.2.2, it often crashes.
It sometimes leave the following message, while somet...## Summary
I cannot come up with a good title, so please bear with me with the title.
I've been using XMonad with GHC 9.0.2 fine,
but when I updated it to GHC9.2.2, it often crashes.
It sometimes leave the following message, while sometimes silently crashes.
```
xmonad-x86_64-linux: internal error: evacuate: strange closure type 0
(GHC version 9.2.2 for x86_64_unknown_linux)
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
Aborted (core dumped)
```
(The closure type depends time to time)
Happens with the most bare-bone XMonad instance. I am lost on how to skin it down further.
Reporting this to GHC, since this specifically happens with GHC9.2.2. All previous versions work fine.
Any directions to diagnose which part is causing the issue?
## Steps to reproduce
1. Install XMonad as dynamically linked
2. Run with the default configuration
3. (At least on my end) performing some action leads to a crash from time to time
## Expected behavior
`internal error: evacuate: strange closure type 0` should not happen.
## Environment
* GHC version used: 9.2.2
Optional:
* Operating System: Ubuntu 20.04.4 LTS, 64-bit, Linux
* System Architecture: x86-649.2.4Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21689GHC HEAD panics (lookupIdSubst) when building fixed-vector-1.2.1.02023-08-21T02:06:18ZRyan ScottGHC HEAD panics (lookupIdSubst) when building fixed-vector-1.2.1.0_(Originally noticed in a `head.hackage` build [here](https://gitlab.haskell.org/ghc/head.hackage/-/jobs/1072936#L5098).)_
The `fixed-vector-1.2.1.0` Hackage library fails to compile with GHC HEAD, but does compile with GHC 9.4, 9.2, an..._(Originally noticed in a `head.hackage` build [here](https://gitlab.haskell.org/ghc/head.hackage/-/jobs/1072936#L5098).)_
The `fixed-vector-1.2.1.0` Hackage library fails to compile with GHC HEAD, but does compile with GHC 9.4, 9.2, and earlier. I have made an attempt to minimize it as much as I could. The panic goes away (AFAICT) if you try to combine all of the relevant code into a single module, but it suffices to split things up into the following two modules:
<details>
```hs
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module UnboxedAux
( Arity
, Dim
, DimM
, IVector
, Mutable
, MVector
, Vector(..)
, constructVec
, inspectVec
, gfoldl'
, gunfold'
) where
import Control.Monad.ST (ST, runST)
import Data.Coerce (coerce)
import Data.Data (Data)
import Data.Functor.Const (Const(..))
import Data.Kind (Type)
import GHC.TypeLits (KnownNat, Nat, type (+), type (-))
-----
-- Data.Vector.Fixed.Cont
-----
data PeanoNum = Z
| S PeanoNum
type family Peano (n :: Nat) :: PeanoNum where
Peano 0 = 'Z
Peano n = 'S (Peano (n - 1))
type family Fn (n :: PeanoNum) (a :: Type) (b :: Type) where
Fn 'Z a b = b
Fn ('S n) a b = a -> Fn n a b
newtype Fun n a b = Fun { unFun :: Fn n a b }
type family Dim (v :: Type -> Type) :: Nat
class Arity (Dim v) => Vector v a where
construct :: Fun (Peano (Dim v)) a (v a)
inspect :: v a -> Fun (Peano (Dim v)) a b -> b
type Arity n = ( ArityPeano (Peano n)
, KnownNat n
, Peano (n+1) ~ 'S (Peano n)
)
class ArityPeano n where
accum :: (forall k. t ('S k) -> a -> t k)
-> (t 'Z -> b)
-> t n
-> Fun n a b
applyFun :: (forall k. t ('S k) -> (a, t k))
-> t n
-> (CVecPeano n a, t 'Z)
gunfoldF :: (Data a)
=> (forall b x. Data b => c (b -> x) -> c x)
-> T_gunfold c r a n -> c r
newtype T_gunfold c r a n = T_gunfold (c (Fn n a r))
gfoldl' :: forall c v a. (Vector v a, Data a)
=> (forall x y. Data x => c (x -> y) -> x -> c y)
-> (forall x . x -> c x)
-> v a -> c (v a)
gfoldl' f inj v
= inspect v
$ gfoldlF f (inj $ unFun (construct :: Fun (Peano (Dim v)) a (v a)))
gunfold' :: forall con c v a. (Vector v a, Data a)
=> (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> con -> c (v a)
gunfold' f inj _
= gunfoldF f gun
where
con = construct :: Fun (Peano (Dim v)) a (v a)
gun = T_gunfold (inj $ unFun con) :: T_gunfold c (v a) a (Peano (Dim v))
gfoldlF :: (ArityPeano n, Data a)
=> (forall x y. Data x => c (x -> y) -> x -> c y)
-> c (Fn n a r) -> Fun n a (c r)
gfoldlF f c0 = accum
(\(T_gfoldl c) x -> T_gfoldl (f c x))
(\(T_gfoldl c) -> c)
(T_gfoldl c0)
newtype T_gfoldl c r a n = T_gfoldl (c (Fn n a r))
newtype ContVec n a = ContVec (forall r. Fun (Peano n) a r -> r)
type instance Dim (ContVec n) = n
instance Arity n => Vector (ContVec n) a where
construct = accum
(\(T_mkN f) a -> T_mkN (f . consPeano a))
(\(T_mkN f) -> toContVec $ f (CVecPeano unFun))
(T_mkN id)
inspect (ContVec c) f = c f
{-# INLINE construct #-}
{-# INLINE inspect #-}
newtype T_mkN n_tot a n = T_mkN (CVecPeano n a -> CVecPeano n_tot a)
toContVec :: CVecPeano (Peano n) a -> ContVec n a
toContVec = coerce
newtype CVecPeano n a = CVecPeano (forall r. Fun n a r -> r)
consPeano :: a -> CVecPeano n a -> CVecPeano ('S n) a
consPeano a (CVecPeano cont) = CVecPeano $ \f -> cont $ curryFirst f a
{-# INLINE consPeano #-}
curryFirst :: Fun ('S n) a b -> a -> Fun n a b
curryFirst = coerce
{-# INLINE curryFirst #-}
apply :: Arity n
=> (forall k. t ('S k) -> (a, t k))
-> t (Peano n)
-> ContVec n a
{-# INLINE apply #-}
apply step' z = toContVec $ fst (applyFun step' z)
-----
-- Data.Vector.Fixed.Mutable
-----
type family Mutable (v :: Type -> Type) :: Type -> Type -> Type
type family DimM (v :: Type -> Type -> Type) :: Nat
class (Arity (DimM v)) => MVector v a where
new :: PrimMonad m => m (v (PrimState m) a)
unsafeWrite :: PrimMonad m => v (PrimState m) a -> Int -> a -> m ()
class (Dim v ~ DimM (Mutable v), MVector (Mutable v) a) => IVector v a where
unsafeFreeze :: PrimMonad m => Mutable v (PrimState m) a -> m (v a)
unsafeIndex :: v a -> Int -> a
inspectVec :: forall v a b. (Arity (Dim v), IVector v a) => v a -> Fun (Peano (Dim v)) a b -> b
{-# INLINE inspectVec #-}
inspectVec v
= inspect cv
where
cv :: ContVec (Dim v) a
cv = apply (\(Const i) -> (unsafeIndex v i, Const (i+1)))
(Const 0 :: Const Int (Peano (Dim v)))
constructVec :: forall v a. (Arity (Dim v), IVector v a) => Fun (Peano (Dim v)) a (v a)
{-# INLINE constructVec #-}
constructVec =
accum step
(\(T_new _ st) -> runST $ unsafeFreeze =<< st :: v a)
(T_new 0 new :: T_new v a (Peano (Dim v)))
data T_new v a n = T_new Int (forall s. ST s (Mutable v s a))
step :: (IVector v a) => T_new v a ('S n) -> a -> T_new v a n
step (T_new i st) x = T_new (i+1) $ do
mv <- st
unsafeWrite mv i x
return mv
-----
-- Control.Monad.Primitive
-----
class Monad m => PrimMonad m where
type PrimState m
instance PrimMonad (ST s) where
type PrimState (ST s) = s
```
```hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
module Unboxed (Vec, MVec, Unbox) where
import Data.Data (Data(..), Constr, DataType, Fixity(..), mkConstr, mkDataType)
import Data.Typeable (Typeable)
import GHC.TypeLits (Nat)
import UnboxedAux
data family Vec (n :: Nat) a
data family MVec (n :: Nat) s a
class (Arity n, IVector (Vec n) a, MVector (MVec n) a) => Unbox n a
type instance Mutable (Vec n) = MVec n
type instance Dim (Vec n) = n
type instance DimM (MVec n) = n
instance (Unbox n a) => Vector (Vec n) a where
construct = constructVec
inspect = inspectVec
{-# INLINE construct #-}
{-# INLINE inspect #-}
instance (Typeable n, Unbox n a, Data a) => Data (Vec n a) where
gfoldl = gfoldl'
gunfold = gunfold'
toConstr _ = con_Vec
dataTypeOf _ = ty_Vec
ty_Vec :: DataType
ty_Vec = mkDataType "Data.Vector.Fixed.Unboxed.Vec" [con_Vec]
con_Vec :: Constr
con_Vec = mkConstr ty_Vec "Vec" [] Prefix
```
</details>
To reproduce the error, compile `Unboxed.hs` with optimizations using HEAD:
```
$ ~/Software/ghc-9.5.20220602/bin/ghc -fforce-recomp -O Unboxed.hs
[1 of 2] Compiling UnboxedAux ( UnboxedAux.hs, UnboxedAux.o )
[2 of 2] Compiling Unboxed ( Unboxed.hs, Unboxed.o )
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.5.20220602:
lookupIdSubst
$d(%,,%)_s4JG
InScope {n_a2Be a_a2Bf $dTypeable_a2Bg $dUnbox_a2Bh $dData_a2Bi
$cgfoldl_a2Bo $cgunfold_a2BM c_a2BT $cgmapQl_a2DJ $cgmapQr_a2E3
$cgmapQ_a2Em $cgmapQi_a2EC $cgmapM_a2ES $cgmapMp_a2Fa $cgmapMo_a2Fv
$cp1Vector_a2FS $cconstruct_a2FU $cinspect_a2G9 co_a4bo $krep_a4bW
$krep_a4bX $krep_a4bY $krep_a4bZ $krep_a4c0 $krep_a4c1 eta_i4G9
eta1_i4Gc eta2_i4Ge $fDataVec $fVectorVeca $tcMVec $tcUnbox $tcVec
$trModule ty_Vec con_Vec ty_Vec_s4Jb ty_Vec_s4Jc ty_Vec_s4Jd
$trModule_s4Je $trModule_s4Jf $trModule_s4Jg $trModule_s4Jh
$tcVec_s4Ji $tcVec_s4Jj $cp1Data_s4Jk $tcMVec_s4Jq $tcMVec_s4Jr
$tcUnbox_s4Js $tcUnbox_s4Jt $cgmapT_s4Ju}
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:182:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Subst.hs:260:17 in ghc:GHC.Core.Subst
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```9.6.1Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21685CSE doesn't correctly handle shadowing.2022-08-02T12:26:32ZAndreas KlebingerCSE doesn't correctly handle shadowing.Here is the relevant core input:
```haskell
join {
exit_X2 :: Int# -> Array Int ()
exit_X2 (wild_X1 :: Int#)
= case $windexError
showSignedInt l_a12J u_a12K (I# wild_X1) ...Here is the relevant core input:
```haskell
join {
exit_X2 :: Int# -> Array Int ()
exit_X2 (wild_X1 :: Int#)
= case $windexError
showSignedInt l_a12J u_a12K (I# wild_X1) (unpackCString# "Int"#)
of wild_00 {
} } in
joinrec {
go3_a1fA :: Int# -> State# RealWorld -> Array Int ()
go3_a1fA (x_a1fB :: Int#) (eta_B0 :: State# RealWorld)
= case x_a1fB of wild_X1 {
__DEFAULT ->
join {
$j_X2 :: Array Int ()
$j_X2 = jump exit_X2 wild_X1 } in
case <=# 1# wild_X1 of { ... };
1# -> jump go3_a1fA 2# eta_B0
}; } in
```
The tricky part here is that the first X2 `exit_X2` and the second X2 `$j_X2` have the same unique! It gets even tricker as the first `exit_X2` is mentioned in the body of `$j_X2` however `X2` in this context refers to `exit_X2` not `$j_X2`.
While is this a very rare combination it's valid core.
CSE get's this wrong however.
After CSE we end up with this:
```
join {
exit_X2 :: Int# -> Array Int ()
exit_X2 (wild_X1 :: Int#)
= ... } in
joinrec {
go3_a1fA (x_a1fB :: Int#) (eta_B0 :: State# RealWorld)
= case x_a1fB of wild_X1 {
__DEFAULT ->
join {
$j_X6 :: Array Int ()
$j_X6 = jump $j_X6 x_a1fB }
in
....
```
However `$j_X6 = jump $j_X6 x_a1fB` is neither correct nor does it compile as `$j_X6` isn't in scope in `$j_X6`s rhs. (Thankfully!)
This is because CSE is subtly broken. We have:
```
cseBind :: TopLevelFlag -> CSEnv -> CoreBind -> (CSEnv, CoreBind)
cseBind toplevel env (NonRec b e)
= (env2, NonRec b2 e2)
where
(env1, b1) = addBinder env b
(env2, (b2, e2)) = cse_bind toplevel env1 (b,e) b1
```
`addBinder` is essentially `substBndr`, we rename `$j_X2` to `$j_X6` and then in `cse_bind` we process the rhs:
```
cse_bind :: TopLevelFlag -> CSEnv -> (InId, InExpr) -> OutId -> (CSEnv, (OutId, OutExpr))
cse_bind toplevel env (in_id, in_rhs) out_id
...
| Just arity <- isJoinId_maybe in_id
-- See Note [Look inside join-point binders]
= let (params, in_body) = collectNBinders arity in_rhs
(env', params') = addBinders env params
out_body = tryForCSE env' in_body
in (env, (out_id, mkLams params' out_body))
...
```
The problem is that we process the rhs with the substitution `X2 -> $j_X6` active.
So in the rhs of `$j_X2 = jump exit_X2 wild_X1` we end up replacing `exit_X2` with `$j_X6` because the code assumes it refers to `$j_X2`. And we end up with `$j_X6 = jump $j_X6 wild_X1`. In short it's a mess.
I think the solution is that we need to use `addBinder` *after* we processed the rhs instead of before. Unless it's a recursive binder. This shouldn't be hard to fix I will write a patch.https://gitlab.haskell.org/ghc/ghc/-/issues/21670Perf builds of HEAD seem broken on Windows2023-11-07T10:58:26Zsheafsam.derbyshire@gmail.comPerf builds of HEAD seem broken on WindowsWhen building HEAD (currently at ed37027f) with a perf flavour with Hadrian on Windows, I seem to obtain a completely broken GHC.
```bash
git clean -xfd
./boot && ./configure --enable-tarballs-autodownload
hadrian/build.bat -j --flavour...When building HEAD (currently at ed37027f) with a perf flavour with Hadrian on Windows, I seem to obtain a completely broken GHC.
```bash
git clean -xfd
./boot && ./configure --enable-tarballs-autodownload
hadrian/build.bat -j --flavour=perf
```
I get a GHC that seems unable to do anything. `ghc --version` stalls for a bit and then returns silently, same with `ghci`. `ghc-pkg` segfaults:
```
$ "_build/stage1/bin/ghc-pkg.exe"
Access violation in generated code when executing data at 0x7ff75be6dd58
Attempting to reconstruct a stack trace...
Frame Code address
* 0xdc9c57d8f0 0x7ff75be6dd58 C:\Haskell\ghc\master\_build\stage1\bin\ghc-pkg.exe+0x33fdd58
* 0xdc9c57d8f8 0xffffffffffffffff
* 0xdc9c57d900 0x2be00000052
* 0xdc9c57d908 0x500000001
* 0xdc9c57d910 0xdc9c57e3f0
```
Trying to run the test-suite fails with the error
```
Exception: Command failed: ['"C:/Haskell/ghc/primops/_build/stage1/bin/ghc-pkg.exe"', 'dump']
```
presumably because `ghc-pkg` segfaults.
Development flavours seem to not be affected; I've been building `devel2` ghcs without issue.https://gitlab.haskell.org/ghc/ghc/-/issues/21634ghc-9.4.1-alpha2 does not compile with ghc 9.0.22022-07-25T08:55:12Zkgardasghc-9.4.1-alpha2 does not compile with ghc 9.0.2## Summary
GHC 9.4.1-alpha2 does not compile with GHC 9.0.2 on Ubuntu 20.04, the compilation fails with:
```
ar: creating _build/stage0/libraries/exceptions/build/libHSexceptions-0.10.5.a
/----------------------------------------------...## Summary
GHC 9.4.1-alpha2 does not compile with GHC 9.0.2 on Ubuntu 20.04, the compilation fails with:
```
ar: creating _build/stage0/libraries/exceptions/build/libHSexceptions-0.10.5.a
/----------------------------------------------------------------------------\
| Successfully built library 'exceptions' (Stage0, way v). |
| Library: _build/stage0/libraries/exceptions/build/libHSexceptions-0.10.5.a |
| Library synopsis: Extensible optionally-pure exceptions. |
\----------------------------------------------------------------------------/
| Copy package 'exceptions'
# cabal-copy (for _build/stage0/lib/package.conf.d/exceptions-0.10.5.conf)
| Register package 'exceptions'
# cabal-register (for _build/stage0/lib/package.conf.d/exceptions-0.10.5.conf)
| Run Ar Pack Stage0: _build/stage0/libraries/bytestring/build/c/cbits/fpstring.o (and 32 more) => _build/stage0/libraries/bytestring/build/libHSbytestring-0.11.3.0.a
ar: creating _build/stage0/libraries/bytestring/build/libHSbytestring-0.11.3.0.a
/--------------------------------------------------------------------------------------\
| Successfully built library 'bytestring' (Stage0, way v). |
| Library: _build/stage0/libraries/bytestring/build/libHSbytestring-0.11.3.0.a |
| Library synopsis: Fast, compact, strict and lazy byte strings with a list interface. |
\--------------------------------------------------------------------------------------/
| Configure package 'binary'
| Copy package 'bytestring'
# cabal-copy (for _build/stage0/lib/package.conf.d/bytestring-0.11.3.0.conf)
| Register package 'bytestring'
# cabal-register (for _build/stage0/lib/package.conf.d/bytestring-0.11.3.0.conf)
| Copy package 'bytestring'
# cabal-copy (for _build/stage0/lib/package.conf.d/bytestring-0.10.12.1.conf)
| Register package 'bytestring'
# cabal-register (for _build/stage0/lib/package.conf.d/bytestring-0.10.12.1.conf)
Error, rule finished running but did not produce file:
_build/stage0/lib/package.conf.d/bytestring-0.10.12.1.conf
Build failed.
karel@silence:/tmp/ghc-9.4.0.20220523$
```
## Steps to reproduce
Take Ubuntu 20.04, install GHC 9.0.2 and try to use it hadrian compile GHC 9.4.1-alpha2. This is 100% reproducible. Failed 4 times from 4 attempts (with -j without it, after wiping dir again). etc.
## Expected behavior
GHC 9.0.2 should be able to compile 9.4.1-alpha2 as per last 2 major release should be able to bootstrap new GHC, right?
## Environment
* GHC version used: 9.0.2
Optional:
* Operating System: Ubuntu 20.04.x LTS
* System Architecture: amd64Matthew PickeringMatthew Pickeringhttps://gitlab.haskell.org/ghc/ghc/-/issues/21624"IntMulMayOfloOp" primop compiles to wrong Aarch64 assembly2022-08-05T14:46:34ZNatsu Kagami"IntMulMayOfloOp" primop compiles to wrong Aarch64 assembly## Summary
The primop `IntMulMayOfloOp` is being translated to a `MUL` instruction followed by a `CSET` (conditional set, with overflow flag) instruction on Aarch64 (see https://gitlab.haskell.org/ghc/ghc/-/blob/master/compiler/GHC/CmmT...## Summary
The primop `IntMulMayOfloOp` is being translated to a `MUL` instruction followed by a `CSET` (conditional set, with overflow flag) instruction on Aarch64 (see https://gitlab.haskell.org/ghc/ghc/-/blob/master/compiler/GHC/CmmToAsm/AArch64/CodeGen.hs#L894).
However, this is not correct: the overflow flag is never set on a `MUL` instruction. According to [A64 documentation](https://developer.arm.com/documentation/100076/0100/A64-Instruction-Set-Reference/Condition-Codes/Condition-flags?lang=en),
> Overflow occurs if the result of a signed add, subtract, or compare is greater than or equal to 2^31, or less than -2^31.
This means that the current primop will most likely return 0 all the time, which is wrong and potentially dangerous.
## Steps to reproduce
The following code always prints 0 in ghc 9.2.2 on Apple M1, but not in ghc 8.10.7 (which uses LLVM backend):
```hs
{-# LANGUAGE MagicHash #-}
module Main where
import GHC.Exts
import Data.Bits
unpack (I# a#) = a#
k :: Int
k = 134534534134534000 -- obviously does not fit in an int32, and so will overflow when squared.
bakaVariable = I# (mulIntMayOflo# (unpack k) (unpack k))
main = do
print bakaVariable
```
## Expected behavior
Should not print 0 at all.
## Environment
* GHC version used: 9.2.2
Optional:
* Operating System: Mac OS Monterey 12.3.1
* System Architecture: Aarch64 (Apple M1 Macbook Air)9.2.4Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21584Job Failed #1048795 due to too long build log cause by C compiler warnings2022-05-18T08:57:30ZMatthew PickeringJob Failed #1048795 due to too long build log cause by C compiler warningsJob [#1048795](https://gitlab.haskell.org/ghc/ghc/-/jobs/1048795) failed for e0566a9b3e0655d71eea4ea7778ad7ad3b8c8fbe:
The build log contains many warnings of the form:
```
250 | EXTERN_INLINE bool LOOKS_LIKE_INFO_PTR_NOT_NULL (StgWord...Job [#1048795](https://gitlab.haskell.org/ghc/ghc/-/jobs/1048795) failed for e0566a9b3e0655d71eea4ea7778ad7ad3b8c8fbe:
The build log contains many warnings of the form:
```
250 | EXTERN_INLINE bool LOOKS_LIKE_INFO_PTR_NOT_NULL (StgWord p)
rts/include/rts/storage/ClosureMacros.h:66:32: error:
warning: no previous prototype for ‘itbl_to_fun_itbl’ [-Wmissing-prototypes]
EXTERN_INLINE StgFunInfoTable *itbl_to_fun_itbl(const StgInfoTable *i) {return (StgFunInfoTable *)(i + 1) - 1;}
^
|
66 | EXTERN_INLINE StgFunInfoTable *itbl_to_fun_itbl(const StgInfoTable *i) {return (StgFunInfoTable *)(i + 1) - 1;}
| ^
|
```
which renders the build log useless.Andreas KlebingerAndreas Klebingerhttps://gitlab.haskell.org/ghc/ghc/-/issues/21579AArch64/Darwin build fails due to bytestring's NEON usage2022-05-19T12:46:55ZBen GamariAArch64/Darwin build fails due to bytestring's NEON usageWhen bumping the `bytestring` dependency in !8233 I found that the build failed with:
```
| Run Ghc CompileCWithGhc Stage0: libraries/bytestring/cbits/itoa.c => _build/stage0/libraries/bytestring/build/c/cbits/itoa.o
Command line: /usr/b...When bumping the `bytestring` dependency in !8233 I found that the build failed with:
```
| Run Ghc CompileCWithGhc Stage0: libraries/bytestring/cbits/itoa.c => _build/stage0/libraries/bytestring/build/c/cbits/itoa.o
Command line: /usr/bin/clang -std=c11 -DNDEBUG=1 -E -MM -MG -MF _build/stage0/libraries/bytestring/build/c/cbits/aarch64/is-valid-utf8.o.d -MT _build/stage0/libraries/bytestring/build/c/cbits/aarch64/is-valid-utf8.o -I_build/stage0/libraries/bytestring/build -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi -I_build/stage0/libraries/bytestring/build/include -Ilibraries/bytestring/include -I/nix/store/iypbf5sw86qc890pl53wwppk00mlq7i7-ghc/lib/ghc-9.2.2/lib/aarch64-osx-ghc-9.2.2/base-4.16.1.0/include -I/nix/store/iypbf5sw86qc890pl53wwppk00mlq7i7-ghc/lib/ghc-9.2.2/lib/aarch64-osx-ghc-9.2.2/ghc-bignum-1.2/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi -I/nix/store/iypbf5sw86qc890pl53wwppk00mlq7i7-ghc/lib/ghc-9.2.2/lib/aarch64-osx-ghc-9.2.2/rts-1.0.2/include -x c libraries/bytestring/cbits/aarch64/is-valid-utf8.c
===> Command failed with error code: 1
In file included from libraries/bytestring/cbits/aarch64/is-valid-utf8.c:35:
/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/arm_neon.h:28:2: error: "NEON intrinsics not available with the soft-float ABI. Please use -mfloat-abi=softfp or -mfloat-abi=hard"
#error "NEON intrinsics not available with the soft-float ABI. Please use -mfloat-abi=softfp or -mfloat-abi=hard"
^
1 error generated.
Command failed
Build failed.
hadrian/build-cabal --flavour=validate -j8 --broken-test= --bignum=gmp --docs=no-sphinx stage1:exe:ghc-bin failed
```
I'm a bit unclear on what is going on here; surely the Darwin toolchain doesn't default to a soft-FP ABI by default!?9.4.1Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21558Short file produces panic on ghc-9.2.22022-06-15T16:31:36ZDavid FoxShort file produces panic on ghc-9.2.2The file below produces a panic on ghc-9.2.2:
```
import Data.Map
type family IxValue (m :: *) :: *
type family Index (m :: *) :: *
data Op a where
Insert :: (a ~ Map (Index a) (IxValue a)) => (Int, Index a, IxValue a) -> Op a
inst...The file below produces a panic on ghc-9.2.2:
```
import Data.Map
type family IxValue (m :: *) :: *
type family Index (m :: *) :: *
data Op a where
Insert :: (a ~ Map (Index a) (IxValue a)) => (Int, Index a, IxValue a) -> Op a
instance Ord a => Ord (Op a) where
compare (Insert a1) (Insert b1) = compare a1 b1
```
Sorry I don't have access to head right now.9.2.3https://gitlab.haskell.org/ghc/ghc/-/issues/21490Live lock in acquire_spin_lock_slow_path2023-11-03T12:39:28ZGuillaume BouchardLive lock in acquire_spin_lock_slow_path## Summary
My program is sometime stuck, tacking CPU (100% of one capability), and making no progress.
When using `perf top`, I can observe that all the time is spent in `acquire_spin_lock_slow_path`, see ![image](/uploads/c60463add19b...## Summary
My program is sometime stuck, tacking CPU (100% of one capability), and making no progress.
When using `perf top`, I can observe that all the time is spent in `acquire_spin_lock_slow_path`, see ![image](/uploads/c60463add19b24e1ff7acc0b20b182eb/image.png)
## Steps to reproduce
Unfortunately, I cannot reproduce easilly. What I know is:
- I'm using GHC 9.2.1
- This program is complex, involve multi threading, using `-N8`
- The program uses weak reference finalizers
## Expected behavior
My program should not live lock?
## Environment
* GHC version used: 9.2.1
Optional:
* Operating System: Linux
* System Architecture: x86_64
I found this log https://gitlab.haskell.org/ghc/ghc/-/snippets/2047 posted by @bgamari which may be related, but no ticket associated. At least, if the problem is already known / fixed, this ticket will be an entrypoint for reference.Ben GamariBen Gamari