Skip to content

Commit

Permalink
Increase the simplifier tick limit on GHC 8.0
Browse files Browse the repository at this point in the history
This is a crude but effective workaround for #50. I have opened #51 as a
reminder to investigate this more carefully and come up with a more robust fix.

Resolves #50.
  • Loading branch information
RyanGlScott committed Jan 2, 2022
1 parent 188e829 commit 4f0f1b0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### next [????.??.??]
* Work around a GHC 8.0–specific issue in which GHC's simplifier ticks would
become exhausted, causing compilation to fail.

### 3.9.4 [2021.12.26]
* Allow the test suite to build with `text-2.0.*` and
`transformers-compat-0.7.1`.
Expand Down
24 changes: 24 additions & 0 deletions src/TextShow/Data/Complex.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
#if __GLASGOW_HASKELL__ == 800
-- See Note [Increased simpl-tick-factor on old GHCs]
{-# OPTIONS_GHC -fsimpl-tick-factor=200 #-}
#endif

{-|
Module: TextShow.Data.Ratio
Expand Down Expand Up @@ -30,3 +35,22 @@ instance TextShow a => TextShow (Complex a) where

-- | /Since: 2/
$(deriveTextShow1 ''Complex)

{-
Note [Increased simpl-tick-factor on old GHCs]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compiling certain text-show modules with optimizations on old versions of GHC
(particularly 8.0 and 8.2) will trigger "Simplifier ticks exhausted" panics.
To make things worse, this sometimes depends on whether a certain version of
the text library is being used. There are two possible ways to work around
this issue:
1. Figure out which uses of the INLINE pragma in text-show are responsible
and remove them.
2. Just increase the tick limit.
Since executing on (1) will require a lot of effort to fix an issue that only
happens on old versions of GHC, I've opted for the simple solution of (2) for
now. Issue #51 is a reminder to revisit this choice.
-}
4 changes: 4 additions & 0 deletions src/TextShow/GHC/Stats.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fno-warn-deprecations #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
# if __GLASGOW_HASKELL__ == 800
-- See Note [Increased simpl-tick-factor on old GHCs] in TextShow.Data.Complex
{-# OPTIONS_GHC -fsimpl-tick-factor=200 #-}
# endif
#endif

{-|
Expand Down
8 changes: 2 additions & 6 deletions tests/Instances/GHC/RTS/Flags.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
{-# LANGUAGE TypeSynonymInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
# if __GLASGOW_HASKELL__ == 802
-- For whatever reason, compiling this module with optimizations on GHC 8.2.2
-- triggers a "Simplifier ticks exhausted" panic, and increasing the tick limit
-- doesn't seem to help. Moreover, 8.2.2 is the /only/ GHC version I have seen
-- this happen on. Life is short, so I'm just going to work around this by
-- disabling optimizations on 8.2.2 only.
{-# OPTIONS_GHC -O0 #-}
-- See Note [Increased simpl-tick-factor on old GHCs] in TextShow.Data.Complex
{-# OPTIONS_GHC -fsimpl-tick-factor=200 #-}
# endif
#endif

Expand Down

0 comments on commit 4f0f1b0

Please sign in to comment.