Make GHCi & TH work when the compiler is built with -prof
ClosedPublic

Authored by simonmar on Oct 30 2015, 6:33 PM.

Details

Summary

Amazingly, there were zero changes to the byte code generator and very
few changes to the interpreter - mainly because we've used good
abstractions that hide the differences between profiling and
non-profiling. So that bit was pleasantly straightforward, but there
were a pile of other wibbles to get the whole test suite through.

Note that a compiler built with -prof is now like one built with
-dynamic, in that to use TH you have to build the code the same way.
For dynamic, we automatically enable -dynamic-too when TH is required,
but we don't have anything equivalent for profiling, so you have to
explicitly use -prof when building code that uses TH with a profiled
compiler. For this reason Cabal won't work with TH. We don't expect
to ship a profiled compiler, so I think that's OK.

Test Plan

validate with GhcProfiled=YES in validate.mk

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Branch
prof-ghci
Lint
Lint WarningsExcuse: meh
SeverityLocationCodeMessage
Warningcompiler/ghci/Linker.hs:528TXT3Line Too Long
Unit
No Unit Test Coverage
Build Status
Buildable 6394
Build 7348: GHC Patch Validation (amd64/Linux)
Build 7347: arc lint + arc unit
simonmar updated this revision to Diff 4811.Oct 30 2015, 6:33 PM
simonmar retitled this revision from to Make GHCi & TH work when the compiler is built with -prof.
simonmar updated this object.
simonmar edited the test plan for this revision. (Show Details)
simonmar added reviewers: bgamari, austin, rwbarton, ezyang.
simonmar updated the Trac tickets for this revision.
simonmar updated this revision to Diff 4812.Oct 30 2015, 6:40 PM
simonmar edited edge metadata.

remove redundant comment

simonmar updated this revision to Diff 4813.Oct 30 2015, 6:46 PM
simonmar edited edge metadata.

fix cabal04

ezyang edited edge metadata.Oct 30 2015, 10:19 PM

Fancy!

Macro somuchwin:

I just looked at the diff here; maybe a full review of the interpreter code would catch other bugs but everything looked in order.

compiler/ghci/Linker.hs
518

So, based on the diff, mkbuildTag is outputting something like "dyn" or ""? Not obvious here.

1211

So, no dynamic profiled for now.

rts/Interpreter.c
534

Wait, did this cause a functional change?

rts/Linker.c
1850

This is wrong, if you want to do the ".p_o" you need thisFileNameSize to be bigger.

ezyang requested changes to this revision.Oct 30 2015, 10:19 PM
ezyang edited edge metadata.

(Noticed one major bug, rest is just minor comments.)

This revision now requires changes to proceed.Oct 30 2015, 10:19 PM
simonmar added inline comments.Oct 31 2015, 1:02 PM
compiler/ghci/Linker.hs
1211

Yes, admittedly I didn't open that can of worms.

rts/Interpreter.c
534

Yes!

Macro historyguy:  pointer arithmetic

rts/Linker.c
1850

Good catch.

simonmar updated this revision to Diff 4823.Oct 31 2015, 1:09 PM
simonmar edited edge metadata.

Fix object filename recognition

rwbarton edited edge metadata.Oct 31 2015, 9:36 PM

zomg

I can probably use a profiled ghc with cabal-install by going around Cabal's back and using --ghc-option=-prof rather than --enable-library-profiling, right? Should be great for profiling ghc on large real-world projects whose dependencies use TH.

@austin, any idea why the build failed here? Something about "Unable to apply patch", but I don't see why that would be.

If anyone's interested, here's where I'm going with this: Trac #11047

bgamari edited edge metadata.Nov 2 2015, 3:35 AM

@austin, any idea why the build failed here? Something about "Unable to apply patch", but I don't see why that would be.

Whenever this happens I usually rebase the patch, sacrifice four crows on a full moon-lit night, update the diff, and hope for the best. I find that this technique works unreasonably well.

simonmar updated this revision to Diff 4892.Nov 3 2015, 8:28 AM
simonmar edited edge metadata.

rebase

thomie added a comment.Nov 4 2015, 7:25 AM

Unexpected failures:

annotations/should_compile/th  annth_compunits [bad stdout] (normal)
annotations/should_compile/th  annth_make [bad stdout] (normal)
plugins                        T10294 [bad exit code] (normal)
plugins                        T10294a [bad exit code] (normal)
plugins                        T10420 [bad exit code] (normal)
plugins                        plugins01 [bad exit code] (normal)
plugins                        plugins02 [stderr mismatch] (normal)
plugins                        plugins03 [stderr mismatch] (normal)
plugins                        plugins07 [bad exit code] (normal)
testsuite/config/ghc
210

The testsuite way is called "prof", not "p".

simonmar updated this revision to Diff 4923.Nov 4 2015, 12:25 PM
simonmar edited edge metadata.

fix tests

simonmar updated this revision to Diff 4927.Nov 4 2015, 12:44 PM
simonmar edited edge metadata.

fix ghc_th_way

simonmar updated this revision to Diff 4934.Nov 4 2015, 5:00 PM
simonmar edited edge metadata.

bring back accidentally deleted files

simonmar updated this revision to Diff 4939.Nov 4 2015, 8:49 PM
simonmar edited edge metadata.

Fix framework failure

ezyang accepted this revision.Nov 4 2015, 9:39 PM
ezyang edited edge metadata.

OK ship it.

This revision was automatically updated to reflect the committed changes.