[WIP] Integrating prettyprint into GHC.
Needs RevisionPublic

Authored by bollu on Jun 15 2017, 6:58 AM.

Details

Summary

The current goal is to first bring in Text, then prettyprint, and then
rip out the old code to make use of the prettyprint library.

bollu created this revision.Jun 15 2017, 6:58 AM

What ticket is this related to? Adding text as a dependency seems like a big change.

bollu added a comment.Jun 15 2017, 9:08 AM

This is related to bringing prettyprint within GHC to improve the front-end for error messages and the like.

bollu updated this revision to Diff 12843.Jun 15 2017, 9:10 AM
  • fix Text import to be qualified
  • Set version numbers of text to 1.2.*
bollu updated this revision to Diff 12844.Jun 15 2017, 9:14 AM
  • Update submodules, see if this causes the diff to show the actual diff
bollu updated this revision to Diff 12845.Jun 15 2017, 9:45 AM

try arc diff again, hopefully picks up the smaller changeset this time.

The build breaks because it treats the unused import of Text as an error. How do I ignore this? Thanks!

bollu updated this revision to Diff 12847.Jun 15 2017, 12:08 PM
  • [WIP] trying to pick up pretty printer. Boot isn't picking it up
  • [WIP] change gitmodules to match others'
  • [WIP] prettyprinter is not getting pick up. Why?

@bgamari : why does ./boot not create ghc.mk files for libraries/prettyprinter?

bollu updated this revision to Diff 12849.Jun 15 2017, 4:36 PM

Split out the core of prettyprinter into separate submodule. It seems that
boot cannot deal with cabal.project, while the prettyprinter repo uses this.

The next step is to replace all uses of pretty with prettyprinter in GHC.

bgamari edited edge metadata.Jun 16 2017, 10:15 AM

What ticket is this related to? Adding text as a dependency seems like a big change.

This is proposed as one approach to address Trac #10735, with an eye for ultimately implementing Trac #8809.

Indeed the text dependency is a significant change. However, in a sense it's inevitable since Cabal will be picking up a text dependency itself quite shortly. Of course, ghc doesn't depend upon Cabal, but if we already have text wired in to the build system it's a small step to have ghc itself depend upon it as well. As always, there is the concern of freezing the text version of install plans involving ghc, but it's not clear just how bad this will be.

Hi @bollu,

Sorry for the belated reply; I was away from the keyboard yesterday. Indeed it looks like you sorted out the boot issue. Let me know if I can help.

bollu updated this revision to Diff 12875.Jun 19 2017, 7:10 AM
  • [WIP] disable everything in Pretty.hs and start aliasing stuff from prettyprinter
bollu updated this revision to Diff 12890.Jun 21 2017, 3:41 AM
  • started rewriting using Prettyprinter primitives
  • fixed implementations of Pretty for fastString, LitString, fastZString
  • convert all but mode and printers
bgamari requested changes to this revision.Jun 21 2017, 2:38 PM

I think the right approach to deal with the semigroups dependency is to make it conditional on a base_with_semigroups Cabal flag.

Bupping out of review queue for now but do let me know if you need help,

This revision now requires changes to proceed.Jun 21 2017, 2:38 PM
bollu updated this revision to Diff 12899.Jun 21 2017, 7:03 PM
bollu edited edge metadata.
  • more or less feature 'complete' Pretty
  • looks like it's compiling
  • fix LLVM BufHandle
  • fix BufHandle in AsmCodeGen
bollu added a comment.Jun 22 2017, 5:09 AM

My build currently breaks at:

"inplace/bin/ghc-stage2" -hisuf dyn_hi -osuf  dyn_o -hcsuf dyn_hc -fPIC -dynamic  -H32m -O -Wall       -hide-all-packages -i -iutils/mkUserGuidePart/. -iutils/mkUserGuidePart/dist/build -Iutils/mkUserGuidePart/dist/build -iutils/mkUserGuidePart/dist/build/mkUserGuidePart/autogen -Iutils/mkUserGuidePart/dist/build/mkUserGuidePart/autogen     -optP-include -optPutils/mkUserGuidePart/dist/build/mkUserGuidePart/autogen/cabal_macros.h -package-id base-4.10.0.0 -package-id ghc-8.3 -XHaskell2010  -no-user-package-db -rtsopts       -Wnoncanonical-monad-instances  -odir utils/mkUserGuidePart/dist/build -hidir utils/mkUserGuidePart/dist/build -stubdir utils/mkUserGuidePart/dist/build    -c utils/mkUserGuidePart/./DList.hs -o utils/mkUserGuidePart/dist/build/DList.dyn_o
/Users/bollu/work/ghc-all/ghc/inplace/lib/package.conf.d/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (not a ghc-pkg db file, wrong file magic number)
/Users/bollu/work/ghc-all/ghc/inplace/lib/package.conf.d/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (not a ghc-pkg db file, wrong file magic number)
/Users/bollu/work/ghc-all/ghc/inplace/lib/package.conf.d/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (not a ghc-pkg db file, wrong file magic number)
/Users/bollu/work/ghc-all/ghc/inplace/lib/package.conf.d/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (not a ghc-pkg db file, wrong file magic number)
/Users/bollu/work/ghc-all/ghc/inplace/lib/package.conf.d/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (not a ghc-pkg db file, wrong file magic number)
make[1]: *** [utils/mkUserGuidePart/dist/build/DList.dyn_o] Error 1

Any ideas why?

bollu updated this revision to Diff 12900.Jun 22 2017, 9:54 AM
  • add back deleted line from packages
bollu updated this revision to Diff 12920.Jun 24 2017, 2:34 PM
  • Move prettyprinter-core -> prettyprinter because of superstition that it could be affecting builds
  • Merge branch 'integrating-text' of github.com:bollu/ghc into integrating-text
  • [NFC] eliminate dead code in Pretty.hs
bollu updated this revision to Diff 12926.Jun 26 2017, 1:01 PM
  • added Prettyprinter module, going to replace Pretty with old Pretty
  • move Prettyprinter into Prettyprinter.hs. Revive old Pretty module, but change Doc -> Doc a so external types don't need to change
bollu updated this revision to Diff 12927.Jun 26 2017, 3:12 PM
  • add a custom OutputablePrettyprinter
bollu updated this revision to Diff 12928.Jun 26 2017, 3:15 PM
  • change module name to OutputablePrettyprinter.
bollu added a comment.Jun 26 2017, 3:17 PM

I don't understand why the addition of OutputablePrettyprinter causes the compile to break:

compiler/utils/OutputablePrettyprinter.hs:1145:30: error:
    • Couldn't match expected type ‘Outputable.SDoc’
                  with actual type ‘SDoc’
      NB: ‘SDoc’ is defined at
            compiler/utils/OutputablePrettyprinter.hs:316:1-56
          ‘Outputable.SDoc’ is defined in ‘Outputable’
    • In the second argument of ‘panicDoc’, namely
        ‘(doc $$ callStackDoc)’
      In the expression: panicDoc s (doc $$ callStackDoc)
      In an equation for ‘pprPanic’:
          pprPanic s doc = panicDoc s (doc $$ callStackDoc)

compiler/utils/OutputablePrettyprinter.hs:1149:15: error:
    • Couldn't match type ‘SDoc’
                     with ‘Outputable.SDoc’
      NB: ‘Outputable.SDoc’ is defined in ‘Outputable’
          ‘SDoc’ is defined at
            compiler/utils/OutputablePrettyprinter.hs:316:1-56
      Expected type: String -> SDoc -> a
        Actual type: String -> Outputable.SDoc -> a
    • In the expression: sorryDoc
      In an equation for ‘pprSorry’: pprSorry = sorryDoc

compiler/utils/OutputablePrettyprinter.hs:1154:15: error:
    • Couldn't match type ‘SDoc’
                     with ‘Outputable.SDoc’
      NB: ‘Outputable.SDoc’ is defined in ‘Outputable’
          ‘SDoc’ is defined at
            compiler/utils/OutputablePrettyprinter.hs:316:1-56
      Expected type: String -> SDoc -> a
        Actual type: String -> Outputable.SDoc -> a
    • In the expression: pgmErrorDoc
      In an equation for ‘pprPgmError’: pprPgmError = pgmErrorDoc
<<ghc: 335138264 bytes, 101 GCs, 15336096/42296472 avg/max bytes residency (6 samples), 89M in use, 0.000 INIT (0.035 elapsed), 0.249 MUT (0.500 elapsed), 0.369 GC (0.466 elapsed) :ghc>>
make[1]: *** [compiler/stage1/build/OutputablePrettyprinter.o] Error 1
make[1]: *** Waiting for unfinished jobs....
<<ghc: 1370728736 bytes, 177 GCs, 25869713/76842968 avg/max bytes residency (8 samples), 165M in use, 0.000 INIT (0.005 elapsed), 1.392 MUT (2.011 elapsed), 0.969 GC (1.366 elapsed) :ghc>>
<<ghc: 626707112 bytes, 135 GCs, 19580992/54261888 avg/max bytes residency (7 samples), 115M in use, 0.000 INIT (0.025 elapsed), 0.557 MUT (0.748 elapsed), 0.522 GC (0.643 elapsed) :ghc>>
<<ghc: 5764003448 bytes, 546 GCs, 56743946/136526240 avg/max bytes residency (11 samples), 344M in use, 0.000 INIT (0.035 elapsed), 4.816 MUT (5.666 elapsed), 2.929 GC (3.471 elapsed) :ghc>>
make: *** [all] Error 2

@bgamari : help? :)

bgamari requested changes to this revision.Jul 11 2017, 1:44 PM

Bumping out of review queue for now.

This revision now requires changes to proceed.Jul 11 2017, 1:44 PM
austin resigned from this revision.Nov 9 2017, 5:35 PM