compiler: make sure we reject -O + HscInterpreted
authorAustin Seipp <austin@well-typed.com>
Tue, 19 May 2015 06:56:48 +0000 (01:56 -0500)
committerAustin Seipp <austin@well-typed.com>
Tue, 2 Jun 2015 13:31:54 +0000 (08:31 -0500)
commit091944e3aec736b440a9c1204f152004e382c967
treed555c9d890864bc9134b06c77e7f1de40d55b702
parentb2b69b2a31e5d41210e851687887377072afd020
compiler: make sure we reject -O + HscInterpreted

When using GHCi, we explicitly reject optimization, because the
compilers optimization passes can introduce unboxed tuples, which the
interpreter is not able to handle. But this goes the other way too: using
GHCi on optimized code may cause the optimizer to float out breakpoints
that the interpreter introduces. This manifests itself in weird ways,
particularly if you as an API client use custom DynFlags to introduce
optimization in combination with HscInterpreted.

It turns out we weren't checking for consistent DynFlag settings when
doing `setSessionDynFlags`, as #10052 showed. While the main driver
handled it in `DynFlags` via `parseDynamicFlags`, we didn't check this
elsewhere.

This does a little refactoring to split out some of the common code, and
immunizes the various `DynFlags` utilities in the `GHC` module from this
particular bug. We should probably be checking other general invariants
too.

This fixes #10052, and adds some notes about the behavior in `GHC` and
`FloatOut`

As a bonus, expose `warningMsg` from `ErrUtils` as a helper since it
didn't exist (somehow).

Signed-off-by: Austin Seipp <austin@well-typed.com>
Reviewed By: edsko

Differential Revision: https://phabricator.haskell.org/D727

GHC Trac Issues: #10052
12 files changed:
compiler/main/DynFlags.hs
compiler/main/ErrUtils.hs
compiler/main/GHC.hs
compiler/simplCore/FloatOut.hs
testsuite/.gitignore
testsuite/tests/ghc-api/T10052/Makefile [new file with mode: 0644]
testsuite/tests/ghc-api/T10052/T10052-input.hs [new file with mode: 0644]
testsuite/tests/ghc-api/T10052/T10052.hs [new file with mode: 0644]
testsuite/tests/ghc-api/T10052/T10052.stderr [new file with mode: 0644]
testsuite/tests/ghc-api/T10052/T10052.stdout [new file with mode: 0644]
testsuite/tests/ghc-api/T10052/all.T [new file with mode: 0644]
testsuite/tests/ghci.debugger/scripts/print007.stderr