Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inlining splitAtArrayListRev causes compilation to hang when cross-compiling to aarch64 #2840

Open
georgefst opened this issue Sep 26, 2024 · 6 comments
Assignees
Labels
type:build build related
Milestone

Comments

@georgefst
Copy link
Contributor

This is a weird one, but I've found that compilation gets stuck (I've left it for over an hour, when it should take seconds) when I'm targeting ARM. It's solved by removing the {-# INLINE splitAtArrayListRev #-} pragma.

This may well be a GHC bug, but I'm recording it here for now. Any ideas? I can try to investigate further if not, e.g. bisecting across Streamly and GHC versions.

georgefst added a commit to georgefst/streamly that referenced this issue Sep 26, 2024
@harendra-kumar
Copy link
Member

No idea about what the root cause might be. But this module is deprecated and we can remove the pragma as a safeguard against this issue.

Try to find which stage of the compiler is hanging, is it core, stg, cmm or asm generation? You may try the -ddump options with -ddump-to-file for various stages to check if the output is growing forever due to some infinite loop. I guess GHC uses llvm backend for ARM or is it using native code generator now? The problem will likely be before the llvm stage.

@harendra-kumar harendra-kumar added this to the 0.11.0 milestone Sep 26, 2024
@harendra-kumar harendra-kumar added the type:build build related label Sep 26, 2024
@georgefst
Copy link
Contributor Author

georgefst commented Sep 26, 2024

I guess GHC uses llvm backend for ARM or is it using native code generator now? The problem will likely be before the llvm stage.

There's been a native codegen since GHC 9.2. I'm using that with an official toolchain from ARM and a locally-built cross-compiling GHC.

Anyway, using the following cabal.project.local:

program-options
  ghc-options:
    -ddump-to-file
    -ddump-parsed
    -ddump-rn
    -ddump-tc
    -ddump-ds
    -ddump-inlinings
    -ddump-simpl
produces the following diff (slightly cleaned-up, new version without pragma is green):
diff -r ../dist-newstyle/build/aarch64-linux/ghc-9.10.1/streamly-core-0.3.0/build/src/Streamly/Internal/Data/Array/Stream.dump-ds /home/gthomas/Desktop/non-inlined/Stream.dump-ds
341c341
< splitAtArrayListRev [InlPrag=INLINE (sat-args=2)]
---
> splitAtArrayListRev
344c344
<  Unf=Unf{Src=StableUser, TopLvl=True,
---
>  Unf=Unf{Src=<vanilla>, TopLvl=True,
346,461c346
<          Guidance=ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False)
<          Tmpl= \ (@a_aaQ5F)
<                  ($dUnbox_aaQ5G :: Unbox a_aaQ5F)
<                  (n_aaPQl :: Int)
<                  (ls_aaPQm [Occ=Once2] :: [Array a_aaQ5F]) ->
<                  letrec {
<                    go_aaPQn [Occ=LoopBreaker]
<                      :: Int -> [Array a_aaQ5F] -> ([Array a_aaQ5F], [Array a_aaQ5F])
<                    [LclId]
<                    go_aaPQn
<                      = \ (ds_daRfE :: Int) (ds_daRfF [Occ=Once1!] :: [Array a_aaQ5F]) ->
<                          case ds_daRfF of {
<                            [] ->
<                              (GHC.Types.[] @(Array a_aaQ5F), GHC.Types.[] @(Array a_aaQ5F));
<                            : x_aaPQp xs_aaPQq ->
<                              let {
<                                len_aaPQr :: Int
<                                [LclId]
<                                len_aaPQr = Array.length @a_aaQ5F $dUnbox_aaQ5G x_aaPQp } in
<                              let {
<                                ds_daRg2 :: ([Array a_aaQ5F], [Array a_aaQ5F])
<                                [LclId]
<                                ds_daRg2
<                                  = go_aaPQn
<                                      (- @Int
<                                         ghc-internal:GHC.Internal.Num.$fNumInt
<                                         ds_daRfE
<                                         len_aaPQr)
<                                      xs_aaPQq } in
<                              case > @Int GHC.Classes.$fOrdInt ds_daRfE len_aaPQr of {
<                                False ->
<                                  case == @Int GHC.Classes.$fEqInt ds_daRfE len_aaPQr of {
<                                    False ->
<                                      let {
<                                        contents_aaPQu
<                                          :: Streamly.Internal.Data.MutByteArray.Type.MutByteArray
<                                        [LclId]
<                                        contents_aaPQu
<                                          = case x_aaPQp of
<                                            { Array bx_daRKi [Occ=Once1] _ [Occ=Dead] _ [Occ=Dead] ->
<                                            Streamly.Internal.Data.MutByteArray.Type.MutByteArray
<                                              bx_daRKi
<                                            } } in
<                                      let {
<                                        end_aaPQw :: Int
<                                        [LclId]
<                                        end_aaPQw
<                                          = case x_aaPQp of
<                                            { Array _ [Occ=Dead] _ [Occ=Dead] bx_daRKe [Occ=Once1] ->
<                                            GHC.Types.I# bx_daRKe
<                                            } } in
<                                      case x_aaPQp of ds_daRfY [Occ=Once1!] { __DEFAULT ->
<                                      let {
<                                        end1_aaPQx :: Int
<                                        [LclId]
<                                        end1_aaPQx
<                                          = - @Int
<                                              ghc-internal:GHC.Internal.Num.$fNumInt
<                                              end_aaPQw
<                                              (* @Int
<                                                 ghc-internal:GHC.Internal.Num.$fNumInt
<                                                 ds_daRfE
<                                                 (sizeOf
<                                                    @a_aaQ5F
<                                                    $dUnbox_aaQ5G
<                                                    (ghc-internal:GHC.Internal.Data.Proxy.Proxy
<                                                       @(*) @a_aaQ5F))) } in
<                                      (ghc-internal:GHC.Internal.Base.build
<                                         @(Array a_aaQ5F)
<                                         (\ (@a_daRfP)
<                                            (c_daRfQ [Occ=Once1!, OS=OneShot]
<                                               :: Array a_aaQ5F -> a_daRfP -> a_daRfP)
<                                            (n_daRfR [Occ=Once1, OS=OneShot] :: a_daRfP) ->
<                                            c_daRfQ
<                                              (Streamly.Internal.Data.Array.Type.$WArray
<                                                 @a_aaQ5F contents_aaPQu end1_aaPQx end_aaPQw)
<                                              n_daRfR),
<                                       GHC.Types.:
<                                         @(Array a_aaQ5F)
<                                         (Streamly.Internal.Data.Array.Type.$WArray
<                                            @a_aaQ5F
<                                            contents_aaPQu
<                                            (case ds_daRfY of
<                                             { Array _ [Occ=Dead] bx_daRKg [Occ=Once1]
<                                                     _ [Occ=Dead] ->
<                                             GHC.Types.I# bx_daRKg
<                                             })
<                                            end1_aaPQx)
<                                         xs_aaPQq)
<                                      };
<                                    True ->
<                                      (ghc-internal:GHC.Internal.Base.build
<                                         @(Array a_aaQ5F)
<                                         (\ (@a_daRfK)
<                                            (c_daRfL [Occ=Once1!, OS=OneShot]
<                                               :: Array a_aaQ5F -> a_daRfK -> a_daRfK)
<                                            (n_daRfM [Occ=Once1, OS=OneShot] :: a_daRfK) ->
<                                            c_daRfL x_aaPQp n_daRfM),
<                                       xs_aaPQq)
<                                  };
<                                True ->
<                                  (GHC.Types.:
<                                     @(Array a_aaQ5F)
<                                     x_aaPQp
<                                     (case ds_daRg2 of { (xs'_aaQ6o [Occ=Once1], _ [Occ=Dead]) ->
<                                      xs'_aaQ6o
<                                      }),
<                                   case ds_daRg2 of { (_ [Occ=Dead], xs''_aaQ6p [Occ=Once1]) ->
<                                   xs''_aaQ6p
<                                   })
<                              }
<                          }; } in
<                  case <= @Int GHC.Classes.$fOrdInt n_aaPQl (GHC.Types.I# 0#) of {
<                    False -> go_aaPQn n_aaPQl ls_aaPQm;
<                    True -> (GHC.Types.[] @(Array a_aaQ5F), ls_aaPQm)
<                  }}]
---
>          Guidance=NEVER}]
465c350
<       (eta_B0 :: Int)
---
>       (n_aaPQl :: Int)
578,579c463,464
<       case <= @Int GHC.Classes.$fOrdInt eta_B0 (GHC.Types.I# 0#) of {
<         False -> go_aaPQn eta_B0 ls_aaPQm;
---
>       case <= @Int GHC.Classes.$fOrdInt n_aaPQl (GHC.Types.I# 0#) of {
>         False -> go_aaPQn n_aaPQl ls_aaPQm;
diff -r ../dist-newstyle/build/aarch64-linux/ghc-9.10.1/streamly-core-0.3.0/build/src/Streamly/Internal/Data/Array/Stream.dump-inlinings /home/gthomas/Desktop/non-inlined/Stream.dump-inlinings
11,13d10
< Inlining done: Streamly.Internal.Data.Array.Type.length
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
< Inlining done: GHC.Internal.Num.$fNumInt_$c*
22,23d18
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
46,47d40
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
60,61d52
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
73,74d63
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
98,99d86
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
101,106d87
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.leInt
144,145d124
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
147,152d125
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.leInt
170,171d142
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
173,178d143
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.leInt
196,197d160
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
254,255d216
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
277,278d237
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
306,307d264
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
335,336d291
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
395,402d349
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.leInt
430,437d376
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.leInt
477,484d415
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.leInt
524,531d454
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.leInt
598,605d520
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.leInt
633,640d547
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.leInt
680,687d586
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.leInt
727,734d625
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.leInt
799,806d689
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.leInt
834,841d716
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.leInt
881,888d755
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.leInt
928,935d794
< Inlining done:
<     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.leInt
973,975d831
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Internal.Base.divInt
982,984d837
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
993,995d845
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
1000,1002d849
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
1013,1017d859
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Internal.Base.divInt
1024,1026d865
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
1031,1033d869
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
1042,1044d877
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
1053,1055d885
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
1064,1066d893
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
1071,1073d897
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
1082,1084d905
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
1093,1095d913
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
1104,1106d921
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
1111,1113d925
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
1122,1124d933
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
1133,1135d941
< Inlining done: GHC.Internal.Base.divInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
1151,1158d956
< Inlining done: GHC.Classes.divInt#
< Inlining done: GHC.Classes.divInt#
< Inlining done: GHC.Classes.divInt#
< Inlining done: GHC.Classes.divInt#
< Inlining done: GHC.Classes.divInt#
< Inlining done: GHC.Classes.divInt#
< Inlining done: GHC.Classes.divInt#
< Inlining done: GHC.Classes.divInt#
1160,1164d957
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
1167d959
< Inlining done: GHC.Classes.leInt
1173,1178c965,966
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
---
> Inlining done: GHC.Classes.leInt
> Inlining done: GHC.Internal.Base.build
1181,1186d968
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.leInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
1189d970
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
1200a982
> Inlining done: GHC.Classes.leInt
1205a988
> Inlining done: GHC.Internal.Num.$fNumInt_$c-
1216a1000
> Inlining done: GHC.Classes.leInt
1221a1006
> Inlining done: GHC.Internal.Num.$fNumInt_$c-
1234d1018
< Inlining done: GHC.Classes.leInt
1237d1020
< Inlining done: GHC.Classes.leInt
1242d1024
< Inlining done: GHC.Classes.leInt
1267,1273d1048
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
1283,1289d1057
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
1308,1314d1075
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
1333,1339d1093
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.gtInt
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Internal.Base.build
< Inlining done: GHC.Classes.eqInt
< Inlining done: GHC.Classes.eqInt
1349,1350d1102
< Inlining done: GHC.Classes.leInt
< Inlining done: GHC.Classes.leInt
1352d1103
< Inlining done: GHC.Classes.leInt
1356d1106
< Inlining done: GHC.Classes.leInt
1367,1368d1116
< Inlining done: GHC.Classes.divInt#
< Inlining done: GHC.Classes.divInt#
1379d1126
< Inlining done: GHC.Classes.divInt#
1385d1131
< Inlining done: GHC.Classes.divInt#
1390d1135
< Inlining done: GHC.Classes.divInt#
1397d1141
< Inlining done: GHC.Classes.divInt#
1403d1146
< Inlining done: GHC.Classes.divInt#
1408d1150
< Inlining done: GHC.Classes.divInt#
1419,1422d1160
< Inlining done: GHC.Classes.divInt#
< Inlining done: GHC.Classes.divInt#
< Inlining done: GHC.Classes.divInt#
< Inlining done: GHC.Classes.divInt#
1431,1434d1168
< Inlining done: GHC.Classes.divInt#
< Inlining done: GHC.Classes.divInt#
< Inlining done: GHC.Classes.divInt#
< Inlining done: GHC.Classes.divInt#
1440,1454d1173
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
1460,1461d1178
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
1464d1180
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
1469d1184
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
1474,1478d1188
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
1484,1486d1193
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
1489d1195
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
1492,1499d1197
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
1541,1543d1238
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
1552,1554d1246
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
1565,1567d1256
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
1578,1580d1266
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: Streamly.Internal.Data.Array.Type.$WArray
< Inlining done: GHC.Internal.Num.$fNumInt_$c-
1589a1276,1339
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
> Inlining done:
>     Streamly.Internal.Data.Array.Stream.splitAtArrayListRev
Only in /home/gthomas/Desktop/non-inlined: Stream.dump-simpl

So it looks like, unsurprisingly, things get stuck at the inlining stage. Even with all these flags (removing --dump-to-file) I don't see any further output produced once GHC hangs. So I still don't know what's going on.

No idea about what the root cause might be. But this module is deprecated and we can remove the pragma as a safeguard against this issue.

Sounds like a good idea, thanks!

@harendra-kumar
Copy link
Member

I am assuming you are not using fusion-plugin, so we can rule that out.

If this is at the simplifier level then why is this happening on arm architecture only? It should be independent of arch. Unless the specific/cross compiling GHC you are using is different from the regular one. Can you use exactly the same GHC but for x86_64?

We can try to extract a minimal example by removing everything else from this module and keep only one user of this function.

georgefst added a commit to georgefst/hello-hs that referenced this issue Sep 27, 2024
This is just a quick experiment to see whether `nix build .#aarch64-unknown-linux-gnu:hello-hs:exe:hello-hs` shows the same behaviour as with my non-Nix cross-compiler. See composewell/streamly#2840.
@georgefst
Copy link
Contributor Author

georgefst commented Sep 27, 2024

I'm not using fusion-plugin, and my cross GHC is built from the commit tagged as the 9.10.1 release, so it should have the same source as my GHCup-distributed native GHC.

I'd like to experiment with different GHC versions, but building cross-compilers is still a bit slow and flaky. Haskell.Nix does effectively distribute binaries, but this isn't too reliable either at the moment (input-output-hk/haskell.nix#1824, input-output-hk/haskell.nix#2236, input-output-hk/haskell.nix#2231). I did somehow manage to get a Haskell.Nix cross-compiler for GHC 9.10.1, and it appears to actually start hanging even earlier in the process of building streamly-core (Streamly.Internal.Data.Fold.Step), regardless of whether I use my fork to avoid the inlining.

Anyway, that's all the time I'm able to spend debugging this for a few days at least.

@harendra-kumar
Copy link
Member

I did somehow manage to get a Haskell.Nix cross-compiler for GHC 9.10.1, and it appears to actually start hanging even earlier in the process of building streamly-core (Streamly.Internal.Data.Fold.Step), regardless of whether I use my fork to avoid the inlining.

That's not a good news. GHC folks should know about this. Is this cross compiler specific?

@georgefst
Copy link
Contributor Author

That's not a good news. GHC folks should know about this.

Indeed. I have a few other GHC-related bug reports to open in the coming days. I'll add it to the list.

Is this cross compiler specific?

I guess so. I have another aarch64 system where I use native compilation (well, via QEMU) with GHC 9.10.1 and I haven't had any issues with Streamly there.

@adithyaov adithyaov self-assigned this Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:build build related
Projects
None yet
Development

No branches or pull requests

3 participants