Add GHC-API logging hooks

* Add 'dumpAction' hook to DynFlags.

It allows GHC API users to catch dumped intermediate codes and
information. The format of the dump (Core, Stg, raw text, etc.) is now
reported allowing easier automatic handling.

* Add 'traceAction' hook to DynFlags.

Some dumps go through the trace mechanism (for instance unfoldings that
have been considered for inlining). This is problematic because:
1) dumps aren't written into files even with -ddump-to-file on
2) dumps are written on stdout even with GHC API
3) in this specific case, dumping depends on unsafe globally stored
DynFlags which is bad for GHC API users

We introduce 'traceAction' hook which allows GHC API to catch those
traces and to avoid using globally stored DynFlags.

* Avoid dumping empty logs via dumpAction/traceAction (but still write
empty files to keep the existing behavior)
22 jobs for master in 586 minutes and 59 seconds (queued for 3 seconds)
Status Job ID Name Coverage
  Lint
passed #223665
lint
lint-linters

00:00:13

passed #223668
lint
lint-submods-branch

00:00:15

passed #223666
lint
lint-testsuite

00:00:14

passed #223667
lint
typecheck-testsuite

00:00:13

 
  Quick Build
passed #223669
x86_64-linux
hadrian-ghc-in-ghci

00:16:16

 
  Build
passed #223670
x86_64-linux
validate-x86_64-linux-deb9-hadrian

03:06:32

 
  Full Build
failed #223673
aarch64-linux allowed to fail
validate-aarch64-linux-deb9

03:18:57

passed #223674
armv7-linux
validate-armv7-linux-deb9

03:26:42

passed #223675
x86_64-linux
validate-i386-linux-deb9

01:53:46

passed #223672
x86_64-darwin
validate-x86_64-darwin

01:04:58

passed #223676
x86_64-linux
validate-x86_64-linux-deb9-debug

04:37:39

passed #223678
x86_64-linux
validate-x86_64-linux-deb9-dwarf

01:56:21

passed #223677
x86_64-linux
validate-x86_64-linux-deb9-integer-simple

00:47:54

passed #223671
x86_64-linux
validate-x86_64-linux-deb9-unreg-hadrian

01:44:27

passed #223679
x86_64-linux
validate-x86_64-linux-fedora27

00:46:57

failed #223681
x86_64-windows allowed to fail
validate-x86_64-windows

00:03:18

failed #223680
x86_64-windows allowed to fail
validate-x86_64-windows-hadrian

01:29:37

 
  Cleanup
passed #223682
x86_64-darwin
cleanup-darwin

00:00:09

 
  Packaging
failed #223683
x86_64-linux allowed to fail
doc-tarball

01:08:24

 
  Testing
manual #223684
x86_64-linux allowed to fail manual
hackage
passed #223685
x86_64-linux
perf-nofib

00:25:34

 
  Deploy
failed #223686
x86_64-linux allowed to fail
pages

00:11:50

 
Name Stage Failure
failed
pages Deploy
$ git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true
warning: no common commits
From https://gitlab.haskell.org/ghc/ghc-performance-notes
* [new ref] refs/notes/perf -> refs/notes/perf
$ mkdir -p public/doc
$ tar -xf haddock.html.tar.xz -C public/doc
tar: haddock.html.tar.xz: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
ERROR: Job failed: exit code 1
failed
doc-tarball Packaging
Skipping Git submodules setup
Downloading artifacts for validate-x86_64-linux-deb9-debug (223676)...
ERROR: Downloading artifacts from coordinator... error error=unexpected EOF id=223676 responseStatus=200 OK token=8Moz3oLy
WARNING: Retrying...
ERROR: Downloading artifacts from coordinator... error error=unexpected EOF id=223676 responseStatus=200 OK token=8Moz3oLy
WARNING: Retrying...
ERROR: Downloading artifacts from coordinator... error error=unexpected EOF id=223676 responseStatus=200 OK token=8Moz3oLy
FATAL: invalid argument
ERROR: Job failed: exit code 1
failed
validate-aarch64-linux-deb9 Full Build
Uploading artifacts...
ghc-aarch64-linux-deb9.tar.xz: found 1 matching files
junit.xml: found 1 matching files

performance-metrics.tsv: found 1 matching files

Uploading artifacts to coordinator... ok
id=223673 responseStatus=201 Created token=FrPDzHhx
Uploading artifacts...
junit.xml: found 1 matching files

Uploading artifacts to coordinator... ok
id=223673 responseStatus=201 Created token=FrPDzHhx
ERROR: Job failed: exit code 1
failed
validate-x86_64-windows-hadrian Full Build
ghc.tar.xz: found 1 matching files                 
WARNING: junit.xml: no matching files
WARNING: Failed to load system CertPool:crypto/x509: system root pool is not available on Windows
Uploading artifacts to coordinator... ok
id=223680 responseStatus=201 Created token=Ud1PytsU
Uploading artifacts...
Runtime platform
arch=amd64 os=windows pid=3952 revision=1f513601 version=11.10.1
WARNING: junit.xml: no matching files
ERROR: No files to upload
ERROR: Job failed: exit status 1
failed
validate-x86_64-windows Full Build
Runtime platform                                    arch=amd64 os=windows pid=13780 revision=1f513601 version=11.10.1
WARNING: ghc-x86_64-mingw32.tar.xz: no matching files
WARNING: junit.xml: no matching files
ERROR: No files to upload
Uploading artifacts...
Runtime platform
arch=amd64 os=windows pid=6832 revision=1f513601 version=11.10.1
WARNING: junit.xml: no matching files
ERROR: No files to upload
ERROR: Job failed: exit status 2